babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  640. static readonly GEQUAL: number;
  641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. /**
  1375. * Loads an image as an HTMLImageElement.
  1376. * @param input url string, ArrayBuffer, or Blob to load
  1377. * @param onLoad callback called when the image successfully loads
  1378. * @param onError callback called when the image fails to load
  1379. * @param offlineProvider offline provider for caching
  1380. * @returns the HTMLImageElement of the loaded image
  1381. */
  1382. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  1383. /**
  1384. * Loads a file
  1385. * @param fileToLoad defines the file to load
  1386. * @param callback defines the callback to call when data is loaded
  1387. * @param progressCallBack defines the callback to call during loading process
  1388. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1389. * @returns a file request object
  1390. */
  1391. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1392. /**
  1393. * Loads a file
  1394. * @param url url string, ArrayBuffer, or Blob to load
  1395. * @param onSuccess callback called when the file successfully loads
  1396. * @param onProgress callback called while file is loading (if the server supports this mode)
  1397. * @param offlineProvider defines the offline provider for caching
  1398. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1399. * @param onError callback called when the file fails to load
  1400. * @returns a file request object
  1401. */
  1402. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  1403. /**
  1404. * Checks if the loaded document was accessed via `file:`-Protocol.
  1405. * @returns boolean
  1406. */
  1407. static IsFileURL(): boolean;
  1408. }
  1409. }
  1410. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1411. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1412. /** @hidden */
  1413. export class ShaderProcessor {
  1414. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1415. private static _ProcessPrecision;
  1416. private static _ExtractOperation;
  1417. private static _BuildSubExpression;
  1418. private static _BuildExpression;
  1419. private static _MoveCursorWithinIf;
  1420. private static _MoveCursor;
  1421. private static _EvaluatePreProcessors;
  1422. private static _PreparePreProcessors;
  1423. private static _ProcessShaderConversion;
  1424. private static _ProcessIncludes;
  1425. }
  1426. }
  1427. declare module "babylonjs/Maths/math.like" {
  1428. import { float, int, DeepImmutable } from "babylonjs/types";
  1429. /**
  1430. * @hidden
  1431. */
  1432. export interface IColor4Like {
  1433. r: float;
  1434. g: float;
  1435. b: float;
  1436. a: float;
  1437. }
  1438. /**
  1439. * @hidden
  1440. */
  1441. export interface IColor3Like {
  1442. r: float;
  1443. g: float;
  1444. b: float;
  1445. }
  1446. /**
  1447. * @hidden
  1448. */
  1449. export interface IVector4Like {
  1450. x: float;
  1451. y: float;
  1452. z: float;
  1453. w: float;
  1454. }
  1455. /**
  1456. * @hidden
  1457. */
  1458. export interface IVector3Like {
  1459. x: float;
  1460. y: float;
  1461. z: float;
  1462. }
  1463. /**
  1464. * @hidden
  1465. */
  1466. export interface IVector2Like {
  1467. x: float;
  1468. y: float;
  1469. }
  1470. /**
  1471. * @hidden
  1472. */
  1473. export interface IMatrixLike {
  1474. toArray(): DeepImmutable<Float32Array>;
  1475. updateFlag: int;
  1476. }
  1477. /**
  1478. * @hidden
  1479. */
  1480. export interface IViewportLike {
  1481. x: float;
  1482. y: float;
  1483. width: float;
  1484. height: float;
  1485. }
  1486. /**
  1487. * @hidden
  1488. */
  1489. export interface IPlaneLike {
  1490. normal: IVector3Like;
  1491. d: float;
  1492. normalize(): void;
  1493. }
  1494. }
  1495. declare module "babylonjs/Materials/iEffectFallbacks" {
  1496. import { Effect } from "babylonjs/Materials/effect";
  1497. /**
  1498. * Interface used to define common properties for effect fallbacks
  1499. */
  1500. export interface IEffectFallbacks {
  1501. /**
  1502. * Removes the defines that should be removed when falling back.
  1503. * @param currentDefines defines the current define statements for the shader.
  1504. * @param effect defines the current effect we try to compile
  1505. * @returns The resulting defines with defines of the current rank removed.
  1506. */
  1507. reduce(currentDefines: string, effect: Effect): string;
  1508. /**
  1509. * Removes the fallback from the bound mesh.
  1510. */
  1511. unBindMesh(): void;
  1512. /**
  1513. * Checks to see if more fallbacks are still availible.
  1514. */
  1515. hasMoreFallbacks: boolean;
  1516. }
  1517. }
  1518. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1519. /**
  1520. * Class used to evalaute queries containing `and` and `or` operators
  1521. */
  1522. export class AndOrNotEvaluator {
  1523. /**
  1524. * Evaluate a query
  1525. * @param query defines the query to evaluate
  1526. * @param evaluateCallback defines the callback used to filter result
  1527. * @returns true if the query matches
  1528. */
  1529. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1530. private static _HandleParenthesisContent;
  1531. private static _SimplifyNegation;
  1532. }
  1533. }
  1534. declare module "babylonjs/Misc/tags" {
  1535. /**
  1536. * Class used to store custom tags
  1537. */
  1538. export class Tags {
  1539. /**
  1540. * Adds support for tags on the given object
  1541. * @param obj defines the object to use
  1542. */
  1543. static EnableFor(obj: any): void;
  1544. /**
  1545. * Removes tags support
  1546. * @param obj defines the object to use
  1547. */
  1548. static DisableFor(obj: any): void;
  1549. /**
  1550. * Gets a boolean indicating if the given object has tags
  1551. * @param obj defines the object to use
  1552. * @returns a boolean
  1553. */
  1554. static HasTags(obj: any): boolean;
  1555. /**
  1556. * Gets the tags available on a given object
  1557. * @param obj defines the object to use
  1558. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1559. * @returns the tags
  1560. */
  1561. static GetTags(obj: any, asString?: boolean): any;
  1562. /**
  1563. * Adds tags to an object
  1564. * @param obj defines the object to use
  1565. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1566. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1567. */
  1568. static AddTagsTo(obj: any, tagsString: string): void;
  1569. /**
  1570. * @hidden
  1571. */
  1572. static _AddTagTo(obj: any, tag: string): void;
  1573. /**
  1574. * Removes specific tags from a specific object
  1575. * @param obj defines the object to use
  1576. * @param tagsString defines the tags to remove
  1577. */
  1578. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1579. /**
  1580. * @hidden
  1581. */
  1582. static _RemoveTagFrom(obj: any, tag: string): void;
  1583. /**
  1584. * Defines if tags hosted on an object match a given query
  1585. * @param obj defines the object to use
  1586. * @param tagsQuery defines the tag query
  1587. * @returns a boolean
  1588. */
  1589. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1590. }
  1591. }
  1592. declare module "babylonjs/Maths/math.scalar" {
  1593. /**
  1594. * Scalar computation library
  1595. */
  1596. export class Scalar {
  1597. /**
  1598. * Two pi constants convenient for computation.
  1599. */
  1600. static TwoPi: number;
  1601. /**
  1602. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1603. * @param a number
  1604. * @param b number
  1605. * @param epsilon (default = 1.401298E-45)
  1606. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1607. */
  1608. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1609. /**
  1610. * Returns a string : the upper case translation of the number i to hexadecimal.
  1611. * @param i number
  1612. * @returns the upper case translation of the number i to hexadecimal.
  1613. */
  1614. static ToHex(i: number): string;
  1615. /**
  1616. * Returns -1 if value is negative and +1 is value is positive.
  1617. * @param value the value
  1618. * @returns the value itself if it's equal to zero.
  1619. */
  1620. static Sign(value: number): number;
  1621. /**
  1622. * Returns the value itself if it's between min and max.
  1623. * Returns min if the value is lower than min.
  1624. * Returns max if the value is greater than max.
  1625. * @param value the value to clmap
  1626. * @param min the min value to clamp to (default: 0)
  1627. * @param max the max value to clamp to (default: 1)
  1628. * @returns the clamped value
  1629. */
  1630. static Clamp(value: number, min?: number, max?: number): number;
  1631. /**
  1632. * the log2 of value.
  1633. * @param value the value to compute log2 of
  1634. * @returns the log2 of value.
  1635. */
  1636. static Log2(value: number): number;
  1637. /**
  1638. * Loops the value, so that it is never larger than length and never smaller than 0.
  1639. *
  1640. * This is similar to the modulo operator but it works with floating point numbers.
  1641. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1642. * With t = 5 and length = 2.5, the result would be 0.0.
  1643. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1644. * @param value the value
  1645. * @param length the length
  1646. * @returns the looped value
  1647. */
  1648. static Repeat(value: number, length: number): number;
  1649. /**
  1650. * Normalize the value between 0.0 and 1.0 using min and max values
  1651. * @param value value to normalize
  1652. * @param min max to normalize between
  1653. * @param max min to normalize between
  1654. * @returns the normalized value
  1655. */
  1656. static Normalize(value: number, min: number, max: number): number;
  1657. /**
  1658. * Denormalize the value from 0.0 and 1.0 using min and max values
  1659. * @param normalized value to denormalize
  1660. * @param min max to denormalize between
  1661. * @param max min to denormalize between
  1662. * @returns the denormalized value
  1663. */
  1664. static Denormalize(normalized: number, min: number, max: number): number;
  1665. /**
  1666. * Calculates the shortest difference between two given angles given in degrees.
  1667. * @param current current angle in degrees
  1668. * @param target target angle in degrees
  1669. * @returns the delta
  1670. */
  1671. static DeltaAngle(current: number, target: number): number;
  1672. /**
  1673. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1674. * @param tx value
  1675. * @param length length
  1676. * @returns The returned value will move back and forth between 0 and length
  1677. */
  1678. static PingPong(tx: number, length: number): number;
  1679. /**
  1680. * Interpolates between min and max with smoothing at the limits.
  1681. *
  1682. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1683. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1684. * @param from from
  1685. * @param to to
  1686. * @param tx value
  1687. * @returns the smooth stepped value
  1688. */
  1689. static SmoothStep(from: number, to: number, tx: number): number;
  1690. /**
  1691. * Moves a value current towards target.
  1692. *
  1693. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1694. * Negative values of maxDelta pushes the value away from target.
  1695. * @param current current value
  1696. * @param target target value
  1697. * @param maxDelta max distance to move
  1698. * @returns resulting value
  1699. */
  1700. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1701. /**
  1702. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1703. *
  1704. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1705. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1706. * @param current current value
  1707. * @param target target value
  1708. * @param maxDelta max distance to move
  1709. * @returns resulting angle
  1710. */
  1711. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1712. /**
  1713. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1714. * @param start start value
  1715. * @param end target value
  1716. * @param amount amount to lerp between
  1717. * @returns the lerped value
  1718. */
  1719. static Lerp(start: number, end: number, amount: number): number;
  1720. /**
  1721. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1722. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1723. * @param start start value
  1724. * @param end target value
  1725. * @param amount amount to lerp between
  1726. * @returns the lerped value
  1727. */
  1728. static LerpAngle(start: number, end: number, amount: number): number;
  1729. /**
  1730. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1731. * @param a start value
  1732. * @param b target value
  1733. * @param value value between a and b
  1734. * @returns the inverseLerp value
  1735. */
  1736. static InverseLerp(a: number, b: number, value: number): number;
  1737. /**
  1738. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1739. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1740. * @param value1 spline value
  1741. * @param tangent1 spline value
  1742. * @param value2 spline value
  1743. * @param tangent2 spline value
  1744. * @param amount input value
  1745. * @returns hermite result
  1746. */
  1747. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1748. /**
  1749. * Returns a random float number between and min and max values
  1750. * @param min min value of random
  1751. * @param max max value of random
  1752. * @returns random value
  1753. */
  1754. static RandomRange(min: number, max: number): number;
  1755. /**
  1756. * This function returns percentage of a number in a given range.
  1757. *
  1758. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1759. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1760. * @param number to convert to percentage
  1761. * @param min min range
  1762. * @param max max range
  1763. * @returns the percentage
  1764. */
  1765. static RangeToPercent(number: number, min: number, max: number): number;
  1766. /**
  1767. * This function returns number that corresponds to the percentage in a given range.
  1768. *
  1769. * PercentToRange(0.34,0,100) will return 34.
  1770. * @param percent to convert to number
  1771. * @param min min range
  1772. * @param max max range
  1773. * @returns the number
  1774. */
  1775. static PercentToRange(percent: number, min: number, max: number): number;
  1776. /**
  1777. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1778. * @param angle The angle to normalize in radian.
  1779. * @return The converted angle.
  1780. */
  1781. static NormalizeRadians(angle: number): number;
  1782. }
  1783. }
  1784. declare module "babylonjs/Maths/math.constants" {
  1785. /**
  1786. * Constant used to convert a value to gamma space
  1787. * @ignorenaming
  1788. */
  1789. export const ToGammaSpace: number;
  1790. /**
  1791. * Constant used to convert a value to linear space
  1792. * @ignorenaming
  1793. */
  1794. export const ToLinearSpace = 2.2;
  1795. /**
  1796. * Constant used to define the minimal number value in Babylon.js
  1797. * @ignorenaming
  1798. */
  1799. let Epsilon: number;
  1800. export { Epsilon };
  1801. }
  1802. declare module "babylonjs/Maths/math.viewport" {
  1803. /**
  1804. * Class used to represent a viewport on screen
  1805. */
  1806. export class Viewport {
  1807. /** viewport left coordinate */
  1808. x: number;
  1809. /** viewport top coordinate */
  1810. y: number;
  1811. /**viewport width */
  1812. width: number;
  1813. /** viewport height */
  1814. height: number;
  1815. /**
  1816. * Creates a Viewport object located at (x, y) and sized (width, height)
  1817. * @param x defines viewport left coordinate
  1818. * @param y defines viewport top coordinate
  1819. * @param width defines the viewport width
  1820. * @param height defines the viewport height
  1821. */
  1822. constructor(
  1823. /** viewport left coordinate */
  1824. x: number,
  1825. /** viewport top coordinate */
  1826. y: number,
  1827. /**viewport width */
  1828. width: number,
  1829. /** viewport height */
  1830. height: number);
  1831. /**
  1832. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1833. * @param renderWidth defines the rendering width
  1834. * @param renderHeight defines the rendering height
  1835. * @returns a new Viewport
  1836. */
  1837. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1838. /**
  1839. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1840. * @param renderWidth defines the rendering width
  1841. * @param renderHeight defines the rendering height
  1842. * @param ref defines the target viewport
  1843. * @returns the current viewport
  1844. */
  1845. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1846. /**
  1847. * Returns a new Viewport copied from the current one
  1848. * @returns a new Viewport
  1849. */
  1850. clone(): Viewport;
  1851. }
  1852. }
  1853. declare module "babylonjs/Misc/arrayTools" {
  1854. /**
  1855. * Class containing a set of static utilities functions for arrays.
  1856. */
  1857. export class ArrayTools {
  1858. /**
  1859. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1860. * @param size the number of element to construct and put in the array
  1861. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1862. * @returns a new array filled with new objects
  1863. */
  1864. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1865. }
  1866. }
  1867. declare module "babylonjs/Maths/math.vector" {
  1868. import { Viewport } from "babylonjs/Maths/math.viewport";
  1869. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1870. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1871. /**
  1872. * Class representing a vector containing 2 coordinates
  1873. */
  1874. export class Vector2 {
  1875. /** defines the first coordinate */
  1876. x: number;
  1877. /** defines the second coordinate */
  1878. y: number;
  1879. /**
  1880. * Creates a new Vector2 from the given x and y coordinates
  1881. * @param x defines the first coordinate
  1882. * @param y defines the second coordinate
  1883. */
  1884. constructor(
  1885. /** defines the first coordinate */
  1886. x?: number,
  1887. /** defines the second coordinate */
  1888. y?: number);
  1889. /**
  1890. * Gets a string with the Vector2 coordinates
  1891. * @returns a string with the Vector2 coordinates
  1892. */
  1893. toString(): string;
  1894. /**
  1895. * Gets class name
  1896. * @returns the string "Vector2"
  1897. */
  1898. getClassName(): string;
  1899. /**
  1900. * Gets current vector hash code
  1901. * @returns the Vector2 hash code as a number
  1902. */
  1903. getHashCode(): number;
  1904. /**
  1905. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1906. * @param array defines the source array
  1907. * @param index defines the offset in source array
  1908. * @returns the current Vector2
  1909. */
  1910. toArray(array: FloatArray, index?: number): Vector2;
  1911. /**
  1912. * Copy the current vector to an array
  1913. * @returns a new array with 2 elements: the Vector2 coordinates.
  1914. */
  1915. asArray(): number[];
  1916. /**
  1917. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1918. * @param source defines the source Vector2
  1919. * @returns the current updated Vector2
  1920. */
  1921. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1922. /**
  1923. * Sets the Vector2 coordinates with the given floats
  1924. * @param x defines the first coordinate
  1925. * @param y defines the second coordinate
  1926. * @returns the current updated Vector2
  1927. */
  1928. copyFromFloats(x: number, y: number): Vector2;
  1929. /**
  1930. * Sets the Vector2 coordinates with the given floats
  1931. * @param x defines the first coordinate
  1932. * @param y defines the second coordinate
  1933. * @returns the current updated Vector2
  1934. */
  1935. set(x: number, y: number): Vector2;
  1936. /**
  1937. * Add another vector with the current one
  1938. * @param otherVector defines the other vector
  1939. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1940. */
  1941. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1942. /**
  1943. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1944. * @param otherVector defines the other vector
  1945. * @param result defines the target vector
  1946. * @returns the unmodified current Vector2
  1947. */
  1948. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1949. /**
  1950. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1951. * @param otherVector defines the other vector
  1952. * @returns the current updated Vector2
  1953. */
  1954. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1955. /**
  1956. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1957. * @param otherVector defines the other vector
  1958. * @returns a new Vector2
  1959. */
  1960. addVector3(otherVector: Vector3): Vector2;
  1961. /**
  1962. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1963. * @param otherVector defines the other vector
  1964. * @returns a new Vector2
  1965. */
  1966. subtract(otherVector: Vector2): Vector2;
  1967. /**
  1968. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1969. * @param otherVector defines the other vector
  1970. * @param result defines the target vector
  1971. * @returns the unmodified current Vector2
  1972. */
  1973. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1974. /**
  1975. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1976. * @param otherVector defines the other vector
  1977. * @returns the current updated Vector2
  1978. */
  1979. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1980. /**
  1981. * Multiplies in place the current Vector2 coordinates by the given ones
  1982. * @param otherVector defines the other vector
  1983. * @returns the current updated Vector2
  1984. */
  1985. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1986. /**
  1987. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1988. * @param otherVector defines the other vector
  1989. * @returns a new Vector2
  1990. */
  1991. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1992. /**
  1993. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1994. * @param otherVector defines the other vector
  1995. * @param result defines the target vector
  1996. * @returns the unmodified current Vector2
  1997. */
  1998. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1999. /**
  2000. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2001. * @param x defines the first coordinate
  2002. * @param y defines the second coordinate
  2003. * @returns a new Vector2
  2004. */
  2005. multiplyByFloats(x: number, y: number): Vector2;
  2006. /**
  2007. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2008. * @param otherVector defines the other vector
  2009. * @returns a new Vector2
  2010. */
  2011. divide(otherVector: Vector2): Vector2;
  2012. /**
  2013. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2014. * @param otherVector defines the other vector
  2015. * @param result defines the target vector
  2016. * @returns the unmodified current Vector2
  2017. */
  2018. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2019. /**
  2020. * Divides the current Vector2 coordinates by the given ones
  2021. * @param otherVector defines the other vector
  2022. * @returns the current updated Vector2
  2023. */
  2024. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2025. /**
  2026. * Gets a new Vector2 with current Vector2 negated coordinates
  2027. * @returns a new Vector2
  2028. */
  2029. negate(): Vector2;
  2030. /**
  2031. * Multiply the Vector2 coordinates by scale
  2032. * @param scale defines the scaling factor
  2033. * @returns the current updated Vector2
  2034. */
  2035. scaleInPlace(scale: number): Vector2;
  2036. /**
  2037. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2038. * @param scale defines the scaling factor
  2039. * @returns a new Vector2
  2040. */
  2041. scale(scale: number): Vector2;
  2042. /**
  2043. * Scale the current Vector2 values by a factor to a given Vector2
  2044. * @param scale defines the scale factor
  2045. * @param result defines the Vector2 object where to store the result
  2046. * @returns the unmodified current Vector2
  2047. */
  2048. scaleToRef(scale: number, result: Vector2): Vector2;
  2049. /**
  2050. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2051. * @param scale defines the scale factor
  2052. * @param result defines the Vector2 object where to store the result
  2053. * @returns the unmodified current Vector2
  2054. */
  2055. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2056. /**
  2057. * Gets a boolean if two vectors are equals
  2058. * @param otherVector defines the other vector
  2059. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2060. */
  2061. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2062. /**
  2063. * Gets a boolean if two vectors are equals (using an epsilon value)
  2064. * @param otherVector defines the other vector
  2065. * @param epsilon defines the minimal distance to consider equality
  2066. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2067. */
  2068. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2069. /**
  2070. * Gets a new Vector2 from current Vector2 floored values
  2071. * @returns a new Vector2
  2072. */
  2073. floor(): Vector2;
  2074. /**
  2075. * Gets a new Vector2 from current Vector2 floored values
  2076. * @returns a new Vector2
  2077. */
  2078. fract(): Vector2;
  2079. /**
  2080. * Gets the length of the vector
  2081. * @returns the vector length (float)
  2082. */
  2083. length(): number;
  2084. /**
  2085. * Gets the vector squared length
  2086. * @returns the vector squared length (float)
  2087. */
  2088. lengthSquared(): number;
  2089. /**
  2090. * Normalize the vector
  2091. * @returns the current updated Vector2
  2092. */
  2093. normalize(): Vector2;
  2094. /**
  2095. * Gets a new Vector2 copied from the Vector2
  2096. * @returns a new Vector2
  2097. */
  2098. clone(): Vector2;
  2099. /**
  2100. * Gets a new Vector2(0, 0)
  2101. * @returns a new Vector2
  2102. */
  2103. static Zero(): Vector2;
  2104. /**
  2105. * Gets a new Vector2(1, 1)
  2106. * @returns a new Vector2
  2107. */
  2108. static One(): Vector2;
  2109. /**
  2110. * Gets a new Vector2 set from the given index element of the given array
  2111. * @param array defines the data source
  2112. * @param offset defines the offset in the data source
  2113. * @returns a new Vector2
  2114. */
  2115. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2116. /**
  2117. * Sets "result" from the given index element of the given array
  2118. * @param array defines the data source
  2119. * @param offset defines the offset in the data source
  2120. * @param result defines the target vector
  2121. */
  2122. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2123. /**
  2124. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2125. * @param value1 defines 1st point of control
  2126. * @param value2 defines 2nd point of control
  2127. * @param value3 defines 3rd point of control
  2128. * @param value4 defines 4th point of control
  2129. * @param amount defines the interpolation factor
  2130. * @returns a new Vector2
  2131. */
  2132. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2133. /**
  2134. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2135. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2136. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2137. * @param value defines the value to clamp
  2138. * @param min defines the lower limit
  2139. * @param max defines the upper limit
  2140. * @returns a new Vector2
  2141. */
  2142. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2143. /**
  2144. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2145. * @param value1 defines the 1st control point
  2146. * @param tangent1 defines the outgoing tangent
  2147. * @param value2 defines the 2nd control point
  2148. * @param tangent2 defines the incoming tangent
  2149. * @param amount defines the interpolation factor
  2150. * @returns a new Vector2
  2151. */
  2152. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2153. /**
  2154. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2155. * @param start defines the start vector
  2156. * @param end defines the end vector
  2157. * @param amount defines the interpolation factor
  2158. * @returns a new Vector2
  2159. */
  2160. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2161. /**
  2162. * Gets the dot product of the vector "left" and the vector "right"
  2163. * @param left defines first vector
  2164. * @param right defines second vector
  2165. * @returns the dot product (float)
  2166. */
  2167. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2168. /**
  2169. * Returns a new Vector2 equal to the normalized given vector
  2170. * @param vector defines the vector to normalize
  2171. * @returns a new Vector2
  2172. */
  2173. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2174. /**
  2175. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2176. * @param left defines 1st vector
  2177. * @param right defines 2nd vector
  2178. * @returns a new Vector2
  2179. */
  2180. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2181. /**
  2182. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2183. * @param left defines 1st vector
  2184. * @param right defines 2nd vector
  2185. * @returns a new Vector2
  2186. */
  2187. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2190. * @param vector defines the vector to transform
  2191. * @param transformation defines the matrix to apply
  2192. * @returns a new Vector2
  2193. */
  2194. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2195. /**
  2196. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2197. * @param vector defines the vector to transform
  2198. * @param transformation defines the matrix to apply
  2199. * @param result defines the target vector
  2200. */
  2201. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2202. /**
  2203. * Determines if a given vector is included in a triangle
  2204. * @param p defines the vector to test
  2205. * @param p0 defines 1st triangle point
  2206. * @param p1 defines 2nd triangle point
  2207. * @param p2 defines 3rd triangle point
  2208. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2209. */
  2210. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2211. /**
  2212. * Gets the distance between the vectors "value1" and "value2"
  2213. * @param value1 defines first vector
  2214. * @param value2 defines second vector
  2215. * @returns the distance between vectors
  2216. */
  2217. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2218. /**
  2219. * Returns the squared distance between the vectors "value1" and "value2"
  2220. * @param value1 defines first vector
  2221. * @param value2 defines second vector
  2222. * @returns the squared distance between vectors
  2223. */
  2224. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2225. /**
  2226. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2227. * @param value1 defines first vector
  2228. * @param value2 defines second vector
  2229. * @returns a new Vector2
  2230. */
  2231. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2234. * @param p defines the middle point
  2235. * @param segA defines one point of the segment
  2236. * @param segB defines the other point of the segment
  2237. * @returns the shortest distance
  2238. */
  2239. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2240. }
  2241. /**
  2242. * Classed used to store (x,y,z) vector representation
  2243. * A Vector3 is the main object used in 3D geometry
  2244. * It can represent etiher the coordinates of a point the space, either a direction
  2245. * Reminder: js uses a left handed forward facing system
  2246. */
  2247. export class Vector3 {
  2248. /**
  2249. * Defines the first coordinates (on X axis)
  2250. */
  2251. x: number;
  2252. /**
  2253. * Defines the second coordinates (on Y axis)
  2254. */
  2255. y: number;
  2256. /**
  2257. * Defines the third coordinates (on Z axis)
  2258. */
  2259. z: number;
  2260. private static _UpReadOnly;
  2261. private static _ZeroReadOnly;
  2262. /**
  2263. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2264. * @param x defines the first coordinates (on X axis)
  2265. * @param y defines the second coordinates (on Y axis)
  2266. * @param z defines the third coordinates (on Z axis)
  2267. */
  2268. constructor(
  2269. /**
  2270. * Defines the first coordinates (on X axis)
  2271. */
  2272. x?: number,
  2273. /**
  2274. * Defines the second coordinates (on Y axis)
  2275. */
  2276. y?: number,
  2277. /**
  2278. * Defines the third coordinates (on Z axis)
  2279. */
  2280. z?: number);
  2281. /**
  2282. * Creates a string representation of the Vector3
  2283. * @returns a string with the Vector3 coordinates.
  2284. */
  2285. toString(): string;
  2286. /**
  2287. * Gets the class name
  2288. * @returns the string "Vector3"
  2289. */
  2290. getClassName(): string;
  2291. /**
  2292. * Creates the Vector3 hash code
  2293. * @returns a number which tends to be unique between Vector3 instances
  2294. */
  2295. getHashCode(): number;
  2296. /**
  2297. * Creates an array containing three elements : the coordinates of the Vector3
  2298. * @returns a new array of numbers
  2299. */
  2300. asArray(): number[];
  2301. /**
  2302. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2303. * @param array defines the destination array
  2304. * @param index defines the offset in the destination array
  2305. * @returns the current Vector3
  2306. */
  2307. toArray(array: FloatArray, index?: number): Vector3;
  2308. /**
  2309. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2310. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2311. */
  2312. toQuaternion(): Quaternion;
  2313. /**
  2314. * Adds the given vector to the current Vector3
  2315. * @param otherVector defines the second operand
  2316. * @returns the current updated Vector3
  2317. */
  2318. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2319. /**
  2320. * Adds the given coordinates to the current Vector3
  2321. * @param x defines the x coordinate of the operand
  2322. * @param y defines the y coordinate of the operand
  2323. * @param z defines the z coordinate of the operand
  2324. * @returns the current updated Vector3
  2325. */
  2326. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2327. /**
  2328. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2329. * @param otherVector defines the second operand
  2330. * @returns the resulting Vector3
  2331. */
  2332. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2333. /**
  2334. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2335. * @param otherVector defines the second operand
  2336. * @param result defines the Vector3 object where to store the result
  2337. * @returns the current Vector3
  2338. */
  2339. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2340. /**
  2341. * Subtract the given vector from the current Vector3
  2342. * @param otherVector defines the second operand
  2343. * @returns the current updated Vector3
  2344. */
  2345. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2346. /**
  2347. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2348. * @param otherVector defines the second operand
  2349. * @returns the resulting Vector3
  2350. */
  2351. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2352. /**
  2353. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2354. * @param otherVector defines the second operand
  2355. * @param result defines the Vector3 object where to store the result
  2356. * @returns the current Vector3
  2357. */
  2358. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2359. /**
  2360. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2361. * @param x defines the x coordinate of the operand
  2362. * @param y defines the y coordinate of the operand
  2363. * @param z defines the z coordinate of the operand
  2364. * @returns the resulting Vector3
  2365. */
  2366. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2367. /**
  2368. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2369. * @param x defines the x coordinate of the operand
  2370. * @param y defines the y coordinate of the operand
  2371. * @param z defines the z coordinate of the operand
  2372. * @param result defines the Vector3 object where to store the result
  2373. * @returns the current Vector3
  2374. */
  2375. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2376. /**
  2377. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2378. * @returns a new Vector3
  2379. */
  2380. negate(): Vector3;
  2381. /**
  2382. * Multiplies the Vector3 coordinates by the float "scale"
  2383. * @param scale defines the multiplier factor
  2384. * @returns the current updated Vector3
  2385. */
  2386. scaleInPlace(scale: number): Vector3;
  2387. /**
  2388. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2389. * @param scale defines the multiplier factor
  2390. * @returns a new Vector3
  2391. */
  2392. scale(scale: number): Vector3;
  2393. /**
  2394. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2395. * @param scale defines the multiplier factor
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. scaleToRef(scale: number, result: Vector3): Vector3;
  2400. /**
  2401. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2402. * @param scale defines the scale factor
  2403. * @param result defines the Vector3 object where to store the result
  2404. * @returns the unmodified current Vector3
  2405. */
  2406. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2407. /**
  2408. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2409. * @param otherVector defines the second operand
  2410. * @returns true if both vectors are equals
  2411. */
  2412. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2413. /**
  2414. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2415. * @param otherVector defines the second operand
  2416. * @param epsilon defines the minimal distance to define values as equals
  2417. * @returns true if both vectors are distant less than epsilon
  2418. */
  2419. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2420. /**
  2421. * Returns true if the current Vector3 coordinates equals the given floats
  2422. * @param x defines the x coordinate of the operand
  2423. * @param y defines the y coordinate of the operand
  2424. * @param z defines the z coordinate of the operand
  2425. * @returns true if both vectors are equals
  2426. */
  2427. equalsToFloats(x: number, y: number, z: number): boolean;
  2428. /**
  2429. * Multiplies the current Vector3 coordinates by the given ones
  2430. * @param otherVector defines the second operand
  2431. * @returns the current updated Vector3
  2432. */
  2433. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2434. /**
  2435. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2436. * @param otherVector defines the second operand
  2437. * @returns the new Vector3
  2438. */
  2439. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2440. /**
  2441. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2442. * @param otherVector defines the second operand
  2443. * @param result defines the Vector3 object where to store the result
  2444. * @returns the current Vector3
  2445. */
  2446. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2447. /**
  2448. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2449. * @param x defines the x coordinate of the operand
  2450. * @param y defines the y coordinate of the operand
  2451. * @param z defines the z coordinate of the operand
  2452. * @returns the new Vector3
  2453. */
  2454. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2455. /**
  2456. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2457. * @param otherVector defines the second operand
  2458. * @returns the new Vector3
  2459. */
  2460. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2461. /**
  2462. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2463. * @param otherVector defines the second operand
  2464. * @param result defines the Vector3 object where to store the result
  2465. * @returns the current Vector3
  2466. */
  2467. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2468. /**
  2469. * Divides the current Vector3 coordinates by the given ones.
  2470. * @param otherVector defines the second operand
  2471. * @returns the current updated Vector3
  2472. */
  2473. divideInPlace(otherVector: Vector3): Vector3;
  2474. /**
  2475. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2476. * @param other defines the second operand
  2477. * @returns the current updated Vector3
  2478. */
  2479. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2480. /**
  2481. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2482. * @param other defines the second operand
  2483. * @returns the current updated Vector3
  2484. */
  2485. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2486. /**
  2487. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2488. * @param x defines the x coordinate of the operand
  2489. * @param y defines the y coordinate of the operand
  2490. * @param z defines the z coordinate of the operand
  2491. * @returns the current updated Vector3
  2492. */
  2493. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2494. /**
  2495. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2496. * @param x defines the x coordinate of the operand
  2497. * @param y defines the y coordinate of the operand
  2498. * @param z defines the z coordinate of the operand
  2499. * @returns the current updated Vector3
  2500. */
  2501. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2502. /**
  2503. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2504. * Check if is non uniform within a certain amount of decimal places to account for this
  2505. * @param epsilon the amount the values can differ
  2506. * @returns if the the vector is non uniform to a certain number of decimal places
  2507. */
  2508. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2509. /**
  2510. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2511. */
  2512. readonly isNonUniform: boolean;
  2513. /**
  2514. * Gets a new Vector3 from current Vector3 floored values
  2515. * @returns a new Vector3
  2516. */
  2517. floor(): Vector3;
  2518. /**
  2519. * Gets a new Vector3 from current Vector3 floored values
  2520. * @returns a new Vector3
  2521. */
  2522. fract(): Vector3;
  2523. /**
  2524. * Gets the length of the Vector3
  2525. * @returns the length of the Vector3
  2526. */
  2527. length(): number;
  2528. /**
  2529. * Gets the squared length of the Vector3
  2530. * @returns squared length of the Vector3
  2531. */
  2532. lengthSquared(): number;
  2533. /**
  2534. * Normalize the current Vector3.
  2535. * Please note that this is an in place operation.
  2536. * @returns the current updated Vector3
  2537. */
  2538. normalize(): Vector3;
  2539. /**
  2540. * Reorders the x y z properties of the vector in place
  2541. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2542. * @returns the current updated vector
  2543. */
  2544. reorderInPlace(order: string): this;
  2545. /**
  2546. * Rotates the vector around 0,0,0 by a quaternion
  2547. * @param quaternion the rotation quaternion
  2548. * @param result vector to store the result
  2549. * @returns the resulting vector
  2550. */
  2551. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2552. /**
  2553. * Rotates a vector around a given point
  2554. * @param quaternion the rotation quaternion
  2555. * @param point the point to rotate around
  2556. * @param result vector to store the result
  2557. * @returns the resulting vector
  2558. */
  2559. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2560. /**
  2561. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2562. * The cross product is then orthogonal to both current and "other"
  2563. * @param other defines the right operand
  2564. * @returns the cross product
  2565. */
  2566. cross(other: Vector3): Vector3;
  2567. /**
  2568. * Normalize the current Vector3 with the given input length.
  2569. * Please note that this is an in place operation.
  2570. * @param len the length of the vector
  2571. * @returns the current updated Vector3
  2572. */
  2573. normalizeFromLength(len: number): Vector3;
  2574. /**
  2575. * Normalize the current Vector3 to a new vector
  2576. * @returns the new Vector3
  2577. */
  2578. normalizeToNew(): Vector3;
  2579. /**
  2580. * Normalize the current Vector3 to the reference
  2581. * @param reference define the Vector3 to update
  2582. * @returns the updated Vector3
  2583. */
  2584. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2585. /**
  2586. * Creates a new Vector3 copied from the current Vector3
  2587. * @returns the new Vector3
  2588. */
  2589. clone(): Vector3;
  2590. /**
  2591. * Copies the given vector coordinates to the current Vector3 ones
  2592. * @param source defines the source Vector3
  2593. * @returns the current updated Vector3
  2594. */
  2595. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2596. /**
  2597. * Copies the given floats to the current Vector3 coordinates
  2598. * @param x defines the x coordinate of the operand
  2599. * @param y defines the y coordinate of the operand
  2600. * @param z defines the z coordinate of the operand
  2601. * @returns the current updated Vector3
  2602. */
  2603. copyFromFloats(x: number, y: number, z: number): Vector3;
  2604. /**
  2605. * Copies the given floats to the current Vector3 coordinates
  2606. * @param x defines the x coordinate of the operand
  2607. * @param y defines the y coordinate of the operand
  2608. * @param z defines the z coordinate of the operand
  2609. * @returns the current updated Vector3
  2610. */
  2611. set(x: number, y: number, z: number): Vector3;
  2612. /**
  2613. * Copies the given float to the current Vector3 coordinates
  2614. * @param v defines the x, y and z coordinates of the operand
  2615. * @returns the current updated Vector3
  2616. */
  2617. setAll(v: number): Vector3;
  2618. /**
  2619. * Get the clip factor between two vectors
  2620. * @param vector0 defines the first operand
  2621. * @param vector1 defines the second operand
  2622. * @param axis defines the axis to use
  2623. * @param size defines the size along the axis
  2624. * @returns the clip factor
  2625. */
  2626. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2627. /**
  2628. * Get angle between two vectors
  2629. * @param vector0 angle between vector0 and vector1
  2630. * @param vector1 angle between vector0 and vector1
  2631. * @param normal direction of the normal
  2632. * @return the angle between vector0 and vector1
  2633. */
  2634. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2635. /**
  2636. * Returns a new Vector3 set from the index "offset" of the given array
  2637. * @param array defines the source array
  2638. * @param offset defines the offset in the source array
  2639. * @returns the new Vector3
  2640. */
  2641. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2642. /**
  2643. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2644. * This function is deprecated. Use FromArray instead
  2645. * @param array defines the source array
  2646. * @param offset defines the offset in the source array
  2647. * @returns the new Vector3
  2648. */
  2649. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2650. /**
  2651. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2652. * @param array defines the source array
  2653. * @param offset defines the offset in the source array
  2654. * @param result defines the Vector3 where to store the result
  2655. */
  2656. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2657. /**
  2658. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2659. * This function is deprecated. Use FromArrayToRef instead.
  2660. * @param array defines the source array
  2661. * @param offset defines the offset in the source array
  2662. * @param result defines the Vector3 where to store the result
  2663. */
  2664. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2665. /**
  2666. * Sets the given vector "result" with the given floats.
  2667. * @param x defines the x coordinate of the source
  2668. * @param y defines the y coordinate of the source
  2669. * @param z defines the z coordinate of the source
  2670. * @param result defines the Vector3 where to store the result
  2671. */
  2672. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2673. /**
  2674. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2675. * @returns a new empty Vector3
  2676. */
  2677. static Zero(): Vector3;
  2678. /**
  2679. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2680. * @returns a new unit Vector3
  2681. */
  2682. static One(): Vector3;
  2683. /**
  2684. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2685. * @returns a new up Vector3
  2686. */
  2687. static Up(): Vector3;
  2688. /**
  2689. * Gets a up Vector3 that must not be updated
  2690. */
  2691. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2692. /**
  2693. * Gets a zero Vector3 that must not be updated
  2694. */
  2695. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2696. /**
  2697. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2698. * @returns a new down Vector3
  2699. */
  2700. static Down(): Vector3;
  2701. /**
  2702. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2703. * @returns a new forward Vector3
  2704. */
  2705. static Forward(): Vector3;
  2706. /**
  2707. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2708. * @returns a new forward Vector3
  2709. */
  2710. static Backward(): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2713. * @returns a new right Vector3
  2714. */
  2715. static Right(): Vector3;
  2716. /**
  2717. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2718. * @returns a new left Vector3
  2719. */
  2720. static Left(): Vector3;
  2721. /**
  2722. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2724. * @param vector defines the Vector3 to transform
  2725. * @param transformation defines the transformation matrix
  2726. * @returns the transformed Vector3
  2727. */
  2728. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2729. /**
  2730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2731. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2732. * @param vector defines the Vector3 to transform
  2733. * @param transformation defines the transformation matrix
  2734. * @param result defines the Vector3 where to store the result
  2735. */
  2736. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2737. /**
  2738. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2739. * This method computes tranformed coordinates only, not transformed direction vectors
  2740. * @param x define the x coordinate of the source vector
  2741. * @param y define the y coordinate of the source vector
  2742. * @param z define the z coordinate of the source vector
  2743. * @param transformation defines the transformation matrix
  2744. * @param result defines the Vector3 where to store the result
  2745. */
  2746. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2747. /**
  2748. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2750. * @param vector defines the Vector3 to transform
  2751. * @param transformation defines the transformation matrix
  2752. * @returns the new Vector3
  2753. */
  2754. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2755. /**
  2756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2758. * @param vector defines the Vector3 to transform
  2759. * @param transformation defines the transformation matrix
  2760. * @param result defines the Vector3 where to store the result
  2761. */
  2762. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2763. /**
  2764. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2765. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2766. * @param x define the x coordinate of the source vector
  2767. * @param y define the y coordinate of the source vector
  2768. * @param z define the z coordinate of the source vector
  2769. * @param transformation defines the transformation matrix
  2770. * @param result defines the Vector3 where to store the result
  2771. */
  2772. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2773. /**
  2774. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2775. * @param value1 defines the first control point
  2776. * @param value2 defines the second control point
  2777. * @param value3 defines the third control point
  2778. * @param value4 defines the fourth control point
  2779. * @param amount defines the amount on the spline to use
  2780. * @returns the new Vector3
  2781. */
  2782. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2783. /**
  2784. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2785. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2786. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2787. * @param value defines the current value
  2788. * @param min defines the lower range value
  2789. * @param max defines the upper range value
  2790. * @returns the new Vector3
  2791. */
  2792. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2793. /**
  2794. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2795. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2796. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2797. * @param value defines the current value
  2798. * @param min defines the lower range value
  2799. * @param max defines the upper range value
  2800. * @param result defines the Vector3 where to store the result
  2801. */
  2802. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2803. /**
  2804. * Checks if a given vector is inside a specific range
  2805. * @param v defines the vector to test
  2806. * @param min defines the minimum range
  2807. * @param max defines the maximum range
  2808. */
  2809. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2810. /**
  2811. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2812. * @param value1 defines the first control point
  2813. * @param tangent1 defines the first tangent vector
  2814. * @param value2 defines the second control point
  2815. * @param tangent2 defines the second tangent vector
  2816. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2817. * @returns the new Vector3
  2818. */
  2819. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2820. /**
  2821. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2822. * @param start defines the start value
  2823. * @param end defines the end value
  2824. * @param amount max defines amount between both (between 0 and 1)
  2825. * @returns the new Vector3
  2826. */
  2827. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2828. /**
  2829. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2830. * @param start defines the start value
  2831. * @param end defines the end value
  2832. * @param amount max defines amount between both (between 0 and 1)
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2836. /**
  2837. * Returns the dot product (float) between the vectors "left" and "right"
  2838. * @param left defines the left operand
  2839. * @param right defines the right operand
  2840. * @returns the dot product
  2841. */
  2842. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2843. /**
  2844. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2845. * The cross product is then orthogonal to both "left" and "right"
  2846. * @param left defines the left operand
  2847. * @param right defines the right operand
  2848. * @returns the cross product
  2849. */
  2850. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2851. /**
  2852. * Sets the given vector "result" with the cross product of "left" and "right"
  2853. * The cross product is then orthogonal to both "left" and "right"
  2854. * @param left defines the left operand
  2855. * @param right defines the right operand
  2856. * @param result defines the Vector3 where to store the result
  2857. */
  2858. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2859. /**
  2860. * Returns a new Vector3 as the normalization of the given vector
  2861. * @param vector defines the Vector3 to normalize
  2862. * @returns the new Vector3
  2863. */
  2864. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2865. /**
  2866. * Sets the given vector "result" with the normalization of the given first vector
  2867. * @param vector defines the Vector3 to normalize
  2868. * @param result defines the Vector3 where to store the result
  2869. */
  2870. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2871. /**
  2872. * Project a Vector3 onto screen space
  2873. * @param vector defines the Vector3 to project
  2874. * @param world defines the world matrix to use
  2875. * @param transform defines the transform (view x projection) matrix to use
  2876. * @param viewport defines the screen viewport to use
  2877. * @returns the new Vector3
  2878. */
  2879. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2880. /** @hidden */
  2881. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2882. /**
  2883. * Unproject from screen space to object space
  2884. * @param source defines the screen space Vector3 to use
  2885. * @param viewportWidth defines the current width of the viewport
  2886. * @param viewportHeight defines the current height of the viewport
  2887. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2888. * @param transform defines the transform (view x projection) matrix to use
  2889. * @returns the new Vector3
  2890. */
  2891. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2892. /**
  2893. * Unproject from screen space to object space
  2894. * @param source defines the screen space Vector3 to use
  2895. * @param viewportWidth defines the current width of the viewport
  2896. * @param viewportHeight defines the current height of the viewport
  2897. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2898. * @param view defines the view matrix to use
  2899. * @param projection defines the projection matrix to use
  2900. * @returns the new Vector3
  2901. */
  2902. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2903. /**
  2904. * Unproject from screen space to object space
  2905. * @param source defines the screen space Vector3 to use
  2906. * @param viewportWidth defines the current width of the viewport
  2907. * @param viewportHeight defines the current height of the viewport
  2908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2909. * @param view defines the view matrix to use
  2910. * @param projection defines the projection matrix to use
  2911. * @param result defines the Vector3 where to store the result
  2912. */
  2913. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2914. /**
  2915. * Unproject from screen space to object space
  2916. * @param sourceX defines the screen space x coordinate to use
  2917. * @param sourceY defines the screen space y coordinate to use
  2918. * @param sourceZ defines the screen space z coordinate to use
  2919. * @param viewportWidth defines the current width of the viewport
  2920. * @param viewportHeight defines the current height of the viewport
  2921. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2922. * @param view defines the view matrix to use
  2923. * @param projection defines the projection matrix to use
  2924. * @param result defines the Vector3 where to store the result
  2925. */
  2926. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2927. /**
  2928. * Gets the minimal coordinate values between two Vector3
  2929. * @param left defines the first operand
  2930. * @param right defines the second operand
  2931. * @returns the new Vector3
  2932. */
  2933. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2934. /**
  2935. * Gets the maximal coordinate values between two Vector3
  2936. * @param left defines the first operand
  2937. * @param right defines the second operand
  2938. * @returns the new Vector3
  2939. */
  2940. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2941. /**
  2942. * Returns the distance between the vectors "value1" and "value2"
  2943. * @param value1 defines the first operand
  2944. * @param value2 defines the second operand
  2945. * @returns the distance
  2946. */
  2947. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2948. /**
  2949. * Returns the squared distance between the vectors "value1" and "value2"
  2950. * @param value1 defines the first operand
  2951. * @param value2 defines the second operand
  2952. * @returns the squared distance
  2953. */
  2954. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2955. /**
  2956. * Returns a new Vector3 located at the center between "value1" and "value2"
  2957. * @param value1 defines the first operand
  2958. * @param value2 defines the second operand
  2959. * @returns the new Vector3
  2960. */
  2961. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2962. /**
  2963. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2964. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2965. * to something in order to rotate it from its local system to the given target system
  2966. * Note: axis1, axis2 and axis3 are normalized during this operation
  2967. * @param axis1 defines the first axis
  2968. * @param axis2 defines the second axis
  2969. * @param axis3 defines the third axis
  2970. * @returns a new Vector3
  2971. */
  2972. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2973. /**
  2974. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2975. * @param axis1 defines the first axis
  2976. * @param axis2 defines the second axis
  2977. * @param axis3 defines the third axis
  2978. * @param ref defines the Vector3 where to store the result
  2979. */
  2980. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2981. }
  2982. /**
  2983. * Vector4 class created for EulerAngle class conversion to Quaternion
  2984. */
  2985. export class Vector4 {
  2986. /** x value of the vector */
  2987. x: number;
  2988. /** y value of the vector */
  2989. y: number;
  2990. /** z value of the vector */
  2991. z: number;
  2992. /** w value of the vector */
  2993. w: number;
  2994. /**
  2995. * Creates a Vector4 object from the given floats.
  2996. * @param x x value of the vector
  2997. * @param y y value of the vector
  2998. * @param z z value of the vector
  2999. * @param w w value of the vector
  3000. */
  3001. constructor(
  3002. /** x value of the vector */
  3003. x: number,
  3004. /** y value of the vector */
  3005. y: number,
  3006. /** z value of the vector */
  3007. z: number,
  3008. /** w value of the vector */
  3009. w: number);
  3010. /**
  3011. * Returns the string with the Vector4 coordinates.
  3012. * @returns a string containing all the vector values
  3013. */
  3014. toString(): string;
  3015. /**
  3016. * Returns the string "Vector4".
  3017. * @returns "Vector4"
  3018. */
  3019. getClassName(): string;
  3020. /**
  3021. * Returns the Vector4 hash code.
  3022. * @returns a unique hash code
  3023. */
  3024. getHashCode(): number;
  3025. /**
  3026. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3027. * @returns the resulting array
  3028. */
  3029. asArray(): number[];
  3030. /**
  3031. * Populates the given array from the given index with the Vector4 coordinates.
  3032. * @param array array to populate
  3033. * @param index index of the array to start at (default: 0)
  3034. * @returns the Vector4.
  3035. */
  3036. toArray(array: FloatArray, index?: number): Vector4;
  3037. /**
  3038. * Adds the given vector to the current Vector4.
  3039. * @param otherVector the vector to add
  3040. * @returns the updated Vector4.
  3041. */
  3042. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3043. /**
  3044. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3045. * @param otherVector the vector to add
  3046. * @returns the resulting vector
  3047. */
  3048. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3049. /**
  3050. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3051. * @param otherVector the vector to add
  3052. * @param result the vector to store the result
  3053. * @returns the current Vector4.
  3054. */
  3055. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3056. /**
  3057. * Subtract in place the given vector from the current Vector4.
  3058. * @param otherVector the vector to subtract
  3059. * @returns the updated Vector4.
  3060. */
  3061. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3062. /**
  3063. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3064. * @param otherVector the vector to add
  3065. * @returns the new vector with the result
  3066. */
  3067. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3068. /**
  3069. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3070. * @param otherVector the vector to subtract
  3071. * @param result the vector to store the result
  3072. * @returns the current Vector4.
  3073. */
  3074. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3075. /**
  3076. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3077. */
  3078. /**
  3079. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3080. * @param x value to subtract
  3081. * @param y value to subtract
  3082. * @param z value to subtract
  3083. * @param w value to subtract
  3084. * @returns new vector containing the result
  3085. */
  3086. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3087. /**
  3088. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3089. * @param x value to subtract
  3090. * @param y value to subtract
  3091. * @param z value to subtract
  3092. * @param w value to subtract
  3093. * @param result the vector to store the result in
  3094. * @returns the current Vector4.
  3095. */
  3096. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3097. /**
  3098. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3099. * @returns a new vector with the negated values
  3100. */
  3101. negate(): Vector4;
  3102. /**
  3103. * Multiplies the current Vector4 coordinates by scale (float).
  3104. * @param scale the number to scale with
  3105. * @returns the updated Vector4.
  3106. */
  3107. scaleInPlace(scale: number): Vector4;
  3108. /**
  3109. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3110. * @param scale the number to scale with
  3111. * @returns a new vector with the result
  3112. */
  3113. scale(scale: number): Vector4;
  3114. /**
  3115. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3116. * @param scale the number to scale with
  3117. * @param result a vector to store the result in
  3118. * @returns the current Vector4.
  3119. */
  3120. scaleToRef(scale: number, result: Vector4): Vector4;
  3121. /**
  3122. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3123. * @param scale defines the scale factor
  3124. * @param result defines the Vector4 object where to store the result
  3125. * @returns the unmodified current Vector4
  3126. */
  3127. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3128. /**
  3129. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3130. * @param otherVector the vector to compare against
  3131. * @returns true if they are equal
  3132. */
  3133. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3134. /**
  3135. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3136. * @param otherVector vector to compare against
  3137. * @param epsilon (Default: very small number)
  3138. * @returns true if they are equal
  3139. */
  3140. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3141. /**
  3142. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3143. * @param x x value to compare against
  3144. * @param y y value to compare against
  3145. * @param z z value to compare against
  3146. * @param w w value to compare against
  3147. * @returns true if equal
  3148. */
  3149. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3150. /**
  3151. * Multiplies in place the current Vector4 by the given one.
  3152. * @param otherVector vector to multiple with
  3153. * @returns the updated Vector4.
  3154. */
  3155. multiplyInPlace(otherVector: Vector4): Vector4;
  3156. /**
  3157. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3158. * @param otherVector vector to multiple with
  3159. * @returns resulting new vector
  3160. */
  3161. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3162. /**
  3163. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3164. * @param otherVector vector to multiple with
  3165. * @param result vector to store the result
  3166. * @returns the current Vector4.
  3167. */
  3168. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3169. /**
  3170. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3171. * @param x x value multiply with
  3172. * @param y y value multiply with
  3173. * @param z z value multiply with
  3174. * @param w w value multiply with
  3175. * @returns resulting new vector
  3176. */
  3177. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3178. /**
  3179. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3180. * @param otherVector vector to devide with
  3181. * @returns resulting new vector
  3182. */
  3183. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3184. /**
  3185. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3186. * @param otherVector vector to devide with
  3187. * @param result vector to store the result
  3188. * @returns the current Vector4.
  3189. */
  3190. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3191. /**
  3192. * Divides the current Vector3 coordinates by the given ones.
  3193. * @param otherVector vector to devide with
  3194. * @returns the updated Vector3.
  3195. */
  3196. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3197. /**
  3198. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3199. * @param other defines the second operand
  3200. * @returns the current updated Vector4
  3201. */
  3202. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3203. /**
  3204. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3205. * @param other defines the second operand
  3206. * @returns the current updated Vector4
  3207. */
  3208. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3209. /**
  3210. * Gets a new Vector4 from current Vector4 floored values
  3211. * @returns a new Vector4
  3212. */
  3213. floor(): Vector4;
  3214. /**
  3215. * Gets a new Vector4 from current Vector3 floored values
  3216. * @returns a new Vector4
  3217. */
  3218. fract(): Vector4;
  3219. /**
  3220. * Returns the Vector4 length (float).
  3221. * @returns the length
  3222. */
  3223. length(): number;
  3224. /**
  3225. * Returns the Vector4 squared length (float).
  3226. * @returns the length squared
  3227. */
  3228. lengthSquared(): number;
  3229. /**
  3230. * Normalizes in place the Vector4.
  3231. * @returns the updated Vector4.
  3232. */
  3233. normalize(): Vector4;
  3234. /**
  3235. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3236. * @returns this converted to a new vector3
  3237. */
  3238. toVector3(): Vector3;
  3239. /**
  3240. * Returns a new Vector4 copied from the current one.
  3241. * @returns the new cloned vector
  3242. */
  3243. clone(): Vector4;
  3244. /**
  3245. * Updates the current Vector4 with the given one coordinates.
  3246. * @param source the source vector to copy from
  3247. * @returns the updated Vector4.
  3248. */
  3249. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3250. /**
  3251. * Updates the current Vector4 coordinates with the given floats.
  3252. * @param x float to copy from
  3253. * @param y float to copy from
  3254. * @param z float to copy from
  3255. * @param w float to copy from
  3256. * @returns the updated Vector4.
  3257. */
  3258. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3259. /**
  3260. * Updates the current Vector4 coordinates with the given floats.
  3261. * @param x float to set from
  3262. * @param y float to set from
  3263. * @param z float to set from
  3264. * @param w float to set from
  3265. * @returns the updated Vector4.
  3266. */
  3267. set(x: number, y: number, z: number, w: number): Vector4;
  3268. /**
  3269. * Copies the given float to the current Vector3 coordinates
  3270. * @param v defines the x, y, z and w coordinates of the operand
  3271. * @returns the current updated Vector3
  3272. */
  3273. setAll(v: number): Vector4;
  3274. /**
  3275. * Returns a new Vector4 set from the starting index of the given array.
  3276. * @param array the array to pull values from
  3277. * @param offset the offset into the array to start at
  3278. * @returns the new vector
  3279. */
  3280. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3281. /**
  3282. * Updates the given vector "result" from the starting index of the given array.
  3283. * @param array the array to pull values from
  3284. * @param offset the offset into the array to start at
  3285. * @param result the vector to store the result in
  3286. */
  3287. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3288. /**
  3289. * Updates the given vector "result" from the starting index of the given Float32Array.
  3290. * @param array the array to pull values from
  3291. * @param offset the offset into the array to start at
  3292. * @param result the vector to store the result in
  3293. */
  3294. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3295. /**
  3296. * Updates the given vector "result" coordinates from the given floats.
  3297. * @param x float to set from
  3298. * @param y float to set from
  3299. * @param z float to set from
  3300. * @param w float to set from
  3301. * @param result the vector to the floats in
  3302. */
  3303. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3304. /**
  3305. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3306. * @returns the new vector
  3307. */
  3308. static Zero(): Vector4;
  3309. /**
  3310. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3311. * @returns the new vector
  3312. */
  3313. static One(): Vector4;
  3314. /**
  3315. * Returns a new normalized Vector4 from the given one.
  3316. * @param vector the vector to normalize
  3317. * @returns the vector
  3318. */
  3319. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3320. /**
  3321. * Updates the given vector "result" from the normalization of the given one.
  3322. * @param vector the vector to normalize
  3323. * @param result the vector to store the result in
  3324. */
  3325. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3326. /**
  3327. * Returns a vector with the minimum values from the left and right vectors
  3328. * @param left left vector to minimize
  3329. * @param right right vector to minimize
  3330. * @returns a new vector with the minimum of the left and right vector values
  3331. */
  3332. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Returns a vector with the maximum values from the left and right vectors
  3335. * @param left left vector to maximize
  3336. * @param right right vector to maximize
  3337. * @returns a new vector with the maximum of the left and right vector values
  3338. */
  3339. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Returns the distance (float) between the vectors "value1" and "value2".
  3342. * @param value1 value to calulate the distance between
  3343. * @param value2 value to calulate the distance between
  3344. * @return the distance between the two vectors
  3345. */
  3346. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3347. /**
  3348. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3349. * @param value1 value to calulate the distance between
  3350. * @param value2 value to calulate the distance between
  3351. * @return the distance between the two vectors squared
  3352. */
  3353. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3354. /**
  3355. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3356. * @param value1 value to calulate the center between
  3357. * @param value2 value to calulate the center between
  3358. * @return the center between the two vectors
  3359. */
  3360. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3361. /**
  3362. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3363. * This methods computes transformed normalized direction vectors only.
  3364. * @param vector the vector to transform
  3365. * @param transformation the transformation matrix to apply
  3366. * @returns the new vector
  3367. */
  3368. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3369. /**
  3370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3371. * This methods computes transformed normalized direction vectors only.
  3372. * @param vector the vector to transform
  3373. * @param transformation the transformation matrix to apply
  3374. * @param result the vector to store the result in
  3375. */
  3376. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3377. /**
  3378. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3379. * This methods computes transformed normalized direction vectors only.
  3380. * @param x value to transform
  3381. * @param y value to transform
  3382. * @param z value to transform
  3383. * @param w value to transform
  3384. * @param transformation the transformation matrix to apply
  3385. * @param result the vector to store the results in
  3386. */
  3387. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3388. /**
  3389. * Creates a new Vector4 from a Vector3
  3390. * @param source defines the source data
  3391. * @param w defines the 4th component (default is 0)
  3392. * @returns a new Vector4
  3393. */
  3394. static FromVector3(source: Vector3, w?: number): Vector4;
  3395. }
  3396. /**
  3397. * Class used to store quaternion data
  3398. * @see https://en.wikipedia.org/wiki/Quaternion
  3399. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3400. */
  3401. export class Quaternion {
  3402. /** defines the first component (0 by default) */
  3403. x: number;
  3404. /** defines the second component (0 by default) */
  3405. y: number;
  3406. /** defines the third component (0 by default) */
  3407. z: number;
  3408. /** defines the fourth component (1.0 by default) */
  3409. w: number;
  3410. /**
  3411. * Creates a new Quaternion from the given floats
  3412. * @param x defines the first component (0 by default)
  3413. * @param y defines the second component (0 by default)
  3414. * @param z defines the third component (0 by default)
  3415. * @param w defines the fourth component (1.0 by default)
  3416. */
  3417. constructor(
  3418. /** defines the first component (0 by default) */
  3419. x?: number,
  3420. /** defines the second component (0 by default) */
  3421. y?: number,
  3422. /** defines the third component (0 by default) */
  3423. z?: number,
  3424. /** defines the fourth component (1.0 by default) */
  3425. w?: number);
  3426. /**
  3427. * Gets a string representation for the current quaternion
  3428. * @returns a string with the Quaternion coordinates
  3429. */
  3430. toString(): string;
  3431. /**
  3432. * Gets the class name of the quaternion
  3433. * @returns the string "Quaternion"
  3434. */
  3435. getClassName(): string;
  3436. /**
  3437. * Gets a hash code for this quaternion
  3438. * @returns the quaternion hash code
  3439. */
  3440. getHashCode(): number;
  3441. /**
  3442. * Copy the quaternion to an array
  3443. * @returns a new array populated with 4 elements from the quaternion coordinates
  3444. */
  3445. asArray(): number[];
  3446. /**
  3447. * Check if two quaternions are equals
  3448. * @param otherQuaternion defines the second operand
  3449. * @return true if the current quaternion and the given one coordinates are strictly equals
  3450. */
  3451. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3452. /**
  3453. * Clone the current quaternion
  3454. * @returns a new quaternion copied from the current one
  3455. */
  3456. clone(): Quaternion;
  3457. /**
  3458. * Copy a quaternion to the current one
  3459. * @param other defines the other quaternion
  3460. * @returns the updated current quaternion
  3461. */
  3462. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3463. /**
  3464. * Updates the current quaternion with the given float coordinates
  3465. * @param x defines the x coordinate
  3466. * @param y defines the y coordinate
  3467. * @param z defines the z coordinate
  3468. * @param w defines the w coordinate
  3469. * @returns the updated current quaternion
  3470. */
  3471. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3472. /**
  3473. * Updates the current quaternion from the given float coordinates
  3474. * @param x defines the x coordinate
  3475. * @param y defines the y coordinate
  3476. * @param z defines the z coordinate
  3477. * @param w defines the w coordinate
  3478. * @returns the updated current quaternion
  3479. */
  3480. set(x: number, y: number, z: number, w: number): Quaternion;
  3481. /**
  3482. * Adds two quaternions
  3483. * @param other defines the second operand
  3484. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3485. */
  3486. add(other: DeepImmutable<Quaternion>): Quaternion;
  3487. /**
  3488. * Add a quaternion to the current one
  3489. * @param other defines the quaternion to add
  3490. * @returns the current quaternion
  3491. */
  3492. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3493. /**
  3494. * Subtract two quaternions
  3495. * @param other defines the second operand
  3496. * @returns a new quaternion as the subtraction result of the given one from the current one
  3497. */
  3498. subtract(other: Quaternion): Quaternion;
  3499. /**
  3500. * Multiplies the current quaternion by a scale factor
  3501. * @param value defines the scale factor
  3502. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3503. */
  3504. scale(value: number): Quaternion;
  3505. /**
  3506. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3507. * @param scale defines the scale factor
  3508. * @param result defines the Quaternion object where to store the result
  3509. * @returns the unmodified current quaternion
  3510. */
  3511. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3512. /**
  3513. * Multiplies in place the current quaternion by a scale factor
  3514. * @param value defines the scale factor
  3515. * @returns the current modified quaternion
  3516. */
  3517. scaleInPlace(value: number): Quaternion;
  3518. /**
  3519. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3520. * @param scale defines the scale factor
  3521. * @param result defines the Quaternion object where to store the result
  3522. * @returns the unmodified current quaternion
  3523. */
  3524. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3525. /**
  3526. * Multiplies two quaternions
  3527. * @param q1 defines the second operand
  3528. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3529. */
  3530. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3531. /**
  3532. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3533. * @param q1 defines the second operand
  3534. * @param result defines the target quaternion
  3535. * @returns the current quaternion
  3536. */
  3537. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3538. /**
  3539. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3540. * @param q1 defines the second operand
  3541. * @returns the currentupdated quaternion
  3542. */
  3543. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3544. /**
  3545. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3546. * @param ref defines the target quaternion
  3547. * @returns the current quaternion
  3548. */
  3549. conjugateToRef(ref: Quaternion): Quaternion;
  3550. /**
  3551. * Conjugates in place (1-q) the current quaternion
  3552. * @returns the current updated quaternion
  3553. */
  3554. conjugateInPlace(): Quaternion;
  3555. /**
  3556. * Conjugates in place (1-q) the current quaternion
  3557. * @returns a new quaternion
  3558. */
  3559. conjugate(): Quaternion;
  3560. /**
  3561. * Gets length of current quaternion
  3562. * @returns the quaternion length (float)
  3563. */
  3564. length(): number;
  3565. /**
  3566. * Normalize in place the current quaternion
  3567. * @returns the current updated quaternion
  3568. */
  3569. normalize(): Quaternion;
  3570. /**
  3571. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3572. * @param order is a reserved parameter and is ignore for now
  3573. * @returns a new Vector3 containing the Euler angles
  3574. */
  3575. toEulerAngles(order?: string): Vector3;
  3576. /**
  3577. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3578. * @param result defines the vector which will be filled with the Euler angles
  3579. * @param order is a reserved parameter and is ignore for now
  3580. * @returns the current unchanged quaternion
  3581. */
  3582. toEulerAnglesToRef(result: Vector3): Quaternion;
  3583. /**
  3584. * Updates the given rotation matrix with the current quaternion values
  3585. * @param result defines the target matrix
  3586. * @returns the current unchanged quaternion
  3587. */
  3588. toRotationMatrix(result: Matrix): Quaternion;
  3589. /**
  3590. * Updates the current quaternion from the given rotation matrix values
  3591. * @param matrix defines the source matrix
  3592. * @returns the current updated quaternion
  3593. */
  3594. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3595. /**
  3596. * Creates a new quaternion from a rotation matrix
  3597. * @param matrix defines the source matrix
  3598. * @returns a new quaternion created from the given rotation matrix values
  3599. */
  3600. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3601. /**
  3602. * Updates the given quaternion with the given rotation matrix values
  3603. * @param matrix defines the source matrix
  3604. * @param result defines the target quaternion
  3605. */
  3606. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3607. /**
  3608. * Returns the dot product (float) between the quaternions "left" and "right"
  3609. * @param left defines the left operand
  3610. * @param right defines the right operand
  3611. * @returns the dot product
  3612. */
  3613. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3614. /**
  3615. * Checks if the two quaternions are close to each other
  3616. * @param quat0 defines the first quaternion to check
  3617. * @param quat1 defines the second quaternion to check
  3618. * @returns true if the two quaternions are close to each other
  3619. */
  3620. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3621. /**
  3622. * Creates an empty quaternion
  3623. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3624. */
  3625. static Zero(): Quaternion;
  3626. /**
  3627. * Inverse a given quaternion
  3628. * @param q defines the source quaternion
  3629. * @returns a new quaternion as the inverted current quaternion
  3630. */
  3631. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3632. /**
  3633. * Inverse a given quaternion
  3634. * @param q defines the source quaternion
  3635. * @param result the quaternion the result will be stored in
  3636. * @returns the result quaternion
  3637. */
  3638. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3639. /**
  3640. * Creates an identity quaternion
  3641. * @returns the identity quaternion
  3642. */
  3643. static Identity(): Quaternion;
  3644. /**
  3645. * Gets a boolean indicating if the given quaternion is identity
  3646. * @param quaternion defines the quaternion to check
  3647. * @returns true if the quaternion is identity
  3648. */
  3649. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3650. /**
  3651. * Creates a quaternion from a rotation around an axis
  3652. * @param axis defines the axis to use
  3653. * @param angle defines the angle to use
  3654. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3655. */
  3656. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3657. /**
  3658. * Creates a rotation around an axis and stores it into the given quaternion
  3659. * @param axis defines the axis to use
  3660. * @param angle defines the angle to use
  3661. * @param result defines the target quaternion
  3662. * @returns the target quaternion
  3663. */
  3664. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3665. /**
  3666. * Creates a new quaternion from data stored into an array
  3667. * @param array defines the data source
  3668. * @param offset defines the offset in the source array where the data starts
  3669. * @returns a new quaternion
  3670. */
  3671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3672. /**
  3673. * Create a quaternion from Euler rotation angles
  3674. * @param x Pitch
  3675. * @param y Yaw
  3676. * @param z Roll
  3677. * @returns the new Quaternion
  3678. */
  3679. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3680. /**
  3681. * Updates a quaternion from Euler rotation angles
  3682. * @param x Pitch
  3683. * @param y Yaw
  3684. * @param z Roll
  3685. * @param result the quaternion to store the result
  3686. * @returns the updated quaternion
  3687. */
  3688. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3689. /**
  3690. * Create a quaternion from Euler rotation vector
  3691. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3692. * @returns the new Quaternion
  3693. */
  3694. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3695. /**
  3696. * Updates a quaternion from Euler rotation vector
  3697. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3698. * @param result the quaternion to store the result
  3699. * @returns the updated quaternion
  3700. */
  3701. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3704. * @param yaw defines the rotation around Y axis
  3705. * @param pitch defines the rotation around X axis
  3706. * @param roll defines the rotation around Z axis
  3707. * @returns the new quaternion
  3708. */
  3709. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3710. /**
  3711. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3712. * @param yaw defines the rotation around Y axis
  3713. * @param pitch defines the rotation around X axis
  3714. * @param roll defines the rotation around Z axis
  3715. * @param result defines the target quaternion
  3716. */
  3717. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3718. /**
  3719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3720. * @param alpha defines the rotation around first axis
  3721. * @param beta defines the rotation around second axis
  3722. * @param gamma defines the rotation around third axis
  3723. * @returns the new quaternion
  3724. */
  3725. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3726. /**
  3727. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3728. * @param alpha defines the rotation around first axis
  3729. * @param beta defines the rotation around second axis
  3730. * @param gamma defines the rotation around third axis
  3731. * @param result defines the target quaternion
  3732. */
  3733. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3734. /**
  3735. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3736. * @param axis1 defines the first axis
  3737. * @param axis2 defines the second axis
  3738. * @param axis3 defines the third axis
  3739. * @returns the new quaternion
  3740. */
  3741. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3742. /**
  3743. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3744. * @param axis1 defines the first axis
  3745. * @param axis2 defines the second axis
  3746. * @param axis3 defines the third axis
  3747. * @param ref defines the target quaternion
  3748. */
  3749. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3750. /**
  3751. * Interpolates between two quaternions
  3752. * @param left defines first quaternion
  3753. * @param right defines second quaternion
  3754. * @param amount defines the gradient to use
  3755. * @returns the new interpolated quaternion
  3756. */
  3757. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3758. /**
  3759. * Interpolates between two quaternions and stores it into a target quaternion
  3760. * @param left defines first quaternion
  3761. * @param right defines second quaternion
  3762. * @param amount defines the gradient to use
  3763. * @param result defines the target quaternion
  3764. */
  3765. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3766. /**
  3767. * Interpolate between two quaternions using Hermite interpolation
  3768. * @param value1 defines first quaternion
  3769. * @param tangent1 defines the incoming tangent
  3770. * @param value2 defines second quaternion
  3771. * @param tangent2 defines the outgoing tangent
  3772. * @param amount defines the target quaternion
  3773. * @returns the new interpolated quaternion
  3774. */
  3775. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3776. }
  3777. /**
  3778. * Class used to store matrix data (4x4)
  3779. */
  3780. export class Matrix {
  3781. private static _updateFlagSeed;
  3782. private static _identityReadOnly;
  3783. private _isIdentity;
  3784. private _isIdentityDirty;
  3785. private _isIdentity3x2;
  3786. private _isIdentity3x2Dirty;
  3787. /**
  3788. * Gets the update flag of the matrix which is an unique number for the matrix.
  3789. * It will be incremented every time the matrix data change.
  3790. * You can use it to speed the comparison between two versions of the same matrix.
  3791. */
  3792. updateFlag: number;
  3793. private readonly _m;
  3794. /**
  3795. * Gets the internal data of the matrix
  3796. */
  3797. readonly m: DeepImmutable<Float32Array>;
  3798. /** @hidden */
  3799. _markAsUpdated(): void;
  3800. /** @hidden */
  3801. private _updateIdentityStatus;
  3802. /**
  3803. * Creates an empty matrix (filled with zeros)
  3804. */
  3805. constructor();
  3806. /**
  3807. * Check if the current matrix is identity
  3808. * @returns true is the matrix is the identity matrix
  3809. */
  3810. isIdentity(): boolean;
  3811. /**
  3812. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3813. * @returns true is the matrix is the identity matrix
  3814. */
  3815. isIdentityAs3x2(): boolean;
  3816. /**
  3817. * Gets the determinant of the matrix
  3818. * @returns the matrix determinant
  3819. */
  3820. determinant(): number;
  3821. /**
  3822. * Returns the matrix as a Float32Array
  3823. * @returns the matrix underlying array
  3824. */
  3825. toArray(): DeepImmutable<Float32Array>;
  3826. /**
  3827. * Returns the matrix as a Float32Array
  3828. * @returns the matrix underlying array.
  3829. */
  3830. asArray(): DeepImmutable<Float32Array>;
  3831. /**
  3832. * Inverts the current matrix in place
  3833. * @returns the current inverted matrix
  3834. */
  3835. invert(): Matrix;
  3836. /**
  3837. * Sets all the matrix elements to zero
  3838. * @returns the current matrix
  3839. */
  3840. reset(): Matrix;
  3841. /**
  3842. * Adds the current matrix with a second one
  3843. * @param other defines the matrix to add
  3844. * @returns a new matrix as the addition of the current matrix and the given one
  3845. */
  3846. add(other: DeepImmutable<Matrix>): Matrix;
  3847. /**
  3848. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3849. * @param other defines the matrix to add
  3850. * @param result defines the target matrix
  3851. * @returns the current matrix
  3852. */
  3853. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3854. /**
  3855. * Adds in place the given matrix to the current matrix
  3856. * @param other defines the second operand
  3857. * @returns the current updated matrix
  3858. */
  3859. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3860. /**
  3861. * Sets the given matrix to the current inverted Matrix
  3862. * @param other defines the target matrix
  3863. * @returns the unmodified current matrix
  3864. */
  3865. invertToRef(other: Matrix): Matrix;
  3866. /**
  3867. * add a value at the specified position in the current Matrix
  3868. * @param index the index of the value within the matrix. between 0 and 15.
  3869. * @param value the value to be added
  3870. * @returns the current updated matrix
  3871. */
  3872. addAtIndex(index: number, value: number): Matrix;
  3873. /**
  3874. * mutiply the specified position in the current Matrix by a value
  3875. * @param index the index of the value within the matrix. between 0 and 15.
  3876. * @param value the value to be added
  3877. * @returns the current updated matrix
  3878. */
  3879. multiplyAtIndex(index: number, value: number): Matrix;
  3880. /**
  3881. * Inserts the translation vector (using 3 floats) in the current matrix
  3882. * @param x defines the 1st component of the translation
  3883. * @param y defines the 2nd component of the translation
  3884. * @param z defines the 3rd component of the translation
  3885. * @returns the current updated matrix
  3886. */
  3887. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3888. /**
  3889. * Adds the translation vector (using 3 floats) in the current matrix
  3890. * @param x defines the 1st component of the translation
  3891. * @param y defines the 2nd component of the translation
  3892. * @param z defines the 3rd component of the translation
  3893. * @returns the current updated matrix
  3894. */
  3895. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3896. /**
  3897. * Inserts the translation vector in the current matrix
  3898. * @param vector3 defines the translation to insert
  3899. * @returns the current updated matrix
  3900. */
  3901. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3902. /**
  3903. * Gets the translation value of the current matrix
  3904. * @returns a new Vector3 as the extracted translation from the matrix
  3905. */
  3906. getTranslation(): Vector3;
  3907. /**
  3908. * Fill a Vector3 with the extracted translation from the matrix
  3909. * @param result defines the Vector3 where to store the translation
  3910. * @returns the current matrix
  3911. */
  3912. getTranslationToRef(result: Vector3): Matrix;
  3913. /**
  3914. * Remove rotation and scaling part from the matrix
  3915. * @returns the updated matrix
  3916. */
  3917. removeRotationAndScaling(): Matrix;
  3918. /**
  3919. * Multiply two matrices
  3920. * @param other defines the second operand
  3921. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3922. */
  3923. multiply(other: DeepImmutable<Matrix>): Matrix;
  3924. /**
  3925. * Copy the current matrix from the given one
  3926. * @param other defines the source matrix
  3927. * @returns the current updated matrix
  3928. */
  3929. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3930. /**
  3931. * Populates the given array from the starting index with the current matrix values
  3932. * @param array defines the target array
  3933. * @param offset defines the offset in the target array where to start storing values
  3934. * @returns the current matrix
  3935. */
  3936. copyToArray(array: Float32Array, offset?: number): Matrix;
  3937. /**
  3938. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3939. * @param other defines the second operand
  3940. * @param result defines the matrix where to store the multiplication
  3941. * @returns the current matrix
  3942. */
  3943. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3944. /**
  3945. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3946. * @param other defines the second operand
  3947. * @param result defines the array where to store the multiplication
  3948. * @param offset defines the offset in the target array where to start storing values
  3949. * @returns the current matrix
  3950. */
  3951. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3952. /**
  3953. * Check equality between this matrix and a second one
  3954. * @param value defines the second matrix to compare
  3955. * @returns true is the current matrix and the given one values are strictly equal
  3956. */
  3957. equals(value: DeepImmutable<Matrix>): boolean;
  3958. /**
  3959. * Clone the current matrix
  3960. * @returns a new matrix from the current matrix
  3961. */
  3962. clone(): Matrix;
  3963. /**
  3964. * Returns the name of the current matrix class
  3965. * @returns the string "Matrix"
  3966. */
  3967. getClassName(): string;
  3968. /**
  3969. * Gets the hash code of the current matrix
  3970. * @returns the hash code
  3971. */
  3972. getHashCode(): number;
  3973. /**
  3974. * Decomposes the current Matrix into a translation, rotation and scaling components
  3975. * @param scale defines the scale vector3 given as a reference to update
  3976. * @param rotation defines the rotation quaternion given as a reference to update
  3977. * @param translation defines the translation vector3 given as a reference to update
  3978. * @returns true if operation was successful
  3979. */
  3980. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3981. /**
  3982. * Gets specific row of the matrix
  3983. * @param index defines the number of the row to get
  3984. * @returns the index-th row of the current matrix as a new Vector4
  3985. */
  3986. getRow(index: number): Nullable<Vector4>;
  3987. /**
  3988. * Sets the index-th row of the current matrix to the vector4 values
  3989. * @param index defines the number of the row to set
  3990. * @param row defines the target vector4
  3991. * @returns the updated current matrix
  3992. */
  3993. setRow(index: number, row: Vector4): Matrix;
  3994. /**
  3995. * Compute the transpose of the matrix
  3996. * @returns the new transposed matrix
  3997. */
  3998. transpose(): Matrix;
  3999. /**
  4000. * Compute the transpose of the matrix and store it in a given matrix
  4001. * @param result defines the target matrix
  4002. * @returns the current matrix
  4003. */
  4004. transposeToRef(result: Matrix): Matrix;
  4005. /**
  4006. * Sets the index-th row of the current matrix with the given 4 x float values
  4007. * @param index defines the row index
  4008. * @param x defines the x component to set
  4009. * @param y defines the y component to set
  4010. * @param z defines the z component to set
  4011. * @param w defines the w component to set
  4012. * @returns the updated current matrix
  4013. */
  4014. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4015. /**
  4016. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4017. * @param scale defines the scale factor
  4018. * @returns a new matrix
  4019. */
  4020. scale(scale: number): Matrix;
  4021. /**
  4022. * Scale the current matrix values by a factor to a given result matrix
  4023. * @param scale defines the scale factor
  4024. * @param result defines the matrix to store the result
  4025. * @returns the current matrix
  4026. */
  4027. scaleToRef(scale: number, result: Matrix): Matrix;
  4028. /**
  4029. * Scale the current matrix values by a factor and add the result to a given matrix
  4030. * @param scale defines the scale factor
  4031. * @param result defines the Matrix to store the result
  4032. * @returns the current matrix
  4033. */
  4034. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4035. /**
  4036. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4037. * @param ref matrix to store the result
  4038. */
  4039. toNormalMatrix(ref: Matrix): void;
  4040. /**
  4041. * Gets only rotation part of the current matrix
  4042. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4043. */
  4044. getRotationMatrix(): Matrix;
  4045. /**
  4046. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4047. * @param result defines the target matrix to store data to
  4048. * @returns the current matrix
  4049. */
  4050. getRotationMatrixToRef(result: Matrix): Matrix;
  4051. /**
  4052. * Toggles model matrix from being right handed to left handed in place and vice versa
  4053. */
  4054. toggleModelMatrixHandInPlace(): void;
  4055. /**
  4056. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4057. */
  4058. toggleProjectionMatrixHandInPlace(): void;
  4059. /**
  4060. * Creates a matrix from an array
  4061. * @param array defines the source array
  4062. * @param offset defines an offset in the source array
  4063. * @returns a new Matrix set from the starting index of the given array
  4064. */
  4065. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4066. /**
  4067. * Copy the content of an array into a given matrix
  4068. * @param array defines the source array
  4069. * @param offset defines an offset in the source array
  4070. * @param result defines the target matrix
  4071. */
  4072. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4073. /**
  4074. * Stores an array into a matrix after having multiplied each component by a given factor
  4075. * @param array defines the source array
  4076. * @param offset defines the offset in the source array
  4077. * @param scale defines the scaling factor
  4078. * @param result defines the target matrix
  4079. */
  4080. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4081. /**
  4082. * Gets an identity matrix that must not be updated
  4083. */
  4084. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4085. /**
  4086. * Stores a list of values (16) inside a given matrix
  4087. * @param initialM11 defines 1st value of 1st row
  4088. * @param initialM12 defines 2nd value of 1st row
  4089. * @param initialM13 defines 3rd value of 1st row
  4090. * @param initialM14 defines 4th value of 1st row
  4091. * @param initialM21 defines 1st value of 2nd row
  4092. * @param initialM22 defines 2nd value of 2nd row
  4093. * @param initialM23 defines 3rd value of 2nd row
  4094. * @param initialM24 defines 4th value of 2nd row
  4095. * @param initialM31 defines 1st value of 3rd row
  4096. * @param initialM32 defines 2nd value of 3rd row
  4097. * @param initialM33 defines 3rd value of 3rd row
  4098. * @param initialM34 defines 4th value of 3rd row
  4099. * @param initialM41 defines 1st value of 4th row
  4100. * @param initialM42 defines 2nd value of 4th row
  4101. * @param initialM43 defines 3rd value of 4th row
  4102. * @param initialM44 defines 4th value of 4th row
  4103. * @param result defines the target matrix
  4104. */
  4105. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4106. /**
  4107. * Creates new matrix from a list of values (16)
  4108. * @param initialM11 defines 1st value of 1st row
  4109. * @param initialM12 defines 2nd value of 1st row
  4110. * @param initialM13 defines 3rd value of 1st row
  4111. * @param initialM14 defines 4th value of 1st row
  4112. * @param initialM21 defines 1st value of 2nd row
  4113. * @param initialM22 defines 2nd value of 2nd row
  4114. * @param initialM23 defines 3rd value of 2nd row
  4115. * @param initialM24 defines 4th value of 2nd row
  4116. * @param initialM31 defines 1st value of 3rd row
  4117. * @param initialM32 defines 2nd value of 3rd row
  4118. * @param initialM33 defines 3rd value of 3rd row
  4119. * @param initialM34 defines 4th value of 3rd row
  4120. * @param initialM41 defines 1st value of 4th row
  4121. * @param initialM42 defines 2nd value of 4th row
  4122. * @param initialM43 defines 3rd value of 4th row
  4123. * @param initialM44 defines 4th value of 4th row
  4124. * @returns the new matrix
  4125. */
  4126. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4127. /**
  4128. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4129. * @param scale defines the scale vector3
  4130. * @param rotation defines the rotation quaternion
  4131. * @param translation defines the translation vector3
  4132. * @returns a new matrix
  4133. */
  4134. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4135. /**
  4136. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4137. * @param scale defines the scale vector3
  4138. * @param rotation defines the rotation quaternion
  4139. * @param translation defines the translation vector3
  4140. * @param result defines the target matrix
  4141. */
  4142. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4143. /**
  4144. * Creates a new identity matrix
  4145. * @returns a new identity matrix
  4146. */
  4147. static Identity(): Matrix;
  4148. /**
  4149. * Creates a new identity matrix and stores the result in a given matrix
  4150. * @param result defines the target matrix
  4151. */
  4152. static IdentityToRef(result: Matrix): void;
  4153. /**
  4154. * Creates a new zero matrix
  4155. * @returns a new zero matrix
  4156. */
  4157. static Zero(): Matrix;
  4158. /**
  4159. * Creates a new rotation matrix for "angle" radians around the X axis
  4160. * @param angle defines the angle (in radians) to use
  4161. * @return the new matrix
  4162. */
  4163. static RotationX(angle: number): Matrix;
  4164. /**
  4165. * Creates a new matrix as the invert of a given matrix
  4166. * @param source defines the source matrix
  4167. * @returns the new matrix
  4168. */
  4169. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4170. /**
  4171. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4172. * @param angle defines the angle (in radians) to use
  4173. * @param result defines the target matrix
  4174. */
  4175. static RotationXToRef(angle: number, result: Matrix): void;
  4176. /**
  4177. * Creates a new rotation matrix for "angle" radians around the Y axis
  4178. * @param angle defines the angle (in radians) to use
  4179. * @return the new matrix
  4180. */
  4181. static RotationY(angle: number): Matrix;
  4182. /**
  4183. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4184. * @param angle defines the angle (in radians) to use
  4185. * @param result defines the target matrix
  4186. */
  4187. static RotationYToRef(angle: number, result: Matrix): void;
  4188. /**
  4189. * Creates a new rotation matrix for "angle" radians around the Z axis
  4190. * @param angle defines the angle (in radians) to use
  4191. * @return the new matrix
  4192. */
  4193. static RotationZ(angle: number): Matrix;
  4194. /**
  4195. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4196. * @param angle defines the angle (in radians) to use
  4197. * @param result defines the target matrix
  4198. */
  4199. static RotationZToRef(angle: number, result: Matrix): void;
  4200. /**
  4201. * Creates a new rotation matrix for "angle" radians around the given axis
  4202. * @param axis defines the axis to use
  4203. * @param angle defines the angle (in radians) to use
  4204. * @return the new matrix
  4205. */
  4206. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4207. /**
  4208. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4209. * @param axis defines the axis to use
  4210. * @param angle defines the angle (in radians) to use
  4211. * @param result defines the target matrix
  4212. */
  4213. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4214. /**
  4215. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4216. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4217. * @param from defines the vector to align
  4218. * @param to defines the vector to align to
  4219. * @param result defines the target matrix
  4220. */
  4221. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4222. /**
  4223. * Creates a rotation matrix
  4224. * @param yaw defines the yaw angle in radians (Y axis)
  4225. * @param pitch defines the pitch angle in radians (X axis)
  4226. * @param roll defines the roll angle in radians (X axis)
  4227. * @returns the new rotation matrix
  4228. */
  4229. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4230. /**
  4231. * Creates a rotation matrix and stores it in a given matrix
  4232. * @param yaw defines the yaw angle in radians (Y axis)
  4233. * @param pitch defines the pitch angle in radians (X axis)
  4234. * @param roll defines the roll angle in radians (X axis)
  4235. * @param result defines the target matrix
  4236. */
  4237. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4238. /**
  4239. * Creates a scaling matrix
  4240. * @param x defines the scale factor on X axis
  4241. * @param y defines the scale factor on Y axis
  4242. * @param z defines the scale factor on Z axis
  4243. * @returns the new matrix
  4244. */
  4245. static Scaling(x: number, y: number, z: number): Matrix;
  4246. /**
  4247. * Creates a scaling matrix and stores it in a given matrix
  4248. * @param x defines the scale factor on X axis
  4249. * @param y defines the scale factor on Y axis
  4250. * @param z defines the scale factor on Z axis
  4251. * @param result defines the target matrix
  4252. */
  4253. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4254. /**
  4255. * Creates a translation matrix
  4256. * @param x defines the translation on X axis
  4257. * @param y defines the translation on Y axis
  4258. * @param z defines the translationon Z axis
  4259. * @returns the new matrix
  4260. */
  4261. static Translation(x: number, y: number, z: number): Matrix;
  4262. /**
  4263. * Creates a translation matrix and stores it in a given matrix
  4264. * @param x defines the translation on X axis
  4265. * @param y defines the translation on Y axis
  4266. * @param z defines the translationon Z axis
  4267. * @param result defines the target matrix
  4268. */
  4269. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4270. /**
  4271. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4272. * @param startValue defines the start value
  4273. * @param endValue defines the end value
  4274. * @param gradient defines the gradient factor
  4275. * @returns the new matrix
  4276. */
  4277. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4278. /**
  4279. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4280. * @param startValue defines the start value
  4281. * @param endValue defines the end value
  4282. * @param gradient defines the gradient factor
  4283. * @param result defines the Matrix object where to store data
  4284. */
  4285. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4286. /**
  4287. * Builds a new matrix whose values are computed by:
  4288. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4289. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4290. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4291. * @param startValue defines the first matrix
  4292. * @param endValue defines the second matrix
  4293. * @param gradient defines the gradient between the two matrices
  4294. * @returns the new matrix
  4295. */
  4296. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4297. /**
  4298. * Update a matrix to values which are computed by:
  4299. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4300. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4301. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4302. * @param startValue defines the first matrix
  4303. * @param endValue defines the second matrix
  4304. * @param gradient defines the gradient between the two matrices
  4305. * @param result defines the target matrix
  4306. */
  4307. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4308. /**
  4309. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4310. * This function works in left handed mode
  4311. * @param eye defines the final position of the entity
  4312. * @param target defines where the entity should look at
  4313. * @param up defines the up vector for the entity
  4314. * @returns the new matrix
  4315. */
  4316. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4317. /**
  4318. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4319. * This function works in left handed mode
  4320. * @param eye defines the final position of the entity
  4321. * @param target defines where the entity should look at
  4322. * @param up defines the up vector for the entity
  4323. * @param result defines the target matrix
  4324. */
  4325. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4326. /**
  4327. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4328. * This function works in right handed mode
  4329. * @param eye defines the final position of the entity
  4330. * @param target defines where the entity should look at
  4331. * @param up defines the up vector for the entity
  4332. * @returns the new matrix
  4333. */
  4334. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4335. /**
  4336. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4337. * This function works in right handed mode
  4338. * @param eye defines the final position of the entity
  4339. * @param target defines where the entity should look at
  4340. * @param up defines the up vector for the entity
  4341. * @param result defines the target matrix
  4342. */
  4343. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4344. /**
  4345. * Create a left-handed orthographic projection matrix
  4346. * @param width defines the viewport width
  4347. * @param height defines the viewport height
  4348. * @param znear defines the near clip plane
  4349. * @param zfar defines the far clip plane
  4350. * @returns a new matrix as a left-handed orthographic projection matrix
  4351. */
  4352. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4353. /**
  4354. * Store a left-handed orthographic projection to a given matrix
  4355. * @param width defines the viewport width
  4356. * @param height defines the viewport height
  4357. * @param znear defines the near clip plane
  4358. * @param zfar defines the far clip plane
  4359. * @param result defines the target matrix
  4360. */
  4361. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4362. /**
  4363. * Create a left-handed orthographic projection matrix
  4364. * @param left defines the viewport left coordinate
  4365. * @param right defines the viewport right coordinate
  4366. * @param bottom defines the viewport bottom coordinate
  4367. * @param top defines the viewport top coordinate
  4368. * @param znear defines the near clip plane
  4369. * @param zfar defines the far clip plane
  4370. * @returns a new matrix as a left-handed orthographic projection matrix
  4371. */
  4372. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4373. /**
  4374. * Stores a left-handed orthographic projection into a given matrix
  4375. * @param left defines the viewport left coordinate
  4376. * @param right defines the viewport right coordinate
  4377. * @param bottom defines the viewport bottom coordinate
  4378. * @param top defines the viewport top coordinate
  4379. * @param znear defines the near clip plane
  4380. * @param zfar defines the far clip plane
  4381. * @param result defines the target matrix
  4382. */
  4383. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4384. /**
  4385. * Creates a right-handed orthographic projection matrix
  4386. * @param left defines the viewport left coordinate
  4387. * @param right defines the viewport right coordinate
  4388. * @param bottom defines the viewport bottom coordinate
  4389. * @param top defines the viewport top coordinate
  4390. * @param znear defines the near clip plane
  4391. * @param zfar defines the far clip plane
  4392. * @returns a new matrix as a right-handed orthographic projection matrix
  4393. */
  4394. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4395. /**
  4396. * Stores a right-handed orthographic projection into a given matrix
  4397. * @param left defines the viewport left coordinate
  4398. * @param right defines the viewport right coordinate
  4399. * @param bottom defines the viewport bottom coordinate
  4400. * @param top defines the viewport top coordinate
  4401. * @param znear defines the near clip plane
  4402. * @param zfar defines the far clip plane
  4403. * @param result defines the target matrix
  4404. */
  4405. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4406. /**
  4407. * Creates a left-handed perspective projection matrix
  4408. * @param width defines the viewport width
  4409. * @param height defines the viewport height
  4410. * @param znear defines the near clip plane
  4411. * @param zfar defines the far clip plane
  4412. * @returns a new matrix as a left-handed perspective projection matrix
  4413. */
  4414. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4415. /**
  4416. * Creates a left-handed perspective projection matrix
  4417. * @param fov defines the horizontal field of view
  4418. * @param aspect defines the aspect ratio
  4419. * @param znear defines the near clip plane
  4420. * @param zfar defines the far clip plane
  4421. * @returns a new matrix as a left-handed perspective projection matrix
  4422. */
  4423. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4424. /**
  4425. * Stores a left-handed perspective projection into a given matrix
  4426. * @param fov defines the horizontal field of view
  4427. * @param aspect defines the aspect ratio
  4428. * @param znear defines the near clip plane
  4429. * @param zfar defines the far clip plane
  4430. * @param result defines the target matrix
  4431. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4432. */
  4433. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4434. /**
  4435. * Creates a right-handed perspective projection matrix
  4436. * @param fov defines the horizontal field of view
  4437. * @param aspect defines the aspect ratio
  4438. * @param znear defines the near clip plane
  4439. * @param zfar defines the far clip plane
  4440. * @returns a new matrix as a right-handed perspective projection matrix
  4441. */
  4442. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4443. /**
  4444. * Stores a right-handed perspective projection into a given matrix
  4445. * @param fov defines the horizontal field of view
  4446. * @param aspect defines the aspect ratio
  4447. * @param znear defines the near clip plane
  4448. * @param zfar defines the far clip plane
  4449. * @param result defines the target matrix
  4450. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4451. */
  4452. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4453. /**
  4454. * Stores a perspective projection for WebVR info a given matrix
  4455. * @param fov defines the field of view
  4456. * @param znear defines the near clip plane
  4457. * @param zfar defines the far clip plane
  4458. * @param result defines the target matrix
  4459. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4460. */
  4461. static PerspectiveFovWebVRToRef(fov: {
  4462. upDegrees: number;
  4463. downDegrees: number;
  4464. leftDegrees: number;
  4465. rightDegrees: number;
  4466. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4467. /**
  4468. * Computes a complete transformation matrix
  4469. * @param viewport defines the viewport to use
  4470. * @param world defines the world matrix
  4471. * @param view defines the view matrix
  4472. * @param projection defines the projection matrix
  4473. * @param zmin defines the near clip plane
  4474. * @param zmax defines the far clip plane
  4475. * @returns the transformation matrix
  4476. */
  4477. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4478. /**
  4479. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4480. * @param matrix defines the matrix to use
  4481. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4482. */
  4483. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4484. /**
  4485. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4486. * @param matrix defines the matrix to use
  4487. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4488. */
  4489. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4490. /**
  4491. * Compute the transpose of a given matrix
  4492. * @param matrix defines the matrix to transpose
  4493. * @returns the new matrix
  4494. */
  4495. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Compute the transpose of a matrix and store it in a target matrix
  4498. * @param matrix defines the matrix to transpose
  4499. * @param result defines the target matrix
  4500. */
  4501. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4502. /**
  4503. * Computes a reflection matrix from a plane
  4504. * @param plane defines the reflection plane
  4505. * @returns a new matrix
  4506. */
  4507. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4508. /**
  4509. * Computes a reflection matrix from a plane
  4510. * @param plane defines the reflection plane
  4511. * @param result defines the target matrix
  4512. */
  4513. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4514. /**
  4515. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4516. * @param xaxis defines the value of the 1st axis
  4517. * @param yaxis defines the value of the 2nd axis
  4518. * @param zaxis defines the value of the 3rd axis
  4519. * @param result defines the target matrix
  4520. */
  4521. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4522. /**
  4523. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4524. * @param quat defines the quaternion to use
  4525. * @param result defines the target matrix
  4526. */
  4527. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4528. }
  4529. /**
  4530. * @hidden
  4531. */
  4532. export class TmpVectors {
  4533. static Vector2: Vector2[];
  4534. static Vector3: Vector3[];
  4535. static Vector4: Vector4[];
  4536. static Quaternion: Quaternion[];
  4537. static Matrix: Matrix[];
  4538. }
  4539. }
  4540. declare module "babylonjs/Maths/math.path" {
  4541. import { DeepImmutable, Nullable } from "babylonjs/types";
  4542. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4543. /**
  4544. * Defines potential orientation for back face culling
  4545. */
  4546. export enum Orientation {
  4547. /**
  4548. * Clockwise
  4549. */
  4550. CW = 0,
  4551. /** Counter clockwise */
  4552. CCW = 1
  4553. }
  4554. /** Class used to represent a Bezier curve */
  4555. export class BezierCurve {
  4556. /**
  4557. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4558. * @param t defines the time
  4559. * @param x1 defines the left coordinate on X axis
  4560. * @param y1 defines the left coordinate on Y axis
  4561. * @param x2 defines the right coordinate on X axis
  4562. * @param y2 defines the right coordinate on Y axis
  4563. * @returns the interpolated value
  4564. */
  4565. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4566. }
  4567. /**
  4568. * Defines angle representation
  4569. */
  4570. export class Angle {
  4571. private _radians;
  4572. /**
  4573. * Creates an Angle object of "radians" radians (float).
  4574. * @param radians the angle in radians
  4575. */
  4576. constructor(radians: number);
  4577. /**
  4578. * Get value in degrees
  4579. * @returns the Angle value in degrees (float)
  4580. */
  4581. degrees(): number;
  4582. /**
  4583. * Get value in radians
  4584. * @returns the Angle value in radians (float)
  4585. */
  4586. radians(): number;
  4587. /**
  4588. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4589. * @param a defines first vector
  4590. * @param b defines second vector
  4591. * @returns a new Angle
  4592. */
  4593. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4594. /**
  4595. * Gets a new Angle object from the given float in radians
  4596. * @param radians defines the angle value in radians
  4597. * @returns a new Angle
  4598. */
  4599. static FromRadians(radians: number): Angle;
  4600. /**
  4601. * Gets a new Angle object from the given float in degrees
  4602. * @param degrees defines the angle value in degrees
  4603. * @returns a new Angle
  4604. */
  4605. static FromDegrees(degrees: number): Angle;
  4606. }
  4607. /**
  4608. * This represents an arc in a 2d space.
  4609. */
  4610. export class Arc2 {
  4611. /** Defines the start point of the arc */
  4612. startPoint: Vector2;
  4613. /** Defines the mid point of the arc */
  4614. midPoint: Vector2;
  4615. /** Defines the end point of the arc */
  4616. endPoint: Vector2;
  4617. /**
  4618. * Defines the center point of the arc.
  4619. */
  4620. centerPoint: Vector2;
  4621. /**
  4622. * Defines the radius of the arc.
  4623. */
  4624. radius: number;
  4625. /**
  4626. * Defines the angle of the arc (from mid point to end point).
  4627. */
  4628. angle: Angle;
  4629. /**
  4630. * Defines the start angle of the arc (from start point to middle point).
  4631. */
  4632. startAngle: Angle;
  4633. /**
  4634. * Defines the orientation of the arc (clock wise/counter clock wise).
  4635. */
  4636. orientation: Orientation;
  4637. /**
  4638. * Creates an Arc object from the three given points : start, middle and end.
  4639. * @param startPoint Defines the start point of the arc
  4640. * @param midPoint Defines the midlle point of the arc
  4641. * @param endPoint Defines the end point of the arc
  4642. */
  4643. constructor(
  4644. /** Defines the start point of the arc */
  4645. startPoint: Vector2,
  4646. /** Defines the mid point of the arc */
  4647. midPoint: Vector2,
  4648. /** Defines the end point of the arc */
  4649. endPoint: Vector2);
  4650. }
  4651. /**
  4652. * Represents a 2D path made up of multiple 2D points
  4653. */
  4654. export class Path2 {
  4655. private _points;
  4656. private _length;
  4657. /**
  4658. * If the path start and end point are the same
  4659. */
  4660. closed: boolean;
  4661. /**
  4662. * Creates a Path2 object from the starting 2D coordinates x and y.
  4663. * @param x the starting points x value
  4664. * @param y the starting points y value
  4665. */
  4666. constructor(x: number, y: number);
  4667. /**
  4668. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4669. * @param x the added points x value
  4670. * @param y the added points y value
  4671. * @returns the updated Path2.
  4672. */
  4673. addLineTo(x: number, y: number): Path2;
  4674. /**
  4675. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4676. * @param midX middle point x value
  4677. * @param midY middle point y value
  4678. * @param endX end point x value
  4679. * @param endY end point y value
  4680. * @param numberOfSegments (default: 36)
  4681. * @returns the updated Path2.
  4682. */
  4683. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4684. /**
  4685. * Closes the Path2.
  4686. * @returns the Path2.
  4687. */
  4688. close(): Path2;
  4689. /**
  4690. * Gets the sum of the distance between each sequential point in the path
  4691. * @returns the Path2 total length (float).
  4692. */
  4693. length(): number;
  4694. /**
  4695. * Gets the points which construct the path
  4696. * @returns the Path2 internal array of points.
  4697. */
  4698. getPoints(): Vector2[];
  4699. /**
  4700. * Retreives the point at the distance aways from the starting point
  4701. * @param normalizedLengthPosition the length along the path to retreive the point from
  4702. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4703. */
  4704. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4705. /**
  4706. * Creates a new path starting from an x and y position
  4707. * @param x starting x value
  4708. * @param y starting y value
  4709. * @returns a new Path2 starting at the coordinates (x, y).
  4710. */
  4711. static StartingAt(x: number, y: number): Path2;
  4712. }
  4713. /**
  4714. * Represents a 3D path made up of multiple 3D points
  4715. */
  4716. export class Path3D {
  4717. /**
  4718. * an array of Vector3, the curve axis of the Path3D
  4719. */
  4720. path: Vector3[];
  4721. private _curve;
  4722. private _distances;
  4723. private _tangents;
  4724. private _normals;
  4725. private _binormals;
  4726. private _raw;
  4727. /**
  4728. * new Path3D(path, normal, raw)
  4729. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4730. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4731. * @param path an array of Vector3, the curve axis of the Path3D
  4732. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4733. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4734. */
  4735. constructor(
  4736. /**
  4737. * an array of Vector3, the curve axis of the Path3D
  4738. */
  4739. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4740. /**
  4741. * Returns the Path3D array of successive Vector3 designing its curve.
  4742. * @returns the Path3D array of successive Vector3 designing its curve.
  4743. */
  4744. getCurve(): Vector3[];
  4745. /**
  4746. * Returns an array populated with tangent vectors on each Path3D curve point.
  4747. * @returns an array populated with tangent vectors on each Path3D curve point.
  4748. */
  4749. getTangents(): Vector3[];
  4750. /**
  4751. * Returns an array populated with normal vectors on each Path3D curve point.
  4752. * @returns an array populated with normal vectors on each Path3D curve point.
  4753. */
  4754. getNormals(): Vector3[];
  4755. /**
  4756. * Returns an array populated with binormal vectors on each Path3D curve point.
  4757. * @returns an array populated with binormal vectors on each Path3D curve point.
  4758. */
  4759. getBinormals(): Vector3[];
  4760. /**
  4761. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4762. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4763. */
  4764. getDistances(): number[];
  4765. /**
  4766. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4767. * @param path path which all values are copied into the curves points
  4768. * @param firstNormal which should be projected onto the curve
  4769. * @returns the same object updated.
  4770. */
  4771. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4772. private _compute;
  4773. private _getFirstNonNullVector;
  4774. private _getLastNonNullVector;
  4775. private _normalVector;
  4776. }
  4777. /**
  4778. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4779. * A Curve3 is designed from a series of successive Vector3.
  4780. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4781. */
  4782. export class Curve3 {
  4783. private _points;
  4784. private _length;
  4785. /**
  4786. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4787. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4788. * @param v1 (Vector3) the control point
  4789. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4790. * @param nbPoints (integer) the wanted number of points in the curve
  4791. * @returns the created Curve3
  4792. */
  4793. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4794. /**
  4795. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4796. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4797. * @param v1 (Vector3) the first control point
  4798. * @param v2 (Vector3) the second control point
  4799. * @param v3 (Vector3) the end point of the Cubic Bezier
  4800. * @param nbPoints (integer) the wanted number of points in the curve
  4801. * @returns the created Curve3
  4802. */
  4803. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4804. /**
  4805. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4806. * @param p1 (Vector3) the origin point of the Hermite Spline
  4807. * @param t1 (Vector3) the tangent vector at the origin point
  4808. * @param p2 (Vector3) the end point of the Hermite Spline
  4809. * @param t2 (Vector3) the tangent vector at the end point
  4810. * @param nbPoints (integer) the wanted number of points in the curve
  4811. * @returns the created Curve3
  4812. */
  4813. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4814. /**
  4815. * Returns a Curve3 object along a CatmullRom Spline curve :
  4816. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4817. * @param nbPoints (integer) the wanted number of points between each curve control points
  4818. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4819. * @returns the created Curve3
  4820. */
  4821. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4822. /**
  4823. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4824. * A Curve3 is designed from a series of successive Vector3.
  4825. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4826. * @param points points which make up the curve
  4827. */
  4828. constructor(points: Vector3[]);
  4829. /**
  4830. * @returns the Curve3 stored array of successive Vector3
  4831. */
  4832. getPoints(): Vector3[];
  4833. /**
  4834. * @returns the computed length (float) of the curve.
  4835. */
  4836. length(): number;
  4837. /**
  4838. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4839. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4840. * curveA and curveB keep unchanged.
  4841. * @param curve the curve to continue from this curve
  4842. * @returns the newly constructed curve
  4843. */
  4844. continue(curve: DeepImmutable<Curve3>): Curve3;
  4845. private _computeLength;
  4846. }
  4847. }
  4848. declare module "babylonjs/Animations/easing" {
  4849. /**
  4850. * This represents the main contract an easing function should follow.
  4851. * Easing functions are used throughout the animation system.
  4852. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4853. */
  4854. export interface IEasingFunction {
  4855. /**
  4856. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4857. * of the easing function.
  4858. * The link below provides some of the most common examples of easing functions.
  4859. * @see https://easings.net/
  4860. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4861. * @returns the corresponding value on the curve defined by the easing function
  4862. */
  4863. ease(gradient: number): number;
  4864. }
  4865. /**
  4866. * Base class used for every default easing function.
  4867. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4868. */
  4869. export class EasingFunction implements IEasingFunction {
  4870. /**
  4871. * Interpolation follows the mathematical formula associated with the easing function.
  4872. */
  4873. static readonly EASINGMODE_EASEIN: number;
  4874. /**
  4875. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4876. */
  4877. static readonly EASINGMODE_EASEOUT: number;
  4878. /**
  4879. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4880. */
  4881. static readonly EASINGMODE_EASEINOUT: number;
  4882. private _easingMode;
  4883. /**
  4884. * Sets the easing mode of the current function.
  4885. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4886. */
  4887. setEasingMode(easingMode: number): void;
  4888. /**
  4889. * Gets the current easing mode.
  4890. * @returns the easing mode
  4891. */
  4892. getEasingMode(): number;
  4893. /**
  4894. * @hidden
  4895. */
  4896. easeInCore(gradient: number): number;
  4897. /**
  4898. * Given an input gradient between 0 and 1, this returns the corresponding value
  4899. * of the easing function.
  4900. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4901. * @returns the corresponding value on the curve defined by the easing function
  4902. */
  4903. ease(gradient: number): number;
  4904. }
  4905. /**
  4906. * Easing function with a circle shape (see link below).
  4907. * @see https://easings.net/#easeInCirc
  4908. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4909. */
  4910. export class CircleEase extends EasingFunction implements IEasingFunction {
  4911. /** @hidden */
  4912. easeInCore(gradient: number): number;
  4913. }
  4914. /**
  4915. * Easing function with a ease back shape (see link below).
  4916. * @see https://easings.net/#easeInBack
  4917. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4918. */
  4919. export class BackEase extends EasingFunction implements IEasingFunction {
  4920. /** Defines the amplitude of the function */
  4921. amplitude: number;
  4922. /**
  4923. * Instantiates a back ease easing
  4924. * @see https://easings.net/#easeInBack
  4925. * @param amplitude Defines the amplitude of the function
  4926. */
  4927. constructor(
  4928. /** Defines the amplitude of the function */
  4929. amplitude?: number);
  4930. /** @hidden */
  4931. easeInCore(gradient: number): number;
  4932. }
  4933. /**
  4934. * Easing function with a bouncing shape (see link below).
  4935. * @see https://easings.net/#easeInBounce
  4936. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4937. */
  4938. export class BounceEase extends EasingFunction implements IEasingFunction {
  4939. /** Defines the number of bounces */
  4940. bounces: number;
  4941. /** Defines the amplitude of the bounce */
  4942. bounciness: number;
  4943. /**
  4944. * Instantiates a bounce easing
  4945. * @see https://easings.net/#easeInBounce
  4946. * @param bounces Defines the number of bounces
  4947. * @param bounciness Defines the amplitude of the bounce
  4948. */
  4949. constructor(
  4950. /** Defines the number of bounces */
  4951. bounces?: number,
  4952. /** Defines the amplitude of the bounce */
  4953. bounciness?: number);
  4954. /** @hidden */
  4955. easeInCore(gradient: number): number;
  4956. }
  4957. /**
  4958. * Easing function with a power of 3 shape (see link below).
  4959. * @see https://easings.net/#easeInCubic
  4960. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4961. */
  4962. export class CubicEase extends EasingFunction implements IEasingFunction {
  4963. /** @hidden */
  4964. easeInCore(gradient: number): number;
  4965. }
  4966. /**
  4967. * Easing function with an elastic shape (see link below).
  4968. * @see https://easings.net/#easeInElastic
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4972. /** Defines the number of oscillations*/
  4973. oscillations: number;
  4974. /** Defines the amplitude of the oscillations*/
  4975. springiness: number;
  4976. /**
  4977. * Instantiates an elastic easing function
  4978. * @see https://easings.net/#easeInElastic
  4979. * @param oscillations Defines the number of oscillations
  4980. * @param springiness Defines the amplitude of the oscillations
  4981. */
  4982. constructor(
  4983. /** Defines the number of oscillations*/
  4984. oscillations?: number,
  4985. /** Defines the amplitude of the oscillations*/
  4986. springiness?: number);
  4987. /** @hidden */
  4988. easeInCore(gradient: number): number;
  4989. }
  4990. /**
  4991. * Easing function with an exponential shape (see link below).
  4992. * @see https://easings.net/#easeInExpo
  4993. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4994. */
  4995. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4996. /** Defines the exponent of the function */
  4997. exponent: number;
  4998. /**
  4999. * Instantiates an exponential easing function
  5000. * @see https://easings.net/#easeInExpo
  5001. * @param exponent Defines the exponent of the function
  5002. */
  5003. constructor(
  5004. /** Defines the exponent of the function */
  5005. exponent?: number);
  5006. /** @hidden */
  5007. easeInCore(gradient: number): number;
  5008. }
  5009. /**
  5010. * Easing function with a power shape (see link below).
  5011. * @see https://easings.net/#easeInQuad
  5012. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5013. */
  5014. export class PowerEase extends EasingFunction implements IEasingFunction {
  5015. /** Defines the power of the function */
  5016. power: number;
  5017. /**
  5018. * Instantiates an power base easing function
  5019. * @see https://easings.net/#easeInQuad
  5020. * @param power Defines the power of the function
  5021. */
  5022. constructor(
  5023. /** Defines the power of the function */
  5024. power?: number);
  5025. /** @hidden */
  5026. easeInCore(gradient: number): number;
  5027. }
  5028. /**
  5029. * Easing function with a power of 2 shape (see link below).
  5030. * @see https://easings.net/#easeInQuad
  5031. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5032. */
  5033. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5034. /** @hidden */
  5035. easeInCore(gradient: number): number;
  5036. }
  5037. /**
  5038. * Easing function with a power of 4 shape (see link below).
  5039. * @see https://easings.net/#easeInQuart
  5040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5041. */
  5042. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5043. /** @hidden */
  5044. easeInCore(gradient: number): number;
  5045. }
  5046. /**
  5047. * Easing function with a power of 5 shape (see link below).
  5048. * @see https://easings.net/#easeInQuint
  5049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5050. */
  5051. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5052. /** @hidden */
  5053. easeInCore(gradient: number): number;
  5054. }
  5055. /**
  5056. * Easing function with a sin shape (see link below).
  5057. * @see https://easings.net/#easeInSine
  5058. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5059. */
  5060. export class SineEase extends EasingFunction implements IEasingFunction {
  5061. /** @hidden */
  5062. easeInCore(gradient: number): number;
  5063. }
  5064. /**
  5065. * Easing function with a bezier shape (see link below).
  5066. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5067. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5068. */
  5069. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5070. /** Defines the x component of the start tangent in the bezier curve */
  5071. x1: number;
  5072. /** Defines the y component of the start tangent in the bezier curve */
  5073. y1: number;
  5074. /** Defines the x component of the end tangent in the bezier curve */
  5075. x2: number;
  5076. /** Defines the y component of the end tangent in the bezier curve */
  5077. y2: number;
  5078. /**
  5079. * Instantiates a bezier function
  5080. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5081. * @param x1 Defines the x component of the start tangent in the bezier curve
  5082. * @param y1 Defines the y component of the start tangent in the bezier curve
  5083. * @param x2 Defines the x component of the end tangent in the bezier curve
  5084. * @param y2 Defines the y component of the end tangent in the bezier curve
  5085. */
  5086. constructor(
  5087. /** Defines the x component of the start tangent in the bezier curve */
  5088. x1?: number,
  5089. /** Defines the y component of the start tangent in the bezier curve */
  5090. y1?: number,
  5091. /** Defines the x component of the end tangent in the bezier curve */
  5092. x2?: number,
  5093. /** Defines the y component of the end tangent in the bezier curve */
  5094. y2?: number);
  5095. /** @hidden */
  5096. easeInCore(gradient: number): number;
  5097. }
  5098. }
  5099. declare module "babylonjs/Maths/math.color" {
  5100. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5101. /**
  5102. * Class used to hold a RBG color
  5103. */
  5104. export class Color3 {
  5105. /**
  5106. * Defines the red component (between 0 and 1, default is 0)
  5107. */
  5108. r: number;
  5109. /**
  5110. * Defines the green component (between 0 and 1, default is 0)
  5111. */
  5112. g: number;
  5113. /**
  5114. * Defines the blue component (between 0 and 1, default is 0)
  5115. */
  5116. b: number;
  5117. /**
  5118. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5119. * @param r defines the red component (between 0 and 1, default is 0)
  5120. * @param g defines the green component (between 0 and 1, default is 0)
  5121. * @param b defines the blue component (between 0 and 1, default is 0)
  5122. */
  5123. constructor(
  5124. /**
  5125. * Defines the red component (between 0 and 1, default is 0)
  5126. */
  5127. r?: number,
  5128. /**
  5129. * Defines the green component (between 0 and 1, default is 0)
  5130. */
  5131. g?: number,
  5132. /**
  5133. * Defines the blue component (between 0 and 1, default is 0)
  5134. */
  5135. b?: number);
  5136. /**
  5137. * Creates a string with the Color3 current values
  5138. * @returns the string representation of the Color3 object
  5139. */
  5140. toString(): string;
  5141. /**
  5142. * Returns the string "Color3"
  5143. * @returns "Color3"
  5144. */
  5145. getClassName(): string;
  5146. /**
  5147. * Compute the Color3 hash code
  5148. * @returns an unique number that can be used to hash Color3 objects
  5149. */
  5150. getHashCode(): number;
  5151. /**
  5152. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5153. * @param array defines the array where to store the r,g,b components
  5154. * @param index defines an optional index in the target array to define where to start storing values
  5155. * @returns the current Color3 object
  5156. */
  5157. toArray(array: FloatArray, index?: number): Color3;
  5158. /**
  5159. * Returns a new Color4 object from the current Color3 and the given alpha
  5160. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5161. * @returns a new Color4 object
  5162. */
  5163. toColor4(alpha?: number): Color4;
  5164. /**
  5165. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5166. * @returns the new array
  5167. */
  5168. asArray(): number[];
  5169. /**
  5170. * Returns the luminance value
  5171. * @returns a float value
  5172. */
  5173. toLuminance(): number;
  5174. /**
  5175. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5176. * @param otherColor defines the second operand
  5177. * @returns the new Color3 object
  5178. */
  5179. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5180. /**
  5181. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5182. * @param otherColor defines the second operand
  5183. * @param result defines the Color3 object where to store the result
  5184. * @returns the current Color3
  5185. */
  5186. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5187. /**
  5188. * Determines equality between Color3 objects
  5189. * @param otherColor defines the second operand
  5190. * @returns true if the rgb values are equal to the given ones
  5191. */
  5192. equals(otherColor: DeepImmutable<Color3>): boolean;
  5193. /**
  5194. * Determines equality between the current Color3 object and a set of r,b,g values
  5195. * @param r defines the red component to check
  5196. * @param g defines the green component to check
  5197. * @param b defines the blue component to check
  5198. * @returns true if the rgb values are equal to the given ones
  5199. */
  5200. equalsFloats(r: number, g: number, b: number): boolean;
  5201. /**
  5202. * Multiplies in place each rgb value by scale
  5203. * @param scale defines the scaling factor
  5204. * @returns the updated Color3
  5205. */
  5206. scale(scale: number): Color3;
  5207. /**
  5208. * Multiplies the rgb values by scale and stores the result into "result"
  5209. * @param scale defines the scaling factor
  5210. * @param result defines the Color3 object where to store the result
  5211. * @returns the unmodified current Color3
  5212. */
  5213. scaleToRef(scale: number, result: Color3): Color3;
  5214. /**
  5215. * Scale the current Color3 values by a factor and add the result to a given Color3
  5216. * @param scale defines the scale factor
  5217. * @param result defines color to store the result into
  5218. * @returns the unmodified current Color3
  5219. */
  5220. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5221. /**
  5222. * Clamps the rgb values by the min and max values and stores the result into "result"
  5223. * @param min defines minimum clamping value (default is 0)
  5224. * @param max defines maximum clamping value (default is 1)
  5225. * @param result defines color to store the result into
  5226. * @returns the original Color3
  5227. */
  5228. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5229. /**
  5230. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5231. * @param otherColor defines the second operand
  5232. * @returns the new Color3
  5233. */
  5234. add(otherColor: DeepImmutable<Color3>): Color3;
  5235. /**
  5236. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5237. * @param otherColor defines the second operand
  5238. * @param result defines Color3 object to store the result into
  5239. * @returns the unmodified current Color3
  5240. */
  5241. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5242. /**
  5243. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5244. * @param otherColor defines the second operand
  5245. * @returns the new Color3
  5246. */
  5247. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5248. /**
  5249. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5250. * @param otherColor defines the second operand
  5251. * @param result defines Color3 object to store the result into
  5252. * @returns the unmodified current Color3
  5253. */
  5254. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5255. /**
  5256. * Copy the current object
  5257. * @returns a new Color3 copied the current one
  5258. */
  5259. clone(): Color3;
  5260. /**
  5261. * Copies the rgb values from the source in the current Color3
  5262. * @param source defines the source Color3 object
  5263. * @returns the updated Color3 object
  5264. */
  5265. copyFrom(source: DeepImmutable<Color3>): Color3;
  5266. /**
  5267. * Updates the Color3 rgb values from the given floats
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @returns the current Color3 object
  5272. */
  5273. copyFromFloats(r: number, g: number, b: number): Color3;
  5274. /**
  5275. * Updates the Color3 rgb values from the given floats
  5276. * @param r defines the red component to read from
  5277. * @param g defines the green component to read from
  5278. * @param b defines the blue component to read from
  5279. * @returns the current Color3 object
  5280. */
  5281. set(r: number, g: number, b: number): Color3;
  5282. /**
  5283. * Compute the Color3 hexadecimal code as a string
  5284. * @returns a string containing the hexadecimal representation of the Color3 object
  5285. */
  5286. toHexString(): string;
  5287. /**
  5288. * Computes a new Color3 converted from the current one to linear space
  5289. * @returns a new Color3 object
  5290. */
  5291. toLinearSpace(): Color3;
  5292. /**
  5293. * Converts current color in rgb space to HSV values
  5294. * @returns a new color3 representing the HSV values
  5295. */
  5296. toHSV(): Color3;
  5297. /**
  5298. * Converts current color in rgb space to HSV values
  5299. * @param result defines the Color3 where to store the HSV values
  5300. */
  5301. toHSVToRef(result: Color3): void;
  5302. /**
  5303. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5304. * @param convertedColor defines the Color3 object where to store the linear space version
  5305. * @returns the unmodified Color3
  5306. */
  5307. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5308. /**
  5309. * Computes a new Color3 converted from the current one to gamma space
  5310. * @returns a new Color3 object
  5311. */
  5312. toGammaSpace(): Color3;
  5313. /**
  5314. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5315. * @param convertedColor defines the Color3 object where to store the gamma space version
  5316. * @returns the unmodified Color3
  5317. */
  5318. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5319. private static _BlackReadOnly;
  5320. /**
  5321. * Convert Hue, saturation and value to a Color3 (RGB)
  5322. * @param hue defines the hue
  5323. * @param saturation defines the saturation
  5324. * @param value defines the value
  5325. * @param result defines the Color3 where to store the RGB values
  5326. */
  5327. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5328. /**
  5329. * Creates a new Color3 from the string containing valid hexadecimal values
  5330. * @param hex defines a string containing valid hexadecimal values
  5331. * @returns a new Color3 object
  5332. */
  5333. static FromHexString(hex: string): Color3;
  5334. /**
  5335. * Creates a new Color3 from the starting index of the given array
  5336. * @param array defines the source array
  5337. * @param offset defines an offset in the source array
  5338. * @returns a new Color3 object
  5339. */
  5340. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5341. /**
  5342. * Creates a new Color3 from integer values (< 256)
  5343. * @param r defines the red component to read from (value between 0 and 255)
  5344. * @param g defines the green component to read from (value between 0 and 255)
  5345. * @param b defines the blue component to read from (value between 0 and 255)
  5346. * @returns a new Color3 object
  5347. */
  5348. static FromInts(r: number, g: number, b: number): Color3;
  5349. /**
  5350. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5351. * @param start defines the start Color3 value
  5352. * @param end defines the end Color3 value
  5353. * @param amount defines the gradient value between start and end
  5354. * @returns a new Color3 object
  5355. */
  5356. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5357. /**
  5358. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5359. * @param left defines the start value
  5360. * @param right defines the end value
  5361. * @param amount defines the gradient factor
  5362. * @param result defines the Color3 object where to store the result
  5363. */
  5364. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5365. /**
  5366. * Returns a Color3 value containing a red color
  5367. * @returns a new Color3 object
  5368. */
  5369. static Red(): Color3;
  5370. /**
  5371. * Returns a Color3 value containing a green color
  5372. * @returns a new Color3 object
  5373. */
  5374. static Green(): Color3;
  5375. /**
  5376. * Returns a Color3 value containing a blue color
  5377. * @returns a new Color3 object
  5378. */
  5379. static Blue(): Color3;
  5380. /**
  5381. * Returns a Color3 value containing a black color
  5382. * @returns a new Color3 object
  5383. */
  5384. static Black(): Color3;
  5385. /**
  5386. * Gets a Color3 value containing a black color that must not be updated
  5387. */
  5388. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5389. /**
  5390. * Returns a Color3 value containing a white color
  5391. * @returns a new Color3 object
  5392. */
  5393. static White(): Color3;
  5394. /**
  5395. * Returns a Color3 value containing a purple color
  5396. * @returns a new Color3 object
  5397. */
  5398. static Purple(): Color3;
  5399. /**
  5400. * Returns a Color3 value containing a magenta color
  5401. * @returns a new Color3 object
  5402. */
  5403. static Magenta(): Color3;
  5404. /**
  5405. * Returns a Color3 value containing a yellow color
  5406. * @returns a new Color3 object
  5407. */
  5408. static Yellow(): Color3;
  5409. /**
  5410. * Returns a Color3 value containing a gray color
  5411. * @returns a new Color3 object
  5412. */
  5413. static Gray(): Color3;
  5414. /**
  5415. * Returns a Color3 value containing a teal color
  5416. * @returns a new Color3 object
  5417. */
  5418. static Teal(): Color3;
  5419. /**
  5420. * Returns a Color3 value containing a random color
  5421. * @returns a new Color3 object
  5422. */
  5423. static Random(): Color3;
  5424. }
  5425. /**
  5426. * Class used to hold a RBGA color
  5427. */
  5428. export class Color4 {
  5429. /**
  5430. * Defines the red component (between 0 and 1, default is 0)
  5431. */
  5432. r: number;
  5433. /**
  5434. * Defines the green component (between 0 and 1, default is 0)
  5435. */
  5436. g: number;
  5437. /**
  5438. * Defines the blue component (between 0 and 1, default is 0)
  5439. */
  5440. b: number;
  5441. /**
  5442. * Defines the alpha component (between 0 and 1, default is 1)
  5443. */
  5444. a: number;
  5445. /**
  5446. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5447. * @param r defines the red component (between 0 and 1, default is 0)
  5448. * @param g defines the green component (between 0 and 1, default is 0)
  5449. * @param b defines the blue component (between 0 and 1, default is 0)
  5450. * @param a defines the alpha component (between 0 and 1, default is 1)
  5451. */
  5452. constructor(
  5453. /**
  5454. * Defines the red component (between 0 and 1, default is 0)
  5455. */
  5456. r?: number,
  5457. /**
  5458. * Defines the green component (between 0 and 1, default is 0)
  5459. */
  5460. g?: number,
  5461. /**
  5462. * Defines the blue component (between 0 and 1, default is 0)
  5463. */
  5464. b?: number,
  5465. /**
  5466. * Defines the alpha component (between 0 and 1, default is 1)
  5467. */
  5468. a?: number);
  5469. /**
  5470. * Adds in place the given Color4 values to the current Color4 object
  5471. * @param right defines the second operand
  5472. * @returns the current updated Color4 object
  5473. */
  5474. addInPlace(right: DeepImmutable<Color4>): Color4;
  5475. /**
  5476. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5477. * @returns the new array
  5478. */
  5479. asArray(): number[];
  5480. /**
  5481. * Stores from the starting index in the given array the Color4 successive values
  5482. * @param array defines the array where to store the r,g,b components
  5483. * @param index defines an optional index in the target array to define where to start storing values
  5484. * @returns the current Color4 object
  5485. */
  5486. toArray(array: number[], index?: number): Color4;
  5487. /**
  5488. * Determines equality between Color4 objects
  5489. * @param otherColor defines the second operand
  5490. * @returns true if the rgba values are equal to the given ones
  5491. */
  5492. equals(otherColor: DeepImmutable<Color4>): boolean;
  5493. /**
  5494. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5495. * @param right defines the second operand
  5496. * @returns a new Color4 object
  5497. */
  5498. add(right: DeepImmutable<Color4>): Color4;
  5499. /**
  5500. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5501. * @param right defines the second operand
  5502. * @returns a new Color4 object
  5503. */
  5504. subtract(right: DeepImmutable<Color4>): Color4;
  5505. /**
  5506. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5507. * @param right defines the second operand
  5508. * @param result defines the Color4 object where to store the result
  5509. * @returns the current Color4 object
  5510. */
  5511. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5512. /**
  5513. * Creates a new Color4 with the current Color4 values multiplied by scale
  5514. * @param scale defines the scaling factor to apply
  5515. * @returns a new Color4 object
  5516. */
  5517. scale(scale: number): Color4;
  5518. /**
  5519. * Multiplies the current Color4 values by scale and stores the result in "result"
  5520. * @param scale defines the scaling factor to apply
  5521. * @param result defines the Color4 object where to store the result
  5522. * @returns the current unmodified Color4
  5523. */
  5524. scaleToRef(scale: number, result: Color4): Color4;
  5525. /**
  5526. * Scale the current Color4 values by a factor and add the result to a given Color4
  5527. * @param scale defines the scale factor
  5528. * @param result defines the Color4 object where to store the result
  5529. * @returns the unmodified current Color4
  5530. */
  5531. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5532. /**
  5533. * Clamps the rgb values by the min and max values and stores the result into "result"
  5534. * @param min defines minimum clamping value (default is 0)
  5535. * @param max defines maximum clamping value (default is 1)
  5536. * @param result defines color to store the result into.
  5537. * @returns the cuurent Color4
  5538. */
  5539. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5540. /**
  5541. * Multipy an Color4 value by another and return a new Color4 object
  5542. * @param color defines the Color4 value to multiply by
  5543. * @returns a new Color4 object
  5544. */
  5545. multiply(color: Color4): Color4;
  5546. /**
  5547. * Multipy a Color4 value by another and push the result in a reference value
  5548. * @param color defines the Color4 value to multiply by
  5549. * @param result defines the Color4 to fill the result in
  5550. * @returns the result Color4
  5551. */
  5552. multiplyToRef(color: Color4, result: Color4): Color4;
  5553. /**
  5554. * Creates a string with the Color4 current values
  5555. * @returns the string representation of the Color4 object
  5556. */
  5557. toString(): string;
  5558. /**
  5559. * Returns the string "Color4"
  5560. * @returns "Color4"
  5561. */
  5562. getClassName(): string;
  5563. /**
  5564. * Compute the Color4 hash code
  5565. * @returns an unique number that can be used to hash Color4 objects
  5566. */
  5567. getHashCode(): number;
  5568. /**
  5569. * Creates a new Color4 copied from the current one
  5570. * @returns a new Color4 object
  5571. */
  5572. clone(): Color4;
  5573. /**
  5574. * Copies the given Color4 values into the current one
  5575. * @param source defines the source Color4 object
  5576. * @returns the current updated Color4 object
  5577. */
  5578. copyFrom(source: Color4): Color4;
  5579. /**
  5580. * Copies the given float values into the current one
  5581. * @param r defines the red component to read from
  5582. * @param g defines the green component to read from
  5583. * @param b defines the blue component to read from
  5584. * @param a defines the alpha component to read from
  5585. * @returns the current updated Color4 object
  5586. */
  5587. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5588. /**
  5589. * Copies the given float values into the current one
  5590. * @param r defines the red component to read from
  5591. * @param g defines the green component to read from
  5592. * @param b defines the blue component to read from
  5593. * @param a defines the alpha component to read from
  5594. * @returns the current updated Color4 object
  5595. */
  5596. set(r: number, g: number, b: number, a: number): Color4;
  5597. /**
  5598. * Compute the Color4 hexadecimal code as a string
  5599. * @returns a string containing the hexadecimal representation of the Color4 object
  5600. */
  5601. toHexString(): string;
  5602. /**
  5603. * Computes a new Color4 converted from the current one to linear space
  5604. * @returns a new Color4 object
  5605. */
  5606. toLinearSpace(): Color4;
  5607. /**
  5608. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5609. * @param convertedColor defines the Color4 object where to store the linear space version
  5610. * @returns the unmodified Color4
  5611. */
  5612. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5613. /**
  5614. * Computes a new Color4 converted from the current one to gamma space
  5615. * @returns a new Color4 object
  5616. */
  5617. toGammaSpace(): Color4;
  5618. /**
  5619. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5620. * @param convertedColor defines the Color4 object where to store the gamma space version
  5621. * @returns the unmodified Color4
  5622. */
  5623. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5624. /**
  5625. * Creates a new Color4 from the string containing valid hexadecimal values
  5626. * @param hex defines a string containing valid hexadecimal values
  5627. * @returns a new Color4 object
  5628. */
  5629. static FromHexString(hex: string): Color4;
  5630. /**
  5631. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5632. * @param left defines the start value
  5633. * @param right defines the end value
  5634. * @param amount defines the gradient factor
  5635. * @returns a new Color4 object
  5636. */
  5637. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5638. /**
  5639. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5640. * @param left defines the start value
  5641. * @param right defines the end value
  5642. * @param amount defines the gradient factor
  5643. * @param result defines the Color4 object where to store data
  5644. */
  5645. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5646. /**
  5647. * Creates a new Color4 from a Color3 and an alpha value
  5648. * @param color3 defines the source Color3 to read from
  5649. * @param alpha defines the alpha component (1.0 by default)
  5650. * @returns a new Color4 object
  5651. */
  5652. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5653. /**
  5654. * Creates a new Color4 from the starting index element of the given array
  5655. * @param array defines the source array to read from
  5656. * @param offset defines the offset in the source array
  5657. * @returns a new Color4 object
  5658. */
  5659. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5660. /**
  5661. * Creates a new Color3 from integer values (< 256)
  5662. * @param r defines the red component to read from (value between 0 and 255)
  5663. * @param g defines the green component to read from (value between 0 and 255)
  5664. * @param b defines the blue component to read from (value between 0 and 255)
  5665. * @param a defines the alpha component to read from (value between 0 and 255)
  5666. * @returns a new Color3 object
  5667. */
  5668. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5669. /**
  5670. * Check the content of a given array and convert it to an array containing RGBA data
  5671. * If the original array was already containing count * 4 values then it is returned directly
  5672. * @param colors defines the array to check
  5673. * @param count defines the number of RGBA data to expect
  5674. * @returns an array containing count * 4 values (RGBA)
  5675. */
  5676. static CheckColors4(colors: number[], count: number): number[];
  5677. }
  5678. /**
  5679. * @hidden
  5680. */
  5681. export class TmpColors {
  5682. static Color3: Color3[];
  5683. static Color4: Color4[];
  5684. }
  5685. }
  5686. declare module "babylonjs/Animations/animationKey" {
  5687. /**
  5688. * Defines an interface which represents an animation key frame
  5689. */
  5690. export interface IAnimationKey {
  5691. /**
  5692. * Frame of the key frame
  5693. */
  5694. frame: number;
  5695. /**
  5696. * Value at the specifies key frame
  5697. */
  5698. value: any;
  5699. /**
  5700. * The input tangent for the cubic hermite spline
  5701. */
  5702. inTangent?: any;
  5703. /**
  5704. * The output tangent for the cubic hermite spline
  5705. */
  5706. outTangent?: any;
  5707. /**
  5708. * The animation interpolation type
  5709. */
  5710. interpolation?: AnimationKeyInterpolation;
  5711. }
  5712. /**
  5713. * Enum for the animation key frame interpolation type
  5714. */
  5715. export enum AnimationKeyInterpolation {
  5716. /**
  5717. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5718. */
  5719. STEP = 1
  5720. }
  5721. }
  5722. declare module "babylonjs/Animations/animationRange" {
  5723. /**
  5724. * Represents the range of an animation
  5725. */
  5726. export class AnimationRange {
  5727. /**The name of the animation range**/
  5728. name: string;
  5729. /**The starting frame of the animation */
  5730. from: number;
  5731. /**The ending frame of the animation*/
  5732. to: number;
  5733. /**
  5734. * Initializes the range of an animation
  5735. * @param name The name of the animation range
  5736. * @param from The starting frame of the animation
  5737. * @param to The ending frame of the animation
  5738. */
  5739. constructor(
  5740. /**The name of the animation range**/
  5741. name: string,
  5742. /**The starting frame of the animation */
  5743. from: number,
  5744. /**The ending frame of the animation*/
  5745. to: number);
  5746. /**
  5747. * Makes a copy of the animation range
  5748. * @returns A copy of the animation range
  5749. */
  5750. clone(): AnimationRange;
  5751. }
  5752. }
  5753. declare module "babylonjs/Animations/animationEvent" {
  5754. /**
  5755. * Composed of a frame, and an action function
  5756. */
  5757. export class AnimationEvent {
  5758. /** The frame for which the event is triggered **/
  5759. frame: number;
  5760. /** The event to perform when triggered **/
  5761. action: (currentFrame: number) => void;
  5762. /** Specifies if the event should be triggered only once**/
  5763. onlyOnce?: boolean | undefined;
  5764. /**
  5765. * Specifies if the animation event is done
  5766. */
  5767. isDone: boolean;
  5768. /**
  5769. * Initializes the animation event
  5770. * @param frame The frame for which the event is triggered
  5771. * @param action The event to perform when triggered
  5772. * @param onlyOnce Specifies if the event should be triggered only once
  5773. */
  5774. constructor(
  5775. /** The frame for which the event is triggered **/
  5776. frame: number,
  5777. /** The event to perform when triggered **/
  5778. action: (currentFrame: number) => void,
  5779. /** Specifies if the event should be triggered only once**/
  5780. onlyOnce?: boolean | undefined);
  5781. /** @hidden */
  5782. _clone(): AnimationEvent;
  5783. }
  5784. }
  5785. declare module "babylonjs/Behaviors/behavior" {
  5786. import { Nullable } from "babylonjs/types";
  5787. /**
  5788. * Interface used to define a behavior
  5789. */
  5790. export interface Behavior<T> {
  5791. /** gets or sets behavior's name */
  5792. name: string;
  5793. /**
  5794. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5795. */
  5796. init(): void;
  5797. /**
  5798. * Called when the behavior is attached to a target
  5799. * @param target defines the target where the behavior is attached to
  5800. */
  5801. attach(target: T): void;
  5802. /**
  5803. * Called when the behavior is detached from its target
  5804. */
  5805. detach(): void;
  5806. }
  5807. /**
  5808. * Interface implemented by classes supporting behaviors
  5809. */
  5810. export interface IBehaviorAware<T> {
  5811. /**
  5812. * Attach a behavior
  5813. * @param behavior defines the behavior to attach
  5814. * @returns the current host
  5815. */
  5816. addBehavior(behavior: Behavior<T>): T;
  5817. /**
  5818. * Remove a behavior from the current object
  5819. * @param behavior defines the behavior to detach
  5820. * @returns the current host
  5821. */
  5822. removeBehavior(behavior: Behavior<T>): T;
  5823. /**
  5824. * Gets a behavior using its name to search
  5825. * @param name defines the name to search
  5826. * @returns the behavior or null if not found
  5827. */
  5828. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5829. }
  5830. }
  5831. declare module "babylonjs/Misc/smartArray" {
  5832. /**
  5833. * Defines an array and its length.
  5834. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5835. */
  5836. export interface ISmartArrayLike<T> {
  5837. /**
  5838. * The data of the array.
  5839. */
  5840. data: Array<T>;
  5841. /**
  5842. * The active length of the array.
  5843. */
  5844. length: number;
  5845. }
  5846. /**
  5847. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5848. */
  5849. export class SmartArray<T> implements ISmartArrayLike<T> {
  5850. /**
  5851. * The full set of data from the array.
  5852. */
  5853. data: Array<T>;
  5854. /**
  5855. * The active length of the array.
  5856. */
  5857. length: number;
  5858. protected _id: number;
  5859. /**
  5860. * Instantiates a Smart Array.
  5861. * @param capacity defines the default capacity of the array.
  5862. */
  5863. constructor(capacity: number);
  5864. /**
  5865. * Pushes a value at the end of the active data.
  5866. * @param value defines the object to push in the array.
  5867. */
  5868. push(value: T): void;
  5869. /**
  5870. * Iterates over the active data and apply the lambda to them.
  5871. * @param func defines the action to apply on each value.
  5872. */
  5873. forEach(func: (content: T) => void): void;
  5874. /**
  5875. * Sorts the full sets of data.
  5876. * @param compareFn defines the comparison function to apply.
  5877. */
  5878. sort(compareFn: (a: T, b: T) => number): void;
  5879. /**
  5880. * Resets the active data to an empty array.
  5881. */
  5882. reset(): void;
  5883. /**
  5884. * Releases all the data from the array as well as the array.
  5885. */
  5886. dispose(): void;
  5887. /**
  5888. * Concats the active data with a given array.
  5889. * @param array defines the data to concatenate with.
  5890. */
  5891. concat(array: any): void;
  5892. /**
  5893. * Returns the position of a value in the active data.
  5894. * @param value defines the value to find the index for
  5895. * @returns the index if found in the active data otherwise -1
  5896. */
  5897. indexOf(value: T): number;
  5898. /**
  5899. * Returns whether an element is part of the active data.
  5900. * @param value defines the value to look for
  5901. * @returns true if found in the active data otherwise false
  5902. */
  5903. contains(value: T): boolean;
  5904. private static _GlobalId;
  5905. }
  5906. /**
  5907. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5908. * The data in this array can only be present once
  5909. */
  5910. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5911. private _duplicateId;
  5912. /**
  5913. * Pushes a value at the end of the active data.
  5914. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5915. * @param value defines the object to push in the array.
  5916. */
  5917. push(value: T): void;
  5918. /**
  5919. * Pushes a value at the end of the active data.
  5920. * If the data is already present, it won t be added again
  5921. * @param value defines the object to push in the array.
  5922. * @returns true if added false if it was already present
  5923. */
  5924. pushNoDuplicate(value: T): boolean;
  5925. /**
  5926. * Resets the active data to an empty array.
  5927. */
  5928. reset(): void;
  5929. /**
  5930. * Concats the active data with a given array.
  5931. * This ensures no dupplicate will be present in the result.
  5932. * @param array defines the data to concatenate with.
  5933. */
  5934. concatWithNoDuplicate(array: any): void;
  5935. }
  5936. }
  5937. declare module "babylonjs/Cameras/cameraInputsManager" {
  5938. import { Nullable } from "babylonjs/types";
  5939. import { Camera } from "babylonjs/Cameras/camera";
  5940. /**
  5941. * @ignore
  5942. * This is a list of all the different input types that are available in the application.
  5943. * Fo instance: ArcRotateCameraGamepadInput...
  5944. */
  5945. export var CameraInputTypes: {};
  5946. /**
  5947. * This is the contract to implement in order to create a new input class.
  5948. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5949. */
  5950. export interface ICameraInput<TCamera extends Camera> {
  5951. /**
  5952. * Defines the camera the input is attached to.
  5953. */
  5954. camera: Nullable<TCamera>;
  5955. /**
  5956. * Gets the class name of the current intput.
  5957. * @returns the class name
  5958. */
  5959. getClassName(): string;
  5960. /**
  5961. * Get the friendly name associated with the input class.
  5962. * @returns the input friendly name
  5963. */
  5964. getSimpleName(): string;
  5965. /**
  5966. * Attach the input controls to a specific dom element to get the input from.
  5967. * @param element Defines the element the controls should be listened from
  5968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5969. */
  5970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5971. /**
  5972. * Detach the current controls from the specified dom element.
  5973. * @param element Defines the element to stop listening the inputs from
  5974. */
  5975. detachControl(element: Nullable<HTMLElement>): void;
  5976. /**
  5977. * Update the current camera state depending on the inputs that have been used this frame.
  5978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5979. */
  5980. checkInputs?: () => void;
  5981. }
  5982. /**
  5983. * Represents a map of input types to input instance or input index to input instance.
  5984. */
  5985. export interface CameraInputsMap<TCamera extends Camera> {
  5986. /**
  5987. * Accessor to the input by input type.
  5988. */
  5989. [name: string]: ICameraInput<TCamera>;
  5990. /**
  5991. * Accessor to the input by input index.
  5992. */
  5993. [idx: number]: ICameraInput<TCamera>;
  5994. }
  5995. /**
  5996. * This represents the input manager used within a camera.
  5997. * It helps dealing with all the different kind of input attached to a camera.
  5998. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  5999. */
  6000. export class CameraInputsManager<TCamera extends Camera> {
  6001. /**
  6002. * Defines the list of inputs attahed to the camera.
  6003. */
  6004. attached: CameraInputsMap<TCamera>;
  6005. /**
  6006. * Defines the dom element the camera is collecting inputs from.
  6007. * This is null if the controls have not been attached.
  6008. */
  6009. attachedElement: Nullable<HTMLElement>;
  6010. /**
  6011. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6012. */
  6013. noPreventDefault: boolean;
  6014. /**
  6015. * Defined the camera the input manager belongs to.
  6016. */
  6017. camera: TCamera;
  6018. /**
  6019. * Update the current camera state depending on the inputs that have been used this frame.
  6020. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6021. */
  6022. checkInputs: () => void;
  6023. /**
  6024. * Instantiate a new Camera Input Manager.
  6025. * @param camera Defines the camera the input manager blongs to
  6026. */
  6027. constructor(camera: TCamera);
  6028. /**
  6029. * Add an input method to a camera
  6030. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6031. * @param input camera input method
  6032. */
  6033. add(input: ICameraInput<TCamera>): void;
  6034. /**
  6035. * Remove a specific input method from a camera
  6036. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6037. * @param inputToRemove camera input method
  6038. */
  6039. remove(inputToRemove: ICameraInput<TCamera>): void;
  6040. /**
  6041. * Remove a specific input type from a camera
  6042. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6043. * @param inputType the type of the input to remove
  6044. */
  6045. removeByType(inputType: string): void;
  6046. private _addCheckInputs;
  6047. /**
  6048. * Attach the input controls to the currently attached dom element to listen the events from.
  6049. * @param input Defines the input to attach
  6050. */
  6051. attachInput(input: ICameraInput<TCamera>): void;
  6052. /**
  6053. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6054. * @param element Defines the dom element to collect the events from
  6055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6056. */
  6057. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6058. /**
  6059. * Detach the current manager inputs controls from a specific dom element.
  6060. * @param element Defines the dom element to collect the events from
  6061. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6062. */
  6063. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6064. /**
  6065. * Rebuild the dynamic inputCheck function from the current list of
  6066. * defined inputs in the manager.
  6067. */
  6068. rebuildInputCheck(): void;
  6069. /**
  6070. * Remove all attached input methods from a camera
  6071. */
  6072. clear(): void;
  6073. /**
  6074. * Serialize the current input manager attached to a camera.
  6075. * This ensures than once parsed,
  6076. * the input associated to the camera will be identical to the current ones
  6077. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6078. */
  6079. serialize(serializedCamera: any): void;
  6080. /**
  6081. * Parses an input manager serialized JSON to restore the previous list of inputs
  6082. * and states associated to a camera.
  6083. * @param parsedCamera Defines the JSON to parse
  6084. */
  6085. parse(parsedCamera: any): void;
  6086. }
  6087. }
  6088. declare module "babylonjs/Meshes/buffer" {
  6089. import { Nullable, DataArray } from "babylonjs/types";
  6090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6091. /**
  6092. * Class used to store data that will be store in GPU memory
  6093. */
  6094. export class Buffer {
  6095. private _engine;
  6096. private _buffer;
  6097. /** @hidden */
  6098. _data: Nullable<DataArray>;
  6099. private _updatable;
  6100. private _instanced;
  6101. /**
  6102. * Gets the byte stride.
  6103. */
  6104. readonly byteStride: number;
  6105. /**
  6106. * Constructor
  6107. * @param engine the engine
  6108. * @param data the data to use for this buffer
  6109. * @param updatable whether the data is updatable
  6110. * @param stride the stride (optional)
  6111. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6112. * @param instanced whether the buffer is instanced (optional)
  6113. * @param useBytes set to true if the stride in in bytes (optional)
  6114. */
  6115. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6116. /**
  6117. * Create a new VertexBuffer based on the current buffer
  6118. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6119. * @param offset defines offset in the buffer (0 by default)
  6120. * @param size defines the size in floats of attributes (position is 3 for instance)
  6121. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6122. * @param instanced defines if the vertex buffer contains indexed data
  6123. * @param useBytes defines if the offset and stride are in bytes
  6124. * @returns the new vertex buffer
  6125. */
  6126. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6127. /**
  6128. * Gets a boolean indicating if the Buffer is updatable?
  6129. * @returns true if the buffer is updatable
  6130. */
  6131. isUpdatable(): boolean;
  6132. /**
  6133. * Gets current buffer's data
  6134. * @returns a DataArray or null
  6135. */
  6136. getData(): Nullable<DataArray>;
  6137. /**
  6138. * Gets underlying native buffer
  6139. * @returns underlying native buffer
  6140. */
  6141. getBuffer(): Nullable<DataBuffer>;
  6142. /**
  6143. * Gets the stride in float32 units (i.e. byte stride / 4).
  6144. * May not be an integer if the byte stride is not divisible by 4.
  6145. * DEPRECATED. Use byteStride instead.
  6146. * @returns the stride in float32 units
  6147. */
  6148. getStrideSize(): number;
  6149. /**
  6150. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6151. * @param data defines the data to store
  6152. */
  6153. create(data?: Nullable<DataArray>): void;
  6154. /** @hidden */
  6155. _rebuild(): void;
  6156. /**
  6157. * Update current buffer data
  6158. * @param data defines the data to store
  6159. */
  6160. update(data: DataArray): void;
  6161. /**
  6162. * Updates the data directly.
  6163. * @param data the new data
  6164. * @param offset the new offset
  6165. * @param vertexCount the vertex count (optional)
  6166. * @param useBytes set to true if the offset is in bytes
  6167. */
  6168. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6169. /**
  6170. * Release all resources
  6171. */
  6172. dispose(): void;
  6173. }
  6174. /**
  6175. * Specialized buffer used to store vertex data
  6176. */
  6177. export class VertexBuffer {
  6178. /** @hidden */
  6179. _buffer: Buffer;
  6180. private _kind;
  6181. private _size;
  6182. private _ownsBuffer;
  6183. private _instanced;
  6184. private _instanceDivisor;
  6185. /**
  6186. * The byte type.
  6187. */
  6188. static readonly BYTE: number;
  6189. /**
  6190. * The unsigned byte type.
  6191. */
  6192. static readonly UNSIGNED_BYTE: number;
  6193. /**
  6194. * The short type.
  6195. */
  6196. static readonly SHORT: number;
  6197. /**
  6198. * The unsigned short type.
  6199. */
  6200. static readonly UNSIGNED_SHORT: number;
  6201. /**
  6202. * The integer type.
  6203. */
  6204. static readonly INT: number;
  6205. /**
  6206. * The unsigned integer type.
  6207. */
  6208. static readonly UNSIGNED_INT: number;
  6209. /**
  6210. * The float type.
  6211. */
  6212. static readonly FLOAT: number;
  6213. /**
  6214. * Gets or sets the instance divisor when in instanced mode
  6215. */
  6216. instanceDivisor: number;
  6217. /**
  6218. * Gets the byte stride.
  6219. */
  6220. readonly byteStride: number;
  6221. /**
  6222. * Gets the byte offset.
  6223. */
  6224. readonly byteOffset: number;
  6225. /**
  6226. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6227. */
  6228. readonly normalized: boolean;
  6229. /**
  6230. * Gets the data type of each component in the array.
  6231. */
  6232. readonly type: number;
  6233. /**
  6234. * Constructor
  6235. * @param engine the engine
  6236. * @param data the data to use for this vertex buffer
  6237. * @param kind the vertex buffer kind
  6238. * @param updatable whether the data is updatable
  6239. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6240. * @param stride the stride (optional)
  6241. * @param instanced whether the buffer is instanced (optional)
  6242. * @param offset the offset of the data (optional)
  6243. * @param size the number of components (optional)
  6244. * @param type the type of the component (optional)
  6245. * @param normalized whether the data contains normalized data (optional)
  6246. * @param useBytes set to true if stride and offset are in bytes (optional)
  6247. */
  6248. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean);
  6249. /** @hidden */
  6250. _rebuild(): void;
  6251. /**
  6252. * Returns the kind of the VertexBuffer (string)
  6253. * @returns a string
  6254. */
  6255. getKind(): string;
  6256. /**
  6257. * Gets a boolean indicating if the VertexBuffer is updatable?
  6258. * @returns true if the buffer is updatable
  6259. */
  6260. isUpdatable(): boolean;
  6261. /**
  6262. * Gets current buffer's data
  6263. * @returns a DataArray or null
  6264. */
  6265. getData(): Nullable<DataArray>;
  6266. /**
  6267. * Gets underlying native buffer
  6268. * @returns underlying native buffer
  6269. */
  6270. getBuffer(): Nullable<DataBuffer>;
  6271. /**
  6272. * Gets the stride in float32 units (i.e. byte stride / 4).
  6273. * May not be an integer if the byte stride is not divisible by 4.
  6274. * DEPRECATED. Use byteStride instead.
  6275. * @returns the stride in float32 units
  6276. */
  6277. getStrideSize(): number;
  6278. /**
  6279. * Returns the offset as a multiple of the type byte length.
  6280. * DEPRECATED. Use byteOffset instead.
  6281. * @returns the offset in bytes
  6282. */
  6283. getOffset(): number;
  6284. /**
  6285. * Returns the number of components per vertex attribute (integer)
  6286. * @returns the size in float
  6287. */
  6288. getSize(): number;
  6289. /**
  6290. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6291. * @returns true if this buffer is instanced
  6292. */
  6293. getIsInstanced(): boolean;
  6294. /**
  6295. * Returns the instancing divisor, zero for non-instanced (integer).
  6296. * @returns a number
  6297. */
  6298. getInstanceDivisor(): number;
  6299. /**
  6300. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6301. * @param data defines the data to store
  6302. */
  6303. create(data?: DataArray): void;
  6304. /**
  6305. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6306. * This function will create a new buffer if the current one is not updatable
  6307. * @param data defines the data to store
  6308. */
  6309. update(data: DataArray): void;
  6310. /**
  6311. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6312. * Returns the directly updated WebGLBuffer.
  6313. * @param data the new data
  6314. * @param offset the new offset
  6315. * @param useBytes set to true if the offset is in bytes
  6316. */
  6317. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6318. /**
  6319. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6320. */
  6321. dispose(): void;
  6322. /**
  6323. * Enumerates each value of this vertex buffer as numbers.
  6324. * @param count the number of values to enumerate
  6325. * @param callback the callback function called for each value
  6326. */
  6327. forEach(count: number, callback: (value: number, index: number) => void): void;
  6328. /**
  6329. * Positions
  6330. */
  6331. static readonly PositionKind: string;
  6332. /**
  6333. * Normals
  6334. */
  6335. static readonly NormalKind: string;
  6336. /**
  6337. * Tangents
  6338. */
  6339. static readonly TangentKind: string;
  6340. /**
  6341. * Texture coordinates
  6342. */
  6343. static readonly UVKind: string;
  6344. /**
  6345. * Texture coordinates 2
  6346. */
  6347. static readonly UV2Kind: string;
  6348. /**
  6349. * Texture coordinates 3
  6350. */
  6351. static readonly UV3Kind: string;
  6352. /**
  6353. * Texture coordinates 4
  6354. */
  6355. static readonly UV4Kind: string;
  6356. /**
  6357. * Texture coordinates 5
  6358. */
  6359. static readonly UV5Kind: string;
  6360. /**
  6361. * Texture coordinates 6
  6362. */
  6363. static readonly UV6Kind: string;
  6364. /**
  6365. * Colors
  6366. */
  6367. static readonly ColorKind: string;
  6368. /**
  6369. * Matrix indices (for bones)
  6370. */
  6371. static readonly MatricesIndicesKind: string;
  6372. /**
  6373. * Matrix weights (for bones)
  6374. */
  6375. static readonly MatricesWeightsKind: string;
  6376. /**
  6377. * Additional matrix indices (for bones)
  6378. */
  6379. static readonly MatricesIndicesExtraKind: string;
  6380. /**
  6381. * Additional matrix weights (for bones)
  6382. */
  6383. static readonly MatricesWeightsExtraKind: string;
  6384. /**
  6385. * Deduces the stride given a kind.
  6386. * @param kind The kind string to deduce
  6387. * @returns The deduced stride
  6388. */
  6389. static DeduceStride(kind: string): number;
  6390. /**
  6391. * Gets the byte length of the given type.
  6392. * @param type the type
  6393. * @returns the number of bytes
  6394. */
  6395. static GetTypeByteLength(type: number): number;
  6396. /**
  6397. * Enumerates each value of the given parameters as numbers.
  6398. * @param data the data to enumerate
  6399. * @param byteOffset the byte offset of the data
  6400. * @param byteStride the byte stride of the data
  6401. * @param componentCount the number of components per element
  6402. * @param componentType the type of the component
  6403. * @param count the number of values to enumerate
  6404. * @param normalized whether the data is normalized
  6405. * @param callback the callback function called for each value
  6406. */
  6407. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6408. private static _GetFloatValue;
  6409. }
  6410. }
  6411. declare module "babylonjs/Collisions/intersectionInfo" {
  6412. import { Nullable } from "babylonjs/types";
  6413. /**
  6414. * @hidden
  6415. */
  6416. export class IntersectionInfo {
  6417. bu: Nullable<number>;
  6418. bv: Nullable<number>;
  6419. distance: number;
  6420. faceId: number;
  6421. subMeshId: number;
  6422. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6423. }
  6424. }
  6425. declare module "babylonjs/Maths/math.plane" {
  6426. import { DeepImmutable } from "babylonjs/types";
  6427. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6428. /**
  6429. * Represens a plane by the equation ax + by + cz + d = 0
  6430. */
  6431. export class Plane {
  6432. private static _TmpMatrix;
  6433. /**
  6434. * Normal of the plane (a,b,c)
  6435. */
  6436. normal: Vector3;
  6437. /**
  6438. * d component of the plane
  6439. */
  6440. d: number;
  6441. /**
  6442. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6443. * @param a a component of the plane
  6444. * @param b b component of the plane
  6445. * @param c c component of the plane
  6446. * @param d d component of the plane
  6447. */
  6448. constructor(a: number, b: number, c: number, d: number);
  6449. /**
  6450. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6451. */
  6452. asArray(): number[];
  6453. /**
  6454. * @returns a new plane copied from the current Plane.
  6455. */
  6456. clone(): Plane;
  6457. /**
  6458. * @returns the string "Plane".
  6459. */
  6460. getClassName(): string;
  6461. /**
  6462. * @returns the Plane hash code.
  6463. */
  6464. getHashCode(): number;
  6465. /**
  6466. * Normalize the current Plane in place.
  6467. * @returns the updated Plane.
  6468. */
  6469. normalize(): Plane;
  6470. /**
  6471. * Applies a transformation the plane and returns the result
  6472. * @param transformation the transformation matrix to be applied to the plane
  6473. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6474. */
  6475. transform(transformation: DeepImmutable<Matrix>): Plane;
  6476. /**
  6477. * Calcualtte the dot product between the point and the plane normal
  6478. * @param point point to calculate the dot product with
  6479. * @returns the dot product (float) of the point coordinates and the plane normal.
  6480. */
  6481. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6482. /**
  6483. * Updates the current Plane from the plane defined by the three given points.
  6484. * @param point1 one of the points used to contruct the plane
  6485. * @param point2 one of the points used to contruct the plane
  6486. * @param point3 one of the points used to contruct the plane
  6487. * @returns the updated Plane.
  6488. */
  6489. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6490. /**
  6491. * Checks if the plane is facing a given direction
  6492. * @param direction the direction to check if the plane is facing
  6493. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6494. * @returns True is the vector "direction" is the same side than the plane normal.
  6495. */
  6496. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6497. /**
  6498. * Calculates the distance to a point
  6499. * @param point point to calculate distance to
  6500. * @returns the signed distance (float) from the given point to the Plane.
  6501. */
  6502. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6503. /**
  6504. * Creates a plane from an array
  6505. * @param array the array to create a plane from
  6506. * @returns a new Plane from the given array.
  6507. */
  6508. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6509. /**
  6510. * Creates a plane from three points
  6511. * @param point1 point used to create the plane
  6512. * @param point2 point used to create the plane
  6513. * @param point3 point used to create the plane
  6514. * @returns a new Plane defined by the three given points.
  6515. */
  6516. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6517. /**
  6518. * Creates a plane from an origin point and a normal
  6519. * @param origin origin of the plane to be constructed
  6520. * @param normal normal of the plane to be constructed
  6521. * @returns a new Plane the normal vector to this plane at the given origin point.
  6522. * Note : the vector "normal" is updated because normalized.
  6523. */
  6524. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6525. /**
  6526. * Calculates the distance from a plane and a point
  6527. * @param origin origin of the plane to be constructed
  6528. * @param normal normal of the plane to be constructed
  6529. * @param point point to calculate distance to
  6530. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6531. */
  6532. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6533. }
  6534. }
  6535. declare module "babylonjs/Culling/boundingSphere" {
  6536. import { DeepImmutable } from "babylonjs/types";
  6537. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6538. import { Plane } from "babylonjs/Maths/math.plane";
  6539. /**
  6540. * Class used to store bounding sphere information
  6541. */
  6542. export class BoundingSphere {
  6543. /**
  6544. * Gets the center of the bounding sphere in local space
  6545. */
  6546. readonly center: Vector3;
  6547. /**
  6548. * Radius of the bounding sphere in local space
  6549. */
  6550. radius: number;
  6551. /**
  6552. * Gets the center of the bounding sphere in world space
  6553. */
  6554. readonly centerWorld: Vector3;
  6555. /**
  6556. * Radius of the bounding sphere in world space
  6557. */
  6558. radiusWorld: number;
  6559. /**
  6560. * Gets the minimum vector in local space
  6561. */
  6562. readonly minimum: Vector3;
  6563. /**
  6564. * Gets the maximum vector in local space
  6565. */
  6566. readonly maximum: Vector3;
  6567. private _worldMatrix;
  6568. private static readonly TmpVector3;
  6569. /**
  6570. * Creates a new bounding sphere
  6571. * @param min defines the minimum vector (in local space)
  6572. * @param max defines the maximum vector (in local space)
  6573. * @param worldMatrix defines the new world matrix
  6574. */
  6575. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6576. /**
  6577. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6578. * @param min defines the new minimum vector (in local space)
  6579. * @param max defines the new maximum vector (in local space)
  6580. * @param worldMatrix defines the new world matrix
  6581. */
  6582. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6583. /**
  6584. * Scale the current bounding sphere by applying a scale factor
  6585. * @param factor defines the scale factor to apply
  6586. * @returns the current bounding box
  6587. */
  6588. scale(factor: number): BoundingSphere;
  6589. /**
  6590. * Gets the world matrix of the bounding box
  6591. * @returns a matrix
  6592. */
  6593. getWorldMatrix(): DeepImmutable<Matrix>;
  6594. /** @hidden */
  6595. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6596. /**
  6597. * Tests if the bounding sphere is intersecting the frustum planes
  6598. * @param frustumPlanes defines the frustum planes to test
  6599. * @returns true if there is an intersection
  6600. */
  6601. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6602. /**
  6603. * Tests if the bounding sphere center is in between the frustum planes.
  6604. * Used for optimistic fast inclusion.
  6605. * @param frustumPlanes defines the frustum planes to test
  6606. * @returns true if the sphere center is in between the frustum planes
  6607. */
  6608. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6609. /**
  6610. * Tests if a point is inside the bounding sphere
  6611. * @param point defines the point to test
  6612. * @returns true if the point is inside the bounding sphere
  6613. */
  6614. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6615. /**
  6616. * Checks if two sphere intersct
  6617. * @param sphere0 sphere 0
  6618. * @param sphere1 sphere 1
  6619. * @returns true if the speres intersect
  6620. */
  6621. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6622. }
  6623. }
  6624. declare module "babylonjs/Culling/boundingBox" {
  6625. import { DeepImmutable } from "babylonjs/types";
  6626. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6627. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6628. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6629. import { Plane } from "babylonjs/Maths/math.plane";
  6630. /**
  6631. * Class used to store bounding box information
  6632. */
  6633. export class BoundingBox implements ICullable {
  6634. /**
  6635. * Gets the 8 vectors representing the bounding box in local space
  6636. */
  6637. readonly vectors: Vector3[];
  6638. /**
  6639. * Gets the center of the bounding box in local space
  6640. */
  6641. readonly center: Vector3;
  6642. /**
  6643. * Gets the center of the bounding box in world space
  6644. */
  6645. readonly centerWorld: Vector3;
  6646. /**
  6647. * Gets the extend size in local space
  6648. */
  6649. readonly extendSize: Vector3;
  6650. /**
  6651. * Gets the extend size in world space
  6652. */
  6653. readonly extendSizeWorld: Vector3;
  6654. /**
  6655. * Gets the OBB (object bounding box) directions
  6656. */
  6657. readonly directions: Vector3[];
  6658. /**
  6659. * Gets the 8 vectors representing the bounding box in world space
  6660. */
  6661. readonly vectorsWorld: Vector3[];
  6662. /**
  6663. * Gets the minimum vector in world space
  6664. */
  6665. readonly minimumWorld: Vector3;
  6666. /**
  6667. * Gets the maximum vector in world space
  6668. */
  6669. readonly maximumWorld: Vector3;
  6670. /**
  6671. * Gets the minimum vector in local space
  6672. */
  6673. readonly minimum: Vector3;
  6674. /**
  6675. * Gets the maximum vector in local space
  6676. */
  6677. readonly maximum: Vector3;
  6678. private _worldMatrix;
  6679. private static readonly TmpVector3;
  6680. /**
  6681. * @hidden
  6682. */
  6683. _tag: number;
  6684. /**
  6685. * Creates a new bounding box
  6686. * @param min defines the minimum vector (in local space)
  6687. * @param max defines the maximum vector (in local space)
  6688. * @param worldMatrix defines the new world matrix
  6689. */
  6690. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6691. /**
  6692. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6693. * @param min defines the new minimum vector (in local space)
  6694. * @param max defines the new maximum vector (in local space)
  6695. * @param worldMatrix defines the new world matrix
  6696. */
  6697. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6698. /**
  6699. * Scale the current bounding box by applying a scale factor
  6700. * @param factor defines the scale factor to apply
  6701. * @returns the current bounding box
  6702. */
  6703. scale(factor: number): BoundingBox;
  6704. /**
  6705. * Gets the world matrix of the bounding box
  6706. * @returns a matrix
  6707. */
  6708. getWorldMatrix(): DeepImmutable<Matrix>;
  6709. /** @hidden */
  6710. _update(world: DeepImmutable<Matrix>): void;
  6711. /**
  6712. * Tests if the bounding box is intersecting the frustum planes
  6713. * @param frustumPlanes defines the frustum planes to test
  6714. * @returns true if there is an intersection
  6715. */
  6716. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6717. /**
  6718. * Tests if the bounding box is entirely inside the frustum planes
  6719. * @param frustumPlanes defines the frustum planes to test
  6720. * @returns true if there is an inclusion
  6721. */
  6722. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6723. /**
  6724. * Tests if a point is inside the bounding box
  6725. * @param point defines the point to test
  6726. * @returns true if the point is inside the bounding box
  6727. */
  6728. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6729. /**
  6730. * Tests if the bounding box intersects with a bounding sphere
  6731. * @param sphere defines the sphere to test
  6732. * @returns true if there is an intersection
  6733. */
  6734. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6735. /**
  6736. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6737. * @param min defines the min vector to use
  6738. * @param max defines the max vector to use
  6739. * @returns true if there is an intersection
  6740. */
  6741. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6742. /**
  6743. * Tests if two bounding boxes are intersections
  6744. * @param box0 defines the first box to test
  6745. * @param box1 defines the second box to test
  6746. * @returns true if there is an intersection
  6747. */
  6748. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6749. /**
  6750. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6751. * @param minPoint defines the minimum vector of the bounding box
  6752. * @param maxPoint defines the maximum vector of the bounding box
  6753. * @param sphereCenter defines the sphere center
  6754. * @param sphereRadius defines the sphere radius
  6755. * @returns true if there is an intersection
  6756. */
  6757. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6758. /**
  6759. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6760. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6761. * @param frustumPlanes defines the frustum planes to test
  6762. * @return true if there is an inclusion
  6763. */
  6764. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6765. /**
  6766. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6767. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6768. * @param frustumPlanes defines the frustum planes to test
  6769. * @return true if there is an intersection
  6770. */
  6771. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6772. }
  6773. }
  6774. declare module "babylonjs/Collisions/collider" {
  6775. import { Nullable, IndicesArray } from "babylonjs/types";
  6776. import { Vector3 } from "babylonjs/Maths/math.vector";
  6777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6778. import { Plane } from "babylonjs/Maths/math.plane";
  6779. /** @hidden */
  6780. export class Collider {
  6781. /** Define if a collision was found */
  6782. collisionFound: boolean;
  6783. /**
  6784. * Define last intersection point in local space
  6785. */
  6786. intersectionPoint: Vector3;
  6787. /**
  6788. * Define last collided mesh
  6789. */
  6790. collidedMesh: Nullable<AbstractMesh>;
  6791. private _collisionPoint;
  6792. private _planeIntersectionPoint;
  6793. private _tempVector;
  6794. private _tempVector2;
  6795. private _tempVector3;
  6796. private _tempVector4;
  6797. private _edge;
  6798. private _baseToVertex;
  6799. private _destinationPoint;
  6800. private _slidePlaneNormal;
  6801. private _displacementVector;
  6802. /** @hidden */
  6803. _radius: Vector3;
  6804. /** @hidden */
  6805. _retry: number;
  6806. private _velocity;
  6807. private _basePoint;
  6808. private _epsilon;
  6809. /** @hidden */
  6810. _velocityWorldLength: number;
  6811. /** @hidden */
  6812. _basePointWorld: Vector3;
  6813. private _velocityWorld;
  6814. private _normalizedVelocity;
  6815. /** @hidden */
  6816. _initialVelocity: Vector3;
  6817. /** @hidden */
  6818. _initialPosition: Vector3;
  6819. private _nearestDistance;
  6820. private _collisionMask;
  6821. collisionMask: number;
  6822. /**
  6823. * Gets the plane normal used to compute the sliding response (in local space)
  6824. */
  6825. readonly slidePlaneNormal: Vector3;
  6826. /** @hidden */
  6827. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6828. /** @hidden */
  6829. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6830. /** @hidden */
  6831. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6832. /** @hidden */
  6833. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6834. /** @hidden */
  6835. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _getResponse(pos: Vector3, vel: Vector3): void;
  6838. }
  6839. }
  6840. declare module "babylonjs/Culling/boundingInfo" {
  6841. import { DeepImmutable } from "babylonjs/types";
  6842. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6843. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6844. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6845. import { Plane } from "babylonjs/Maths/math.plane";
  6846. import { Collider } from "babylonjs/Collisions/collider";
  6847. /**
  6848. * Interface for cullable objects
  6849. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6850. */
  6851. export interface ICullable {
  6852. /**
  6853. * Checks if the object or part of the object is in the frustum
  6854. * @param frustumPlanes Camera near/planes
  6855. * @returns true if the object is in frustum otherwise false
  6856. */
  6857. isInFrustum(frustumPlanes: Plane[]): boolean;
  6858. /**
  6859. * Checks if a cullable object (mesh...) is in the camera frustum
  6860. * Unlike isInFrustum this cheks the full bounding box
  6861. * @param frustumPlanes Camera near/planes
  6862. * @returns true if the object is in frustum otherwise false
  6863. */
  6864. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6865. }
  6866. /**
  6867. * Info for a bounding data of a mesh
  6868. */
  6869. export class BoundingInfo implements ICullable {
  6870. /**
  6871. * Bounding box for the mesh
  6872. */
  6873. readonly boundingBox: BoundingBox;
  6874. /**
  6875. * Bounding sphere for the mesh
  6876. */
  6877. readonly boundingSphere: BoundingSphere;
  6878. private _isLocked;
  6879. private static readonly TmpVector3;
  6880. /**
  6881. * Constructs bounding info
  6882. * @param minimum min vector of the bounding box/sphere
  6883. * @param maximum max vector of the bounding box/sphere
  6884. * @param worldMatrix defines the new world matrix
  6885. */
  6886. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6887. /**
  6888. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6889. * @param min defines the new minimum vector (in local space)
  6890. * @param max defines the new maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6894. /**
  6895. * min vector of the bounding box/sphere
  6896. */
  6897. readonly minimum: Vector3;
  6898. /**
  6899. * max vector of the bounding box/sphere
  6900. */
  6901. readonly maximum: Vector3;
  6902. /**
  6903. * If the info is locked and won't be updated to avoid perf overhead
  6904. */
  6905. isLocked: boolean;
  6906. /**
  6907. * Updates the bounding sphere and box
  6908. * @param world world matrix to be used to update
  6909. */
  6910. update(world: DeepImmutable<Matrix>): void;
  6911. /**
  6912. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6913. * @param center New center of the bounding info
  6914. * @param extend New extend of the bounding info
  6915. * @returns the current bounding info
  6916. */
  6917. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6918. /**
  6919. * Scale the current bounding info by applying a scale factor
  6920. * @param factor defines the scale factor to apply
  6921. * @returns the current bounding info
  6922. */
  6923. scale(factor: number): BoundingInfo;
  6924. /**
  6925. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6926. * @param frustumPlanes defines the frustum to test
  6927. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6928. * @returns true if the bounding info is in the frustum planes
  6929. */
  6930. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6931. /**
  6932. * Gets the world distance between the min and max points of the bounding box
  6933. */
  6934. readonly diagonalLength: number;
  6935. /**
  6936. * Checks if a cullable object (mesh...) is in the camera frustum
  6937. * Unlike isInFrustum this cheks the full bounding box
  6938. * @param frustumPlanes Camera near/planes
  6939. * @returns true if the object is in frustum otherwise false
  6940. */
  6941. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6942. /** @hidden */
  6943. _checkCollision(collider: Collider): boolean;
  6944. /**
  6945. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6946. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6947. * @param point the point to check intersection with
  6948. * @returns if the point intersects
  6949. */
  6950. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6951. /**
  6952. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6953. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6954. * @param boundingInfo the bounding info to check intersection with
  6955. * @param precise if the intersection should be done using OBB
  6956. * @returns if the bounding info intersects
  6957. */
  6958. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6959. }
  6960. }
  6961. declare module "babylonjs/Maths/math.functions" {
  6962. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6963. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6964. /**
  6965. * Extracts minimum and maximum values from a list of indexed positions
  6966. * @param positions defines the positions to use
  6967. * @param indices defines the indices to the positions
  6968. * @param indexStart defines the start index
  6969. * @param indexCount defines the end index
  6970. * @param bias defines bias value to add to the result
  6971. * @return minimum and maximum values
  6972. */
  6973. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6974. minimum: Vector3;
  6975. maximum: Vector3;
  6976. };
  6977. /**
  6978. * Extracts minimum and maximum values from a list of positions
  6979. * @param positions defines the positions to use
  6980. * @param start defines the start index in the positions array
  6981. * @param count defines the number of positions to handle
  6982. * @param bias defines bias value to add to the result
  6983. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6984. * @return minimum and maximum values
  6985. */
  6986. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6987. minimum: Vector3;
  6988. maximum: Vector3;
  6989. };
  6990. }
  6991. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6992. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6993. /** @hidden */
  6994. export class WebGLDataBuffer extends DataBuffer {
  6995. private _buffer;
  6996. constructor(resource: WebGLBuffer);
  6997. readonly underlyingResource: any;
  6998. }
  6999. }
  7000. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7002. import { Nullable } from "babylonjs/types";
  7003. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7004. /** @hidden */
  7005. export class WebGLPipelineContext implements IPipelineContext {
  7006. engine: ThinEngine;
  7007. program: Nullable<WebGLProgram>;
  7008. context?: WebGLRenderingContext;
  7009. vertexShader?: WebGLShader;
  7010. fragmentShader?: WebGLShader;
  7011. isParallelCompiled: boolean;
  7012. onCompiled?: () => void;
  7013. transformFeedback?: WebGLTransformFeedback | null;
  7014. readonly isAsync: boolean;
  7015. readonly isReady: boolean;
  7016. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7017. }
  7018. }
  7019. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7020. import { FloatArray, Nullable } from "babylonjs/types";
  7021. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7022. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7023. module "babylonjs/Engines/thinEngine" {
  7024. interface ThinEngine {
  7025. /**
  7026. * Create an uniform buffer
  7027. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7028. * @param elements defines the content of the uniform buffer
  7029. * @returns the webGL uniform buffer
  7030. */
  7031. createUniformBuffer(elements: FloatArray): DataBuffer;
  7032. /**
  7033. * Create a dynamic uniform buffer
  7034. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7035. * @param elements defines the content of the uniform buffer
  7036. * @returns the webGL uniform buffer
  7037. */
  7038. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7039. /**
  7040. * Update an existing uniform buffer
  7041. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7042. * @param uniformBuffer defines the target uniform buffer
  7043. * @param elements defines the content to update
  7044. * @param offset defines the offset in the uniform buffer where update should start
  7045. * @param count defines the size of the data to update
  7046. */
  7047. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7048. /**
  7049. * Bind an uniform buffer to the current webGL context
  7050. * @param buffer defines the buffer to bind
  7051. */
  7052. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7053. /**
  7054. * Bind a buffer to the current webGL context at a given location
  7055. * @param buffer defines the buffer to bind
  7056. * @param location defines the index where to bind the buffer
  7057. */
  7058. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7059. /**
  7060. * Bind a specific block at a given index in a specific shader program
  7061. * @param pipelineContext defines the pipeline context to use
  7062. * @param blockName defines the block name
  7063. * @param index defines the index where to bind the block
  7064. */
  7065. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7066. }
  7067. }
  7068. }
  7069. declare module "babylonjs/Materials/uniformBuffer" {
  7070. import { Nullable, FloatArray } from "babylonjs/types";
  7071. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7072. import { Engine } from "babylonjs/Engines/engine";
  7073. import { Effect } from "babylonjs/Materials/effect";
  7074. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7075. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7076. import { Color3 } from "babylonjs/Maths/math.color";
  7077. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7078. /**
  7079. * Uniform buffer objects.
  7080. *
  7081. * Handles blocks of uniform on the GPU.
  7082. *
  7083. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7084. *
  7085. * For more information, please refer to :
  7086. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7087. */
  7088. export class UniformBuffer {
  7089. private _engine;
  7090. private _buffer;
  7091. private _data;
  7092. private _bufferData;
  7093. private _dynamic?;
  7094. private _uniformLocations;
  7095. private _uniformSizes;
  7096. private _uniformLocationPointer;
  7097. private _needSync;
  7098. private _noUBO;
  7099. private _currentEffect;
  7100. private static _MAX_UNIFORM_SIZE;
  7101. private static _tempBuffer;
  7102. /**
  7103. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7104. * This is dynamic to allow compat with webgl 1 and 2.
  7105. * You will need to pass the name of the uniform as well as the value.
  7106. */
  7107. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7108. /**
  7109. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7110. * This is dynamic to allow compat with webgl 1 and 2.
  7111. * You will need to pass the name of the uniform as well as the value.
  7112. */
  7113. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7114. /**
  7115. * Lambda to Update a single float in a uniform buffer.
  7116. * This is dynamic to allow compat with webgl 1 and 2.
  7117. * You will need to pass the name of the uniform as well as the value.
  7118. */
  7119. updateFloat: (name: string, x: number) => void;
  7120. /**
  7121. * Lambda to Update a vec2 of float in a uniform buffer.
  7122. * This is dynamic to allow compat with webgl 1 and 2.
  7123. * You will need to pass the name of the uniform as well as the value.
  7124. */
  7125. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7126. /**
  7127. * Lambda to Update a vec3 of float in a uniform buffer.
  7128. * This is dynamic to allow compat with webgl 1 and 2.
  7129. * You will need to pass the name of the uniform as well as the value.
  7130. */
  7131. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7132. /**
  7133. * Lambda to Update a vec4 of float in a uniform buffer.
  7134. * This is dynamic to allow compat with webgl 1 and 2.
  7135. * You will need to pass the name of the uniform as well as the value.
  7136. */
  7137. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7138. /**
  7139. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7140. * This is dynamic to allow compat with webgl 1 and 2.
  7141. * You will need to pass the name of the uniform as well as the value.
  7142. */
  7143. updateMatrix: (name: string, mat: Matrix) => void;
  7144. /**
  7145. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7146. * This is dynamic to allow compat with webgl 1 and 2.
  7147. * You will need to pass the name of the uniform as well as the value.
  7148. */
  7149. updateVector3: (name: string, vector: Vector3) => void;
  7150. /**
  7151. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7152. * This is dynamic to allow compat with webgl 1 and 2.
  7153. * You will need to pass the name of the uniform as well as the value.
  7154. */
  7155. updateVector4: (name: string, vector: Vector4) => void;
  7156. /**
  7157. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7158. * This is dynamic to allow compat with webgl 1 and 2.
  7159. * You will need to pass the name of the uniform as well as the value.
  7160. */
  7161. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7162. /**
  7163. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7164. * This is dynamic to allow compat with webgl 1 and 2.
  7165. * You will need to pass the name of the uniform as well as the value.
  7166. */
  7167. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7168. /**
  7169. * Instantiates a new Uniform buffer objects.
  7170. *
  7171. * Handles blocks of uniform on the GPU.
  7172. *
  7173. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7174. *
  7175. * For more information, please refer to :
  7176. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7177. * @param engine Define the engine the buffer is associated with
  7178. * @param data Define the data contained in the buffer
  7179. * @param dynamic Define if the buffer is updatable
  7180. */
  7181. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7182. /**
  7183. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7184. * or just falling back on setUniformXXX calls.
  7185. */
  7186. readonly useUbo: boolean;
  7187. /**
  7188. * Indicates if the WebGL underlying uniform buffer is in sync
  7189. * with the javascript cache data.
  7190. */
  7191. readonly isSync: boolean;
  7192. /**
  7193. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7194. * Also, a dynamic UniformBuffer will disable cache verification and always
  7195. * update the underlying WebGL uniform buffer to the GPU.
  7196. * @returns if Dynamic, otherwise false
  7197. */
  7198. isDynamic(): boolean;
  7199. /**
  7200. * The data cache on JS side.
  7201. * @returns the underlying data as a float array
  7202. */
  7203. getData(): Float32Array;
  7204. /**
  7205. * The underlying WebGL Uniform buffer.
  7206. * @returns the webgl buffer
  7207. */
  7208. getBuffer(): Nullable<DataBuffer>;
  7209. /**
  7210. * std140 layout specifies how to align data within an UBO structure.
  7211. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7212. * for specs.
  7213. */
  7214. private _fillAlignment;
  7215. /**
  7216. * Adds an uniform in the buffer.
  7217. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7218. * for the layout to be correct !
  7219. * @param name Name of the uniform, as used in the uniform block in the shader.
  7220. * @param size Data size, or data directly.
  7221. */
  7222. addUniform(name: string, size: number | number[]): void;
  7223. /**
  7224. * Adds a Matrix 4x4 to the uniform buffer.
  7225. * @param name Name of the uniform, as used in the uniform block in the shader.
  7226. * @param mat A 4x4 matrix.
  7227. */
  7228. addMatrix(name: string, mat: Matrix): void;
  7229. /**
  7230. * Adds a vec2 to the uniform buffer.
  7231. * @param name Name of the uniform, as used in the uniform block in the shader.
  7232. * @param x Define the x component value of the vec2
  7233. * @param y Define the y component value of the vec2
  7234. */
  7235. addFloat2(name: string, x: number, y: number): void;
  7236. /**
  7237. * Adds a vec3 to the uniform buffer.
  7238. * @param name Name of the uniform, as used in the uniform block in the shader.
  7239. * @param x Define the x component value of the vec3
  7240. * @param y Define the y component value of the vec3
  7241. * @param z Define the z component value of the vec3
  7242. */
  7243. addFloat3(name: string, x: number, y: number, z: number): void;
  7244. /**
  7245. * Adds a vec3 to the uniform buffer.
  7246. * @param name Name of the uniform, as used in the uniform block in the shader.
  7247. * @param color Define the vec3 from a Color
  7248. */
  7249. addColor3(name: string, color: Color3): void;
  7250. /**
  7251. * Adds a vec4 to the uniform buffer.
  7252. * @param name Name of the uniform, as used in the uniform block in the shader.
  7253. * @param color Define the rgb components from a Color
  7254. * @param alpha Define the a component of the vec4
  7255. */
  7256. addColor4(name: string, color: Color3, alpha: number): void;
  7257. /**
  7258. * Adds a vec3 to the uniform buffer.
  7259. * @param name Name of the uniform, as used in the uniform block in the shader.
  7260. * @param vector Define the vec3 components from a Vector
  7261. */
  7262. addVector3(name: string, vector: Vector3): void;
  7263. /**
  7264. * Adds a Matrix 3x3 to the uniform buffer.
  7265. * @param name Name of the uniform, as used in the uniform block in the shader.
  7266. */
  7267. addMatrix3x3(name: string): void;
  7268. /**
  7269. * Adds a Matrix 2x2 to the uniform buffer.
  7270. * @param name Name of the uniform, as used in the uniform block in the shader.
  7271. */
  7272. addMatrix2x2(name: string): void;
  7273. /**
  7274. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7275. */
  7276. create(): void;
  7277. /** @hidden */
  7278. _rebuild(): void;
  7279. /**
  7280. * Updates the WebGL Uniform Buffer on the GPU.
  7281. * If the `dynamic` flag is set to true, no cache comparison is done.
  7282. * Otherwise, the buffer will be updated only if the cache differs.
  7283. */
  7284. update(): void;
  7285. /**
  7286. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7287. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7288. * @param data Define the flattened data
  7289. * @param size Define the size of the data.
  7290. */
  7291. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7292. private _valueCache;
  7293. private _cacheMatrix;
  7294. private _updateMatrix3x3ForUniform;
  7295. private _updateMatrix3x3ForEffect;
  7296. private _updateMatrix2x2ForEffect;
  7297. private _updateMatrix2x2ForUniform;
  7298. private _updateFloatForEffect;
  7299. private _updateFloatForUniform;
  7300. private _updateFloat2ForEffect;
  7301. private _updateFloat2ForUniform;
  7302. private _updateFloat3ForEffect;
  7303. private _updateFloat3ForUniform;
  7304. private _updateFloat4ForEffect;
  7305. private _updateFloat4ForUniform;
  7306. private _updateMatrixForEffect;
  7307. private _updateMatrixForUniform;
  7308. private _updateVector3ForEffect;
  7309. private _updateVector3ForUniform;
  7310. private _updateVector4ForEffect;
  7311. private _updateVector4ForUniform;
  7312. private _updateColor3ForEffect;
  7313. private _updateColor3ForUniform;
  7314. private _updateColor4ForEffect;
  7315. private _updateColor4ForUniform;
  7316. /**
  7317. * Sets a sampler uniform on the effect.
  7318. * @param name Define the name of the sampler.
  7319. * @param texture Define the texture to set in the sampler
  7320. */
  7321. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7322. /**
  7323. * Directly updates the value of the uniform in the cache AND on the GPU.
  7324. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7325. * @param data Define the flattened data
  7326. */
  7327. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7328. /**
  7329. * Binds this uniform buffer to an effect.
  7330. * @param effect Define the effect to bind the buffer to
  7331. * @param name Name of the uniform block in the shader.
  7332. */
  7333. bindToEffect(effect: Effect, name: string): void;
  7334. /**
  7335. * Disposes the uniform buffer.
  7336. */
  7337. dispose(): void;
  7338. }
  7339. }
  7340. declare module "babylonjs/Misc/iInspectable" {
  7341. /**
  7342. * Enum that determines the text-wrapping mode to use.
  7343. */
  7344. export enum InspectableType {
  7345. /**
  7346. * Checkbox for booleans
  7347. */
  7348. Checkbox = 0,
  7349. /**
  7350. * Sliders for numbers
  7351. */
  7352. Slider = 1,
  7353. /**
  7354. * Vector3
  7355. */
  7356. Vector3 = 2,
  7357. /**
  7358. * Quaternions
  7359. */
  7360. Quaternion = 3,
  7361. /**
  7362. * Color3
  7363. */
  7364. Color3 = 4,
  7365. /**
  7366. * String
  7367. */
  7368. String = 5
  7369. }
  7370. /**
  7371. * Interface used to define custom inspectable properties.
  7372. * This interface is used by the inspector to display custom property grids
  7373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7374. */
  7375. export interface IInspectable {
  7376. /**
  7377. * Gets the label to display
  7378. */
  7379. label: string;
  7380. /**
  7381. * Gets the name of the property to edit
  7382. */
  7383. propertyName: string;
  7384. /**
  7385. * Gets the type of the editor to use
  7386. */
  7387. type: InspectableType;
  7388. /**
  7389. * Gets the minimum value of the property when using in "slider" mode
  7390. */
  7391. min?: number;
  7392. /**
  7393. * Gets the maximum value of the property when using in "slider" mode
  7394. */
  7395. max?: number;
  7396. /**
  7397. * Gets the setp to use when using in "slider" mode
  7398. */
  7399. step?: number;
  7400. }
  7401. }
  7402. declare module "babylonjs/Misc/timingTools" {
  7403. /**
  7404. * Class used to provide helper for timing
  7405. */
  7406. export class TimingTools {
  7407. /**
  7408. * Polyfill for setImmediate
  7409. * @param action defines the action to execute after the current execution block
  7410. */
  7411. static SetImmediate(action: () => void): void;
  7412. }
  7413. }
  7414. declare module "babylonjs/Misc/instantiationTools" {
  7415. /**
  7416. * Class used to enable instatition of objects by class name
  7417. */
  7418. export class InstantiationTools {
  7419. /**
  7420. * Use this object to register external classes like custom textures or material
  7421. * to allow the laoders to instantiate them
  7422. */
  7423. static RegisteredExternalClasses: {
  7424. [key: string]: Object;
  7425. };
  7426. /**
  7427. * Tries to instantiate a new object from a given class name
  7428. * @param className defines the class name to instantiate
  7429. * @returns the new object or null if the system was not able to do the instantiation
  7430. */
  7431. static Instantiate(className: string): any;
  7432. }
  7433. }
  7434. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7435. /**
  7436. * Define options used to create a depth texture
  7437. */
  7438. export class DepthTextureCreationOptions {
  7439. /** Specifies whether or not a stencil should be allocated in the texture */
  7440. generateStencil?: boolean;
  7441. /** Specifies whether or not bilinear filtering is enable on the texture */
  7442. bilinearFiltering?: boolean;
  7443. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7444. comparisonFunction?: number;
  7445. /** Specifies if the created texture is a cube texture */
  7446. isCube?: boolean;
  7447. }
  7448. }
  7449. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7451. import { Nullable } from "babylonjs/types";
  7452. import { Scene } from "babylonjs/scene";
  7453. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7454. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Creates a depth stencil cube texture.
  7459. * This is only available in WebGL 2.
  7460. * @param size The size of face edge in the cube texture.
  7461. * @param options The options defining the cube texture.
  7462. * @returns The cube texture
  7463. */
  7464. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7465. /**
  7466. * Creates a cube texture
  7467. * @param rootUrl defines the url where the files to load is located
  7468. * @param scene defines the current scene
  7469. * @param files defines the list of files to load (1 per face)
  7470. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7471. * @param onLoad defines an optional callback raised when the texture is loaded
  7472. * @param onError defines an optional callback raised if there is an issue to load the texture
  7473. * @param format defines the format of the data
  7474. * @param forcedExtension defines the extension to use to pick the right loader
  7475. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7476. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7477. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7478. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7479. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7480. * @returns the cube texture as an InternalTexture
  7481. */
  7482. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7483. /**
  7484. * Creates a cube texture
  7485. * @param rootUrl defines the url where the files to load is located
  7486. * @param scene defines the current scene
  7487. * @param files defines the list of files to load (1 per face)
  7488. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7489. * @param onLoad defines an optional callback raised when the texture is loaded
  7490. * @param onError defines an optional callback raised if there is an issue to load the texture
  7491. * @param format defines the format of the data
  7492. * @param forcedExtension defines the extension to use to pick the right loader
  7493. * @returns the cube texture as an InternalTexture
  7494. */
  7495. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7496. /**
  7497. * Creates a cube texture
  7498. * @param rootUrl defines the url where the files to load is located
  7499. * @param scene defines the current scene
  7500. * @param files defines the list of files to load (1 per face)
  7501. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7502. * @param onLoad defines an optional callback raised when the texture is loaded
  7503. * @param onError defines an optional callback raised if there is an issue to load the texture
  7504. * @param format defines the format of the data
  7505. * @param forcedExtension defines the extension to use to pick the right loader
  7506. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7507. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7508. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7509. * @returns the cube texture as an InternalTexture
  7510. */
  7511. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7512. /** @hidden */
  7513. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7514. /** @hidden */
  7515. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7520. }
  7521. }
  7522. }
  7523. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7524. import { Nullable } from "babylonjs/types";
  7525. import { Scene } from "babylonjs/scene";
  7526. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7528. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7529. /**
  7530. * Class for creating a cube texture
  7531. */
  7532. export class CubeTexture extends BaseTexture {
  7533. private _delayedOnLoad;
  7534. /**
  7535. * The url of the texture
  7536. */
  7537. url: string;
  7538. /**
  7539. * Gets or sets the center of the bounding box associated with the cube texture.
  7540. * It must define where the camera used to render the texture was set
  7541. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7542. */
  7543. boundingBoxPosition: Vector3;
  7544. private _boundingBoxSize;
  7545. /**
  7546. * Gets or sets the size of the bounding box associated with the cube texture
  7547. * When defined, the cubemap will switch to local mode
  7548. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7549. * @example https://www.babylonjs-playground.com/#RNASML
  7550. */
  7551. /**
  7552. * Returns the bounding box size
  7553. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7554. */
  7555. boundingBoxSize: Vector3;
  7556. protected _rotationY: number;
  7557. /**
  7558. * Sets texture matrix rotation angle around Y axis in radians.
  7559. */
  7560. /**
  7561. * Gets texture matrix rotation angle around Y axis radians.
  7562. */
  7563. rotationY: number;
  7564. /**
  7565. * Are mip maps generated for this texture or not.
  7566. */
  7567. readonly noMipmap: boolean;
  7568. private _noMipmap;
  7569. private _files;
  7570. protected _forcedExtension: Nullable<string>;
  7571. private _extensions;
  7572. private _textureMatrix;
  7573. private _format;
  7574. private _createPolynomials;
  7575. /** @hidden */
  7576. _prefiltered: boolean;
  7577. /**
  7578. * Creates a cube texture from an array of image urls
  7579. * @param files defines an array of image urls
  7580. * @param scene defines the hosting scene
  7581. * @param noMipmap specifies if mip maps are not used
  7582. * @returns a cube texture
  7583. */
  7584. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7585. /**
  7586. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7587. * @param url defines the url of the prefiltered texture
  7588. * @param scene defines the scene the texture is attached to
  7589. * @param forcedExtension defines the extension of the file if different from the url
  7590. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7591. * @return the prefiltered texture
  7592. */
  7593. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7594. /**
  7595. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7596. * as prefiltered data.
  7597. * @param rootUrl defines the url of the texture or the root name of the six images
  7598. * @param scene defines the scene the texture is attached to
  7599. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7600. * @param noMipmap defines if mipmaps should be created or not
  7601. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7602. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7603. * @param onError defines a callback triggered in case of error during load
  7604. * @param format defines the internal format to use for the texture once loaded
  7605. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7606. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7607. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7608. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7609. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7610. * @return the cube texture
  7611. */
  7612. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7613. /**
  7614. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7615. */
  7616. readonly isPrefiltered: boolean;
  7617. /**
  7618. * Get the current class name of the texture useful for serialization or dynamic coding.
  7619. * @returns "CubeTexture"
  7620. */
  7621. getClassName(): string;
  7622. /**
  7623. * Update the url (and optional buffer) of this texture if url was null during construction.
  7624. * @param url the url of the texture
  7625. * @param forcedExtension defines the extension to use
  7626. * @param onLoad callback called when the texture is loaded (defaults to null)
  7627. */
  7628. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7629. /**
  7630. * Delays loading of the cube texture
  7631. * @param forcedExtension defines the extension to use
  7632. */
  7633. delayLoad(forcedExtension?: string): void;
  7634. /**
  7635. * Returns the reflection texture matrix
  7636. * @returns the reflection texture matrix
  7637. */
  7638. getReflectionTextureMatrix(): Matrix;
  7639. /**
  7640. * Sets the reflection texture matrix
  7641. * @param value Reflection texture matrix
  7642. */
  7643. setReflectionTextureMatrix(value: Matrix): void;
  7644. /**
  7645. * Parses text to create a cube texture
  7646. * @param parsedTexture define the serialized text to read from
  7647. * @param scene defines the hosting scene
  7648. * @param rootUrl defines the root url of the cube texture
  7649. * @returns a cube texture
  7650. */
  7651. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7652. /**
  7653. * Makes a clone, or deep copy, of the cube texture
  7654. * @returns a new cube texture
  7655. */
  7656. clone(): CubeTexture;
  7657. }
  7658. }
  7659. declare module "babylonjs/Materials/materialDefines" {
  7660. /**
  7661. * Manages the defines for the Material
  7662. */
  7663. export class MaterialDefines {
  7664. /** @hidden */
  7665. protected _keys: string[];
  7666. private _isDirty;
  7667. /** @hidden */
  7668. _renderId: number;
  7669. /** @hidden */
  7670. _areLightsDirty: boolean;
  7671. /** @hidden */
  7672. _areLightsDisposed: boolean;
  7673. /** @hidden */
  7674. _areAttributesDirty: boolean;
  7675. /** @hidden */
  7676. _areTexturesDirty: boolean;
  7677. /** @hidden */
  7678. _areFresnelDirty: boolean;
  7679. /** @hidden */
  7680. _areMiscDirty: boolean;
  7681. /** @hidden */
  7682. _areImageProcessingDirty: boolean;
  7683. /** @hidden */
  7684. _normals: boolean;
  7685. /** @hidden */
  7686. _uvs: boolean;
  7687. /** @hidden */
  7688. _needNormals: boolean;
  7689. /** @hidden */
  7690. _needUVs: boolean;
  7691. [id: string]: any;
  7692. /**
  7693. * Specifies if the material needs to be re-calculated
  7694. */
  7695. readonly isDirty: boolean;
  7696. /**
  7697. * Marks the material to indicate that it has been re-calculated
  7698. */
  7699. markAsProcessed(): void;
  7700. /**
  7701. * Marks the material to indicate that it needs to be re-calculated
  7702. */
  7703. markAsUnprocessed(): void;
  7704. /**
  7705. * Marks the material to indicate all of its defines need to be re-calculated
  7706. */
  7707. markAllAsDirty(): void;
  7708. /**
  7709. * Marks the material to indicate that image processing needs to be re-calculated
  7710. */
  7711. markAsImageProcessingDirty(): void;
  7712. /**
  7713. * Marks the material to indicate the lights need to be re-calculated
  7714. * @param disposed Defines whether the light is dirty due to dispose or not
  7715. */
  7716. markAsLightDirty(disposed?: boolean): void;
  7717. /**
  7718. * Marks the attribute state as changed
  7719. */
  7720. markAsAttributesDirty(): void;
  7721. /**
  7722. * Marks the texture state as changed
  7723. */
  7724. markAsTexturesDirty(): void;
  7725. /**
  7726. * Marks the fresnel state as changed
  7727. */
  7728. markAsFresnelDirty(): void;
  7729. /**
  7730. * Marks the misc state as changed
  7731. */
  7732. markAsMiscDirty(): void;
  7733. /**
  7734. * Rebuilds the material defines
  7735. */
  7736. rebuild(): void;
  7737. /**
  7738. * Specifies if two material defines are equal
  7739. * @param other - A material define instance to compare to
  7740. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7741. */
  7742. isEqual(other: MaterialDefines): boolean;
  7743. /**
  7744. * Clones this instance's defines to another instance
  7745. * @param other - material defines to clone values to
  7746. */
  7747. cloneTo(other: MaterialDefines): void;
  7748. /**
  7749. * Resets the material define values
  7750. */
  7751. reset(): void;
  7752. /**
  7753. * Converts the material define values to a string
  7754. * @returns - String of material define information
  7755. */
  7756. toString(): string;
  7757. }
  7758. }
  7759. declare module "babylonjs/Materials/colorCurves" {
  7760. import { Effect } from "babylonjs/Materials/effect";
  7761. /**
  7762. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7763. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7764. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7765. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7766. */
  7767. export class ColorCurves {
  7768. private _dirty;
  7769. private _tempColor;
  7770. private _globalCurve;
  7771. private _highlightsCurve;
  7772. private _midtonesCurve;
  7773. private _shadowsCurve;
  7774. private _positiveCurve;
  7775. private _negativeCurve;
  7776. private _globalHue;
  7777. private _globalDensity;
  7778. private _globalSaturation;
  7779. private _globalExposure;
  7780. /**
  7781. * Gets the global Hue value.
  7782. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7783. */
  7784. /**
  7785. * Sets the global Hue value.
  7786. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7787. */
  7788. globalHue: number;
  7789. /**
  7790. * Gets the global Density value.
  7791. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7792. * Values less than zero provide a filter of opposite hue.
  7793. */
  7794. /**
  7795. * Sets the global Density value.
  7796. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7797. * Values less than zero provide a filter of opposite hue.
  7798. */
  7799. globalDensity: number;
  7800. /**
  7801. * Gets the global Saturation value.
  7802. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7803. */
  7804. /**
  7805. * Sets the global Saturation value.
  7806. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7807. */
  7808. globalSaturation: number;
  7809. /**
  7810. * Gets the global Exposure value.
  7811. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7812. */
  7813. /**
  7814. * Sets the global Exposure value.
  7815. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7816. */
  7817. globalExposure: number;
  7818. private _highlightsHue;
  7819. private _highlightsDensity;
  7820. private _highlightsSaturation;
  7821. private _highlightsExposure;
  7822. /**
  7823. * Gets the highlights Hue value.
  7824. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7825. */
  7826. /**
  7827. * Sets the highlights Hue value.
  7828. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7829. */
  7830. highlightsHue: number;
  7831. /**
  7832. * Gets the highlights Density value.
  7833. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7834. * Values less than zero provide a filter of opposite hue.
  7835. */
  7836. /**
  7837. * Sets the highlights Density value.
  7838. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7839. * Values less than zero provide a filter of opposite hue.
  7840. */
  7841. highlightsDensity: number;
  7842. /**
  7843. * Gets the highlights Saturation value.
  7844. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7845. */
  7846. /**
  7847. * Sets the highlights Saturation value.
  7848. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7849. */
  7850. highlightsSaturation: number;
  7851. /**
  7852. * Gets the highlights Exposure value.
  7853. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7854. */
  7855. /**
  7856. * Sets the highlights Exposure value.
  7857. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7858. */
  7859. highlightsExposure: number;
  7860. private _midtonesHue;
  7861. private _midtonesDensity;
  7862. private _midtonesSaturation;
  7863. private _midtonesExposure;
  7864. /**
  7865. * Gets the midtones Hue value.
  7866. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7867. */
  7868. /**
  7869. * Sets the midtones Hue value.
  7870. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7871. */
  7872. midtonesHue: number;
  7873. /**
  7874. * Gets the midtones Density value.
  7875. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7876. * Values less than zero provide a filter of opposite hue.
  7877. */
  7878. /**
  7879. * Sets the midtones Density value.
  7880. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7881. * Values less than zero provide a filter of opposite hue.
  7882. */
  7883. midtonesDensity: number;
  7884. /**
  7885. * Gets the midtones Saturation value.
  7886. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7887. */
  7888. /**
  7889. * Sets the midtones Saturation value.
  7890. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7891. */
  7892. midtonesSaturation: number;
  7893. /**
  7894. * Gets the midtones Exposure value.
  7895. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7896. */
  7897. /**
  7898. * Sets the midtones Exposure value.
  7899. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7900. */
  7901. midtonesExposure: number;
  7902. private _shadowsHue;
  7903. private _shadowsDensity;
  7904. private _shadowsSaturation;
  7905. private _shadowsExposure;
  7906. /**
  7907. * Gets the shadows Hue value.
  7908. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7909. */
  7910. /**
  7911. * Sets the shadows Hue value.
  7912. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7913. */
  7914. shadowsHue: number;
  7915. /**
  7916. * Gets the shadows Density value.
  7917. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7918. * Values less than zero provide a filter of opposite hue.
  7919. */
  7920. /**
  7921. * Sets the shadows Density value.
  7922. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7923. * Values less than zero provide a filter of opposite hue.
  7924. */
  7925. shadowsDensity: number;
  7926. /**
  7927. * Gets the shadows Saturation value.
  7928. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7929. */
  7930. /**
  7931. * Sets the shadows Saturation value.
  7932. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7933. */
  7934. shadowsSaturation: number;
  7935. /**
  7936. * Gets the shadows Exposure value.
  7937. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7938. */
  7939. /**
  7940. * Sets the shadows Exposure value.
  7941. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7942. */
  7943. shadowsExposure: number;
  7944. /**
  7945. * Returns the class name
  7946. * @returns The class name
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Binds the color curves to the shader.
  7951. * @param colorCurves The color curve to bind
  7952. * @param effect The effect to bind to
  7953. * @param positiveUniform The positive uniform shader parameter
  7954. * @param neutralUniform The neutral uniform shader parameter
  7955. * @param negativeUniform The negative uniform shader parameter
  7956. */
  7957. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7958. /**
  7959. * Prepare the list of uniforms associated with the ColorCurves effects.
  7960. * @param uniformsList The list of uniforms used in the effect
  7961. */
  7962. static PrepareUniforms(uniformsList: string[]): void;
  7963. /**
  7964. * Returns color grading data based on a hue, density, saturation and exposure value.
  7965. * @param filterHue The hue of the color filter.
  7966. * @param filterDensity The density of the color filter.
  7967. * @param saturation The saturation.
  7968. * @param exposure The exposure.
  7969. * @param result The result data container.
  7970. */
  7971. private getColorGradingDataToRef;
  7972. /**
  7973. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7974. * @param value The input slider value in range [-100,100].
  7975. * @returns Adjusted value.
  7976. */
  7977. private static applyColorGradingSliderNonlinear;
  7978. /**
  7979. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7980. * @param hue The hue (H) input.
  7981. * @param saturation The saturation (S) input.
  7982. * @param brightness The brightness (B) input.
  7983. * @result An RGBA color represented as Vector4.
  7984. */
  7985. private static fromHSBToRef;
  7986. /**
  7987. * Returns a value clamped between min and max
  7988. * @param value The value to clamp
  7989. * @param min The minimum of value
  7990. * @param max The maximum of value
  7991. * @returns The clamped value.
  7992. */
  7993. private static clamp;
  7994. /**
  7995. * Clones the current color curve instance.
  7996. * @return The cloned curves
  7997. */
  7998. clone(): ColorCurves;
  7999. /**
  8000. * Serializes the current color curve instance to a json representation.
  8001. * @return a JSON representation
  8002. */
  8003. serialize(): any;
  8004. /**
  8005. * Parses the color curve from a json representation.
  8006. * @param source the JSON source to parse
  8007. * @return The parsed curves
  8008. */
  8009. static Parse(source: any): ColorCurves;
  8010. }
  8011. }
  8012. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8013. import { Observable } from "babylonjs/Misc/observable";
  8014. import { Nullable } from "babylonjs/types";
  8015. import { Color4 } from "babylonjs/Maths/math.color";
  8016. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8017. import { Effect } from "babylonjs/Materials/effect";
  8018. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8019. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8020. /**
  8021. * Interface to follow in your material defines to integrate easily the
  8022. * Image proccessing functions.
  8023. * @hidden
  8024. */
  8025. export interface IImageProcessingConfigurationDefines {
  8026. IMAGEPROCESSING: boolean;
  8027. VIGNETTE: boolean;
  8028. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8029. VIGNETTEBLENDMODEOPAQUE: boolean;
  8030. TONEMAPPING: boolean;
  8031. TONEMAPPING_ACES: boolean;
  8032. CONTRAST: boolean;
  8033. EXPOSURE: boolean;
  8034. COLORCURVES: boolean;
  8035. COLORGRADING: boolean;
  8036. COLORGRADING3D: boolean;
  8037. SAMPLER3DGREENDEPTH: boolean;
  8038. SAMPLER3DBGRMAP: boolean;
  8039. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8040. }
  8041. /**
  8042. * @hidden
  8043. */
  8044. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8045. IMAGEPROCESSING: boolean;
  8046. VIGNETTE: boolean;
  8047. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8048. VIGNETTEBLENDMODEOPAQUE: boolean;
  8049. TONEMAPPING: boolean;
  8050. TONEMAPPING_ACES: boolean;
  8051. CONTRAST: boolean;
  8052. COLORCURVES: boolean;
  8053. COLORGRADING: boolean;
  8054. COLORGRADING3D: boolean;
  8055. SAMPLER3DGREENDEPTH: boolean;
  8056. SAMPLER3DBGRMAP: boolean;
  8057. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8058. EXPOSURE: boolean;
  8059. constructor();
  8060. }
  8061. /**
  8062. * This groups together the common properties used for image processing either in direct forward pass
  8063. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8064. * or not.
  8065. */
  8066. export class ImageProcessingConfiguration {
  8067. /**
  8068. * Default tone mapping applied in BabylonJS.
  8069. */
  8070. static readonly TONEMAPPING_STANDARD: number;
  8071. /**
  8072. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8073. * to other engines rendering to increase portability.
  8074. */
  8075. static readonly TONEMAPPING_ACES: number;
  8076. /**
  8077. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8078. */
  8079. colorCurves: Nullable<ColorCurves>;
  8080. private _colorCurvesEnabled;
  8081. /**
  8082. * Gets wether the color curves effect is enabled.
  8083. */
  8084. /**
  8085. * Sets wether the color curves effect is enabled.
  8086. */
  8087. colorCurvesEnabled: boolean;
  8088. private _colorGradingTexture;
  8089. /**
  8090. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8091. */
  8092. /**
  8093. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8094. */
  8095. colorGradingTexture: Nullable<BaseTexture>;
  8096. private _colorGradingEnabled;
  8097. /**
  8098. * Gets wether the color grading effect is enabled.
  8099. */
  8100. /**
  8101. * Sets wether the color grading effect is enabled.
  8102. */
  8103. colorGradingEnabled: boolean;
  8104. private _colorGradingWithGreenDepth;
  8105. /**
  8106. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8107. */
  8108. /**
  8109. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8110. */
  8111. colorGradingWithGreenDepth: boolean;
  8112. private _colorGradingBGR;
  8113. /**
  8114. * Gets wether the color grading texture contains BGR values.
  8115. */
  8116. /**
  8117. * Sets wether the color grading texture contains BGR values.
  8118. */
  8119. colorGradingBGR: boolean;
  8120. /** @hidden */
  8121. _exposure: number;
  8122. /**
  8123. * Gets the Exposure used in the effect.
  8124. */
  8125. /**
  8126. * Sets the Exposure used in the effect.
  8127. */
  8128. exposure: number;
  8129. private _toneMappingEnabled;
  8130. /**
  8131. * Gets wether the tone mapping effect is enabled.
  8132. */
  8133. /**
  8134. * Sets wether the tone mapping effect is enabled.
  8135. */
  8136. toneMappingEnabled: boolean;
  8137. private _toneMappingType;
  8138. /**
  8139. * Gets the type of tone mapping effect.
  8140. */
  8141. /**
  8142. * Sets the type of tone mapping effect used in BabylonJS.
  8143. */
  8144. toneMappingType: number;
  8145. protected _contrast: number;
  8146. /**
  8147. * Gets the contrast used in the effect.
  8148. */
  8149. /**
  8150. * Sets the contrast used in the effect.
  8151. */
  8152. contrast: number;
  8153. /**
  8154. * Vignette stretch size.
  8155. */
  8156. vignetteStretch: number;
  8157. /**
  8158. * Vignette centre X Offset.
  8159. */
  8160. vignetteCentreX: number;
  8161. /**
  8162. * Vignette centre Y Offset.
  8163. */
  8164. vignetteCentreY: number;
  8165. /**
  8166. * Vignette weight or intensity of the vignette effect.
  8167. */
  8168. vignetteWeight: number;
  8169. /**
  8170. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8171. * if vignetteEnabled is set to true.
  8172. */
  8173. vignetteColor: Color4;
  8174. /**
  8175. * Camera field of view used by the Vignette effect.
  8176. */
  8177. vignetteCameraFov: number;
  8178. private _vignetteBlendMode;
  8179. /**
  8180. * Gets the vignette blend mode allowing different kind of effect.
  8181. */
  8182. /**
  8183. * Sets the vignette blend mode allowing different kind of effect.
  8184. */
  8185. vignetteBlendMode: number;
  8186. private _vignetteEnabled;
  8187. /**
  8188. * Gets wether the vignette effect is enabled.
  8189. */
  8190. /**
  8191. * Sets wether the vignette effect is enabled.
  8192. */
  8193. vignetteEnabled: boolean;
  8194. private _applyByPostProcess;
  8195. /**
  8196. * Gets wether the image processing is applied through a post process or not.
  8197. */
  8198. /**
  8199. * Sets wether the image processing is applied through a post process or not.
  8200. */
  8201. applyByPostProcess: boolean;
  8202. private _isEnabled;
  8203. /**
  8204. * Gets wether the image processing is enabled or not.
  8205. */
  8206. /**
  8207. * Sets wether the image processing is enabled or not.
  8208. */
  8209. isEnabled: boolean;
  8210. /**
  8211. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8212. */
  8213. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8214. /**
  8215. * Method called each time the image processing information changes requires to recompile the effect.
  8216. */
  8217. protected _updateParameters(): void;
  8218. /**
  8219. * Gets the current class name.
  8220. * @return "ImageProcessingConfiguration"
  8221. */
  8222. getClassName(): string;
  8223. /**
  8224. * Prepare the list of uniforms associated with the Image Processing effects.
  8225. * @param uniforms The list of uniforms used in the effect
  8226. * @param defines the list of defines currently in use
  8227. */
  8228. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8229. /**
  8230. * Prepare the list of samplers associated with the Image Processing effects.
  8231. * @param samplersList The list of uniforms used in the effect
  8232. * @param defines the list of defines currently in use
  8233. */
  8234. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8235. /**
  8236. * Prepare the list of defines associated to the shader.
  8237. * @param defines the list of defines to complete
  8238. * @param forPostProcess Define if we are currently in post process mode or not
  8239. */
  8240. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8241. /**
  8242. * Returns true if all the image processing information are ready.
  8243. * @returns True if ready, otherwise, false
  8244. */
  8245. isReady(): boolean;
  8246. /**
  8247. * Binds the image processing to the shader.
  8248. * @param effect The effect to bind to
  8249. * @param aspectRatio Define the current aspect ratio of the effect
  8250. */
  8251. bind(effect: Effect, aspectRatio?: number): void;
  8252. /**
  8253. * Clones the current image processing instance.
  8254. * @return The cloned image processing
  8255. */
  8256. clone(): ImageProcessingConfiguration;
  8257. /**
  8258. * Serializes the current image processing instance to a json representation.
  8259. * @return a JSON representation
  8260. */
  8261. serialize(): any;
  8262. /**
  8263. * Parses the image processing from a json representation.
  8264. * @param source the JSON source to parse
  8265. * @return The parsed image processing
  8266. */
  8267. static Parse(source: any): ImageProcessingConfiguration;
  8268. private static _VIGNETTEMODE_MULTIPLY;
  8269. private static _VIGNETTEMODE_OPAQUE;
  8270. /**
  8271. * Used to apply the vignette as a mix with the pixel color.
  8272. */
  8273. static readonly VIGNETTEMODE_MULTIPLY: number;
  8274. /**
  8275. * Used to apply the vignette as a replacement of the pixel color.
  8276. */
  8277. static readonly VIGNETTEMODE_OPAQUE: number;
  8278. }
  8279. }
  8280. declare module "babylonjs/Shaders/postprocess.vertex" {
  8281. /** @hidden */
  8282. export var postprocessVertexShader: {
  8283. name: string;
  8284. shader: string;
  8285. };
  8286. }
  8287. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8288. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8289. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8290. module "babylonjs/Engines/thinEngine" {
  8291. interface ThinEngine {
  8292. /**
  8293. * Creates a new render target texture
  8294. * @param size defines the size of the texture
  8295. * @param options defines the options used to create the texture
  8296. * @returns a new render target texture stored in an InternalTexture
  8297. */
  8298. createRenderTargetTexture(size: number | {
  8299. width: number;
  8300. height: number;
  8301. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8302. }
  8303. }
  8304. }
  8305. declare module "babylonjs/Maths/math.axis" {
  8306. import { Vector3 } from "babylonjs/Maths/math.vector";
  8307. /** Defines supported spaces */
  8308. export enum Space {
  8309. /** Local (object) space */
  8310. LOCAL = 0,
  8311. /** World space */
  8312. WORLD = 1,
  8313. /** Bone space */
  8314. BONE = 2
  8315. }
  8316. /** Defines the 3 main axes */
  8317. export class Axis {
  8318. /** X axis */
  8319. static X: Vector3;
  8320. /** Y axis */
  8321. static Y: Vector3;
  8322. /** Z axis */
  8323. static Z: Vector3;
  8324. }
  8325. }
  8326. declare module "babylonjs/Cameras/targetCamera" {
  8327. import { Nullable } from "babylonjs/types";
  8328. import { Camera } from "babylonjs/Cameras/camera";
  8329. import { Scene } from "babylonjs/scene";
  8330. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8331. /**
  8332. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8333. * This is the base of the follow, arc rotate cameras and Free camera
  8334. * @see http://doc.babylonjs.com/features/cameras
  8335. */
  8336. export class TargetCamera extends Camera {
  8337. private static _RigCamTransformMatrix;
  8338. private static _TargetTransformMatrix;
  8339. private static _TargetFocalPoint;
  8340. /**
  8341. * Define the current direction the camera is moving to
  8342. */
  8343. cameraDirection: Vector3;
  8344. /**
  8345. * Define the current rotation the camera is rotating to
  8346. */
  8347. cameraRotation: Vector2;
  8348. /**
  8349. * When set, the up vector of the camera will be updated by the rotation of the camera
  8350. */
  8351. updateUpVectorFromRotation: boolean;
  8352. private _tmpQuaternion;
  8353. /**
  8354. * Define the current rotation of the camera
  8355. */
  8356. rotation: Vector3;
  8357. /**
  8358. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8359. */
  8360. rotationQuaternion: Quaternion;
  8361. /**
  8362. * Define the current speed of the camera
  8363. */
  8364. speed: number;
  8365. /**
  8366. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8367. * around all axis.
  8368. */
  8369. noRotationConstraint: boolean;
  8370. /**
  8371. * Define the current target of the camera as an object or a position.
  8372. */
  8373. lockedTarget: any;
  8374. /** @hidden */
  8375. _currentTarget: Vector3;
  8376. /** @hidden */
  8377. _initialFocalDistance: number;
  8378. /** @hidden */
  8379. _viewMatrix: Matrix;
  8380. /** @hidden */
  8381. _camMatrix: Matrix;
  8382. /** @hidden */
  8383. _cameraTransformMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraRotationMatrix: Matrix;
  8386. /** @hidden */
  8387. _referencePoint: Vector3;
  8388. /** @hidden */
  8389. _transformedReferencePoint: Vector3;
  8390. protected _globalCurrentTarget: Vector3;
  8391. protected _globalCurrentUpVector: Vector3;
  8392. /** @hidden */
  8393. _reset: () => void;
  8394. private _defaultUp;
  8395. /**
  8396. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8397. * This is the base of the follow, arc rotate cameras and Free camera
  8398. * @see http://doc.babylonjs.com/features/cameras
  8399. * @param name Defines the name of the camera in the scene
  8400. * @param position Defines the start position of the camera in the scene
  8401. * @param scene Defines the scene the camera belongs to
  8402. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8403. */
  8404. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8405. /**
  8406. * Gets the position in front of the camera at a given distance.
  8407. * @param distance The distance from the camera we want the position to be
  8408. * @returns the position
  8409. */
  8410. getFrontPosition(distance: number): Vector3;
  8411. /** @hidden */
  8412. _getLockedTargetPosition(): Nullable<Vector3>;
  8413. private _storedPosition;
  8414. private _storedRotation;
  8415. private _storedRotationQuaternion;
  8416. /**
  8417. * Store current camera state of the camera (fov, position, rotation, etc..)
  8418. * @returns the camera
  8419. */
  8420. storeState(): Camera;
  8421. /**
  8422. * Restored camera state. You must call storeState() first
  8423. * @returns whether it was successful or not
  8424. * @hidden
  8425. */
  8426. _restoreStateValues(): boolean;
  8427. /** @hidden */
  8428. _initCache(): void;
  8429. /** @hidden */
  8430. _updateCache(ignoreParentClass?: boolean): void;
  8431. /** @hidden */
  8432. _isSynchronizedViewMatrix(): boolean;
  8433. /** @hidden */
  8434. _computeLocalCameraSpeed(): number;
  8435. /**
  8436. * Defines the target the camera should look at.
  8437. * @param target Defines the new target as a Vector or a mesh
  8438. */
  8439. setTarget(target: Vector3): void;
  8440. /**
  8441. * Return the current target position of the camera. This value is expressed in local space.
  8442. * @returns the target position
  8443. */
  8444. getTarget(): Vector3;
  8445. /** @hidden */
  8446. _decideIfNeedsToMove(): boolean;
  8447. /** @hidden */
  8448. _updatePosition(): void;
  8449. /** @hidden */
  8450. _checkInputs(): void;
  8451. protected _updateCameraRotationMatrix(): void;
  8452. /**
  8453. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8454. * @returns the current camera
  8455. */
  8456. private _rotateUpVectorWithCameraRotationMatrix;
  8457. private _cachedRotationZ;
  8458. private _cachedQuaternionRotationZ;
  8459. /** @hidden */
  8460. _getViewMatrix(): Matrix;
  8461. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8462. /**
  8463. * @hidden
  8464. */
  8465. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8466. /**
  8467. * @hidden
  8468. */
  8469. _updateRigCameras(): void;
  8470. private _getRigCamPositionAndTarget;
  8471. /**
  8472. * Gets the current object class name.
  8473. * @return the class name
  8474. */
  8475. getClassName(): string;
  8476. }
  8477. }
  8478. declare module "babylonjs/Events/keyboardEvents" {
  8479. /**
  8480. * Gather the list of keyboard event types as constants.
  8481. */
  8482. export class KeyboardEventTypes {
  8483. /**
  8484. * The keydown event is fired when a key becomes active (pressed).
  8485. */
  8486. static readonly KEYDOWN: number;
  8487. /**
  8488. * The keyup event is fired when a key has been released.
  8489. */
  8490. static readonly KEYUP: number;
  8491. }
  8492. /**
  8493. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8494. */
  8495. export class KeyboardInfo {
  8496. /**
  8497. * Defines the type of event (KeyboardEventTypes)
  8498. */
  8499. type: number;
  8500. /**
  8501. * Defines the related dom event
  8502. */
  8503. event: KeyboardEvent;
  8504. /**
  8505. * Instantiates a new keyboard info.
  8506. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8507. * @param type Defines the type of event (KeyboardEventTypes)
  8508. * @param event Defines the related dom event
  8509. */
  8510. constructor(
  8511. /**
  8512. * Defines the type of event (KeyboardEventTypes)
  8513. */
  8514. type: number,
  8515. /**
  8516. * Defines the related dom event
  8517. */
  8518. event: KeyboardEvent);
  8519. }
  8520. /**
  8521. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8522. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8523. */
  8524. export class KeyboardInfoPre extends KeyboardInfo {
  8525. /**
  8526. * Defines the type of event (KeyboardEventTypes)
  8527. */
  8528. type: number;
  8529. /**
  8530. * Defines the related dom event
  8531. */
  8532. event: KeyboardEvent;
  8533. /**
  8534. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8535. */
  8536. skipOnPointerObservable: boolean;
  8537. /**
  8538. * Instantiates a new keyboard pre info.
  8539. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8540. * @param type Defines the type of event (KeyboardEventTypes)
  8541. * @param event Defines the related dom event
  8542. */
  8543. constructor(
  8544. /**
  8545. * Defines the type of event (KeyboardEventTypes)
  8546. */
  8547. type: number,
  8548. /**
  8549. * Defines the related dom event
  8550. */
  8551. event: KeyboardEvent);
  8552. }
  8553. }
  8554. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8555. import { Nullable } from "babylonjs/types";
  8556. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8557. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8558. /**
  8559. * Manage the keyboard inputs to control the movement of a free camera.
  8560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8561. */
  8562. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8563. /**
  8564. * Defines the camera the input is attached to.
  8565. */
  8566. camera: FreeCamera;
  8567. /**
  8568. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8569. */
  8570. keysUp: number[];
  8571. /**
  8572. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8573. */
  8574. keysDown: number[];
  8575. /**
  8576. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8577. */
  8578. keysLeft: number[];
  8579. /**
  8580. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8581. */
  8582. keysRight: number[];
  8583. private _keys;
  8584. private _onCanvasBlurObserver;
  8585. private _onKeyboardObserver;
  8586. private _engine;
  8587. private _scene;
  8588. /**
  8589. * Attach the input controls to a specific dom element to get the input from.
  8590. * @param element Defines the element the controls should be listened from
  8591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8592. */
  8593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8594. /**
  8595. * Detach the current controls from the specified dom element.
  8596. * @param element Defines the element to stop listening the inputs from
  8597. */
  8598. detachControl(element: Nullable<HTMLElement>): void;
  8599. /**
  8600. * Update the current camera state depending on the inputs that have been used this frame.
  8601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8602. */
  8603. checkInputs(): void;
  8604. /**
  8605. * Gets the class name of the current intput.
  8606. * @returns the class name
  8607. */
  8608. getClassName(): string;
  8609. /** @hidden */
  8610. _onLostFocus(): void;
  8611. /**
  8612. * Get the friendly name associated with the input class.
  8613. * @returns the input friendly name
  8614. */
  8615. getSimpleName(): string;
  8616. }
  8617. }
  8618. declare module "babylonjs/Lights/shadowLight" {
  8619. import { Camera } from "babylonjs/Cameras/camera";
  8620. import { Scene } from "babylonjs/scene";
  8621. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8623. import { Light } from "babylonjs/Lights/light";
  8624. /**
  8625. * Interface describing all the common properties and methods a shadow light needs to implement.
  8626. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8627. * as well as binding the different shadow properties to the effects.
  8628. */
  8629. export interface IShadowLight extends Light {
  8630. /**
  8631. * The light id in the scene (used in scene.findLighById for instance)
  8632. */
  8633. id: string;
  8634. /**
  8635. * The position the shdow will be casted from.
  8636. */
  8637. position: Vector3;
  8638. /**
  8639. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8640. */
  8641. direction: Vector3;
  8642. /**
  8643. * The transformed position. Position of the light in world space taking parenting in account.
  8644. */
  8645. transformedPosition: Vector3;
  8646. /**
  8647. * The transformed direction. Direction of the light in world space taking parenting in account.
  8648. */
  8649. transformedDirection: Vector3;
  8650. /**
  8651. * The friendly name of the light in the scene.
  8652. */
  8653. name: string;
  8654. /**
  8655. * Defines the shadow projection clipping minimum z value.
  8656. */
  8657. shadowMinZ: number;
  8658. /**
  8659. * Defines the shadow projection clipping maximum z value.
  8660. */
  8661. shadowMaxZ: number;
  8662. /**
  8663. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8664. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8665. */
  8666. computeTransformedInformation(): boolean;
  8667. /**
  8668. * Gets the scene the light belongs to.
  8669. * @returns The scene
  8670. */
  8671. getScene(): Scene;
  8672. /**
  8673. * Callback defining a custom Projection Matrix Builder.
  8674. * This can be used to override the default projection matrix computation.
  8675. */
  8676. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8677. /**
  8678. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8679. * @param matrix The materix to updated with the projection information
  8680. * @param viewMatrix The transform matrix of the light
  8681. * @param renderList The list of mesh to render in the map
  8682. * @returns The current light
  8683. */
  8684. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8685. /**
  8686. * Gets the current depth scale used in ESM.
  8687. * @returns The scale
  8688. */
  8689. getDepthScale(): number;
  8690. /**
  8691. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8692. * @returns true if a cube texture needs to be use
  8693. */
  8694. needCube(): boolean;
  8695. /**
  8696. * Detects if the projection matrix requires to be recomputed this frame.
  8697. * @returns true if it requires to be recomputed otherwise, false.
  8698. */
  8699. needProjectionMatrixCompute(): boolean;
  8700. /**
  8701. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8702. */
  8703. forceProjectionMatrixCompute(): void;
  8704. /**
  8705. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8706. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8707. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8708. */
  8709. getShadowDirection(faceIndex?: number): Vector3;
  8710. /**
  8711. * Gets the minZ used for shadow according to both the scene and the light.
  8712. * @param activeCamera The camera we are returning the min for
  8713. * @returns the depth min z
  8714. */
  8715. getDepthMinZ(activeCamera: Camera): number;
  8716. /**
  8717. * Gets the maxZ used for shadow according to both the scene and the light.
  8718. * @param activeCamera The camera we are returning the max for
  8719. * @returns the depth max z
  8720. */
  8721. getDepthMaxZ(activeCamera: Camera): number;
  8722. }
  8723. /**
  8724. * Base implementation IShadowLight
  8725. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8726. */
  8727. export abstract class ShadowLight extends Light implements IShadowLight {
  8728. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8729. protected _position: Vector3;
  8730. protected _setPosition(value: Vector3): void;
  8731. /**
  8732. * Sets the position the shadow will be casted from. Also use as the light position for both
  8733. * point and spot lights.
  8734. */
  8735. /**
  8736. * Sets the position the shadow will be casted from. Also use as the light position for both
  8737. * point and spot lights.
  8738. */
  8739. position: Vector3;
  8740. protected _direction: Vector3;
  8741. protected _setDirection(value: Vector3): void;
  8742. /**
  8743. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8744. * Also use as the light direction on spot and directional lights.
  8745. */
  8746. /**
  8747. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8748. * Also use as the light direction on spot and directional lights.
  8749. */
  8750. direction: Vector3;
  8751. private _shadowMinZ;
  8752. /**
  8753. * Gets the shadow projection clipping minimum z value.
  8754. */
  8755. /**
  8756. * Sets the shadow projection clipping minimum z value.
  8757. */
  8758. shadowMinZ: number;
  8759. private _shadowMaxZ;
  8760. /**
  8761. * Sets the shadow projection clipping maximum z value.
  8762. */
  8763. /**
  8764. * Gets the shadow projection clipping maximum z value.
  8765. */
  8766. shadowMaxZ: number;
  8767. /**
  8768. * Callback defining a custom Projection Matrix Builder.
  8769. * This can be used to override the default projection matrix computation.
  8770. */
  8771. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8772. /**
  8773. * The transformed position. Position of the light in world space taking parenting in account.
  8774. */
  8775. transformedPosition: Vector3;
  8776. /**
  8777. * The transformed direction. Direction of the light in world space taking parenting in account.
  8778. */
  8779. transformedDirection: Vector3;
  8780. private _needProjectionMatrixCompute;
  8781. /**
  8782. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8783. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8784. */
  8785. computeTransformedInformation(): boolean;
  8786. /**
  8787. * Return the depth scale used for the shadow map.
  8788. * @returns the depth scale.
  8789. */
  8790. getDepthScale(): number;
  8791. /**
  8792. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8793. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8794. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8795. */
  8796. getShadowDirection(faceIndex?: number): Vector3;
  8797. /**
  8798. * Returns the ShadowLight absolute position in the World.
  8799. * @returns the position vector in world space
  8800. */
  8801. getAbsolutePosition(): Vector3;
  8802. /**
  8803. * Sets the ShadowLight direction toward the passed target.
  8804. * @param target The point to target in local space
  8805. * @returns the updated ShadowLight direction
  8806. */
  8807. setDirectionToTarget(target: Vector3): Vector3;
  8808. /**
  8809. * Returns the light rotation in euler definition.
  8810. * @returns the x y z rotation in local space.
  8811. */
  8812. getRotation(): Vector3;
  8813. /**
  8814. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8815. * @returns true if a cube texture needs to be use
  8816. */
  8817. needCube(): boolean;
  8818. /**
  8819. * Detects if the projection matrix requires to be recomputed this frame.
  8820. * @returns true if it requires to be recomputed otherwise, false.
  8821. */
  8822. needProjectionMatrixCompute(): boolean;
  8823. /**
  8824. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8825. */
  8826. forceProjectionMatrixCompute(): void;
  8827. /** @hidden */
  8828. _initCache(): void;
  8829. /** @hidden */
  8830. _isSynchronized(): boolean;
  8831. /**
  8832. * Computes the world matrix of the node
  8833. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8834. * @returns the world matrix
  8835. */
  8836. computeWorldMatrix(force?: boolean): Matrix;
  8837. /**
  8838. * Gets the minZ used for shadow according to both the scene and the light.
  8839. * @param activeCamera The camera we are returning the min for
  8840. * @returns the depth min z
  8841. */
  8842. getDepthMinZ(activeCamera: Camera): number;
  8843. /**
  8844. * Gets the maxZ used for shadow according to both the scene and the light.
  8845. * @param activeCamera The camera we are returning the max for
  8846. * @returns the depth max z
  8847. */
  8848. getDepthMaxZ(activeCamera: Camera): number;
  8849. /**
  8850. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8851. * @param matrix The materix to updated with the projection information
  8852. * @param viewMatrix The transform matrix of the light
  8853. * @param renderList The list of mesh to render in the map
  8854. * @returns The current light
  8855. */
  8856. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8857. }
  8858. }
  8859. declare module "babylonjs/Materials/effectFallbacks" {
  8860. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8861. import { Effect } from "babylonjs/Materials/effect";
  8862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8863. /**
  8864. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8865. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8866. */
  8867. export class EffectFallbacks implements IEffectFallbacks {
  8868. private _defines;
  8869. private _currentRank;
  8870. private _maxRank;
  8871. private _mesh;
  8872. /**
  8873. * Removes the fallback from the bound mesh.
  8874. */
  8875. unBindMesh(): void;
  8876. /**
  8877. * Adds a fallback on the specified property.
  8878. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8879. * @param define The name of the define in the shader
  8880. */
  8881. addFallback(rank: number, define: string): void;
  8882. /**
  8883. * Sets the mesh to use CPU skinning when needing to fallback.
  8884. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8885. * @param mesh The mesh to use the fallbacks.
  8886. */
  8887. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8888. /**
  8889. * Checks to see if more fallbacks are still availible.
  8890. */
  8891. readonly hasMoreFallbacks: boolean;
  8892. /**
  8893. * Removes the defines that should be removed when falling back.
  8894. * @param currentDefines defines the current define statements for the shader.
  8895. * @param effect defines the current effect we try to compile
  8896. * @returns The resulting defines with defines of the current rank removed.
  8897. */
  8898. reduce(currentDefines: string, effect: Effect): string;
  8899. }
  8900. }
  8901. declare module "babylonjs/Materials/materialHelper" {
  8902. import { Nullable } from "babylonjs/types";
  8903. import { Scene } from "babylonjs/scene";
  8904. import { Engine } from "babylonjs/Engines/engine";
  8905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8906. import { Light } from "babylonjs/Lights/light";
  8907. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8908. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8909. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8910. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8911. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8912. /**
  8913. * "Static Class" containing the most commonly used helper while dealing with material for
  8914. * rendering purpose.
  8915. *
  8916. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8917. *
  8918. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8919. */
  8920. export class MaterialHelper {
  8921. /**
  8922. * Bind the current view position to an effect.
  8923. * @param effect The effect to be bound
  8924. * @param scene The scene the eyes position is used from
  8925. */
  8926. static BindEyePosition(effect: Effect, scene: Scene): void;
  8927. /**
  8928. * Helps preparing the defines values about the UVs in used in the effect.
  8929. * UVs are shared as much as we can accross channels in the shaders.
  8930. * @param texture The texture we are preparing the UVs for
  8931. * @param defines The defines to update
  8932. * @param key The channel key "diffuse", "specular"... used in the shader
  8933. */
  8934. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8935. /**
  8936. * Binds a texture matrix value to its corrsponding uniform
  8937. * @param texture The texture to bind the matrix for
  8938. * @param uniformBuffer The uniform buffer receivin the data
  8939. * @param key The channel key "diffuse", "specular"... used in the shader
  8940. */
  8941. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8942. /**
  8943. * Gets the current status of the fog (should it be enabled?)
  8944. * @param mesh defines the mesh to evaluate for fog support
  8945. * @param scene defines the hosting scene
  8946. * @returns true if fog must be enabled
  8947. */
  8948. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8949. /**
  8950. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8951. * @param mesh defines the current mesh
  8952. * @param scene defines the current scene
  8953. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8954. * @param pointsCloud defines if point cloud rendering has to be turned on
  8955. * @param fogEnabled defines if fog has to be turned on
  8956. * @param alphaTest defines if alpha testing has to be turned on
  8957. * @param defines defines the current list of defines
  8958. */
  8959. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8960. /**
  8961. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8962. * @param scene defines the current scene
  8963. * @param engine defines the current engine
  8964. * @param defines specifies the list of active defines
  8965. * @param useInstances defines if instances have to be turned on
  8966. * @param useClipPlane defines if clip plane have to be turned on
  8967. */
  8968. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8969. /**
  8970. * Prepares the defines for bones
  8971. * @param mesh The mesh containing the geometry data we will draw
  8972. * @param defines The defines to update
  8973. */
  8974. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8975. /**
  8976. * Prepares the defines for morph targets
  8977. * @param mesh The mesh containing the geometry data we will draw
  8978. * @param defines The defines to update
  8979. */
  8980. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8981. /**
  8982. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8983. * @param mesh The mesh containing the geometry data we will draw
  8984. * @param defines The defines to update
  8985. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8986. * @param useBones Precise whether bones should be used or not (override mesh info)
  8987. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8988. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8989. * @returns false if defines are considered not dirty and have not been checked
  8990. */
  8991. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8992. /**
  8993. * Prepares the defines related to multiview
  8994. * @param scene The scene we are intending to draw
  8995. * @param defines The defines to update
  8996. */
  8997. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8998. /**
  8999. * Prepares the defines related to the light information passed in parameter
  9000. * @param scene The scene we are intending to draw
  9001. * @param mesh The mesh the effect is compiling for
  9002. * @param light The light the effect is compiling for
  9003. * @param lightIndex The index of the light
  9004. * @param defines The defines to update
  9005. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9006. * @param state Defines the current state regarding what is needed (normals, etc...)
  9007. */
  9008. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9009. needNormals: boolean;
  9010. needRebuild: boolean;
  9011. shadowEnabled: boolean;
  9012. specularEnabled: boolean;
  9013. lightmapMode: boolean;
  9014. }): void;
  9015. /**
  9016. * Prepares the defines related to the light information passed in parameter
  9017. * @param scene The scene we are intending to draw
  9018. * @param mesh The mesh the effect is compiling for
  9019. * @param defines The defines to update
  9020. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9021. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9022. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9023. * @returns true if normals will be required for the rest of the effect
  9024. */
  9025. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9026. /**
  9027. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9028. * @param lightIndex defines the light index
  9029. * @param uniformsList The uniform list
  9030. * @param samplersList The sampler list
  9031. * @param projectedLightTexture defines if projected texture must be used
  9032. * @param uniformBuffersList defines an optional list of uniform buffers
  9033. */
  9034. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9035. /**
  9036. * Prepares the uniforms and samplers list to be used in the effect
  9037. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9038. * @param samplersList The sampler list
  9039. * @param defines The defines helping in the list generation
  9040. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9041. */
  9042. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9043. /**
  9044. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9045. * @param defines The defines to update while falling back
  9046. * @param fallbacks The authorized effect fallbacks
  9047. * @param maxSimultaneousLights The maximum number of lights allowed
  9048. * @param rank the current rank of the Effect
  9049. * @returns The newly affected rank
  9050. */
  9051. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9052. private static _TmpMorphInfluencers;
  9053. /**
  9054. * Prepares the list of attributes required for morph targets according to the effect defines.
  9055. * @param attribs The current list of supported attribs
  9056. * @param mesh The mesh to prepare the morph targets attributes for
  9057. * @param influencers The number of influencers
  9058. */
  9059. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9060. /**
  9061. * Prepares the list of attributes required for morph targets according to the effect defines.
  9062. * @param attribs The current list of supported attribs
  9063. * @param mesh The mesh to prepare the morph targets attributes for
  9064. * @param defines The current Defines of the effect
  9065. */
  9066. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9067. /**
  9068. * Prepares the list of attributes required for bones according to the effect defines.
  9069. * @param attribs The current list of supported attribs
  9070. * @param mesh The mesh to prepare the bones attributes for
  9071. * @param defines The current Defines of the effect
  9072. * @param fallbacks The current efffect fallback strategy
  9073. */
  9074. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9075. /**
  9076. * Check and prepare the list of attributes required for instances according to the effect defines.
  9077. * @param attribs The current list of supported attribs
  9078. * @param defines The current MaterialDefines of the effect
  9079. */
  9080. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9081. /**
  9082. * Add the list of attributes required for instances to the attribs array.
  9083. * @param attribs The current list of supported attribs
  9084. */
  9085. static PushAttributesForInstances(attribs: string[]): void;
  9086. /**
  9087. * Binds the light shadow information to the effect for the given mesh.
  9088. * @param light The light containing the generator
  9089. * @param scene The scene the lights belongs to
  9090. * @param mesh The mesh we are binding the information to render
  9091. * @param lightIndex The light index in the effect used to render the mesh
  9092. * @param effect The effect we are binding the data to
  9093. */
  9094. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9095. /**
  9096. * Binds the light information to the effect.
  9097. * @param light The light containing the generator
  9098. * @param effect The effect we are binding the data to
  9099. * @param lightIndex The light index in the effect used to render
  9100. */
  9101. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9102. /**
  9103. * Binds the lights information from the scene to the effect for the given mesh.
  9104. * @param light Light to bind
  9105. * @param lightIndex Light index
  9106. * @param scene The scene where the light belongs to
  9107. * @param mesh The mesh we are binding the information to render
  9108. * @param effect The effect we are binding the data to
  9109. * @param useSpecular Defines if specular is supported
  9110. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9111. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9112. */
  9113. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9114. /**
  9115. * Binds the lights information from the scene to the effect for the given mesh.
  9116. * @param scene The scene the lights belongs to
  9117. * @param mesh The mesh we are binding the information to render
  9118. * @param effect The effect we are binding the data to
  9119. * @param defines The generated defines for the effect
  9120. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9121. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9122. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9123. */
  9124. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9125. private static _tempFogColor;
  9126. /**
  9127. * Binds the fog information from the scene to the effect for the given mesh.
  9128. * @param scene The scene the lights belongs to
  9129. * @param mesh The mesh we are binding the information to render
  9130. * @param effect The effect we are binding the data to
  9131. * @param linearSpace Defines if the fog effect is applied in linear space
  9132. */
  9133. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9134. /**
  9135. * Binds the bones information from the mesh to the effect.
  9136. * @param mesh The mesh we are binding the information to render
  9137. * @param effect The effect we are binding the data to
  9138. */
  9139. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9140. /**
  9141. * Binds the morph targets information from the mesh to the effect.
  9142. * @param abstractMesh The mesh we are binding the information to render
  9143. * @param effect The effect we are binding the data to
  9144. */
  9145. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9146. /**
  9147. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9148. * @param defines The generated defines used in the effect
  9149. * @param effect The effect we are binding the data to
  9150. * @param scene The scene we are willing to render with logarithmic scale for
  9151. */
  9152. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9153. /**
  9154. * Binds the clip plane information from the scene to the effect.
  9155. * @param scene The scene the clip plane information are extracted from
  9156. * @param effect The effect we are binding the data to
  9157. */
  9158. static BindClipPlane(effect: Effect, scene: Scene): void;
  9159. }
  9160. }
  9161. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9162. /** @hidden */
  9163. export var packingFunctions: {
  9164. name: string;
  9165. shader: string;
  9166. };
  9167. }
  9168. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9169. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9170. /** @hidden */
  9171. export var shadowMapPixelShader: {
  9172. name: string;
  9173. shader: string;
  9174. };
  9175. }
  9176. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9177. /** @hidden */
  9178. export var bonesDeclaration: {
  9179. name: string;
  9180. shader: string;
  9181. };
  9182. }
  9183. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9184. /** @hidden */
  9185. export var morphTargetsVertexGlobalDeclaration: {
  9186. name: string;
  9187. shader: string;
  9188. };
  9189. }
  9190. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9191. /** @hidden */
  9192. export var morphTargetsVertexDeclaration: {
  9193. name: string;
  9194. shader: string;
  9195. };
  9196. }
  9197. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9198. /** @hidden */
  9199. export var instancesDeclaration: {
  9200. name: string;
  9201. shader: string;
  9202. };
  9203. }
  9204. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9205. /** @hidden */
  9206. export var helperFunctions: {
  9207. name: string;
  9208. shader: string;
  9209. };
  9210. }
  9211. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9212. /** @hidden */
  9213. export var morphTargetsVertex: {
  9214. name: string;
  9215. shader: string;
  9216. };
  9217. }
  9218. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9219. /** @hidden */
  9220. export var instancesVertex: {
  9221. name: string;
  9222. shader: string;
  9223. };
  9224. }
  9225. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9226. /** @hidden */
  9227. export var bonesVertex: {
  9228. name: string;
  9229. shader: string;
  9230. };
  9231. }
  9232. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9234. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9235. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9238. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9239. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9240. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9241. /** @hidden */
  9242. export var shadowMapVertexShader: {
  9243. name: string;
  9244. shader: string;
  9245. };
  9246. }
  9247. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9248. /** @hidden */
  9249. export var depthBoxBlurPixelShader: {
  9250. name: string;
  9251. shader: string;
  9252. };
  9253. }
  9254. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9255. import { Nullable } from "babylonjs/types";
  9256. import { Scene } from "babylonjs/scene";
  9257. import { Matrix } from "babylonjs/Maths/math.vector";
  9258. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9260. import { Mesh } from "babylonjs/Meshes/mesh";
  9261. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9262. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9263. import { Effect } from "babylonjs/Materials/effect";
  9264. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9265. import "babylonjs/Shaders/shadowMap.fragment";
  9266. import "babylonjs/Shaders/shadowMap.vertex";
  9267. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9268. import { Observable } from "babylonjs/Misc/observable";
  9269. /**
  9270. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9271. */
  9272. export interface ICustomShaderOptions {
  9273. /**
  9274. * Gets or sets the custom shader name to use
  9275. */
  9276. shaderName: string;
  9277. /**
  9278. * The list of attribute names used in the shader
  9279. */
  9280. attributes?: string[];
  9281. /**
  9282. * The list of unifrom names used in the shader
  9283. */
  9284. uniforms?: string[];
  9285. /**
  9286. * The list of sampler names used in the shader
  9287. */
  9288. samplers?: string[];
  9289. /**
  9290. * The list of defines used in the shader
  9291. */
  9292. defines?: string[];
  9293. }
  9294. /**
  9295. * Interface to implement to create a shadow generator compatible with BJS.
  9296. */
  9297. export interface IShadowGenerator {
  9298. /**
  9299. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9300. * @returns The render target texture if present otherwise, null
  9301. */
  9302. getShadowMap(): Nullable<RenderTargetTexture>;
  9303. /**
  9304. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9305. * @returns The render target texture if the shadow map is present otherwise, null
  9306. */
  9307. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9308. /**
  9309. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9310. * @param subMesh The submesh we want to render in the shadow map
  9311. * @param useInstances Defines wether will draw in the map using instances
  9312. * @returns true if ready otherwise, false
  9313. */
  9314. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9315. /**
  9316. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9317. * @param defines Defines of the material we want to update
  9318. * @param lightIndex Index of the light in the enabled light list of the material
  9319. */
  9320. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9321. /**
  9322. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9323. * defined in the generator but impacting the effect).
  9324. * It implies the unifroms available on the materials are the standard BJS ones.
  9325. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9326. * @param effect The effect we are binfing the information for
  9327. */
  9328. bindShadowLight(lightIndex: string, effect: Effect): void;
  9329. /**
  9330. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9331. * (eq to shadow prjection matrix * light transform matrix)
  9332. * @returns The transform matrix used to create the shadow map
  9333. */
  9334. getTransformMatrix(): Matrix;
  9335. /**
  9336. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9337. * Cube and 2D textures for instance.
  9338. */
  9339. recreateShadowMap(): void;
  9340. /**
  9341. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9342. * @param onCompiled Callback triggered at the and of the effects compilation
  9343. * @param options Sets of optional options forcing the compilation with different modes
  9344. */
  9345. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9346. useInstances: boolean;
  9347. }>): void;
  9348. /**
  9349. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9350. * @param options Sets of optional options forcing the compilation with different modes
  9351. * @returns A promise that resolves when the compilation completes
  9352. */
  9353. forceCompilationAsync(options?: Partial<{
  9354. useInstances: boolean;
  9355. }>): Promise<void>;
  9356. /**
  9357. * Serializes the shadow generator setup to a json object.
  9358. * @returns The serialized JSON object
  9359. */
  9360. serialize(): any;
  9361. /**
  9362. * Disposes the Shadow map and related Textures and effects.
  9363. */
  9364. dispose(): void;
  9365. }
  9366. /**
  9367. * Default implementation IShadowGenerator.
  9368. * This is the main object responsible of generating shadows in the framework.
  9369. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9370. */
  9371. export class ShadowGenerator implements IShadowGenerator {
  9372. /**
  9373. * Shadow generator mode None: no filtering applied.
  9374. */
  9375. static readonly FILTER_NONE: number;
  9376. /**
  9377. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9378. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9379. */
  9380. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9381. /**
  9382. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9383. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9384. */
  9385. static readonly FILTER_POISSONSAMPLING: number;
  9386. /**
  9387. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9388. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9389. */
  9390. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9391. /**
  9392. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9393. * edge artifacts on steep falloff.
  9394. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9395. */
  9396. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9397. /**
  9398. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9399. * edge artifacts on steep falloff.
  9400. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9401. */
  9402. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9403. /**
  9404. * Shadow generator mode PCF: Percentage Closer Filtering
  9405. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9406. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9407. */
  9408. static readonly FILTER_PCF: number;
  9409. /**
  9410. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9411. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9412. * Contact Hardening
  9413. */
  9414. static readonly FILTER_PCSS: number;
  9415. /**
  9416. * Reserved for PCF and PCSS
  9417. * Highest Quality.
  9418. *
  9419. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9420. *
  9421. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9422. */
  9423. static readonly QUALITY_HIGH: number;
  9424. /**
  9425. * Reserved for PCF and PCSS
  9426. * Good tradeoff for quality/perf cross devices
  9427. *
  9428. * Execute PCF on a 3*3 kernel.
  9429. *
  9430. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9431. */
  9432. static readonly QUALITY_MEDIUM: number;
  9433. /**
  9434. * Reserved for PCF and PCSS
  9435. * The lowest quality but the fastest.
  9436. *
  9437. * Execute PCF on a 1*1 kernel.
  9438. *
  9439. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9440. */
  9441. static readonly QUALITY_LOW: number;
  9442. /** Gets or sets the custom shader name to use */
  9443. customShaderOptions: ICustomShaderOptions;
  9444. /**
  9445. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9446. */
  9447. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9448. /**
  9449. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9450. */
  9451. onAfterShadowMapRenderObservable: Observable<Effect>;
  9452. /**
  9453. * Observable triggered before a mesh is rendered in the shadow map.
  9454. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9455. */
  9456. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9457. /**
  9458. * Observable triggered after a mesh is rendered in the shadow map.
  9459. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9460. */
  9461. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9462. private _bias;
  9463. /**
  9464. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9465. */
  9466. /**
  9467. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9468. */
  9469. bias: number;
  9470. private _normalBias;
  9471. /**
  9472. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9473. */
  9474. /**
  9475. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9476. */
  9477. normalBias: number;
  9478. private _blurBoxOffset;
  9479. /**
  9480. * Gets the blur box offset: offset applied during the blur pass.
  9481. * Only useful if useKernelBlur = false
  9482. */
  9483. /**
  9484. * Sets the blur box offset: offset applied during the blur pass.
  9485. * Only useful if useKernelBlur = false
  9486. */
  9487. blurBoxOffset: number;
  9488. private _blurScale;
  9489. /**
  9490. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9491. * 2 means half of the size.
  9492. */
  9493. /**
  9494. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9495. * 2 means half of the size.
  9496. */
  9497. blurScale: number;
  9498. private _blurKernel;
  9499. /**
  9500. * Gets the blur kernel: kernel size of the blur pass.
  9501. * Only useful if useKernelBlur = true
  9502. */
  9503. /**
  9504. * Sets the blur kernel: kernel size of the blur pass.
  9505. * Only useful if useKernelBlur = true
  9506. */
  9507. blurKernel: number;
  9508. private _useKernelBlur;
  9509. /**
  9510. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9511. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9512. */
  9513. /**
  9514. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9515. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9516. */
  9517. useKernelBlur: boolean;
  9518. private _depthScale;
  9519. /**
  9520. * Gets the depth scale used in ESM mode.
  9521. */
  9522. /**
  9523. * Sets the depth scale used in ESM mode.
  9524. * This can override the scale stored on the light.
  9525. */
  9526. depthScale: number;
  9527. private _filter;
  9528. /**
  9529. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9530. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9531. */
  9532. /**
  9533. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9534. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9535. */
  9536. filter: number;
  9537. /**
  9538. * Gets if the current filter is set to Poisson Sampling.
  9539. */
  9540. /**
  9541. * Sets the current filter to Poisson Sampling.
  9542. */
  9543. usePoissonSampling: boolean;
  9544. /**
  9545. * Gets if the current filter is set to ESM.
  9546. */
  9547. /**
  9548. * Sets the current filter is to ESM.
  9549. */
  9550. useExponentialShadowMap: boolean;
  9551. /**
  9552. * Gets if the current filter is set to filtered ESM.
  9553. */
  9554. /**
  9555. * Gets if the current filter is set to filtered ESM.
  9556. */
  9557. useBlurExponentialShadowMap: boolean;
  9558. /**
  9559. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9560. * exponential to prevent steep falloff artifacts).
  9561. */
  9562. /**
  9563. * Sets the current filter to "close ESM" (using the inverse of the
  9564. * exponential to prevent steep falloff artifacts).
  9565. */
  9566. useCloseExponentialShadowMap: boolean;
  9567. /**
  9568. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9569. * exponential to prevent steep falloff artifacts).
  9570. */
  9571. /**
  9572. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9573. * exponential to prevent steep falloff artifacts).
  9574. */
  9575. useBlurCloseExponentialShadowMap: boolean;
  9576. /**
  9577. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9578. */
  9579. /**
  9580. * Sets the current filter to "PCF" (percentage closer filtering).
  9581. */
  9582. usePercentageCloserFiltering: boolean;
  9583. private _filteringQuality;
  9584. /**
  9585. * Gets the PCF or PCSS Quality.
  9586. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9587. */
  9588. /**
  9589. * Sets the PCF or PCSS Quality.
  9590. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9591. */
  9592. filteringQuality: number;
  9593. /**
  9594. * Gets if the current filter is set to "PCSS" (contact hardening).
  9595. */
  9596. /**
  9597. * Sets the current filter to "PCSS" (contact hardening).
  9598. */
  9599. useContactHardeningShadow: boolean;
  9600. private _contactHardeningLightSizeUVRatio;
  9601. /**
  9602. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9603. * Using a ratio helps keeping shape stability independently of the map size.
  9604. *
  9605. * It does not account for the light projection as it was having too much
  9606. * instability during the light setup or during light position changes.
  9607. *
  9608. * Only valid if useContactHardeningShadow is true.
  9609. */
  9610. /**
  9611. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9612. * Using a ratio helps keeping shape stability independently of the map size.
  9613. *
  9614. * It does not account for the light projection as it was having too much
  9615. * instability during the light setup or during light position changes.
  9616. *
  9617. * Only valid if useContactHardeningShadow is true.
  9618. */
  9619. contactHardeningLightSizeUVRatio: number;
  9620. private _darkness;
  9621. /** Gets or sets the actual darkness of a shadow */
  9622. darkness: number;
  9623. /**
  9624. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9625. * 0 means strongest and 1 would means no shadow.
  9626. * @returns the darkness.
  9627. */
  9628. getDarkness(): number;
  9629. /**
  9630. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9631. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9632. * @returns the shadow generator allowing fluent coding.
  9633. */
  9634. setDarkness(darkness: number): ShadowGenerator;
  9635. private _transparencyShadow;
  9636. /** Gets or sets the ability to have transparent shadow */
  9637. transparencyShadow: boolean;
  9638. /**
  9639. * Sets the ability to have transparent shadow (boolean).
  9640. * @param transparent True if transparent else False
  9641. * @returns the shadow generator allowing fluent coding
  9642. */
  9643. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9644. private _shadowMap;
  9645. private _shadowMap2;
  9646. /**
  9647. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9648. * @returns The render target texture if present otherwise, null
  9649. */
  9650. getShadowMap(): Nullable<RenderTargetTexture>;
  9651. /**
  9652. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9653. * @returns The render target texture if the shadow map is present otherwise, null
  9654. */
  9655. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9656. /**
  9657. * Gets the class name of that object
  9658. * @returns "ShadowGenerator"
  9659. */
  9660. getClassName(): string;
  9661. /**
  9662. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9663. * @param mesh Mesh to add
  9664. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9665. * @returns the Shadow Generator itself
  9666. */
  9667. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9668. /**
  9669. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9670. * @param mesh Mesh to remove
  9671. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9672. * @returns the Shadow Generator itself
  9673. */
  9674. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9675. /**
  9676. * Controls the extent to which the shadows fade out at the edge of the frustum
  9677. * Used only by directionals and spots
  9678. */
  9679. frustumEdgeFalloff: number;
  9680. private _light;
  9681. /**
  9682. * Returns the associated light object.
  9683. * @returns the light generating the shadow
  9684. */
  9685. getLight(): IShadowLight;
  9686. /**
  9687. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9688. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9689. * It might on the other hand introduce peter panning.
  9690. */
  9691. forceBackFacesOnly: boolean;
  9692. private _scene;
  9693. private _lightDirection;
  9694. private _effect;
  9695. private _viewMatrix;
  9696. private _projectionMatrix;
  9697. private _transformMatrix;
  9698. private _cachedPosition;
  9699. private _cachedDirection;
  9700. private _cachedDefines;
  9701. private _currentRenderID;
  9702. private _boxBlurPostprocess;
  9703. private _kernelBlurXPostprocess;
  9704. private _kernelBlurYPostprocess;
  9705. private _blurPostProcesses;
  9706. private _mapSize;
  9707. private _currentFaceIndex;
  9708. private _currentFaceIndexCache;
  9709. private _textureType;
  9710. private _defaultTextureMatrix;
  9711. private _storedUniqueId;
  9712. /** @hidden */
  9713. static _SceneComponentInitialization: (scene: Scene) => void;
  9714. /**
  9715. * Creates a ShadowGenerator object.
  9716. * A ShadowGenerator is the required tool to use the shadows.
  9717. * Each light casting shadows needs to use its own ShadowGenerator.
  9718. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9719. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9720. * @param light The light object generating the shadows.
  9721. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  9722. */
  9723. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9724. private _initializeGenerator;
  9725. private _initializeShadowMap;
  9726. private _initializeBlurRTTAndPostProcesses;
  9727. private _renderForShadowMap;
  9728. private _renderSubMeshForShadowMap;
  9729. private _applyFilterValues;
  9730. /**
  9731. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9732. * @param onCompiled Callback triggered at the and of the effects compilation
  9733. * @param options Sets of optional options forcing the compilation with different modes
  9734. */
  9735. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9736. useInstances: boolean;
  9737. }>): void;
  9738. /**
  9739. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9740. * @param options Sets of optional options forcing the compilation with different modes
  9741. * @returns A promise that resolves when the compilation completes
  9742. */
  9743. forceCompilationAsync(options?: Partial<{
  9744. useInstances: boolean;
  9745. }>): Promise<void>;
  9746. /**
  9747. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9748. * @param subMesh The submesh we want to render in the shadow map
  9749. * @param useInstances Defines wether will draw in the map using instances
  9750. * @returns true if ready otherwise, false
  9751. */
  9752. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9753. /**
  9754. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9755. * @param defines Defines of the material we want to update
  9756. * @param lightIndex Index of the light in the enabled light list of the material
  9757. */
  9758. prepareDefines(defines: any, lightIndex: number): void;
  9759. /**
  9760. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9761. * defined in the generator but impacting the effect).
  9762. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9763. * @param effect The effect we are binfing the information for
  9764. */
  9765. bindShadowLight(lightIndex: string, effect: Effect): void;
  9766. /**
  9767. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9768. * (eq to shadow prjection matrix * light transform matrix)
  9769. * @returns The transform matrix used to create the shadow map
  9770. */
  9771. getTransformMatrix(): Matrix;
  9772. /**
  9773. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9774. * Cube and 2D textures for instance.
  9775. */
  9776. recreateShadowMap(): void;
  9777. private _disposeBlurPostProcesses;
  9778. private _disposeRTTandPostProcesses;
  9779. /**
  9780. * Disposes the ShadowGenerator.
  9781. * Returns nothing.
  9782. */
  9783. dispose(): void;
  9784. /**
  9785. * Serializes the shadow generator setup to a json object.
  9786. * @returns The serialized JSON object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9791. * @param parsedShadowGenerator The JSON object to parse
  9792. * @param scene The scene to create the shadow map for
  9793. * @returns The parsed shadow generator
  9794. */
  9795. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9796. }
  9797. }
  9798. declare module "babylonjs/Lights/light" {
  9799. import { Nullable } from "babylonjs/types";
  9800. import { Scene } from "babylonjs/scene";
  9801. import { Vector3 } from "babylonjs/Maths/math.vector";
  9802. import { Color3 } from "babylonjs/Maths/math.color";
  9803. import { Node } from "babylonjs/node";
  9804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9805. import { Effect } from "babylonjs/Materials/effect";
  9806. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9807. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9808. /**
  9809. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9810. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9811. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  9812. */
  9813. export abstract class Light extends Node {
  9814. /**
  9815. * Falloff Default: light is falling off following the material specification:
  9816. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9817. */
  9818. static readonly FALLOFF_DEFAULT: number;
  9819. /**
  9820. * Falloff Physical: light is falling off following the inverse squared distance law.
  9821. */
  9822. static readonly FALLOFF_PHYSICAL: number;
  9823. /**
  9824. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9825. * to enhance interoperability with other engines.
  9826. */
  9827. static readonly FALLOFF_GLTF: number;
  9828. /**
  9829. * Falloff Standard: light is falling off like in the standard material
  9830. * to enhance interoperability with other materials.
  9831. */
  9832. static readonly FALLOFF_STANDARD: number;
  9833. /**
  9834. * If every light affecting the material is in this lightmapMode,
  9835. * material.lightmapTexture adds or multiplies
  9836. * (depends on material.useLightmapAsShadowmap)
  9837. * after every other light calculations.
  9838. */
  9839. static readonly LIGHTMAP_DEFAULT: number;
  9840. /**
  9841. * material.lightmapTexture as only diffuse lighting from this light
  9842. * adds only specular lighting from this light
  9843. * adds dynamic shadows
  9844. */
  9845. static readonly LIGHTMAP_SPECULAR: number;
  9846. /**
  9847. * material.lightmapTexture as only lighting
  9848. * no light calculation from this light
  9849. * only adds dynamic shadows from this light
  9850. */
  9851. static readonly LIGHTMAP_SHADOWSONLY: number;
  9852. /**
  9853. * Each light type uses the default quantity according to its type:
  9854. * point/spot lights use luminous intensity
  9855. * directional lights use illuminance
  9856. */
  9857. static readonly INTENSITYMODE_AUTOMATIC: number;
  9858. /**
  9859. * lumen (lm)
  9860. */
  9861. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9862. /**
  9863. * candela (lm/sr)
  9864. */
  9865. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9866. /**
  9867. * lux (lm/m^2)
  9868. */
  9869. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9870. /**
  9871. * nit (cd/m^2)
  9872. */
  9873. static readonly INTENSITYMODE_LUMINANCE: number;
  9874. /**
  9875. * Light type const id of the point light.
  9876. */
  9877. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9878. /**
  9879. * Light type const id of the directional light.
  9880. */
  9881. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9882. /**
  9883. * Light type const id of the spot light.
  9884. */
  9885. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9886. /**
  9887. * Light type const id of the hemispheric light.
  9888. */
  9889. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9890. /**
  9891. * Diffuse gives the basic color to an object.
  9892. */
  9893. diffuse: Color3;
  9894. /**
  9895. * Specular produces a highlight color on an object.
  9896. * Note: This is note affecting PBR materials.
  9897. */
  9898. specular: Color3;
  9899. /**
  9900. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9901. * falling off base on range or angle.
  9902. * This can be set to any values in Light.FALLOFF_x.
  9903. *
  9904. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9905. * other types of materials.
  9906. */
  9907. falloffType: number;
  9908. /**
  9909. * Strength of the light.
  9910. * Note: By default it is define in the framework own unit.
  9911. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9912. */
  9913. intensity: number;
  9914. private _range;
  9915. protected _inverseSquaredRange: number;
  9916. /**
  9917. * Defines how far from the source the light is impacting in scene units.
  9918. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9919. */
  9920. /**
  9921. * Defines how far from the source the light is impacting in scene units.
  9922. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9923. */
  9924. range: number;
  9925. /**
  9926. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9927. * of light.
  9928. */
  9929. private _photometricScale;
  9930. private _intensityMode;
  9931. /**
  9932. * Gets the photometric scale used to interpret the intensity.
  9933. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9934. */
  9935. /**
  9936. * Sets the photometric scale used to interpret the intensity.
  9937. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9938. */
  9939. intensityMode: number;
  9940. private _radius;
  9941. /**
  9942. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9943. */
  9944. /**
  9945. * sets the light radius used by PBR Materials to simulate soft area lights.
  9946. */
  9947. radius: number;
  9948. private _renderPriority;
  9949. /**
  9950. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9951. * exceeding the number allowed of the materials.
  9952. */
  9953. renderPriority: number;
  9954. private _shadowEnabled;
  9955. /**
  9956. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9957. * the current shadow generator.
  9958. */
  9959. /**
  9960. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9961. * the current shadow generator.
  9962. */
  9963. shadowEnabled: boolean;
  9964. private _includedOnlyMeshes;
  9965. /**
  9966. * Gets the only meshes impacted by this light.
  9967. */
  9968. /**
  9969. * Sets the only meshes impacted by this light.
  9970. */
  9971. includedOnlyMeshes: AbstractMesh[];
  9972. private _excludedMeshes;
  9973. /**
  9974. * Gets the meshes not impacted by this light.
  9975. */
  9976. /**
  9977. * Sets the meshes not impacted by this light.
  9978. */
  9979. excludedMeshes: AbstractMesh[];
  9980. private _excludeWithLayerMask;
  9981. /**
  9982. * Gets the layer id use to find what meshes are not impacted by the light.
  9983. * Inactive if 0
  9984. */
  9985. /**
  9986. * Sets the layer id use to find what meshes are not impacted by the light.
  9987. * Inactive if 0
  9988. */
  9989. excludeWithLayerMask: number;
  9990. private _includeOnlyWithLayerMask;
  9991. /**
  9992. * Gets the layer id use to find what meshes are impacted by the light.
  9993. * Inactive if 0
  9994. */
  9995. /**
  9996. * Sets the layer id use to find what meshes are impacted by the light.
  9997. * Inactive if 0
  9998. */
  9999. includeOnlyWithLayerMask: number;
  10000. private _lightmapMode;
  10001. /**
  10002. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10003. */
  10004. /**
  10005. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10006. */
  10007. lightmapMode: number;
  10008. /**
  10009. * Shadow generator associted to the light.
  10010. * @hidden Internal use only.
  10011. */
  10012. _shadowGenerator: Nullable<IShadowGenerator>;
  10013. /**
  10014. * @hidden Internal use only.
  10015. */
  10016. _excludedMeshesIds: string[];
  10017. /**
  10018. * @hidden Internal use only.
  10019. */
  10020. _includedOnlyMeshesIds: string[];
  10021. /**
  10022. * The current light unifom buffer.
  10023. * @hidden Internal use only.
  10024. */
  10025. _uniformBuffer: UniformBuffer;
  10026. /**
  10027. * Creates a Light object in the scene.
  10028. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10029. * @param name The firendly name of the light
  10030. * @param scene The scene the light belongs too
  10031. */
  10032. constructor(name: string, scene: Scene);
  10033. protected abstract _buildUniformLayout(): void;
  10034. /**
  10035. * Sets the passed Effect "effect" with the Light information.
  10036. * @param effect The effect to update
  10037. * @param lightIndex The index of the light in the effect to update
  10038. * @returns The light
  10039. */
  10040. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10041. /**
  10042. * Sets the passed Effect "effect" with the Light information.
  10043. * @param effect The effect to update
  10044. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10045. * @returns The light
  10046. */
  10047. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10048. /**
  10049. * Returns the string "Light".
  10050. * @returns the class name
  10051. */
  10052. getClassName(): string;
  10053. /** @hidden */
  10054. readonly _isLight: boolean;
  10055. /**
  10056. * Converts the light information to a readable string for debug purpose.
  10057. * @param fullDetails Supports for multiple levels of logging within scene loading
  10058. * @returns the human readable light info
  10059. */
  10060. toString(fullDetails?: boolean): string;
  10061. /** @hidden */
  10062. protected _syncParentEnabledState(): void;
  10063. /**
  10064. * Set the enabled state of this node.
  10065. * @param value - the new enabled state
  10066. */
  10067. setEnabled(value: boolean): void;
  10068. /**
  10069. * Returns the Light associated shadow generator if any.
  10070. * @return the associated shadow generator.
  10071. */
  10072. getShadowGenerator(): Nullable<IShadowGenerator>;
  10073. /**
  10074. * Returns a Vector3, the absolute light position in the World.
  10075. * @returns the world space position of the light
  10076. */
  10077. getAbsolutePosition(): Vector3;
  10078. /**
  10079. * Specifies if the light will affect the passed mesh.
  10080. * @param mesh The mesh to test against the light
  10081. * @return true the mesh is affected otherwise, false.
  10082. */
  10083. canAffectMesh(mesh: AbstractMesh): boolean;
  10084. /**
  10085. * Sort function to order lights for rendering.
  10086. * @param a First Light object to compare to second.
  10087. * @param b Second Light object to compare first.
  10088. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10089. */
  10090. static CompareLightsPriority(a: Light, b: Light): number;
  10091. /**
  10092. * Releases resources associated with this node.
  10093. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10094. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10095. */
  10096. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10097. /**
  10098. * Returns the light type ID (integer).
  10099. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10100. */
  10101. getTypeID(): number;
  10102. /**
  10103. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10104. * @returns the scaled intensity in intensity mode unit
  10105. */
  10106. getScaledIntensity(): number;
  10107. /**
  10108. * Returns a new Light object, named "name", from the current one.
  10109. * @param name The name of the cloned light
  10110. * @returns the new created light
  10111. */
  10112. clone(name: string): Nullable<Light>;
  10113. /**
  10114. * Serializes the current light into a Serialization object.
  10115. * @returns the serialized object.
  10116. */
  10117. serialize(): any;
  10118. /**
  10119. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10120. * This new light is named "name" and added to the passed scene.
  10121. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10122. * @param name The friendly name of the light
  10123. * @param scene The scene the new light will belong to
  10124. * @returns the constructor function
  10125. */
  10126. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10127. /**
  10128. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10129. * @param parsedLight The JSON representation of the light
  10130. * @param scene The scene to create the parsed light in
  10131. * @returns the created light after parsing
  10132. */
  10133. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10134. private _hookArrayForExcluded;
  10135. private _hookArrayForIncludedOnly;
  10136. private _resyncMeshes;
  10137. /**
  10138. * Forces the meshes to update their light related information in their rendering used effects
  10139. * @hidden Internal Use Only
  10140. */
  10141. _markMeshesAsLightDirty(): void;
  10142. /**
  10143. * Recomputes the cached photometric scale if needed.
  10144. */
  10145. private _computePhotometricScale;
  10146. /**
  10147. * Returns the Photometric Scale according to the light type and intensity mode.
  10148. */
  10149. private _getPhotometricScale;
  10150. /**
  10151. * Reorder the light in the scene according to their defined priority.
  10152. * @hidden Internal Use Only
  10153. */
  10154. _reorderLightsInScene(): void;
  10155. /**
  10156. * Prepares the list of defines specific to the light type.
  10157. * @param defines the list of defines
  10158. * @param lightIndex defines the index of the light for the effect
  10159. */
  10160. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10161. }
  10162. }
  10163. declare module "babylonjs/Actions/action" {
  10164. import { Observable } from "babylonjs/Misc/observable";
  10165. import { Condition } from "babylonjs/Actions/condition";
  10166. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10167. import { ActionManager } from "babylonjs/Actions/actionManager";
  10168. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10169. /**
  10170. * Interface used to define Action
  10171. */
  10172. export interface IAction {
  10173. /**
  10174. * Trigger for the action
  10175. */
  10176. trigger: number;
  10177. /** Options of the trigger */
  10178. triggerOptions: any;
  10179. /**
  10180. * Gets the trigger parameters
  10181. * @returns the trigger parameters
  10182. */
  10183. getTriggerParameter(): any;
  10184. /**
  10185. * Internal only - executes current action event
  10186. * @hidden
  10187. */
  10188. _executeCurrent(evt?: ActionEvent): void;
  10189. /**
  10190. * Serialize placeholder for child classes
  10191. * @param parent of child
  10192. * @returns the serialized object
  10193. */
  10194. serialize(parent: any): any;
  10195. /**
  10196. * Internal only
  10197. * @hidden
  10198. */
  10199. _prepare(): void;
  10200. /**
  10201. * Internal only - manager for action
  10202. * @hidden
  10203. */
  10204. _actionManager: AbstractActionManager;
  10205. /**
  10206. * Adds action to chain of actions, may be a DoNothingAction
  10207. * @param action defines the next action to execute
  10208. * @returns The action passed in
  10209. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10210. */
  10211. then(action: IAction): IAction;
  10212. }
  10213. /**
  10214. * The action to be carried out following a trigger
  10215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10216. */
  10217. export class Action implements IAction {
  10218. /** the trigger, with or without parameters, for the action */
  10219. triggerOptions: any;
  10220. /**
  10221. * Trigger for the action
  10222. */
  10223. trigger: number;
  10224. /**
  10225. * Internal only - manager for action
  10226. * @hidden
  10227. */
  10228. _actionManager: ActionManager;
  10229. private _nextActiveAction;
  10230. private _child;
  10231. private _condition?;
  10232. private _triggerParameter;
  10233. /**
  10234. * An event triggered prior to action being executed.
  10235. */
  10236. onBeforeExecuteObservable: Observable<Action>;
  10237. /**
  10238. * Creates a new Action
  10239. * @param triggerOptions the trigger, with or without parameters, for the action
  10240. * @param condition an optional determinant of action
  10241. */
  10242. constructor(
  10243. /** the trigger, with or without parameters, for the action */
  10244. triggerOptions: any, condition?: Condition);
  10245. /**
  10246. * Internal only
  10247. * @hidden
  10248. */
  10249. _prepare(): void;
  10250. /**
  10251. * Gets the trigger parameters
  10252. * @returns the trigger parameters
  10253. */
  10254. getTriggerParameter(): any;
  10255. /**
  10256. * Internal only - executes current action event
  10257. * @hidden
  10258. */
  10259. _executeCurrent(evt?: ActionEvent): void;
  10260. /**
  10261. * Execute placeholder for child classes
  10262. * @param evt optional action event
  10263. */
  10264. execute(evt?: ActionEvent): void;
  10265. /**
  10266. * Skips to next active action
  10267. */
  10268. skipToNextActiveAction(): void;
  10269. /**
  10270. * Adds action to chain of actions, may be a DoNothingAction
  10271. * @param action defines the next action to execute
  10272. * @returns The action passed in
  10273. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10274. */
  10275. then(action: Action): Action;
  10276. /**
  10277. * Internal only
  10278. * @hidden
  10279. */
  10280. _getProperty(propertyPath: string): string;
  10281. /**
  10282. * Internal only
  10283. * @hidden
  10284. */
  10285. _getEffectiveTarget(target: any, propertyPath: string): any;
  10286. /**
  10287. * Serialize placeholder for child classes
  10288. * @param parent of child
  10289. * @returns the serialized object
  10290. */
  10291. serialize(parent: any): any;
  10292. /**
  10293. * Internal only called by serialize
  10294. * @hidden
  10295. */
  10296. protected _serialize(serializedAction: any, parent?: any): any;
  10297. /**
  10298. * Internal only
  10299. * @hidden
  10300. */
  10301. static _SerializeValueAsString: (value: any) => string;
  10302. /**
  10303. * Internal only
  10304. * @hidden
  10305. */
  10306. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10307. name: string;
  10308. targetType: string;
  10309. value: string;
  10310. };
  10311. }
  10312. }
  10313. declare module "babylonjs/Actions/condition" {
  10314. import { ActionManager } from "babylonjs/Actions/actionManager";
  10315. /**
  10316. * A Condition applied to an Action
  10317. */
  10318. export class Condition {
  10319. /**
  10320. * Internal only - manager for action
  10321. * @hidden
  10322. */
  10323. _actionManager: ActionManager;
  10324. /**
  10325. * Internal only
  10326. * @hidden
  10327. */
  10328. _evaluationId: number;
  10329. /**
  10330. * Internal only
  10331. * @hidden
  10332. */
  10333. _currentResult: boolean;
  10334. /**
  10335. * Creates a new Condition
  10336. * @param actionManager the manager of the action the condition is applied to
  10337. */
  10338. constructor(actionManager: ActionManager);
  10339. /**
  10340. * Check if the current condition is valid
  10341. * @returns a boolean
  10342. */
  10343. isValid(): boolean;
  10344. /**
  10345. * Internal only
  10346. * @hidden
  10347. */
  10348. _getProperty(propertyPath: string): string;
  10349. /**
  10350. * Internal only
  10351. * @hidden
  10352. */
  10353. _getEffectiveTarget(target: any, propertyPath: string): any;
  10354. /**
  10355. * Serialize placeholder for child classes
  10356. * @returns the serialized object
  10357. */
  10358. serialize(): any;
  10359. /**
  10360. * Internal only
  10361. * @hidden
  10362. */
  10363. protected _serialize(serializedCondition: any): any;
  10364. }
  10365. /**
  10366. * Defines specific conditional operators as extensions of Condition
  10367. */
  10368. export class ValueCondition extends Condition {
  10369. /** path to specify the property of the target the conditional operator uses */
  10370. propertyPath: string;
  10371. /** the value compared by the conditional operator against the current value of the property */
  10372. value: any;
  10373. /** the conditional operator, default ValueCondition.IsEqual */
  10374. operator: number;
  10375. /**
  10376. * Internal only
  10377. * @hidden
  10378. */
  10379. private static _IsEqual;
  10380. /**
  10381. * Internal only
  10382. * @hidden
  10383. */
  10384. private static _IsDifferent;
  10385. /**
  10386. * Internal only
  10387. * @hidden
  10388. */
  10389. private static _IsGreater;
  10390. /**
  10391. * Internal only
  10392. * @hidden
  10393. */
  10394. private static _IsLesser;
  10395. /**
  10396. * returns the number for IsEqual
  10397. */
  10398. static readonly IsEqual: number;
  10399. /**
  10400. * Returns the number for IsDifferent
  10401. */
  10402. static readonly IsDifferent: number;
  10403. /**
  10404. * Returns the number for IsGreater
  10405. */
  10406. static readonly IsGreater: number;
  10407. /**
  10408. * Returns the number for IsLesser
  10409. */
  10410. static readonly IsLesser: number;
  10411. /**
  10412. * Internal only The action manager for the condition
  10413. * @hidden
  10414. */
  10415. _actionManager: ActionManager;
  10416. /**
  10417. * Internal only
  10418. * @hidden
  10419. */
  10420. private _target;
  10421. /**
  10422. * Internal only
  10423. * @hidden
  10424. */
  10425. private _effectiveTarget;
  10426. /**
  10427. * Internal only
  10428. * @hidden
  10429. */
  10430. private _property;
  10431. /**
  10432. * Creates a new ValueCondition
  10433. * @param actionManager manager for the action the condition applies to
  10434. * @param target for the action
  10435. * @param propertyPath path to specify the property of the target the conditional operator uses
  10436. * @param value the value compared by the conditional operator against the current value of the property
  10437. * @param operator the conditional operator, default ValueCondition.IsEqual
  10438. */
  10439. constructor(actionManager: ActionManager, target: any,
  10440. /** path to specify the property of the target the conditional operator uses */
  10441. propertyPath: string,
  10442. /** the value compared by the conditional operator against the current value of the property */
  10443. value: any,
  10444. /** the conditional operator, default ValueCondition.IsEqual */
  10445. operator?: number);
  10446. /**
  10447. * Compares the given value with the property value for the specified conditional operator
  10448. * @returns the result of the comparison
  10449. */
  10450. isValid(): boolean;
  10451. /**
  10452. * Serialize the ValueCondition into a JSON compatible object
  10453. * @returns serialization object
  10454. */
  10455. serialize(): any;
  10456. /**
  10457. * Gets the name of the conditional operator for the ValueCondition
  10458. * @param operator the conditional operator
  10459. * @returns the name
  10460. */
  10461. static GetOperatorName(operator: number): string;
  10462. }
  10463. /**
  10464. * Defines a predicate condition as an extension of Condition
  10465. */
  10466. export class PredicateCondition extends Condition {
  10467. /** defines the predicate function used to validate the condition */
  10468. predicate: () => boolean;
  10469. /**
  10470. * Internal only - manager for action
  10471. * @hidden
  10472. */
  10473. _actionManager: ActionManager;
  10474. /**
  10475. * Creates a new PredicateCondition
  10476. * @param actionManager manager for the action the condition applies to
  10477. * @param predicate defines the predicate function used to validate the condition
  10478. */
  10479. constructor(actionManager: ActionManager,
  10480. /** defines the predicate function used to validate the condition */
  10481. predicate: () => boolean);
  10482. /**
  10483. * @returns the validity of the predicate condition
  10484. */
  10485. isValid(): boolean;
  10486. }
  10487. /**
  10488. * Defines a state condition as an extension of Condition
  10489. */
  10490. export class StateCondition extends Condition {
  10491. /** Value to compare with target state */
  10492. value: string;
  10493. /**
  10494. * Internal only - manager for action
  10495. * @hidden
  10496. */
  10497. _actionManager: ActionManager;
  10498. /**
  10499. * Internal only
  10500. * @hidden
  10501. */
  10502. private _target;
  10503. /**
  10504. * Creates a new StateCondition
  10505. * @param actionManager manager for the action the condition applies to
  10506. * @param target of the condition
  10507. * @param value to compare with target state
  10508. */
  10509. constructor(actionManager: ActionManager, target: any,
  10510. /** Value to compare with target state */
  10511. value: string);
  10512. /**
  10513. * Gets a boolean indicating if the current condition is met
  10514. * @returns the validity of the state
  10515. */
  10516. isValid(): boolean;
  10517. /**
  10518. * Serialize the StateCondition into a JSON compatible object
  10519. * @returns serialization object
  10520. */
  10521. serialize(): any;
  10522. }
  10523. }
  10524. declare module "babylonjs/Actions/directActions" {
  10525. import { Action } from "babylonjs/Actions/action";
  10526. import { Condition } from "babylonjs/Actions/condition";
  10527. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10528. /**
  10529. * This defines an action responsible to toggle a boolean once triggered.
  10530. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10531. */
  10532. export class SwitchBooleanAction extends Action {
  10533. /**
  10534. * The path to the boolean property in the target object
  10535. */
  10536. propertyPath: string;
  10537. private _target;
  10538. private _effectiveTarget;
  10539. private _property;
  10540. /**
  10541. * Instantiate the action
  10542. * @param triggerOptions defines the trigger options
  10543. * @param target defines the object containing the boolean
  10544. * @param propertyPath defines the path to the boolean property in the target object
  10545. * @param condition defines the trigger related conditions
  10546. */
  10547. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10548. /** @hidden */
  10549. _prepare(): void;
  10550. /**
  10551. * Execute the action toggle the boolean value.
  10552. */
  10553. execute(): void;
  10554. /**
  10555. * Serializes the actions and its related information.
  10556. * @param parent defines the object to serialize in
  10557. * @returns the serialized object
  10558. */
  10559. serialize(parent: any): any;
  10560. }
  10561. /**
  10562. * This defines an action responsible to set a the state field of the target
  10563. * to a desired value once triggered.
  10564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10565. */
  10566. export class SetStateAction extends Action {
  10567. /**
  10568. * The value to store in the state field.
  10569. */
  10570. value: string;
  10571. private _target;
  10572. /**
  10573. * Instantiate the action
  10574. * @param triggerOptions defines the trigger options
  10575. * @param target defines the object containing the state property
  10576. * @param value defines the value to store in the state field
  10577. * @param condition defines the trigger related conditions
  10578. */
  10579. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10580. /**
  10581. * Execute the action and store the value on the target state property.
  10582. */
  10583. execute(): void;
  10584. /**
  10585. * Serializes the actions and its related information.
  10586. * @param parent defines the object to serialize in
  10587. * @returns the serialized object
  10588. */
  10589. serialize(parent: any): any;
  10590. }
  10591. /**
  10592. * This defines an action responsible to set a property of the target
  10593. * to a desired value once triggered.
  10594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10595. */
  10596. export class SetValueAction extends Action {
  10597. /**
  10598. * The path of the property to set in the target.
  10599. */
  10600. propertyPath: string;
  10601. /**
  10602. * The value to set in the property
  10603. */
  10604. value: any;
  10605. private _target;
  10606. private _effectiveTarget;
  10607. private _property;
  10608. /**
  10609. * Instantiate the action
  10610. * @param triggerOptions defines the trigger options
  10611. * @param target defines the object containing the property
  10612. * @param propertyPath defines the path of the property to set in the target
  10613. * @param value defines the value to set in the property
  10614. * @param condition defines the trigger related conditions
  10615. */
  10616. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10617. /** @hidden */
  10618. _prepare(): void;
  10619. /**
  10620. * Execute the action and set the targetted property to the desired value.
  10621. */
  10622. execute(): void;
  10623. /**
  10624. * Serializes the actions and its related information.
  10625. * @param parent defines the object to serialize in
  10626. * @returns the serialized object
  10627. */
  10628. serialize(parent: any): any;
  10629. }
  10630. /**
  10631. * This defines an action responsible to increment the target value
  10632. * to a desired value once triggered.
  10633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10634. */
  10635. export class IncrementValueAction extends Action {
  10636. /**
  10637. * The path of the property to increment in the target.
  10638. */
  10639. propertyPath: string;
  10640. /**
  10641. * The value we should increment the property by.
  10642. */
  10643. value: any;
  10644. private _target;
  10645. private _effectiveTarget;
  10646. private _property;
  10647. /**
  10648. * Instantiate the action
  10649. * @param triggerOptions defines the trigger options
  10650. * @param target defines the object containing the property
  10651. * @param propertyPath defines the path of the property to increment in the target
  10652. * @param value defines the value value we should increment the property by
  10653. * @param condition defines the trigger related conditions
  10654. */
  10655. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10656. /** @hidden */
  10657. _prepare(): void;
  10658. /**
  10659. * Execute the action and increment the target of the value amount.
  10660. */
  10661. execute(): void;
  10662. /**
  10663. * Serializes the actions and its related information.
  10664. * @param parent defines the object to serialize in
  10665. * @returns the serialized object
  10666. */
  10667. serialize(parent: any): any;
  10668. }
  10669. /**
  10670. * This defines an action responsible to start an animation once triggered.
  10671. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10672. */
  10673. export class PlayAnimationAction extends Action {
  10674. /**
  10675. * Where the animation should start (animation frame)
  10676. */
  10677. from: number;
  10678. /**
  10679. * Where the animation should stop (animation frame)
  10680. */
  10681. to: number;
  10682. /**
  10683. * Define if the animation should loop or stop after the first play.
  10684. */
  10685. loop?: boolean;
  10686. private _target;
  10687. /**
  10688. * Instantiate the action
  10689. * @param triggerOptions defines the trigger options
  10690. * @param target defines the target animation or animation name
  10691. * @param from defines from where the animation should start (animation frame)
  10692. * @param end defines where the animation should stop (animation frame)
  10693. * @param loop defines if the animation should loop or stop after the first play
  10694. * @param condition defines the trigger related conditions
  10695. */
  10696. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10697. /** @hidden */
  10698. _prepare(): void;
  10699. /**
  10700. * Execute the action and play the animation.
  10701. */
  10702. execute(): void;
  10703. /**
  10704. * Serializes the actions and its related information.
  10705. * @param parent defines the object to serialize in
  10706. * @returns the serialized object
  10707. */
  10708. serialize(parent: any): any;
  10709. }
  10710. /**
  10711. * This defines an action responsible to stop an animation once triggered.
  10712. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10713. */
  10714. export class StopAnimationAction extends Action {
  10715. private _target;
  10716. /**
  10717. * Instantiate the action
  10718. * @param triggerOptions defines the trigger options
  10719. * @param target defines the target animation or animation name
  10720. * @param condition defines the trigger related conditions
  10721. */
  10722. constructor(triggerOptions: any, target: any, condition?: Condition);
  10723. /** @hidden */
  10724. _prepare(): void;
  10725. /**
  10726. * Execute the action and stop the animation.
  10727. */
  10728. execute(): void;
  10729. /**
  10730. * Serializes the actions and its related information.
  10731. * @param parent defines the object to serialize in
  10732. * @returns the serialized object
  10733. */
  10734. serialize(parent: any): any;
  10735. }
  10736. /**
  10737. * This defines an action responsible that does nothing once triggered.
  10738. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10739. */
  10740. export class DoNothingAction extends Action {
  10741. /**
  10742. * Instantiate the action
  10743. * @param triggerOptions defines the trigger options
  10744. * @param condition defines the trigger related conditions
  10745. */
  10746. constructor(triggerOptions?: any, condition?: Condition);
  10747. /**
  10748. * Execute the action and do nothing.
  10749. */
  10750. execute(): void;
  10751. /**
  10752. * Serializes the actions and its related information.
  10753. * @param parent defines the object to serialize in
  10754. * @returns the serialized object
  10755. */
  10756. serialize(parent: any): any;
  10757. }
  10758. /**
  10759. * This defines an action responsible to trigger several actions once triggered.
  10760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10761. */
  10762. export class CombineAction extends Action {
  10763. /**
  10764. * The list of aggregated animations to run.
  10765. */
  10766. children: Action[];
  10767. /**
  10768. * Instantiate the action
  10769. * @param triggerOptions defines the trigger options
  10770. * @param children defines the list of aggregated animations to run
  10771. * @param condition defines the trigger related conditions
  10772. */
  10773. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10774. /** @hidden */
  10775. _prepare(): void;
  10776. /**
  10777. * Execute the action and executes all the aggregated actions.
  10778. */
  10779. execute(evt: ActionEvent): void;
  10780. /**
  10781. * Serializes the actions and its related information.
  10782. * @param parent defines the object to serialize in
  10783. * @returns the serialized object
  10784. */
  10785. serialize(parent: any): any;
  10786. }
  10787. /**
  10788. * This defines an action responsible to run code (external event) once triggered.
  10789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10790. */
  10791. export class ExecuteCodeAction extends Action {
  10792. /**
  10793. * The callback function to run.
  10794. */
  10795. func: (evt: ActionEvent) => void;
  10796. /**
  10797. * Instantiate the action
  10798. * @param triggerOptions defines the trigger options
  10799. * @param func defines the callback function to run
  10800. * @param condition defines the trigger related conditions
  10801. */
  10802. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10803. /**
  10804. * Execute the action and run the attached code.
  10805. */
  10806. execute(evt: ActionEvent): void;
  10807. }
  10808. /**
  10809. * This defines an action responsible to set the parent property of the target once triggered.
  10810. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10811. */
  10812. export class SetParentAction extends Action {
  10813. private _parent;
  10814. private _target;
  10815. /**
  10816. * Instantiate the action
  10817. * @param triggerOptions defines the trigger options
  10818. * @param target defines the target containing the parent property
  10819. * @param parent defines from where the animation should start (animation frame)
  10820. * @param condition defines the trigger related conditions
  10821. */
  10822. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10823. /** @hidden */
  10824. _prepare(): void;
  10825. /**
  10826. * Execute the action and set the parent property.
  10827. */
  10828. execute(): void;
  10829. /**
  10830. * Serializes the actions and its related information.
  10831. * @param parent defines the object to serialize in
  10832. * @returns the serialized object
  10833. */
  10834. serialize(parent: any): any;
  10835. }
  10836. }
  10837. declare module "babylonjs/Actions/actionManager" {
  10838. import { Nullable } from "babylonjs/types";
  10839. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10840. import { Scene } from "babylonjs/scene";
  10841. import { IAction } from "babylonjs/Actions/action";
  10842. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10843. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10844. /**
  10845. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10846. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10848. */
  10849. export class ActionManager extends AbstractActionManager {
  10850. /**
  10851. * Nothing
  10852. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10853. */
  10854. static readonly NothingTrigger: number;
  10855. /**
  10856. * On pick
  10857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10858. */
  10859. static readonly OnPickTrigger: number;
  10860. /**
  10861. * On left pick
  10862. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10863. */
  10864. static readonly OnLeftPickTrigger: number;
  10865. /**
  10866. * On right pick
  10867. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10868. */
  10869. static readonly OnRightPickTrigger: number;
  10870. /**
  10871. * On center pick
  10872. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10873. */
  10874. static readonly OnCenterPickTrigger: number;
  10875. /**
  10876. * On pick down
  10877. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10878. */
  10879. static readonly OnPickDownTrigger: number;
  10880. /**
  10881. * On double pick
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10883. */
  10884. static readonly OnDoublePickTrigger: number;
  10885. /**
  10886. * On pick up
  10887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10888. */
  10889. static readonly OnPickUpTrigger: number;
  10890. /**
  10891. * On pick out.
  10892. * This trigger will only be raised if you also declared a OnPickDown
  10893. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10894. */
  10895. static readonly OnPickOutTrigger: number;
  10896. /**
  10897. * On long press
  10898. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10899. */
  10900. static readonly OnLongPressTrigger: number;
  10901. /**
  10902. * On pointer over
  10903. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10904. */
  10905. static readonly OnPointerOverTrigger: number;
  10906. /**
  10907. * On pointer out
  10908. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10909. */
  10910. static readonly OnPointerOutTrigger: number;
  10911. /**
  10912. * On every frame
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10914. */
  10915. static readonly OnEveryFrameTrigger: number;
  10916. /**
  10917. * On intersection enter
  10918. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10919. */
  10920. static readonly OnIntersectionEnterTrigger: number;
  10921. /**
  10922. * On intersection exit
  10923. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10924. */
  10925. static readonly OnIntersectionExitTrigger: number;
  10926. /**
  10927. * On key down
  10928. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10929. */
  10930. static readonly OnKeyDownTrigger: number;
  10931. /**
  10932. * On key up
  10933. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10934. */
  10935. static readonly OnKeyUpTrigger: number;
  10936. private _scene;
  10937. /**
  10938. * Creates a new action manager
  10939. * @param scene defines the hosting scene
  10940. */
  10941. constructor(scene: Scene);
  10942. /**
  10943. * Releases all associated resources
  10944. */
  10945. dispose(): void;
  10946. /**
  10947. * Gets hosting scene
  10948. * @returns the hosting scene
  10949. */
  10950. getScene(): Scene;
  10951. /**
  10952. * Does this action manager handles actions of any of the given triggers
  10953. * @param triggers defines the triggers to be tested
  10954. * @return a boolean indicating whether one (or more) of the triggers is handled
  10955. */
  10956. hasSpecificTriggers(triggers: number[]): boolean;
  10957. /**
  10958. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10959. * speed.
  10960. * @param triggerA defines the trigger to be tested
  10961. * @param triggerB defines the trigger to be tested
  10962. * @return a boolean indicating whether one (or more) of the triggers is handled
  10963. */
  10964. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10965. /**
  10966. * Does this action manager handles actions of a given trigger
  10967. * @param trigger defines the trigger to be tested
  10968. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10969. * @return whether the trigger is handled
  10970. */
  10971. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10972. /**
  10973. * Does this action manager has pointer triggers
  10974. */
  10975. readonly hasPointerTriggers: boolean;
  10976. /**
  10977. * Does this action manager has pick triggers
  10978. */
  10979. readonly hasPickTriggers: boolean;
  10980. /**
  10981. * Registers an action to this action manager
  10982. * @param action defines the action to be registered
  10983. * @return the action amended (prepared) after registration
  10984. */
  10985. registerAction(action: IAction): Nullable<IAction>;
  10986. /**
  10987. * Unregisters an action to this action manager
  10988. * @param action defines the action to be unregistered
  10989. * @return a boolean indicating whether the action has been unregistered
  10990. */
  10991. unregisterAction(action: IAction): Boolean;
  10992. /**
  10993. * Process a specific trigger
  10994. * @param trigger defines the trigger to process
  10995. * @param evt defines the event details to be processed
  10996. */
  10997. processTrigger(trigger: number, evt?: IActionEvent): void;
  10998. /** @hidden */
  10999. _getEffectiveTarget(target: any, propertyPath: string): any;
  11000. /** @hidden */
  11001. _getProperty(propertyPath: string): string;
  11002. /**
  11003. * Serialize this manager to a JSON object
  11004. * @param name defines the property name to store this manager
  11005. * @returns a JSON representation of this manager
  11006. */
  11007. serialize(name: string): any;
  11008. /**
  11009. * Creates a new ActionManager from a JSON data
  11010. * @param parsedActions defines the JSON data to read from
  11011. * @param object defines the hosting mesh
  11012. * @param scene defines the hosting scene
  11013. */
  11014. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11015. /**
  11016. * Get a trigger name by index
  11017. * @param trigger defines the trigger index
  11018. * @returns a trigger name
  11019. */
  11020. static GetTriggerName(trigger: number): string;
  11021. }
  11022. }
  11023. declare module "babylonjs/Culling/ray" {
  11024. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11025. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11027. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11028. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11029. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11031. import { Plane } from "babylonjs/Maths/math.plane";
  11032. /**
  11033. * Class representing a ray with position and direction
  11034. */
  11035. export class Ray {
  11036. /** origin point */
  11037. origin: Vector3;
  11038. /** direction */
  11039. direction: Vector3;
  11040. /** length of the ray */
  11041. length: number;
  11042. private static readonly TmpVector3;
  11043. private _tmpRay;
  11044. /**
  11045. * Creates a new ray
  11046. * @param origin origin point
  11047. * @param direction direction
  11048. * @param length length of the ray
  11049. */
  11050. constructor(
  11051. /** origin point */
  11052. origin: Vector3,
  11053. /** direction */
  11054. direction: Vector3,
  11055. /** length of the ray */
  11056. length?: number);
  11057. /**
  11058. * Checks if the ray intersects a box
  11059. * @param minimum bound of the box
  11060. * @param maximum bound of the box
  11061. * @param intersectionTreshold extra extend to be added to the box in all direction
  11062. * @returns if the box was hit
  11063. */
  11064. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11065. /**
  11066. * Checks if the ray intersects a box
  11067. * @param box the bounding box to check
  11068. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11069. * @returns if the box was hit
  11070. */
  11071. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11072. /**
  11073. * If the ray hits a sphere
  11074. * @param sphere the bounding sphere to check
  11075. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11076. * @returns true if it hits the sphere
  11077. */
  11078. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11079. /**
  11080. * If the ray hits a triange
  11081. * @param vertex0 triangle vertex
  11082. * @param vertex1 triangle vertex
  11083. * @param vertex2 triangle vertex
  11084. * @returns intersection information if hit
  11085. */
  11086. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11087. /**
  11088. * Checks if ray intersects a plane
  11089. * @param plane the plane to check
  11090. * @returns the distance away it was hit
  11091. */
  11092. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11093. /**
  11094. * Calculate the intercept of a ray on a given axis
  11095. * @param axis to check 'x' | 'y' | 'z'
  11096. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11097. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11098. */
  11099. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11100. /**
  11101. * Checks if ray intersects a mesh
  11102. * @param mesh the mesh to check
  11103. * @param fastCheck if only the bounding box should checked
  11104. * @returns picking info of the intersecton
  11105. */
  11106. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11107. /**
  11108. * Checks if ray intersects a mesh
  11109. * @param meshes the meshes to check
  11110. * @param fastCheck if only the bounding box should checked
  11111. * @param results array to store result in
  11112. * @returns Array of picking infos
  11113. */
  11114. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11115. private _comparePickingInfo;
  11116. private static smallnum;
  11117. private static rayl;
  11118. /**
  11119. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11120. * @param sega the first point of the segment to test the intersection against
  11121. * @param segb the second point of the segment to test the intersection against
  11122. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11123. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11124. */
  11125. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11126. /**
  11127. * Update the ray from viewport position
  11128. * @param x position
  11129. * @param y y position
  11130. * @param viewportWidth viewport width
  11131. * @param viewportHeight viewport height
  11132. * @param world world matrix
  11133. * @param view view matrix
  11134. * @param projection projection matrix
  11135. * @returns this ray updated
  11136. */
  11137. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11138. /**
  11139. * Creates a ray with origin and direction of 0,0,0
  11140. * @returns the new ray
  11141. */
  11142. static Zero(): Ray;
  11143. /**
  11144. * Creates a new ray from screen space and viewport
  11145. * @param x position
  11146. * @param y y position
  11147. * @param viewportWidth viewport width
  11148. * @param viewportHeight viewport height
  11149. * @param world world matrix
  11150. * @param view view matrix
  11151. * @param projection projection matrix
  11152. * @returns new ray
  11153. */
  11154. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11155. /**
  11156. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  11157. * transformed to the given world matrix.
  11158. * @param origin The origin point
  11159. * @param end The end point
  11160. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11161. * @returns the new ray
  11162. */
  11163. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11164. /**
  11165. * Transforms a ray by a matrix
  11166. * @param ray ray to transform
  11167. * @param matrix matrix to apply
  11168. * @returns the resulting new ray
  11169. */
  11170. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11171. /**
  11172. * Transforms a ray by a matrix
  11173. * @param ray ray to transform
  11174. * @param matrix matrix to apply
  11175. * @param result ray to store result in
  11176. */
  11177. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11178. /**
  11179. * Unproject a ray from screen space to object space
  11180. * @param sourceX defines the screen space x coordinate to use
  11181. * @param sourceY defines the screen space y coordinate to use
  11182. * @param viewportWidth defines the current width of the viewport
  11183. * @param viewportHeight defines the current height of the viewport
  11184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11185. * @param view defines the view matrix to use
  11186. * @param projection defines the projection matrix to use
  11187. */
  11188. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11189. }
  11190. /**
  11191. * Type used to define predicate used to select faces when a mesh intersection is detected
  11192. */
  11193. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11194. module "babylonjs/scene" {
  11195. interface Scene {
  11196. /** @hidden */
  11197. _tempPickingRay: Nullable<Ray>;
  11198. /** @hidden */
  11199. _cachedRayForTransform: Ray;
  11200. /** @hidden */
  11201. _pickWithRayInverseMatrix: Matrix;
  11202. /** @hidden */
  11203. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11204. /** @hidden */
  11205. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11206. }
  11207. }
  11208. }
  11209. declare module "babylonjs/sceneComponent" {
  11210. import { Scene } from "babylonjs/scene";
  11211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11212. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11213. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11214. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11215. import { Nullable } from "babylonjs/types";
  11216. import { Camera } from "babylonjs/Cameras/camera";
  11217. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11218. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11219. import { AbstractScene } from "babylonjs/abstractScene";
  11220. /**
  11221. * Groups all the scene component constants in one place to ease maintenance.
  11222. * @hidden
  11223. */
  11224. export class SceneComponentConstants {
  11225. static readonly NAME_EFFECTLAYER: string;
  11226. static readonly NAME_LAYER: string;
  11227. static readonly NAME_LENSFLARESYSTEM: string;
  11228. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11229. static readonly NAME_PARTICLESYSTEM: string;
  11230. static readonly NAME_GAMEPAD: string;
  11231. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11232. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11233. static readonly NAME_DEPTHRENDERER: string;
  11234. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11235. static readonly NAME_SPRITE: string;
  11236. static readonly NAME_OUTLINERENDERER: string;
  11237. static readonly NAME_PROCEDURALTEXTURE: string;
  11238. static readonly NAME_SHADOWGENERATOR: string;
  11239. static readonly NAME_OCTREE: string;
  11240. static readonly NAME_PHYSICSENGINE: string;
  11241. static readonly NAME_AUDIO: string;
  11242. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11243. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11244. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11245. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11247. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11248. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11249. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11250. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11251. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11252. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11253. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11254. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11255. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11256. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11257. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11258. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11259. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11262. static readonly STEP_AFTERRENDER_AUDIO: number;
  11263. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11264. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11267. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_POINTERMOVE_SPRITE: number;
  11269. static readonly STEP_POINTERDOWN_SPRITE: number;
  11270. static readonly STEP_POINTERUP_SPRITE: number;
  11271. }
  11272. /**
  11273. * This represents a scene component.
  11274. *
  11275. * This is used to decouple the dependency the scene is having on the different workloads like
  11276. * layers, post processes...
  11277. */
  11278. export interface ISceneComponent {
  11279. /**
  11280. * The name of the component. Each component must have a unique name.
  11281. */
  11282. name: string;
  11283. /**
  11284. * The scene the component belongs to.
  11285. */
  11286. scene: Scene;
  11287. /**
  11288. * Register the component to one instance of a scene.
  11289. */
  11290. register(): void;
  11291. /**
  11292. * Rebuilds the elements related to this component in case of
  11293. * context lost for instance.
  11294. */
  11295. rebuild(): void;
  11296. /**
  11297. * Disposes the component and the associated ressources.
  11298. */
  11299. dispose(): void;
  11300. }
  11301. /**
  11302. * This represents a SERIALIZABLE scene component.
  11303. *
  11304. * This extends Scene Component to add Serialization methods on top.
  11305. */
  11306. export interface ISceneSerializableComponent extends ISceneComponent {
  11307. /**
  11308. * Adds all the elements from the container to the scene
  11309. * @param container the container holding the elements
  11310. */
  11311. addFromContainer(container: AbstractScene): void;
  11312. /**
  11313. * Removes all the elements in the container from the scene
  11314. * @param container contains the elements to remove
  11315. * @param dispose if the removed element should be disposed (default: false)
  11316. */
  11317. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11318. /**
  11319. * Serializes the component data to the specified json object
  11320. * @param serializationObject The object to serialize to
  11321. */
  11322. serialize(serializationObject: any): void;
  11323. }
  11324. /**
  11325. * Strong typing of a Mesh related stage step action
  11326. */
  11327. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11328. /**
  11329. * Strong typing of a Evaluate Sub Mesh related stage step action
  11330. */
  11331. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11332. /**
  11333. * Strong typing of a Active Mesh related stage step action
  11334. */
  11335. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11336. /**
  11337. * Strong typing of a Camera related stage step action
  11338. */
  11339. export type CameraStageAction = (camera: Camera) => void;
  11340. /**
  11341. * Strong typing of a Camera Frame buffer related stage step action
  11342. */
  11343. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11344. /**
  11345. * Strong typing of a Render Target related stage step action
  11346. */
  11347. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11348. /**
  11349. * Strong typing of a RenderingGroup related stage step action
  11350. */
  11351. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11352. /**
  11353. * Strong typing of a Mesh Render related stage step action
  11354. */
  11355. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11356. /**
  11357. * Strong typing of a simple stage step action
  11358. */
  11359. export type SimpleStageAction = () => void;
  11360. /**
  11361. * Strong typing of a render target action.
  11362. */
  11363. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11364. /**
  11365. * Strong typing of a pointer move action.
  11366. */
  11367. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11368. /**
  11369. * Strong typing of a pointer up/down action.
  11370. */
  11371. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11372. /**
  11373. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11374. * @hidden
  11375. */
  11376. export class Stage<T extends Function> extends Array<{
  11377. index: number;
  11378. component: ISceneComponent;
  11379. action: T;
  11380. }> {
  11381. /**
  11382. * Hide ctor from the rest of the world.
  11383. * @param items The items to add.
  11384. */
  11385. private constructor();
  11386. /**
  11387. * Creates a new Stage.
  11388. * @returns A new instance of a Stage
  11389. */
  11390. static Create<T extends Function>(): Stage<T>;
  11391. /**
  11392. * Registers a step in an ordered way in the targeted stage.
  11393. * @param index Defines the position to register the step in
  11394. * @param component Defines the component attached to the step
  11395. * @param action Defines the action to launch during the step
  11396. */
  11397. registerStep(index: number, component: ISceneComponent, action: T): void;
  11398. /**
  11399. * Clears all the steps from the stage.
  11400. */
  11401. clear(): void;
  11402. }
  11403. }
  11404. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11405. import { Nullable } from "babylonjs/types";
  11406. import { Observable } from "babylonjs/Misc/observable";
  11407. import { Scene } from "babylonjs/scene";
  11408. import { Sprite } from "babylonjs/Sprites/sprite";
  11409. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11410. import { Ray } from "babylonjs/Culling/ray";
  11411. import { Camera } from "babylonjs/Cameras/camera";
  11412. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11413. import { ISceneComponent } from "babylonjs/sceneComponent";
  11414. module "babylonjs/scene" {
  11415. interface Scene {
  11416. /** @hidden */
  11417. _pointerOverSprite: Nullable<Sprite>;
  11418. /** @hidden */
  11419. _pickedDownSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _tempSpritePickingRay: Nullable<Ray>;
  11422. /**
  11423. * All of the sprite managers added to this scene
  11424. * @see http://doc.babylonjs.com/babylon101/sprites
  11425. */
  11426. spriteManagers: Array<ISpriteManager>;
  11427. /**
  11428. * An event triggered when sprites rendering is about to start
  11429. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11430. */
  11431. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11432. /**
  11433. * An event triggered when sprites rendering is done
  11434. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11435. */
  11436. onAfterSpritesRenderingObservable: Observable<Scene>;
  11437. /** @hidden */
  11438. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11439. /** Launch a ray to try to pick a sprite in the scene
  11440. * @param x position on screen
  11441. * @param y position on screen
  11442. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11444. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11445. * @returns a PickingInfo
  11446. */
  11447. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11448. /** Use the given ray to pick a sprite in the scene
  11449. * @param ray The ray (in world space) to use to pick meshes
  11450. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11451. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11452. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11453. * @returns a PickingInfo
  11454. */
  11455. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11456. /** @hidden */
  11457. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11458. /** Launch a ray to try to pick sprites in the scene
  11459. * @param x position on screen
  11460. * @param y position on screen
  11461. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11462. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11463. * @returns a PickingInfo array
  11464. */
  11465. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11466. /** Use the given ray to pick sprites in the scene
  11467. * @param ray The ray (in world space) to use to pick meshes
  11468. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  11469. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11470. * @returns a PickingInfo array
  11471. */
  11472. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11473. /**
  11474. * Force the sprite under the pointer
  11475. * @param sprite defines the sprite to use
  11476. */
  11477. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11478. /**
  11479. * Gets the sprite under the pointer
  11480. * @returns a Sprite or null if no sprite is under the pointer
  11481. */
  11482. getPointerOverSprite(): Nullable<Sprite>;
  11483. }
  11484. }
  11485. /**
  11486. * Defines the sprite scene component responsible to manage sprites
  11487. * in a given scene.
  11488. */
  11489. export class SpriteSceneComponent implements ISceneComponent {
  11490. /**
  11491. * The component name helpfull to identify the component in the list of scene components.
  11492. */
  11493. readonly name: string;
  11494. /**
  11495. * The scene the component belongs to.
  11496. */
  11497. scene: Scene;
  11498. /** @hidden */
  11499. private _spritePredicate;
  11500. /**
  11501. * Creates a new instance of the component for the given scene
  11502. * @param scene Defines the scene to register the component in
  11503. */
  11504. constructor(scene: Scene);
  11505. /**
  11506. * Registers the component in a given scene
  11507. */
  11508. register(): void;
  11509. /**
  11510. * Rebuilds the elements related to this component in case of
  11511. * context lost for instance.
  11512. */
  11513. rebuild(): void;
  11514. /**
  11515. * Disposes the component and the associated ressources.
  11516. */
  11517. dispose(): void;
  11518. private _pickSpriteButKeepRay;
  11519. private _pointerMove;
  11520. private _pointerDown;
  11521. private _pointerUp;
  11522. }
  11523. }
  11524. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11525. /** @hidden */
  11526. export var fogFragmentDeclaration: {
  11527. name: string;
  11528. shader: string;
  11529. };
  11530. }
  11531. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11532. /** @hidden */
  11533. export var fogFragment: {
  11534. name: string;
  11535. shader: string;
  11536. };
  11537. }
  11538. declare module "babylonjs/Shaders/sprites.fragment" {
  11539. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11540. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11541. /** @hidden */
  11542. export var spritesPixelShader: {
  11543. name: string;
  11544. shader: string;
  11545. };
  11546. }
  11547. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11548. /** @hidden */
  11549. export var fogVertexDeclaration: {
  11550. name: string;
  11551. shader: string;
  11552. };
  11553. }
  11554. declare module "babylonjs/Shaders/sprites.vertex" {
  11555. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11556. /** @hidden */
  11557. export var spritesVertexShader: {
  11558. name: string;
  11559. shader: string;
  11560. };
  11561. }
  11562. declare module "babylonjs/Sprites/spriteManager" {
  11563. import { IDisposable, Scene } from "babylonjs/scene";
  11564. import { Nullable } from "babylonjs/types";
  11565. import { Observable } from "babylonjs/Misc/observable";
  11566. import { Sprite } from "babylonjs/Sprites/sprite";
  11567. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11568. import { Camera } from "babylonjs/Cameras/camera";
  11569. import { Texture } from "babylonjs/Materials/Textures/texture";
  11570. import "babylonjs/Shaders/sprites.fragment";
  11571. import "babylonjs/Shaders/sprites.vertex";
  11572. import { Ray } from "babylonjs/Culling/ray";
  11573. /**
  11574. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11575. */
  11576. export interface ISpriteManager extends IDisposable {
  11577. /**
  11578. * Restricts the camera to viewing objects with the same layerMask.
  11579. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11580. */
  11581. layerMask: number;
  11582. /**
  11583. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11584. */
  11585. isPickable: boolean;
  11586. /**
  11587. * Specifies the rendering group id for this mesh (0 by default)
  11588. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11589. */
  11590. renderingGroupId: number;
  11591. /**
  11592. * Defines the list of sprites managed by the manager.
  11593. */
  11594. sprites: Array<Sprite>;
  11595. /**
  11596. * Tests the intersection of a sprite with a specific ray.
  11597. * @param ray The ray we are sending to test the collision
  11598. * @param camera The camera space we are sending rays in
  11599. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11600. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11601. * @returns picking info or null.
  11602. */
  11603. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11604. /**
  11605. * Intersects the sprites with a ray
  11606. * @param ray defines the ray to intersect with
  11607. * @param camera defines the current active camera
  11608. * @param predicate defines a predicate used to select candidate sprites
  11609. * @returns null if no hit or a PickingInfo array
  11610. */
  11611. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11612. /**
  11613. * Renders the list of sprites on screen.
  11614. */
  11615. render(): void;
  11616. }
  11617. /**
  11618. * Class used to manage multiple sprites on the same spritesheet
  11619. * @see http://doc.babylonjs.com/babylon101/sprites
  11620. */
  11621. export class SpriteManager implements ISpriteManager {
  11622. /** defines the manager's name */
  11623. name: string;
  11624. /** Gets the list of sprites */
  11625. sprites: Sprite[];
  11626. /** Gets or sets the rendering group id (0 by default) */
  11627. renderingGroupId: number;
  11628. /** Gets or sets camera layer mask */
  11629. layerMask: number;
  11630. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11631. fogEnabled: boolean;
  11632. /** Gets or sets a boolean indicating if the sprites are pickable */
  11633. isPickable: boolean;
  11634. /** Defines the default width of a cell in the spritesheet */
  11635. cellWidth: number;
  11636. /** Defines the default height of a cell in the spritesheet */
  11637. cellHeight: number;
  11638. /** Associative array from JSON sprite data file */
  11639. private _cellData;
  11640. /** Array of sprite names from JSON sprite data file */
  11641. private _spriteMap;
  11642. /** True when packed cell data from JSON file is ready*/
  11643. private _packedAndReady;
  11644. /**
  11645. * An event triggered when the manager is disposed.
  11646. */
  11647. onDisposeObservable: Observable<SpriteManager>;
  11648. private _onDisposeObserver;
  11649. /**
  11650. * Callback called when the manager is disposed
  11651. */
  11652. onDispose: () => void;
  11653. private _capacity;
  11654. private _fromPacked;
  11655. private _spriteTexture;
  11656. private _epsilon;
  11657. private _scene;
  11658. private _vertexData;
  11659. private _buffer;
  11660. private _vertexBuffers;
  11661. private _indexBuffer;
  11662. private _effectBase;
  11663. private _effectFog;
  11664. /**
  11665. * Gets or sets the spritesheet texture
  11666. */
  11667. texture: Texture;
  11668. /**
  11669. * Creates a new sprite manager
  11670. * @param name defines the manager's name
  11671. * @param imgUrl defines the sprite sheet url
  11672. * @param capacity defines the maximum allowed number of sprites
  11673. * @param cellSize defines the size of a sprite cell
  11674. * @param scene defines the hosting scene
  11675. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11676. * @param samplingMode defines the smapling mode to use with spritesheet
  11677. * @param fromPacked set to false; do not alter
  11678. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11679. */
  11680. constructor(
  11681. /** defines the manager's name */
  11682. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11683. private _makePacked;
  11684. private _appendSpriteVertex;
  11685. /**
  11686. * Intersects the sprites with a ray
  11687. * @param ray defines the ray to intersect with
  11688. * @param camera defines the current active camera
  11689. * @param predicate defines a predicate used to select candidate sprites
  11690. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11691. * @returns null if no hit or a PickingInfo
  11692. */
  11693. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11694. /**
  11695. * Intersects the sprites with a ray
  11696. * @param ray defines the ray to intersect with
  11697. * @param camera defines the current active camera
  11698. * @param predicate defines a predicate used to select candidate sprites
  11699. * @returns null if no hit or a PickingInfo array
  11700. */
  11701. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11702. /**
  11703. * Render all child sprites
  11704. */
  11705. render(): void;
  11706. /**
  11707. * Release associated resources
  11708. */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Sprites/sprite" {
  11713. import { Vector3 } from "babylonjs/Maths/math.vector";
  11714. import { Nullable } from "babylonjs/types";
  11715. import { ActionManager } from "babylonjs/Actions/actionManager";
  11716. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11717. import { Color4 } from "babylonjs/Maths/math.color";
  11718. /**
  11719. * Class used to represent a sprite
  11720. * @see http://doc.babylonjs.com/babylon101/sprites
  11721. */
  11722. export class Sprite {
  11723. /** defines the name */
  11724. name: string;
  11725. /** Gets or sets the current world position */
  11726. position: Vector3;
  11727. /** Gets or sets the main color */
  11728. color: Color4;
  11729. /** Gets or sets the width */
  11730. width: number;
  11731. /** Gets or sets the height */
  11732. height: number;
  11733. /** Gets or sets rotation angle */
  11734. angle: number;
  11735. /** Gets or sets the cell index in the sprite sheet */
  11736. cellIndex: number;
  11737. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11738. cellRef: string;
  11739. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11740. invertU: number;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11742. invertV: number;
  11743. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11744. disposeWhenFinishedAnimating: boolean;
  11745. /** Gets the list of attached animations */
  11746. animations: Animation[];
  11747. /** Gets or sets a boolean indicating if the sprite can be picked */
  11748. isPickable: boolean;
  11749. /**
  11750. * Gets or sets the associated action manager
  11751. */
  11752. actionManager: Nullable<ActionManager>;
  11753. private _animationStarted;
  11754. private _loopAnimation;
  11755. private _fromIndex;
  11756. private _toIndex;
  11757. private _delay;
  11758. private _direction;
  11759. private _manager;
  11760. private _time;
  11761. private _onAnimationEnd;
  11762. /**
  11763. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11764. */
  11765. isVisible: boolean;
  11766. /**
  11767. * Gets or sets the sprite size
  11768. */
  11769. size: number;
  11770. /**
  11771. * Creates a new Sprite
  11772. * @param name defines the name
  11773. * @param manager defines the manager
  11774. */
  11775. constructor(
  11776. /** defines the name */
  11777. name: string, manager: ISpriteManager);
  11778. /**
  11779. * Starts an animation
  11780. * @param from defines the initial key
  11781. * @param to defines the end key
  11782. * @param loop defines if the animation must loop
  11783. * @param delay defines the start delay (in ms)
  11784. * @param onAnimationEnd defines a callback to call when animation ends
  11785. */
  11786. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11787. /** Stops current animation (if any) */
  11788. stopAnimation(): void;
  11789. /** @hidden */
  11790. _animate(deltaTime: number): void;
  11791. /** Release associated resources */
  11792. dispose(): void;
  11793. }
  11794. }
  11795. declare module "babylonjs/Collisions/pickingInfo" {
  11796. import { Nullable } from "babylonjs/types";
  11797. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11798. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11799. import { Sprite } from "babylonjs/Sprites/sprite";
  11800. import { Ray } from "babylonjs/Culling/ray";
  11801. /**
  11802. * Information about the result of picking within a scene
  11803. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11804. */
  11805. export class PickingInfo {
  11806. /** @hidden */
  11807. _pickingUnavailable: boolean;
  11808. /**
  11809. * If the pick collided with an object
  11810. */
  11811. hit: boolean;
  11812. /**
  11813. * Distance away where the pick collided
  11814. */
  11815. distance: number;
  11816. /**
  11817. * The location of pick collision
  11818. */
  11819. pickedPoint: Nullable<Vector3>;
  11820. /**
  11821. * The mesh corresponding the the pick collision
  11822. */
  11823. pickedMesh: Nullable<AbstractMesh>;
  11824. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11825. bu: number;
  11826. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bv: number;
  11828. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11829. faceId: number;
  11830. /** Id of the the submesh that was picked */
  11831. subMeshId: number;
  11832. /** If a sprite was picked, this will be the sprite the pick collided with */
  11833. pickedSprite: Nullable<Sprite>;
  11834. /**
  11835. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11836. */
  11837. originMesh: Nullable<AbstractMesh>;
  11838. /**
  11839. * The ray that was used to perform the picking.
  11840. */
  11841. ray: Nullable<Ray>;
  11842. /**
  11843. * Gets the normal correspodning to the face the pick collided with
  11844. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11845. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11846. * @returns The normal correspodning to the face the pick collided with
  11847. */
  11848. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11849. /**
  11850. * Gets the texture coordinates of where the pick occured
  11851. * @returns the vector containing the coordnates of the texture
  11852. */
  11853. getTextureCoordinates(): Nullable<Vector2>;
  11854. }
  11855. }
  11856. declare module "babylonjs/Events/pointerEvents" {
  11857. import { Nullable } from "babylonjs/types";
  11858. import { Vector2 } from "babylonjs/Maths/math.vector";
  11859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11860. import { Ray } from "babylonjs/Culling/ray";
  11861. /**
  11862. * Gather the list of pointer event types as constants.
  11863. */
  11864. export class PointerEventTypes {
  11865. /**
  11866. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  11867. */
  11868. static readonly POINTERDOWN: number;
  11869. /**
  11870. * The pointerup event is fired when a pointer is no longer active.
  11871. */
  11872. static readonly POINTERUP: number;
  11873. /**
  11874. * The pointermove event is fired when a pointer changes coordinates.
  11875. */
  11876. static readonly POINTERMOVE: number;
  11877. /**
  11878. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11879. */
  11880. static readonly POINTERWHEEL: number;
  11881. /**
  11882. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11883. */
  11884. static readonly POINTERPICK: number;
  11885. /**
  11886. * The pointertap event is fired when a the object has been touched and released without drag.
  11887. */
  11888. static readonly POINTERTAP: number;
  11889. /**
  11890. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11891. */
  11892. static readonly POINTERDOUBLETAP: number;
  11893. }
  11894. /**
  11895. * Base class of pointer info types.
  11896. */
  11897. export class PointerInfoBase {
  11898. /**
  11899. * Defines the type of event (PointerEventTypes)
  11900. */
  11901. type: number;
  11902. /**
  11903. * Defines the related dom event
  11904. */
  11905. event: PointerEvent | MouseWheelEvent;
  11906. /**
  11907. * Instantiates the base class of pointers info.
  11908. * @param type Defines the type of event (PointerEventTypes)
  11909. * @param event Defines the related dom event
  11910. */
  11911. constructor(
  11912. /**
  11913. * Defines the type of event (PointerEventTypes)
  11914. */
  11915. type: number,
  11916. /**
  11917. * Defines the related dom event
  11918. */
  11919. event: PointerEvent | MouseWheelEvent);
  11920. }
  11921. /**
  11922. * This class is used to store pointer related info for the onPrePointerObservable event.
  11923. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11924. */
  11925. export class PointerInfoPre extends PointerInfoBase {
  11926. /**
  11927. * Ray from a pointer if availible (eg. 6dof controller)
  11928. */
  11929. ray: Nullable<Ray>;
  11930. /**
  11931. * Defines the local position of the pointer on the canvas.
  11932. */
  11933. localPosition: Vector2;
  11934. /**
  11935. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11936. */
  11937. skipOnPointerObservable: boolean;
  11938. /**
  11939. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11940. * @param type Defines the type of event (PointerEventTypes)
  11941. * @param event Defines the related dom event
  11942. * @param localX Defines the local x coordinates of the pointer when the event occured
  11943. * @param localY Defines the local y coordinates of the pointer when the event occured
  11944. */
  11945. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11946. }
  11947. /**
  11948. * This type contains all the data related to a pointer event in Babylon.js.
  11949. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  11950. */
  11951. export class PointerInfo extends PointerInfoBase {
  11952. /**
  11953. * Defines the picking info associated to the info (if any)\
  11954. */
  11955. pickInfo: Nullable<PickingInfo>;
  11956. /**
  11957. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11958. * @param type Defines the type of event (PointerEventTypes)
  11959. * @param event Defines the related dom event
  11960. * @param pickInfo Defines the picking info associated to the info (if any)\
  11961. */
  11962. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11963. /**
  11964. * Defines the picking info associated to the info (if any)\
  11965. */
  11966. pickInfo: Nullable<PickingInfo>);
  11967. }
  11968. /**
  11969. * Data relating to a touch event on the screen.
  11970. */
  11971. export interface PointerTouch {
  11972. /**
  11973. * X coordinate of touch.
  11974. */
  11975. x: number;
  11976. /**
  11977. * Y coordinate of touch.
  11978. */
  11979. y: number;
  11980. /**
  11981. * Id of touch. Unique for each finger.
  11982. */
  11983. pointerId: number;
  11984. /**
  11985. * Event type passed from DOM.
  11986. */
  11987. type: any;
  11988. }
  11989. }
  11990. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11991. import { Observable } from "babylonjs/Misc/observable";
  11992. import { Nullable } from "babylonjs/types";
  11993. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11994. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11995. /**
  11996. * Manage the mouse inputs to control the movement of a free camera.
  11997. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11998. */
  11999. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12000. /**
  12001. * Define if touch is enabled in the mouse input
  12002. */
  12003. touchEnabled: boolean;
  12004. /**
  12005. * Defines the camera the input is attached to.
  12006. */
  12007. camera: FreeCamera;
  12008. /**
  12009. * Defines the buttons associated with the input to handle camera move.
  12010. */
  12011. buttons: number[];
  12012. /**
  12013. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12014. */
  12015. angularSensibility: number;
  12016. private _pointerInput;
  12017. private _onMouseMove;
  12018. private _observer;
  12019. private previousPosition;
  12020. /**
  12021. * Observable for when a pointer move event occurs containing the move offset
  12022. */
  12023. onPointerMovedObservable: Observable<{
  12024. offsetX: number;
  12025. offsetY: number;
  12026. }>;
  12027. /**
  12028. * @hidden
  12029. * If the camera should be rotated automatically based on pointer movement
  12030. */
  12031. _allowCameraRotation: boolean;
  12032. /**
  12033. * Manage the mouse inputs to control the movement of a free camera.
  12034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12035. * @param touchEnabled Defines if touch is enabled or not
  12036. */
  12037. constructor(
  12038. /**
  12039. * Define if touch is enabled in the mouse input
  12040. */
  12041. touchEnabled?: boolean);
  12042. /**
  12043. * Attach the input controls to a specific dom element to get the input from.
  12044. * @param element Defines the element the controls should be listened from
  12045. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12046. */
  12047. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12048. /**
  12049. * Called on JS contextmenu event.
  12050. * Override this method to provide functionality.
  12051. */
  12052. protected onContextMenu(evt: PointerEvent): void;
  12053. /**
  12054. * Detach the current controls from the specified dom element.
  12055. * @param element Defines the element to stop listening the inputs from
  12056. */
  12057. detachControl(element: Nullable<HTMLElement>): void;
  12058. /**
  12059. * Gets the class name of the current intput.
  12060. * @returns the class name
  12061. */
  12062. getClassName(): string;
  12063. /**
  12064. * Get the friendly name associated with the input class.
  12065. * @returns the input friendly name
  12066. */
  12067. getSimpleName(): string;
  12068. }
  12069. }
  12070. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12071. import { Nullable } from "babylonjs/types";
  12072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12073. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12074. /**
  12075. * Manage the touch inputs to control the movement of a free camera.
  12076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12077. */
  12078. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12079. /**
  12080. * Defines the camera the input is attached to.
  12081. */
  12082. camera: FreeCamera;
  12083. /**
  12084. * Defines the touch sensibility for rotation.
  12085. * The higher the faster.
  12086. */
  12087. touchAngularSensibility: number;
  12088. /**
  12089. * Defines the touch sensibility for move.
  12090. * The higher the faster.
  12091. */
  12092. touchMoveSensibility: number;
  12093. private _offsetX;
  12094. private _offsetY;
  12095. private _pointerPressed;
  12096. private _pointerInput;
  12097. private _observer;
  12098. private _onLostFocus;
  12099. /**
  12100. * Attach the input controls to a specific dom element to get the input from.
  12101. * @param element Defines the element the controls should be listened from
  12102. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12103. */
  12104. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12105. /**
  12106. * Detach the current controls from the specified dom element.
  12107. * @param element Defines the element to stop listening the inputs from
  12108. */
  12109. detachControl(element: Nullable<HTMLElement>): void;
  12110. /**
  12111. * Update the current camera state depending on the inputs that have been used this frame.
  12112. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12113. */
  12114. checkInputs(): void;
  12115. /**
  12116. * Gets the class name of the current intput.
  12117. * @returns the class name
  12118. */
  12119. getClassName(): string;
  12120. /**
  12121. * Get the friendly name associated with the input class.
  12122. * @returns the input friendly name
  12123. */
  12124. getSimpleName(): string;
  12125. }
  12126. }
  12127. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12129. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12130. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12131. import { Nullable } from "babylonjs/types";
  12132. /**
  12133. * Default Inputs manager for the FreeCamera.
  12134. * It groups all the default supported inputs for ease of use.
  12135. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12136. */
  12137. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12138. /**
  12139. * @hidden
  12140. */
  12141. _mouseInput: Nullable<FreeCameraMouseInput>;
  12142. /**
  12143. * Instantiates a new FreeCameraInputsManager.
  12144. * @param camera Defines the camera the inputs belong to
  12145. */
  12146. constructor(camera: FreeCamera);
  12147. /**
  12148. * Add keyboard input support to the input manager.
  12149. * @returns the current input manager
  12150. */
  12151. addKeyboard(): FreeCameraInputsManager;
  12152. /**
  12153. * Add mouse input support to the input manager.
  12154. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12155. * @returns the current input manager
  12156. */
  12157. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12158. /**
  12159. * Removes the mouse input support from the manager
  12160. * @returns the current input manager
  12161. */
  12162. removeMouse(): FreeCameraInputsManager;
  12163. /**
  12164. * Add touch input support to the input manager.
  12165. * @returns the current input manager
  12166. */
  12167. addTouch(): FreeCameraInputsManager;
  12168. /**
  12169. * Remove all attached input methods from a camera
  12170. */
  12171. clear(): void;
  12172. }
  12173. }
  12174. declare module "babylonjs/Cameras/freeCamera" {
  12175. import { Vector3 } from "babylonjs/Maths/math.vector";
  12176. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12177. import { Scene } from "babylonjs/scene";
  12178. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12179. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12180. /**
  12181. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12182. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12183. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12184. */
  12185. export class FreeCamera extends TargetCamera {
  12186. /**
  12187. * Define the collision ellipsoid of the camera.
  12188. * This is helpful to simulate a camera body like the player body around the camera
  12189. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12190. */
  12191. ellipsoid: Vector3;
  12192. /**
  12193. * Define an offset for the position of the ellipsoid around the camera.
  12194. * This can be helpful to determine the center of the body near the gravity center of the body
  12195. * instead of its head.
  12196. */
  12197. ellipsoidOffset: Vector3;
  12198. /**
  12199. * Enable or disable collisions of the camera with the rest of the scene objects.
  12200. */
  12201. checkCollisions: boolean;
  12202. /**
  12203. * Enable or disable gravity on the camera.
  12204. */
  12205. applyGravity: boolean;
  12206. /**
  12207. * Define the input manager associated to the camera.
  12208. */
  12209. inputs: FreeCameraInputsManager;
  12210. /**
  12211. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12212. * Higher values reduce sensitivity.
  12213. */
  12214. /**
  12215. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12216. * Higher values reduce sensitivity.
  12217. */
  12218. angularSensibility: number;
  12219. /**
  12220. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12221. */
  12222. keysUp: number[];
  12223. /**
  12224. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12225. */
  12226. keysDown: number[];
  12227. /**
  12228. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12229. */
  12230. keysLeft: number[];
  12231. /**
  12232. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12233. */
  12234. keysRight: number[];
  12235. /**
  12236. * Event raised when the camera collide with a mesh in the scene.
  12237. */
  12238. onCollide: (collidedMesh: AbstractMesh) => void;
  12239. private _collider;
  12240. private _needMoveForGravity;
  12241. private _oldPosition;
  12242. private _diffPosition;
  12243. private _newPosition;
  12244. /** @hidden */
  12245. _localDirection: Vector3;
  12246. /** @hidden */
  12247. _transformedDirection: Vector3;
  12248. /**
  12249. * Instantiates a Free Camera.
  12250. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12251. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12252. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12253. * @param name Define the name of the camera in the scene
  12254. * @param position Define the start position of the camera in the scene
  12255. * @param scene Define the scene the camera belongs to
  12256. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12257. */
  12258. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12259. /**
  12260. * Attached controls to the current camera.
  12261. * @param element Defines the element the controls should be listened from
  12262. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12263. */
  12264. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12265. /**
  12266. * Detach the current controls from the camera.
  12267. * The camera will stop reacting to inputs.
  12268. * @param element Defines the element to stop listening the inputs from
  12269. */
  12270. detachControl(element: HTMLElement): void;
  12271. private _collisionMask;
  12272. /**
  12273. * Define a collision mask to limit the list of object the camera can collide with
  12274. */
  12275. collisionMask: number;
  12276. /** @hidden */
  12277. _collideWithWorld(displacement: Vector3): void;
  12278. private _onCollisionPositionChange;
  12279. /** @hidden */
  12280. _checkInputs(): void;
  12281. /** @hidden */
  12282. _decideIfNeedsToMove(): boolean;
  12283. /** @hidden */
  12284. _updatePosition(): void;
  12285. /**
  12286. * Destroy the camera and release the current resources hold by it.
  12287. */
  12288. dispose(): void;
  12289. /**
  12290. * Gets the current object class name.
  12291. * @return the class name
  12292. */
  12293. getClassName(): string;
  12294. }
  12295. }
  12296. declare module "babylonjs/Gamepads/gamepad" {
  12297. import { Observable } from "babylonjs/Misc/observable";
  12298. /**
  12299. * Represents a gamepad control stick position
  12300. */
  12301. export class StickValues {
  12302. /**
  12303. * The x component of the control stick
  12304. */
  12305. x: number;
  12306. /**
  12307. * The y component of the control stick
  12308. */
  12309. y: number;
  12310. /**
  12311. * Initializes the gamepad x and y control stick values
  12312. * @param x The x component of the gamepad control stick value
  12313. * @param y The y component of the gamepad control stick value
  12314. */
  12315. constructor(
  12316. /**
  12317. * The x component of the control stick
  12318. */
  12319. x: number,
  12320. /**
  12321. * The y component of the control stick
  12322. */
  12323. y: number);
  12324. }
  12325. /**
  12326. * An interface which manages callbacks for gamepad button changes
  12327. */
  12328. export interface GamepadButtonChanges {
  12329. /**
  12330. * Called when a gamepad has been changed
  12331. */
  12332. changed: boolean;
  12333. /**
  12334. * Called when a gamepad press event has been triggered
  12335. */
  12336. pressChanged: boolean;
  12337. /**
  12338. * Called when a touch event has been triggered
  12339. */
  12340. touchChanged: boolean;
  12341. /**
  12342. * Called when a value has changed
  12343. */
  12344. valueChanged: boolean;
  12345. }
  12346. /**
  12347. * Represents a gamepad
  12348. */
  12349. export class Gamepad {
  12350. /**
  12351. * The id of the gamepad
  12352. */
  12353. id: string;
  12354. /**
  12355. * The index of the gamepad
  12356. */
  12357. index: number;
  12358. /**
  12359. * The browser gamepad
  12360. */
  12361. browserGamepad: any;
  12362. /**
  12363. * Specifies what type of gamepad this represents
  12364. */
  12365. type: number;
  12366. private _leftStick;
  12367. private _rightStick;
  12368. /** @hidden */
  12369. _isConnected: boolean;
  12370. private _leftStickAxisX;
  12371. private _leftStickAxisY;
  12372. private _rightStickAxisX;
  12373. private _rightStickAxisY;
  12374. /**
  12375. * Triggered when the left control stick has been changed
  12376. */
  12377. private _onleftstickchanged;
  12378. /**
  12379. * Triggered when the right control stick has been changed
  12380. */
  12381. private _onrightstickchanged;
  12382. /**
  12383. * Represents a gamepad controller
  12384. */
  12385. static GAMEPAD: number;
  12386. /**
  12387. * Represents a generic controller
  12388. */
  12389. static GENERIC: number;
  12390. /**
  12391. * Represents an XBox controller
  12392. */
  12393. static XBOX: number;
  12394. /**
  12395. * Represents a pose-enabled controller
  12396. */
  12397. static POSE_ENABLED: number;
  12398. /**
  12399. * Represents an Dual Shock controller
  12400. */
  12401. static DUALSHOCK: number;
  12402. /**
  12403. * Specifies whether the left control stick should be Y-inverted
  12404. */
  12405. protected _invertLeftStickY: boolean;
  12406. /**
  12407. * Specifies if the gamepad has been connected
  12408. */
  12409. readonly isConnected: boolean;
  12410. /**
  12411. * Initializes the gamepad
  12412. * @param id The id of the gamepad
  12413. * @param index The index of the gamepad
  12414. * @param browserGamepad The browser gamepad
  12415. * @param leftStickX The x component of the left joystick
  12416. * @param leftStickY The y component of the left joystick
  12417. * @param rightStickX The x component of the right joystick
  12418. * @param rightStickY The y component of the right joystick
  12419. */
  12420. constructor(
  12421. /**
  12422. * The id of the gamepad
  12423. */
  12424. id: string,
  12425. /**
  12426. * The index of the gamepad
  12427. */
  12428. index: number,
  12429. /**
  12430. * The browser gamepad
  12431. */
  12432. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12433. /**
  12434. * Callback triggered when the left joystick has changed
  12435. * @param callback
  12436. */
  12437. onleftstickchanged(callback: (values: StickValues) => void): void;
  12438. /**
  12439. * Callback triggered when the right joystick has changed
  12440. * @param callback
  12441. */
  12442. onrightstickchanged(callback: (values: StickValues) => void): void;
  12443. /**
  12444. * Gets the left joystick
  12445. */
  12446. /**
  12447. * Sets the left joystick values
  12448. */
  12449. leftStick: StickValues;
  12450. /**
  12451. * Gets the right joystick
  12452. */
  12453. /**
  12454. * Sets the right joystick value
  12455. */
  12456. rightStick: StickValues;
  12457. /**
  12458. * Updates the gamepad joystick positions
  12459. */
  12460. update(): void;
  12461. /**
  12462. * Disposes the gamepad
  12463. */
  12464. dispose(): void;
  12465. }
  12466. /**
  12467. * Represents a generic gamepad
  12468. */
  12469. export class GenericPad extends Gamepad {
  12470. private _buttons;
  12471. private _onbuttondown;
  12472. private _onbuttonup;
  12473. /**
  12474. * Observable triggered when a button has been pressed
  12475. */
  12476. onButtonDownObservable: Observable<number>;
  12477. /**
  12478. * Observable triggered when a button has been released
  12479. */
  12480. onButtonUpObservable: Observable<number>;
  12481. /**
  12482. * Callback triggered when a button has been pressed
  12483. * @param callback Called when a button has been pressed
  12484. */
  12485. onbuttondown(callback: (buttonPressed: number) => void): void;
  12486. /**
  12487. * Callback triggered when a button has been released
  12488. * @param callback Called when a button has been released
  12489. */
  12490. onbuttonup(callback: (buttonReleased: number) => void): void;
  12491. /**
  12492. * Initializes the generic gamepad
  12493. * @param id The id of the generic gamepad
  12494. * @param index The index of the generic gamepad
  12495. * @param browserGamepad The browser gamepad
  12496. */
  12497. constructor(id: string, index: number, browserGamepad: any);
  12498. private _setButtonValue;
  12499. /**
  12500. * Updates the generic gamepad
  12501. */
  12502. update(): void;
  12503. /**
  12504. * Disposes the generic gamepad
  12505. */
  12506. dispose(): void;
  12507. }
  12508. }
  12509. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12510. import { Nullable } from "babylonjs/types";
  12511. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12512. import { Scene } from "babylonjs/scene";
  12513. module "babylonjs/Engines/engine" {
  12514. interface Engine {
  12515. /**
  12516. * Creates a raw texture
  12517. * @param data defines the data to store in the texture
  12518. * @param width defines the width of the texture
  12519. * @param height defines the height of the texture
  12520. * @param format defines the format of the data
  12521. * @param generateMipMaps defines if the engine should generate the mip levels
  12522. * @param invertY defines if data must be stored with Y axis inverted
  12523. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12524. * @param compression defines the compression used (null by default)
  12525. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12526. * @returns the raw texture inside an InternalTexture
  12527. */
  12528. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12529. /**
  12530. * Update a raw texture
  12531. * @param texture defines the texture to update
  12532. * @param data defines the data to store in the texture
  12533. * @param format defines the format of the data
  12534. * @param invertY defines if data must be stored with Y axis inverted
  12535. */
  12536. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12537. /**
  12538. * Update a raw texture
  12539. * @param texture defines the texture to update
  12540. * @param data defines the data to store in the texture
  12541. * @param format defines the format of the data
  12542. * @param invertY defines if data must be stored with Y axis inverted
  12543. * @param compression defines the compression used (null by default)
  12544. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12545. */
  12546. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12547. /**
  12548. * Creates a new raw cube texture
  12549. * @param data defines the array of data to use to create each face
  12550. * @param size defines the size of the textures
  12551. * @param format defines the format of the data
  12552. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12553. * @param generateMipMaps defines if the engine should generate the mip levels
  12554. * @param invertY defines if data must be stored with Y axis inverted
  12555. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12556. * @param compression defines the compression used (null by default)
  12557. * @returns the cube texture as an InternalTexture
  12558. */
  12559. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12560. /**
  12561. * Update a raw cube texture
  12562. * @param texture defines the texture to udpdate
  12563. * @param data defines the data to store
  12564. * @param format defines the data format
  12565. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12566. * @param invertY defines if data must be stored with Y axis inverted
  12567. */
  12568. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12569. /**
  12570. * Update a raw cube texture
  12571. * @param texture defines the texture to udpdate
  12572. * @param data defines the data to store
  12573. * @param format defines the data format
  12574. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12575. * @param invertY defines if data must be stored with Y axis inverted
  12576. * @param compression defines the compression used (null by default)
  12577. */
  12578. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12579. /**
  12580. * Update a raw cube texture
  12581. * @param texture defines the texture to udpdate
  12582. * @param data defines the data to store
  12583. * @param format defines the data format
  12584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12585. * @param invertY defines if data must be stored with Y axis inverted
  12586. * @param compression defines the compression used (null by default)
  12587. * @param level defines which level of the texture to update
  12588. */
  12589. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12590. /**
  12591. * Creates a new raw cube texture from a specified url
  12592. * @param url defines the url where the data is located
  12593. * @param scene defines the current scene
  12594. * @param size defines the size of the textures
  12595. * @param format defines the format of the data
  12596. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12597. * @param noMipmap defines if the engine should avoid generating the mip levels
  12598. * @param callback defines a callback used to extract texture data from loaded data
  12599. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12600. * @param onLoad defines a callback called when texture is loaded
  12601. * @param onError defines a callback called if there is an error
  12602. * @returns the cube texture as an InternalTexture
  12603. */
  12604. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  12605. /**
  12606. * Creates a new raw cube texture from a specified url
  12607. * @param url defines the url where the data is located
  12608. * @param scene defines the current scene
  12609. * @param size defines the size of the textures
  12610. * @param format defines the format of the data
  12611. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12612. * @param noMipmap defines if the engine should avoid generating the mip levels
  12613. * @param callback defines a callback used to extract texture data from loaded data
  12614. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12615. * @param onLoad defines a callback called when texture is loaded
  12616. * @param onError defines a callback called if there is an error
  12617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12618. * @param invertY defines if data must be stored with Y axis inverted
  12619. * @returns the cube texture as an InternalTexture
  12620. */
  12621. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  12622. /**
  12623. * Creates a new raw 3D texture
  12624. * @param data defines the data used to create the texture
  12625. * @param width defines the width of the texture
  12626. * @param height defines the height of the texture
  12627. * @param depth defines the depth of the texture
  12628. * @param format defines the format of the texture
  12629. * @param generateMipMaps defines if the engine must generate mip levels
  12630. * @param invertY defines if data must be stored with Y axis inverted
  12631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12632. * @param compression defines the compressed used (can be null)
  12633. * @param textureType defines the compressed used (can be null)
  12634. * @returns a new raw 3D texture (stored in an InternalTexture)
  12635. */
  12636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12637. /**
  12638. * Update a raw 3D texture
  12639. * @param texture defines the texture to update
  12640. * @param data defines the data to store
  12641. * @param format defines the data format
  12642. * @param invertY defines if data must be stored with Y axis inverted
  12643. */
  12644. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12645. /**
  12646. * Update a raw 3D texture
  12647. * @param texture defines the texture to update
  12648. * @param data defines the data to store
  12649. * @param format defines the data format
  12650. * @param invertY defines if data must be stored with Y axis inverted
  12651. * @param compression defines the used compression (can be null)
  12652. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12653. */
  12654. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12655. }
  12656. }
  12657. }
  12658. declare module "babylonjs/Materials/Textures/rawTexture" {
  12659. import { Scene } from "babylonjs/scene";
  12660. import { Texture } from "babylonjs/Materials/Textures/texture";
  12661. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12662. /**
  12663. * Raw texture can help creating a texture directly from an array of data.
  12664. * This can be super useful if you either get the data from an uncompressed source or
  12665. * if you wish to create your texture pixel by pixel.
  12666. */
  12667. export class RawTexture extends Texture {
  12668. /**
  12669. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12670. */
  12671. format: number;
  12672. private _engine;
  12673. /**
  12674. * Instantiates a new RawTexture.
  12675. * Raw texture can help creating a texture directly from an array of data.
  12676. * This can be super useful if you either get the data from an uncompressed source or
  12677. * if you wish to create your texture pixel by pixel.
  12678. * @param data define the array of data to use to create the texture
  12679. * @param width define the width of the texture
  12680. * @param height define the height of the texture
  12681. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12682. * @param scene define the scene the texture belongs to
  12683. * @param generateMipMaps define whether mip maps should be generated or not
  12684. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12685. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12686. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12687. */
  12688. constructor(data: ArrayBufferView, width: number, height: number,
  12689. /**
  12690. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12691. */
  12692. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12693. /**
  12694. * Updates the texture underlying data.
  12695. * @param data Define the new data of the texture
  12696. */
  12697. update(data: ArrayBufferView): void;
  12698. /**
  12699. * Creates a luminance texture from some data.
  12700. * @param data Define the texture data
  12701. * @param width Define the width of the texture
  12702. * @param height Define the height of the texture
  12703. * @param scene Define the scene the texture belongs to
  12704. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12705. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12706. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12707. * @returns the luminance texture
  12708. */
  12709. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12710. /**
  12711. * Creates a luminance alpha texture from some data.
  12712. * @param data Define the texture data
  12713. * @param width Define the width of the texture
  12714. * @param height Define the height of the texture
  12715. * @param scene Define the scene the texture belongs to
  12716. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12717. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12718. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12719. * @returns the luminance alpha texture
  12720. */
  12721. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12722. /**
  12723. * Creates an alpha texture from some data.
  12724. * @param data Define the texture data
  12725. * @param width Define the width of the texture
  12726. * @param height Define the height of the texture
  12727. * @param scene Define the scene the texture belongs to
  12728. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12729. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12730. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12731. * @returns the alpha texture
  12732. */
  12733. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12734. /**
  12735. * Creates a RGB texture from some data.
  12736. * @param data Define the texture data
  12737. * @param width Define the width of the texture
  12738. * @param height Define the height of the texture
  12739. * @param scene Define the scene the texture belongs to
  12740. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12741. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12742. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12743. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12744. * @returns the RGB alpha texture
  12745. */
  12746. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12747. /**
  12748. * Creates a RGBA texture from some data.
  12749. * @param data Define the texture data
  12750. * @param width Define the width of the texture
  12751. * @param height Define the height of the texture
  12752. * @param scene Define the scene the texture belongs to
  12753. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12754. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12755. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12756. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12757. * @returns the RGBA texture
  12758. */
  12759. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12760. /**
  12761. * Creates a R texture from some data.
  12762. * @param data Define the texture data
  12763. * @param width Define the width of the texture
  12764. * @param height Define the height of the texture
  12765. * @param scene Define the scene the texture belongs to
  12766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12769. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12770. * @returns the R texture
  12771. */
  12772. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12773. }
  12774. }
  12775. declare module "babylonjs/Maths/math.size" {
  12776. /**
  12777. * Interface for the size containing width and height
  12778. */
  12779. export interface ISize {
  12780. /**
  12781. * Width
  12782. */
  12783. width: number;
  12784. /**
  12785. * Heighht
  12786. */
  12787. height: number;
  12788. }
  12789. /**
  12790. * Size containing widht and height
  12791. */
  12792. export class Size implements ISize {
  12793. /**
  12794. * Width
  12795. */
  12796. width: number;
  12797. /**
  12798. * Height
  12799. */
  12800. height: number;
  12801. /**
  12802. * Creates a Size object from the given width and height (floats).
  12803. * @param width width of the new size
  12804. * @param height height of the new size
  12805. */
  12806. constructor(width: number, height: number);
  12807. /**
  12808. * Returns a string with the Size width and height
  12809. * @returns a string with the Size width and height
  12810. */
  12811. toString(): string;
  12812. /**
  12813. * "Size"
  12814. * @returns the string "Size"
  12815. */
  12816. getClassName(): string;
  12817. /**
  12818. * Returns the Size hash code.
  12819. * @returns a hash code for a unique width and height
  12820. */
  12821. getHashCode(): number;
  12822. /**
  12823. * Updates the current size from the given one.
  12824. * @param src the given size
  12825. */
  12826. copyFrom(src: Size): void;
  12827. /**
  12828. * Updates in place the current Size from the given floats.
  12829. * @param width width of the new size
  12830. * @param height height of the new size
  12831. * @returns the updated Size.
  12832. */
  12833. copyFromFloats(width: number, height: number): Size;
  12834. /**
  12835. * Updates in place the current Size from the given floats.
  12836. * @param width width to set
  12837. * @param height height to set
  12838. * @returns the updated Size.
  12839. */
  12840. set(width: number, height: number): Size;
  12841. /**
  12842. * Multiplies the width and height by numbers
  12843. * @param w factor to multiple the width by
  12844. * @param h factor to multiple the height by
  12845. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12846. */
  12847. multiplyByFloats(w: number, h: number): Size;
  12848. /**
  12849. * Clones the size
  12850. * @returns a new Size copied from the given one.
  12851. */
  12852. clone(): Size;
  12853. /**
  12854. * True if the current Size and the given one width and height are strictly equal.
  12855. * @param other the other size to compare against
  12856. * @returns True if the current Size and the given one width and height are strictly equal.
  12857. */
  12858. equals(other: Size): boolean;
  12859. /**
  12860. * The surface of the Size : width * height (float).
  12861. */
  12862. readonly surface: number;
  12863. /**
  12864. * Create a new size of zero
  12865. * @returns a new Size set to (0.0, 0.0)
  12866. */
  12867. static Zero(): Size;
  12868. /**
  12869. * Sums the width and height of two sizes
  12870. * @param otherSize size to add to this size
  12871. * @returns a new Size set as the addition result of the current Size and the given one.
  12872. */
  12873. add(otherSize: Size): Size;
  12874. /**
  12875. * Subtracts the width and height of two
  12876. * @param otherSize size to subtract to this size
  12877. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12878. */
  12879. subtract(otherSize: Size): Size;
  12880. /**
  12881. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12882. * @param start starting size to lerp between
  12883. * @param end end size to lerp between
  12884. * @param amount amount to lerp between the start and end values
  12885. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12886. */
  12887. static Lerp(start: Size, end: Size, amount: number): Size;
  12888. }
  12889. }
  12890. declare module "babylonjs/Animations/runtimeAnimation" {
  12891. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12892. import { Animatable } from "babylonjs/Animations/animatable";
  12893. import { Scene } from "babylonjs/scene";
  12894. /**
  12895. * Defines a runtime animation
  12896. */
  12897. export class RuntimeAnimation {
  12898. private _events;
  12899. /**
  12900. * The current frame of the runtime animation
  12901. */
  12902. private _currentFrame;
  12903. /**
  12904. * The animation used by the runtime animation
  12905. */
  12906. private _animation;
  12907. /**
  12908. * The target of the runtime animation
  12909. */
  12910. private _target;
  12911. /**
  12912. * The initiating animatable
  12913. */
  12914. private _host;
  12915. /**
  12916. * The original value of the runtime animation
  12917. */
  12918. private _originalValue;
  12919. /**
  12920. * The original blend value of the runtime animation
  12921. */
  12922. private _originalBlendValue;
  12923. /**
  12924. * The offsets cache of the runtime animation
  12925. */
  12926. private _offsetsCache;
  12927. /**
  12928. * The high limits cache of the runtime animation
  12929. */
  12930. private _highLimitsCache;
  12931. /**
  12932. * Specifies if the runtime animation has been stopped
  12933. */
  12934. private _stopped;
  12935. /**
  12936. * The blending factor of the runtime animation
  12937. */
  12938. private _blendingFactor;
  12939. /**
  12940. * The BabylonJS scene
  12941. */
  12942. private _scene;
  12943. /**
  12944. * The current value of the runtime animation
  12945. */
  12946. private _currentValue;
  12947. /** @hidden */
  12948. _animationState: _IAnimationState;
  12949. /**
  12950. * The active target of the runtime animation
  12951. */
  12952. private _activeTargets;
  12953. private _currentActiveTarget;
  12954. private _directTarget;
  12955. /**
  12956. * The target path of the runtime animation
  12957. */
  12958. private _targetPath;
  12959. /**
  12960. * The weight of the runtime animation
  12961. */
  12962. private _weight;
  12963. /**
  12964. * The ratio offset of the runtime animation
  12965. */
  12966. private _ratioOffset;
  12967. /**
  12968. * The previous delay of the runtime animation
  12969. */
  12970. private _previousDelay;
  12971. /**
  12972. * The previous ratio of the runtime animation
  12973. */
  12974. private _previousRatio;
  12975. private _enableBlending;
  12976. private _keys;
  12977. private _minFrame;
  12978. private _maxFrame;
  12979. private _minValue;
  12980. private _maxValue;
  12981. private _targetIsArray;
  12982. /**
  12983. * Gets the current frame of the runtime animation
  12984. */
  12985. readonly currentFrame: number;
  12986. /**
  12987. * Gets the weight of the runtime animation
  12988. */
  12989. readonly weight: number;
  12990. /**
  12991. * Gets the current value of the runtime animation
  12992. */
  12993. readonly currentValue: any;
  12994. /**
  12995. * Gets the target path of the runtime animation
  12996. */
  12997. readonly targetPath: string;
  12998. /**
  12999. * Gets the actual target of the runtime animation
  13000. */
  13001. readonly target: any;
  13002. /** @hidden */
  13003. _onLoop: () => void;
  13004. /**
  13005. * Create a new RuntimeAnimation object
  13006. * @param target defines the target of the animation
  13007. * @param animation defines the source animation object
  13008. * @param scene defines the hosting scene
  13009. * @param host defines the initiating Animatable
  13010. */
  13011. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13012. private _preparePath;
  13013. /**
  13014. * Gets the animation from the runtime animation
  13015. */
  13016. readonly animation: Animation;
  13017. /**
  13018. * Resets the runtime animation to the beginning
  13019. * @param restoreOriginal defines whether to restore the target property to the original value
  13020. */
  13021. reset(restoreOriginal?: boolean): void;
  13022. /**
  13023. * Specifies if the runtime animation is stopped
  13024. * @returns Boolean specifying if the runtime animation is stopped
  13025. */
  13026. isStopped(): boolean;
  13027. /**
  13028. * Disposes of the runtime animation
  13029. */
  13030. dispose(): void;
  13031. /**
  13032. * Apply the interpolated value to the target
  13033. * @param currentValue defines the value computed by the animation
  13034. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13035. */
  13036. setValue(currentValue: any, weight: number): void;
  13037. private _getOriginalValues;
  13038. private _setValue;
  13039. /**
  13040. * Gets the loop pmode of the runtime animation
  13041. * @returns Loop Mode
  13042. */
  13043. private _getCorrectLoopMode;
  13044. /**
  13045. * Move the current animation to a given frame
  13046. * @param frame defines the frame to move to
  13047. */
  13048. goToFrame(frame: number): void;
  13049. /**
  13050. * @hidden Internal use only
  13051. */
  13052. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13053. /**
  13054. * Execute the current animation
  13055. * @param delay defines the delay to add to the current frame
  13056. * @param from defines the lower bound of the animation range
  13057. * @param to defines the upper bound of the animation range
  13058. * @param loop defines if the current animation must loop
  13059. * @param speedRatio defines the current speed ratio
  13060. * @param weight defines the weight of the animation (default is -1 so no weight)
  13061. * @param onLoop optional callback called when animation loops
  13062. * @returns a boolean indicating if the animation is running
  13063. */
  13064. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13065. }
  13066. }
  13067. declare module "babylonjs/Animations/animatable" {
  13068. import { Animation } from "babylonjs/Animations/animation";
  13069. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13070. import { Nullable } from "babylonjs/types";
  13071. import { Observable } from "babylonjs/Misc/observable";
  13072. import { Scene } from "babylonjs/scene";
  13073. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13074. import { Node } from "babylonjs/node";
  13075. /**
  13076. * Class used to store an actual running animation
  13077. */
  13078. export class Animatable {
  13079. /** defines the target object */
  13080. target: any;
  13081. /** defines the starting frame number (default is 0) */
  13082. fromFrame: number;
  13083. /** defines the ending frame number (default is 100) */
  13084. toFrame: number;
  13085. /** defines if the animation must loop (default is false) */
  13086. loopAnimation: boolean;
  13087. /** defines a callback to call when animation ends if it is not looping */
  13088. onAnimationEnd?: (() => void) | null | undefined;
  13089. /** defines a callback to call when animation loops */
  13090. onAnimationLoop?: (() => void) | null | undefined;
  13091. private _localDelayOffset;
  13092. private _pausedDelay;
  13093. private _runtimeAnimations;
  13094. private _paused;
  13095. private _scene;
  13096. private _speedRatio;
  13097. private _weight;
  13098. private _syncRoot;
  13099. /**
  13100. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13101. * This will only apply for non looping animation (default is true)
  13102. */
  13103. disposeOnEnd: boolean;
  13104. /**
  13105. * Gets a boolean indicating if the animation has started
  13106. */
  13107. animationStarted: boolean;
  13108. /**
  13109. * Observer raised when the animation ends
  13110. */
  13111. onAnimationEndObservable: Observable<Animatable>;
  13112. /**
  13113. * Observer raised when the animation loops
  13114. */
  13115. onAnimationLoopObservable: Observable<Animatable>;
  13116. /**
  13117. * Gets the root Animatable used to synchronize and normalize animations
  13118. */
  13119. readonly syncRoot: Nullable<Animatable>;
  13120. /**
  13121. * Gets the current frame of the first RuntimeAnimation
  13122. * Used to synchronize Animatables
  13123. */
  13124. readonly masterFrame: number;
  13125. /**
  13126. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13127. */
  13128. weight: number;
  13129. /**
  13130. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13131. */
  13132. speedRatio: number;
  13133. /**
  13134. * Creates a new Animatable
  13135. * @param scene defines the hosting scene
  13136. * @param target defines the target object
  13137. * @param fromFrame defines the starting frame number (default is 0)
  13138. * @param toFrame defines the ending frame number (default is 100)
  13139. * @param loopAnimation defines if the animation must loop (default is false)
  13140. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13141. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13142. * @param animations defines a group of animation to add to the new Animatable
  13143. * @param onAnimationLoop defines a callback to call when animation loops
  13144. */
  13145. constructor(scene: Scene,
  13146. /** defines the target object */
  13147. target: any,
  13148. /** defines the starting frame number (default is 0) */
  13149. fromFrame?: number,
  13150. /** defines the ending frame number (default is 100) */
  13151. toFrame?: number,
  13152. /** defines if the animation must loop (default is false) */
  13153. loopAnimation?: boolean, speedRatio?: number,
  13154. /** defines a callback to call when animation ends if it is not looping */
  13155. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13156. /** defines a callback to call when animation loops */
  13157. onAnimationLoop?: (() => void) | null | undefined);
  13158. /**
  13159. * Synchronize and normalize current Animatable with a source Animatable
  13160. * This is useful when using animation weights and when animations are not of the same length
  13161. * @param root defines the root Animatable to synchronize with
  13162. * @returns the current Animatable
  13163. */
  13164. syncWith(root: Animatable): Animatable;
  13165. /**
  13166. * Gets the list of runtime animations
  13167. * @returns an array of RuntimeAnimation
  13168. */
  13169. getAnimations(): RuntimeAnimation[];
  13170. /**
  13171. * Adds more animations to the current animatable
  13172. * @param target defines the target of the animations
  13173. * @param animations defines the new animations to add
  13174. */
  13175. appendAnimations(target: any, animations: Animation[]): void;
  13176. /**
  13177. * Gets the source animation for a specific property
  13178. * @param property defines the propertyu to look for
  13179. * @returns null or the source animation for the given property
  13180. */
  13181. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13182. /**
  13183. * Gets the runtime animation for a specific property
  13184. * @param property defines the propertyu to look for
  13185. * @returns null or the runtime animation for the given property
  13186. */
  13187. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13188. /**
  13189. * Resets the animatable to its original state
  13190. */
  13191. reset(): void;
  13192. /**
  13193. * Allows the animatable to blend with current running animations
  13194. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13195. * @param blendingSpeed defines the blending speed to use
  13196. */
  13197. enableBlending(blendingSpeed: number): void;
  13198. /**
  13199. * Disable animation blending
  13200. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13201. */
  13202. disableBlending(): void;
  13203. /**
  13204. * Jump directly to a given frame
  13205. * @param frame defines the frame to jump to
  13206. */
  13207. goToFrame(frame: number): void;
  13208. /**
  13209. * Pause the animation
  13210. */
  13211. pause(): void;
  13212. /**
  13213. * Restart the animation
  13214. */
  13215. restart(): void;
  13216. private _raiseOnAnimationEnd;
  13217. /**
  13218. * Stop and delete the current animation
  13219. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13220. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  13221. */
  13222. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13223. /**
  13224. * Wait asynchronously for the animation to end
  13225. * @returns a promise which will be fullfilled when the animation ends
  13226. */
  13227. waitAsync(): Promise<Animatable>;
  13228. /** @hidden */
  13229. _animate(delay: number): boolean;
  13230. }
  13231. module "babylonjs/scene" {
  13232. interface Scene {
  13233. /** @hidden */
  13234. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13235. /** @hidden */
  13236. _processLateAnimationBindingsForMatrices(holder: {
  13237. totalWeight: number;
  13238. animations: RuntimeAnimation[];
  13239. originalValue: Matrix;
  13240. }): any;
  13241. /** @hidden */
  13242. _processLateAnimationBindingsForQuaternions(holder: {
  13243. totalWeight: number;
  13244. animations: RuntimeAnimation[];
  13245. originalValue: Quaternion;
  13246. }, refQuaternion: Quaternion): Quaternion;
  13247. /** @hidden */
  13248. _processLateAnimationBindings(): void;
  13249. /**
  13250. * Will start the animation sequence of a given target
  13251. * @param target defines the target
  13252. * @param from defines from which frame should animation start
  13253. * @param to defines until which frame should animation run.
  13254. * @param weight defines the weight to apply to the animation (1.0 by default)
  13255. * @param loop defines if the animation loops
  13256. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13257. * @param onAnimationEnd defines the function to be executed when the animation ends
  13258. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13259. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13260. * @param onAnimationLoop defines the callback to call when an animation loops
  13261. * @returns the animatable object created for this animation
  13262. */
  13263. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13264. /**
  13265. * Will start the animation sequence of a given target
  13266. * @param target defines the target
  13267. * @param from defines from which frame should animation start
  13268. * @param to defines until which frame should animation run.
  13269. * @param loop defines if the animation loops
  13270. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13271. * @param onAnimationEnd defines the function to be executed when the animation ends
  13272. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13273. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13274. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13275. * @param onAnimationLoop defines the callback to call when an animation loops
  13276. * @returns the animatable object created for this animation
  13277. */
  13278. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13279. /**
  13280. * Will start the animation sequence of a given target and its hierarchy
  13281. * @param target defines the target
  13282. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13283. * @param from defines from which frame should animation start
  13284. * @param to defines until which frame should animation run.
  13285. * @param loop defines if the animation loops
  13286. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13287. * @param onAnimationEnd defines the function to be executed when the animation ends
  13288. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13289. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13290. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13291. * @param onAnimationLoop defines the callback to call when an animation loops
  13292. * @returns the list of created animatables
  13293. */
  13294. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  13295. /**
  13296. * Begin a new animation on a given node
  13297. * @param target defines the target where the animation will take place
  13298. * @param animations defines the list of animations to start
  13299. * @param from defines the initial value
  13300. * @param to defines the final value
  13301. * @param loop defines if you want animation to loop (off by default)
  13302. * @param speedRatio defines the speed ratio to apply to all animations
  13303. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13304. * @param onAnimationLoop defines the callback to call when an animation loops
  13305. * @returns the list of created animatables
  13306. */
  13307. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13308. /**
  13309. * Begin a new animation on a given node and its hierarchy
  13310. * @param target defines the root node where the animation will take place
  13311. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  13312. * @param animations defines the list of animations to start
  13313. * @param from defines the initial value
  13314. * @param to defines the final value
  13315. * @param loop defines if you want animation to loop (off by default)
  13316. * @param speedRatio defines the speed ratio to apply to all animations
  13317. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13318. * @param onAnimationLoop defines the callback to call when an animation loops
  13319. * @returns the list of animatables created for all nodes
  13320. */
  13321. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13322. /**
  13323. * Gets the animatable associated with a specific target
  13324. * @param target defines the target of the animatable
  13325. * @returns the required animatable if found
  13326. */
  13327. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13328. /**
  13329. * Gets all animatables associated with a given target
  13330. * @param target defines the target to look animatables for
  13331. * @returns an array of Animatables
  13332. */
  13333. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13334. /**
  13335. * Stops and removes all animations that have been applied to the scene
  13336. */
  13337. stopAllAnimations(): void;
  13338. /**
  13339. * Gets the current delta time used by animation engine
  13340. */
  13341. deltaTime: number;
  13342. }
  13343. }
  13344. module "babylonjs/Bones/bone" {
  13345. interface Bone {
  13346. /**
  13347. * Copy an animation range from another bone
  13348. * @param source defines the source bone
  13349. * @param rangeName defines the range name to copy
  13350. * @param frameOffset defines the frame offset
  13351. * @param rescaleAsRequired defines if rescaling must be applied if required
  13352. * @param skelDimensionsRatio defines the scaling ratio
  13353. * @returns true if operation was successful
  13354. */
  13355. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13356. }
  13357. }
  13358. }
  13359. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13360. /**
  13361. * Class used to override all child animations of a given target
  13362. */
  13363. export class AnimationPropertiesOverride {
  13364. /**
  13365. * Gets or sets a value indicating if animation blending must be used
  13366. */
  13367. enableBlending: boolean;
  13368. /**
  13369. * Gets or sets the blending speed to use when enableBlending is true
  13370. */
  13371. blendingSpeed: number;
  13372. /**
  13373. * Gets or sets the default loop mode to use
  13374. */
  13375. loopMode: number;
  13376. }
  13377. }
  13378. declare module "babylonjs/Bones/skeleton" {
  13379. import { Bone } from "babylonjs/Bones/bone";
  13380. import { Observable } from "babylonjs/Misc/observable";
  13381. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13382. import { Scene } from "babylonjs/scene";
  13383. import { Nullable } from "babylonjs/types";
  13384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13386. import { Animatable } from "babylonjs/Animations/animatable";
  13387. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13388. import { Animation } from "babylonjs/Animations/animation";
  13389. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13390. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13392. /**
  13393. * Class used to handle skinning animations
  13394. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13395. */
  13396. export class Skeleton implements IAnimatable {
  13397. /** defines the skeleton name */
  13398. name: string;
  13399. /** defines the skeleton Id */
  13400. id: string;
  13401. /**
  13402. * Defines the list of child bones
  13403. */
  13404. bones: Bone[];
  13405. /**
  13406. * Defines an estimate of the dimension of the skeleton at rest
  13407. */
  13408. dimensionsAtRest: Vector3;
  13409. /**
  13410. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13411. */
  13412. needInitialSkinMatrix: boolean;
  13413. /**
  13414. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13415. */
  13416. overrideMesh: Nullable<AbstractMesh>;
  13417. /**
  13418. * Gets the list of animations attached to this skeleton
  13419. */
  13420. animations: Array<Animation>;
  13421. private _scene;
  13422. private _isDirty;
  13423. private _transformMatrices;
  13424. private _transformMatrixTexture;
  13425. private _meshesWithPoseMatrix;
  13426. private _animatables;
  13427. private _identity;
  13428. private _synchronizedWithMesh;
  13429. private _ranges;
  13430. private _lastAbsoluteTransformsUpdateId;
  13431. private _canUseTextureForBones;
  13432. private _uniqueId;
  13433. /** @hidden */
  13434. _numBonesWithLinkedTransformNode: number;
  13435. /** @hidden */
  13436. _hasWaitingData: Nullable<boolean>;
  13437. /**
  13438. * Specifies if the skeleton should be serialized
  13439. */
  13440. doNotSerialize: boolean;
  13441. private _useTextureToStoreBoneMatrices;
  13442. /**
  13443. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13444. * Please note that this option is not available if the hardware does not support it
  13445. */
  13446. useTextureToStoreBoneMatrices: boolean;
  13447. private _animationPropertiesOverride;
  13448. /**
  13449. * Gets or sets the animation properties override
  13450. */
  13451. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13452. /**
  13453. * List of inspectable custom properties (used by the Inspector)
  13454. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13455. */
  13456. inspectableCustomProperties: IInspectable[];
  13457. /**
  13458. * An observable triggered before computing the skeleton's matrices
  13459. */
  13460. onBeforeComputeObservable: Observable<Skeleton>;
  13461. /**
  13462. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13463. */
  13464. readonly isUsingTextureForMatrices: boolean;
  13465. /**
  13466. * Gets the unique ID of this skeleton
  13467. */
  13468. readonly uniqueId: number;
  13469. /**
  13470. * Creates a new skeleton
  13471. * @param name defines the skeleton name
  13472. * @param id defines the skeleton Id
  13473. * @param scene defines the hosting scene
  13474. */
  13475. constructor(
  13476. /** defines the skeleton name */
  13477. name: string,
  13478. /** defines the skeleton Id */
  13479. id: string, scene: Scene);
  13480. /**
  13481. * Gets the current object class name.
  13482. * @return the class name
  13483. */
  13484. getClassName(): string;
  13485. /**
  13486. * Returns an array containing the root bones
  13487. * @returns an array containing the root bones
  13488. */
  13489. getChildren(): Array<Bone>;
  13490. /**
  13491. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13492. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13493. * @returns a Float32Array containing matrices data
  13494. */
  13495. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13496. /**
  13497. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13498. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13499. * @returns a raw texture containing the data
  13500. */
  13501. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13502. /**
  13503. * Gets the current hosting scene
  13504. * @returns a scene object
  13505. */
  13506. getScene(): Scene;
  13507. /**
  13508. * Gets a string representing the current skeleton data
  13509. * @param fullDetails defines a boolean indicating if we want a verbose version
  13510. * @returns a string representing the current skeleton data
  13511. */
  13512. toString(fullDetails?: boolean): string;
  13513. /**
  13514. * Get bone's index searching by name
  13515. * @param name defines bone's name to search for
  13516. * @return the indice of the bone. Returns -1 if not found
  13517. */
  13518. getBoneIndexByName(name: string): number;
  13519. /**
  13520. * Creater a new animation range
  13521. * @param name defines the name of the range
  13522. * @param from defines the start key
  13523. * @param to defines the end key
  13524. */
  13525. createAnimationRange(name: string, from: number, to: number): void;
  13526. /**
  13527. * Delete a specific animation range
  13528. * @param name defines the name of the range
  13529. * @param deleteFrames defines if frames must be removed as well
  13530. */
  13531. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13532. /**
  13533. * Gets a specific animation range
  13534. * @param name defines the name of the range to look for
  13535. * @returns the requested animation range or null if not found
  13536. */
  13537. getAnimationRange(name: string): Nullable<AnimationRange>;
  13538. /**
  13539. * Gets the list of all animation ranges defined on this skeleton
  13540. * @returns an array
  13541. */
  13542. getAnimationRanges(): Nullable<AnimationRange>[];
  13543. /**
  13544. * Copy animation range from a source skeleton.
  13545. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13546. * @param source defines the source skeleton
  13547. * @param name defines the name of the range to copy
  13548. * @param rescaleAsRequired defines if rescaling must be applied if required
  13549. * @returns true if operation was successful
  13550. */
  13551. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13552. /**
  13553. * Forces the skeleton to go to rest pose
  13554. */
  13555. returnToRest(): void;
  13556. private _getHighestAnimationFrame;
  13557. /**
  13558. * Begin a specific animation range
  13559. * @param name defines the name of the range to start
  13560. * @param loop defines if looping must be turned on (false by default)
  13561. * @param speedRatio defines the speed ratio to apply (1 by default)
  13562. * @param onAnimationEnd defines a callback which will be called when animation will end
  13563. * @returns a new animatable
  13564. */
  13565. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13566. /** @hidden */
  13567. _markAsDirty(): void;
  13568. /** @hidden */
  13569. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13570. /** @hidden */
  13571. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. private _computeTransformMatrices;
  13573. /**
  13574. * Build all resources required to render a skeleton
  13575. */
  13576. prepare(): void;
  13577. /**
  13578. * Gets the list of animatables currently running for this skeleton
  13579. * @returns an array of animatables
  13580. */
  13581. getAnimatables(): IAnimatable[];
  13582. /**
  13583. * Clone the current skeleton
  13584. * @param name defines the name of the new skeleton
  13585. * @param id defines the id of the new skeleton
  13586. * @returns the new skeleton
  13587. */
  13588. clone(name: string, id: string): Skeleton;
  13589. /**
  13590. * Enable animation blending for this skeleton
  13591. * @param blendingSpeed defines the blending speed to apply
  13592. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13593. */
  13594. enableBlending(blendingSpeed?: number): void;
  13595. /**
  13596. * Releases all resources associated with the current skeleton
  13597. */
  13598. dispose(): void;
  13599. /**
  13600. * Serialize the skeleton in a JSON object
  13601. * @returns a JSON object
  13602. */
  13603. serialize(): any;
  13604. /**
  13605. * Creates a new skeleton from serialized data
  13606. * @param parsedSkeleton defines the serialized data
  13607. * @param scene defines the hosting scene
  13608. * @returns a new skeleton
  13609. */
  13610. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13611. /**
  13612. * Compute all node absolute transforms
  13613. * @param forceUpdate defines if computation must be done even if cache is up to date
  13614. */
  13615. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13616. /**
  13617. * Gets the root pose matrix
  13618. * @returns a matrix
  13619. */
  13620. getPoseMatrix(): Nullable<Matrix>;
  13621. /**
  13622. * Sorts bones per internal index
  13623. */
  13624. sortBones(): void;
  13625. private _sortBones;
  13626. }
  13627. }
  13628. declare module "babylonjs/Bones/bone" {
  13629. import { Skeleton } from "babylonjs/Bones/skeleton";
  13630. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13631. import { Nullable } from "babylonjs/types";
  13632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13633. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13634. import { Node } from "babylonjs/node";
  13635. import { Space } from "babylonjs/Maths/math.axis";
  13636. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13637. /**
  13638. * Class used to store bone information
  13639. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13640. */
  13641. export class Bone extends Node {
  13642. /**
  13643. * defines the bone name
  13644. */
  13645. name: string;
  13646. private static _tmpVecs;
  13647. private static _tmpQuat;
  13648. private static _tmpMats;
  13649. /**
  13650. * Gets the list of child bones
  13651. */
  13652. children: Bone[];
  13653. /** Gets the animations associated with this bone */
  13654. animations: import("babylonjs/Animations/animation").Animation[];
  13655. /**
  13656. * Gets or sets bone length
  13657. */
  13658. length: number;
  13659. /**
  13660. * @hidden Internal only
  13661. * Set this value to map this bone to a different index in the transform matrices
  13662. * Set this value to -1 to exclude the bone from the transform matrices
  13663. */
  13664. _index: Nullable<number>;
  13665. private _skeleton;
  13666. private _localMatrix;
  13667. private _restPose;
  13668. private _baseMatrix;
  13669. private _absoluteTransform;
  13670. private _invertedAbsoluteTransform;
  13671. private _parent;
  13672. private _scalingDeterminant;
  13673. private _worldTransform;
  13674. private _localScaling;
  13675. private _localRotation;
  13676. private _localPosition;
  13677. private _needToDecompose;
  13678. private _needToCompose;
  13679. /** @hidden */
  13680. _linkedTransformNode: Nullable<TransformNode>;
  13681. /** @hidden */
  13682. _waitingTransformNodeId: Nullable<string>;
  13683. /** @hidden */
  13684. /** @hidden */
  13685. _matrix: Matrix;
  13686. /**
  13687. * Create a new bone
  13688. * @param name defines the bone name
  13689. * @param skeleton defines the parent skeleton
  13690. * @param parentBone defines the parent (can be null if the bone is the root)
  13691. * @param localMatrix defines the local matrix
  13692. * @param restPose defines the rest pose matrix
  13693. * @param baseMatrix defines the base matrix
  13694. * @param index defines index of the bone in the hiearchy
  13695. */
  13696. constructor(
  13697. /**
  13698. * defines the bone name
  13699. */
  13700. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13701. /**
  13702. * Gets the current object class name.
  13703. * @return the class name
  13704. */
  13705. getClassName(): string;
  13706. /**
  13707. * Gets the parent skeleton
  13708. * @returns a skeleton
  13709. */
  13710. getSkeleton(): Skeleton;
  13711. /**
  13712. * Gets parent bone
  13713. * @returns a bone or null if the bone is the root of the bone hierarchy
  13714. */
  13715. getParent(): Nullable<Bone>;
  13716. /**
  13717. * Returns an array containing the root bones
  13718. * @returns an array containing the root bones
  13719. */
  13720. getChildren(): Array<Bone>;
  13721. /**
  13722. * Sets the parent bone
  13723. * @param parent defines the parent (can be null if the bone is the root)
  13724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13725. */
  13726. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13727. /**
  13728. * Gets the local matrix
  13729. * @returns a matrix
  13730. */
  13731. getLocalMatrix(): Matrix;
  13732. /**
  13733. * Gets the base matrix (initial matrix which remains unchanged)
  13734. * @returns a matrix
  13735. */
  13736. getBaseMatrix(): Matrix;
  13737. /**
  13738. * Gets the rest pose matrix
  13739. * @returns a matrix
  13740. */
  13741. getRestPose(): Matrix;
  13742. /**
  13743. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13744. */
  13745. getWorldMatrix(): Matrix;
  13746. /**
  13747. * Sets the local matrix to rest pose matrix
  13748. */
  13749. returnToRest(): void;
  13750. /**
  13751. * Gets the inverse of the absolute transform matrix.
  13752. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13753. * @returns a matrix
  13754. */
  13755. getInvertedAbsoluteTransform(): Matrix;
  13756. /**
  13757. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13758. * @returns a matrix
  13759. */
  13760. getAbsoluteTransform(): Matrix;
  13761. /**
  13762. * Links with the given transform node.
  13763. * The local matrix of this bone is copied from the transform node every frame.
  13764. * @param transformNode defines the transform node to link to
  13765. */
  13766. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13767. /**
  13768. * Gets the node used to drive the bone's transformation
  13769. * @returns a transform node or null
  13770. */
  13771. getTransformNode(): Nullable<TransformNode>;
  13772. /** Gets or sets current position (in local space) */
  13773. position: Vector3;
  13774. /** Gets or sets current rotation (in local space) */
  13775. rotation: Vector3;
  13776. /** Gets or sets current rotation quaternion (in local space) */
  13777. rotationQuaternion: Quaternion;
  13778. /** Gets or sets current scaling (in local space) */
  13779. scaling: Vector3;
  13780. /**
  13781. * Gets the animation properties override
  13782. */
  13783. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13784. private _decompose;
  13785. private _compose;
  13786. /**
  13787. * Update the base and local matrices
  13788. * @param matrix defines the new base or local matrix
  13789. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13790. * @param updateLocalMatrix defines if the local matrix should be updated
  13791. */
  13792. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13793. /** @hidden */
  13794. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13795. /**
  13796. * Flag the bone as dirty (Forcing it to update everything)
  13797. */
  13798. markAsDirty(): void;
  13799. /** @hidden */
  13800. _markAsDirtyAndCompose(): void;
  13801. private _markAsDirtyAndDecompose;
  13802. /**
  13803. * Translate the bone in local or world space
  13804. * @param vec The amount to translate the bone
  13805. * @param space The space that the translation is in
  13806. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13807. */
  13808. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13809. /**
  13810. * Set the postion of the bone in local or world space
  13811. * @param position The position to set the bone
  13812. * @param space The space that the position is in
  13813. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13814. */
  13815. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13816. /**
  13817. * Set the absolute position of the bone (world space)
  13818. * @param position The position to set the bone
  13819. * @param mesh The mesh that this bone is attached to
  13820. */
  13821. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13822. /**
  13823. * Scale the bone on the x, y and z axes (in local space)
  13824. * @param x The amount to scale the bone on the x axis
  13825. * @param y The amount to scale the bone on the y axis
  13826. * @param z The amount to scale the bone on the z axis
  13827. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13828. */
  13829. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13830. /**
  13831. * Set the bone scaling in local space
  13832. * @param scale defines the scaling vector
  13833. */
  13834. setScale(scale: Vector3): void;
  13835. /**
  13836. * Gets the current scaling in local space
  13837. * @returns the current scaling vector
  13838. */
  13839. getScale(): Vector3;
  13840. /**
  13841. * Gets the current scaling in local space and stores it in a target vector
  13842. * @param result defines the target vector
  13843. */
  13844. getScaleToRef(result: Vector3): void;
  13845. /**
  13846. * Set the yaw, pitch, and roll of the bone in local or world space
  13847. * @param yaw The rotation of the bone on the y axis
  13848. * @param pitch The rotation of the bone on the x axis
  13849. * @param roll The rotation of the bone on the z axis
  13850. * @param space The space that the axes of rotation are in
  13851. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13852. */
  13853. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13854. /**
  13855. * Add a rotation to the bone on an axis in local or world space
  13856. * @param axis The axis to rotate the bone on
  13857. * @param amount The amount to rotate the bone
  13858. * @param space The space that the axis is in
  13859. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13860. */
  13861. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13862. /**
  13863. * Set the rotation of the bone to a particular axis angle in local or world space
  13864. * @param axis The axis to rotate the bone on
  13865. * @param angle The angle that the bone should be rotated to
  13866. * @param space The space that the axis is in
  13867. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13868. */
  13869. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13870. /**
  13871. * Set the euler rotation of the bone in local of world space
  13872. * @param rotation The euler rotation that the bone should be set to
  13873. * @param space The space that the rotation is in
  13874. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13875. */
  13876. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13877. /**
  13878. * Set the quaternion rotation of the bone in local of world space
  13879. * @param quat The quaternion rotation that the bone should be set to
  13880. * @param space The space that the rotation is in
  13881. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13882. */
  13883. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13884. /**
  13885. * Set the rotation matrix of the bone in local of world space
  13886. * @param rotMat The rotation matrix that the bone should be set to
  13887. * @param space The space that the rotation is in
  13888. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13889. */
  13890. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13891. private _rotateWithMatrix;
  13892. private _getNegativeRotationToRef;
  13893. /**
  13894. * Get the position of the bone in local or world space
  13895. * @param space The space that the returned position is in
  13896. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13897. * @returns The position of the bone
  13898. */
  13899. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13900. /**
  13901. * Copy the position of the bone to a vector3 in local or world space
  13902. * @param space The space that the returned position is in
  13903. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13904. * @param result The vector3 to copy the position to
  13905. */
  13906. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13907. /**
  13908. * Get the absolute position of the bone (world space)
  13909. * @param mesh The mesh that this bone is attached to
  13910. * @returns The absolute position of the bone
  13911. */
  13912. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13913. /**
  13914. * Copy the absolute position of the bone (world space) to the result param
  13915. * @param mesh The mesh that this bone is attached to
  13916. * @param result The vector3 to copy the absolute position to
  13917. */
  13918. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13919. /**
  13920. * Compute the absolute transforms of this bone and its children
  13921. */
  13922. computeAbsoluteTransforms(): void;
  13923. /**
  13924. * Get the world direction from an axis that is in the local space of the bone
  13925. * @param localAxis The local direction that is used to compute the world direction
  13926. * @param mesh The mesh that this bone is attached to
  13927. * @returns The world direction
  13928. */
  13929. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13930. /**
  13931. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13932. * @param localAxis The local direction that is used to compute the world direction
  13933. * @param mesh The mesh that this bone is attached to
  13934. * @param result The vector3 that the world direction will be copied to
  13935. */
  13936. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13937. /**
  13938. * Get the euler rotation of the bone in local or world space
  13939. * @param space The space that the rotation should be in
  13940. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13941. * @returns The euler rotation
  13942. */
  13943. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13944. /**
  13945. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13946. * @param space The space that the rotation should be in
  13947. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13948. * @param result The vector3 that the rotation should be copied to
  13949. */
  13950. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13951. /**
  13952. * Get the quaternion rotation of the bone in either local or world space
  13953. * @param space The space that the rotation should be in
  13954. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13955. * @returns The quaternion rotation
  13956. */
  13957. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13958. /**
  13959. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13960. * @param space The space that the rotation should be in
  13961. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13962. * @param result The quaternion that the rotation should be copied to
  13963. */
  13964. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13965. /**
  13966. * Get the rotation matrix of the bone in local or world space
  13967. * @param space The space that the rotation should be in
  13968. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13969. * @returns The rotation matrix
  13970. */
  13971. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13972. /**
  13973. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13974. * @param space The space that the rotation should be in
  13975. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13976. * @param result The quaternion that the rotation should be copied to
  13977. */
  13978. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13979. /**
  13980. * Get the world position of a point that is in the local space of the bone
  13981. * @param position The local position
  13982. * @param mesh The mesh that this bone is attached to
  13983. * @returns The world position
  13984. */
  13985. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13986. /**
  13987. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13988. * @param position The local position
  13989. * @param mesh The mesh that this bone is attached to
  13990. * @param result The vector3 that the world position should be copied to
  13991. */
  13992. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13993. /**
  13994. * Get the local position of a point that is in world space
  13995. * @param position The world position
  13996. * @param mesh The mesh that this bone is attached to
  13997. * @returns The local position
  13998. */
  13999. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14000. /**
  14001. * Get the local position of a point that is in world space and copy it to the result param
  14002. * @param position The world position
  14003. * @param mesh The mesh that this bone is attached to
  14004. * @param result The vector3 that the local position should be copied to
  14005. */
  14006. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14007. }
  14008. }
  14009. declare module "babylonjs/Meshes/transformNode" {
  14010. import { DeepImmutable } from "babylonjs/types";
  14011. import { Observable } from "babylonjs/Misc/observable";
  14012. import { Nullable } from "babylonjs/types";
  14013. import { Camera } from "babylonjs/Cameras/camera";
  14014. import { Scene } from "babylonjs/scene";
  14015. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14016. import { Node } from "babylonjs/node";
  14017. import { Bone } from "babylonjs/Bones/bone";
  14018. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14019. import { Space } from "babylonjs/Maths/math.axis";
  14020. /**
  14021. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  14022. * @see https://doc.babylonjs.com/how_to/transformnode
  14023. */
  14024. export class TransformNode extends Node {
  14025. /**
  14026. * Object will not rotate to face the camera
  14027. */
  14028. static BILLBOARDMODE_NONE: number;
  14029. /**
  14030. * Object will rotate to face the camera but only on the x axis
  14031. */
  14032. static BILLBOARDMODE_X: number;
  14033. /**
  14034. * Object will rotate to face the camera but only on the y axis
  14035. */
  14036. static BILLBOARDMODE_Y: number;
  14037. /**
  14038. * Object will rotate to face the camera but only on the z axis
  14039. */
  14040. static BILLBOARDMODE_Z: number;
  14041. /**
  14042. * Object will rotate to face the camera
  14043. */
  14044. static BILLBOARDMODE_ALL: number;
  14045. /**
  14046. * Object will rotate to face the camera's position instead of orientation
  14047. */
  14048. static BILLBOARDMODE_USE_POSITION: number;
  14049. private _forward;
  14050. private _forwardInverted;
  14051. private _up;
  14052. private _right;
  14053. private _rightInverted;
  14054. private _position;
  14055. private _rotation;
  14056. private _rotationQuaternion;
  14057. protected _scaling: Vector3;
  14058. protected _isDirty: boolean;
  14059. private _transformToBoneReferal;
  14060. private _isAbsoluteSynced;
  14061. private _billboardMode;
  14062. /**
  14063. * Gets or sets the billboard mode. Default is 0.
  14064. *
  14065. * | Value | Type | Description |
  14066. * | --- | --- | --- |
  14067. * | 0 | BILLBOARDMODE_NONE | |
  14068. * | 1 | BILLBOARDMODE_X | |
  14069. * | 2 | BILLBOARDMODE_Y | |
  14070. * | 4 | BILLBOARDMODE_Z | |
  14071. * | 7 | BILLBOARDMODE_ALL | |
  14072. *
  14073. */
  14074. billboardMode: number;
  14075. private _preserveParentRotationForBillboard;
  14076. /**
  14077. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14078. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14079. */
  14080. preserveParentRotationForBillboard: boolean;
  14081. /**
  14082. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  14083. */
  14084. scalingDeterminant: number;
  14085. private _infiniteDistance;
  14086. /**
  14087. * Gets or sets the distance of the object to max, often used by skybox
  14088. */
  14089. infiniteDistance: boolean;
  14090. /**
  14091. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14092. * By default the system will update normals to compensate
  14093. */
  14094. ignoreNonUniformScaling: boolean;
  14095. /**
  14096. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  14097. */
  14098. reIntegrateRotationIntoRotationQuaternion: boolean;
  14099. /** @hidden */
  14100. _poseMatrix: Nullable<Matrix>;
  14101. /** @hidden */
  14102. _localMatrix: Matrix;
  14103. private _usePivotMatrix;
  14104. private _absolutePosition;
  14105. private _absoluteScaling;
  14106. private _absoluteRotationQuaternion;
  14107. private _pivotMatrix;
  14108. private _pivotMatrixInverse;
  14109. protected _postMultiplyPivotMatrix: boolean;
  14110. protected _isWorldMatrixFrozen: boolean;
  14111. /** @hidden */
  14112. _indexInSceneTransformNodesArray: number;
  14113. /**
  14114. * An event triggered after the world matrix is updated
  14115. */
  14116. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14117. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14118. /**
  14119. * Gets a string identifying the name of the class
  14120. * @returns "TransformNode" string
  14121. */
  14122. getClassName(): string;
  14123. /**
  14124. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14125. */
  14126. position: Vector3;
  14127. /**
  14128. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14129. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14130. */
  14131. rotation: Vector3;
  14132. /**
  14133. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  14134. */
  14135. scaling: Vector3;
  14136. /**
  14137. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  14138. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14139. */
  14140. rotationQuaternion: Nullable<Quaternion>;
  14141. /**
  14142. * The forward direction of that transform in world space.
  14143. */
  14144. readonly forward: Vector3;
  14145. /**
  14146. * The up direction of that transform in world space.
  14147. */
  14148. readonly up: Vector3;
  14149. /**
  14150. * The right direction of that transform in world space.
  14151. */
  14152. readonly right: Vector3;
  14153. /**
  14154. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14155. * @param matrix the matrix to copy the pose from
  14156. * @returns this TransformNode.
  14157. */
  14158. updatePoseMatrix(matrix: Matrix): TransformNode;
  14159. /**
  14160. * Returns the mesh Pose matrix.
  14161. * @returns the pose matrix
  14162. */
  14163. getPoseMatrix(): Matrix;
  14164. /** @hidden */
  14165. _isSynchronized(): boolean;
  14166. /** @hidden */
  14167. _initCache(): void;
  14168. /**
  14169. * Flag the transform node as dirty (Forcing it to update everything)
  14170. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14171. * @returns this transform node
  14172. */
  14173. markAsDirty(property: string): TransformNode;
  14174. /**
  14175. * Returns the current mesh absolute position.
  14176. * Returns a Vector3.
  14177. */
  14178. readonly absolutePosition: Vector3;
  14179. /**
  14180. * Returns the current mesh absolute scaling.
  14181. * Returns a Vector3.
  14182. */
  14183. readonly absoluteScaling: Vector3;
  14184. /**
  14185. * Returns the current mesh absolute rotation.
  14186. * Returns a Quaternion.
  14187. */
  14188. readonly absoluteRotationQuaternion: Quaternion;
  14189. /**
  14190. * Sets a new matrix to apply before all other transformation
  14191. * @param matrix defines the transform matrix
  14192. * @returns the current TransformNode
  14193. */
  14194. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14195. /**
  14196. * Sets a new pivot matrix to the current node
  14197. * @param matrix defines the new pivot matrix to use
  14198. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  14199. * @returns the current TransformNode
  14200. */
  14201. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14202. /**
  14203. * Returns the mesh pivot matrix.
  14204. * Default : Identity.
  14205. * @returns the matrix
  14206. */
  14207. getPivotMatrix(): Matrix;
  14208. /**
  14209. * Instantiate (when possible) or clone that node with its hierarchy
  14210. * @param newParent defines the new parent to use for the instance (or clone)
  14211. * @returns an instance (or a clone) of the current node with its hiearchy
  14212. */
  14213. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14214. /**
  14215. * Prevents the World matrix to be computed any longer
  14216. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14217. * @returns the TransformNode.
  14218. */
  14219. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14220. /**
  14221. * Allows back the World matrix computation.
  14222. * @returns the TransformNode.
  14223. */
  14224. unfreezeWorldMatrix(): this;
  14225. /**
  14226. * True if the World matrix has been frozen.
  14227. */
  14228. readonly isWorldMatrixFrozen: boolean;
  14229. /**
  14230. * Retuns the mesh absolute position in the World.
  14231. * @returns a Vector3.
  14232. */
  14233. getAbsolutePosition(): Vector3;
  14234. /**
  14235. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14236. * @param absolutePosition the absolute position to set
  14237. * @returns the TransformNode.
  14238. */
  14239. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14240. /**
  14241. * Sets the mesh position in its local space.
  14242. * @param vector3 the position to set in localspace
  14243. * @returns the TransformNode.
  14244. */
  14245. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14246. /**
  14247. * Returns the mesh position in the local space from the current World matrix values.
  14248. * @returns a new Vector3.
  14249. */
  14250. getPositionExpressedInLocalSpace(): Vector3;
  14251. /**
  14252. * Translates the mesh along the passed Vector3 in its local space.
  14253. * @param vector3 the distance to translate in localspace
  14254. * @returns the TransformNode.
  14255. */
  14256. locallyTranslate(vector3: Vector3): TransformNode;
  14257. private static _lookAtVectorCache;
  14258. /**
  14259. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14260. * @param targetPoint the position (must be in same space as current mesh) to look at
  14261. * @param yawCor optional yaw (y-axis) correction in radians
  14262. * @param pitchCor optional pitch (x-axis) correction in radians
  14263. * @param rollCor optional roll (z-axis) correction in radians
  14264. * @param space the choosen space of the target
  14265. * @returns the TransformNode.
  14266. */
  14267. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14268. /**
  14269. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14270. * This Vector3 is expressed in the World space.
  14271. * @param localAxis axis to rotate
  14272. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14273. */
  14274. getDirection(localAxis: Vector3): Vector3;
  14275. /**
  14276. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14277. * localAxis is expressed in the mesh local space.
  14278. * result is computed in the Wordl space from the mesh World matrix.
  14279. * @param localAxis axis to rotate
  14280. * @param result the resulting transformnode
  14281. * @returns this TransformNode.
  14282. */
  14283. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14284. /**
  14285. * Sets this transform node rotation to the given local axis.
  14286. * @param localAxis the axis in local space
  14287. * @param yawCor optional yaw (y-axis) correction in radians
  14288. * @param pitchCor optional pitch (x-axis) correction in radians
  14289. * @param rollCor optional roll (z-axis) correction in radians
  14290. * @returns this TransformNode
  14291. */
  14292. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14293. /**
  14294. * Sets a new pivot point to the current node
  14295. * @param point defines the new pivot point to use
  14296. * @param space defines if the point is in world or local space (local by default)
  14297. * @returns the current TransformNode
  14298. */
  14299. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14300. /**
  14301. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14302. * @returns the pivot point
  14303. */
  14304. getPivotPoint(): Vector3;
  14305. /**
  14306. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14307. * @param result the vector3 to store the result
  14308. * @returns this TransformNode.
  14309. */
  14310. getPivotPointToRef(result: Vector3): TransformNode;
  14311. /**
  14312. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14313. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14314. */
  14315. getAbsolutePivotPoint(): Vector3;
  14316. /**
  14317. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14318. * @param result vector3 to store the result
  14319. * @returns this TransformNode.
  14320. */
  14321. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14322. /**
  14323. * Defines the passed node as the parent of the current node.
  14324. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14325. * @see https://doc.babylonjs.com/how_to/parenting
  14326. * @param node the node ot set as the parent
  14327. * @returns this TransformNode.
  14328. */
  14329. setParent(node: Nullable<Node>): TransformNode;
  14330. private _nonUniformScaling;
  14331. /**
  14332. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14333. */
  14334. readonly nonUniformScaling: boolean;
  14335. /** @hidden */
  14336. _updateNonUniformScalingState(value: boolean): boolean;
  14337. /**
  14338. * Attach the current TransformNode to another TransformNode associated with a bone
  14339. * @param bone Bone affecting the TransformNode
  14340. * @param affectedTransformNode TransformNode associated with the bone
  14341. * @returns this object
  14342. */
  14343. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14344. /**
  14345. * Detach the transform node if its associated with a bone
  14346. * @returns this object
  14347. */
  14348. detachFromBone(): TransformNode;
  14349. private static _rotationAxisCache;
  14350. /**
  14351. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14352. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14353. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14354. * The passed axis is also normalized.
  14355. * @param axis the axis to rotate around
  14356. * @param amount the amount to rotate in radians
  14357. * @param space Space to rotate in (Default: local)
  14358. * @returns the TransformNode.
  14359. */
  14360. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14361. /**
  14362. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14363. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14364. * The passed axis is also normalized. .
  14365. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14366. * @param point the point to rotate around
  14367. * @param axis the axis to rotate around
  14368. * @param amount the amount to rotate in radians
  14369. * @returns the TransformNode
  14370. */
  14371. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14372. /**
  14373. * Translates the mesh along the axis vector for the passed distance in the given space.
  14374. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14375. * @param axis the axis to translate in
  14376. * @param distance the distance to translate
  14377. * @param space Space to rotate in (Default: local)
  14378. * @returns the TransformNode.
  14379. */
  14380. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14381. /**
  14382. * Adds a rotation step to the mesh current rotation.
  14383. * x, y, z are Euler angles expressed in radians.
  14384. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14385. * This means this rotation is made in the mesh local space only.
  14386. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14387. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14388. * ```javascript
  14389. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14390. * ```
  14391. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14392. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14393. * @param x Rotation to add
  14394. * @param y Rotation to add
  14395. * @param z Rotation to add
  14396. * @returns the TransformNode.
  14397. */
  14398. addRotation(x: number, y: number, z: number): TransformNode;
  14399. /**
  14400. * @hidden
  14401. */
  14402. protected _getEffectiveParent(): Nullable<Node>;
  14403. /**
  14404. * Computes the world matrix of the node
  14405. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14406. * @returns the world matrix
  14407. */
  14408. computeWorldMatrix(force?: boolean): Matrix;
  14409. protected _afterComputeWorldMatrix(): void;
  14410. /**
  14411. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14412. * @param func callback function to add
  14413. *
  14414. * @returns the TransformNode.
  14415. */
  14416. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14417. /**
  14418. * Removes a registered callback function.
  14419. * @param func callback function to remove
  14420. * @returns the TransformNode.
  14421. */
  14422. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14423. /**
  14424. * Gets the position of the current mesh in camera space
  14425. * @param camera defines the camera to use
  14426. * @returns a position
  14427. */
  14428. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14429. /**
  14430. * Returns the distance from the mesh to the active camera
  14431. * @param camera defines the camera to use
  14432. * @returns the distance
  14433. */
  14434. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14435. /**
  14436. * Clone the current transform node
  14437. * @param name Name of the new clone
  14438. * @param newParent New parent for the clone
  14439. * @param doNotCloneChildren Do not clone children hierarchy
  14440. * @returns the new transform node
  14441. */
  14442. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14443. /**
  14444. * Serializes the objects information.
  14445. * @param currentSerializationObject defines the object to serialize in
  14446. * @returns the serialized object
  14447. */
  14448. serialize(currentSerializationObject?: any): any;
  14449. /**
  14450. * Returns a new TransformNode object parsed from the source provided.
  14451. * @param parsedTransformNode is the source.
  14452. * @param scene the scne the object belongs to
  14453. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14454. * @returns a new TransformNode object parsed from the source provided.
  14455. */
  14456. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14457. /**
  14458. * Get all child-transformNodes of this node
  14459. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14460. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14461. * @returns an array of TransformNode
  14462. */
  14463. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14464. /**
  14465. * Releases resources associated with this transform node.
  14466. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14467. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14468. */
  14469. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14470. /**
  14471. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14472. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14473. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14474. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14475. * @returns the current mesh
  14476. */
  14477. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14478. private _syncAbsoluteScalingAndRotation;
  14479. }
  14480. }
  14481. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14482. import { Observable } from "babylonjs/Misc/observable";
  14483. import { Nullable } from "babylonjs/types";
  14484. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14485. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14487. import { Ray } from "babylonjs/Culling/ray";
  14488. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14489. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14490. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14491. /**
  14492. * Defines the types of pose enabled controllers that are supported
  14493. */
  14494. export enum PoseEnabledControllerType {
  14495. /**
  14496. * HTC Vive
  14497. */
  14498. VIVE = 0,
  14499. /**
  14500. * Oculus Rift
  14501. */
  14502. OCULUS = 1,
  14503. /**
  14504. * Windows mixed reality
  14505. */
  14506. WINDOWS = 2,
  14507. /**
  14508. * Samsung gear VR
  14509. */
  14510. GEAR_VR = 3,
  14511. /**
  14512. * Google Daydream
  14513. */
  14514. DAYDREAM = 4,
  14515. /**
  14516. * Generic
  14517. */
  14518. GENERIC = 5
  14519. }
  14520. /**
  14521. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14522. */
  14523. export interface MutableGamepadButton {
  14524. /**
  14525. * Value of the button/trigger
  14526. */
  14527. value: number;
  14528. /**
  14529. * If the button/trigger is currently touched
  14530. */
  14531. touched: boolean;
  14532. /**
  14533. * If the button/trigger is currently pressed
  14534. */
  14535. pressed: boolean;
  14536. }
  14537. /**
  14538. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14539. * @hidden
  14540. */
  14541. export interface ExtendedGamepadButton extends GamepadButton {
  14542. /**
  14543. * If the button/trigger is currently pressed
  14544. */
  14545. readonly pressed: boolean;
  14546. /**
  14547. * If the button/trigger is currently touched
  14548. */
  14549. readonly touched: boolean;
  14550. /**
  14551. * Value of the button/trigger
  14552. */
  14553. readonly value: number;
  14554. }
  14555. /** @hidden */
  14556. export interface _GamePadFactory {
  14557. /**
  14558. * Returns wether or not the current gamepad can be created for this type of controller.
  14559. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14560. * @returns true if it can be created, otherwise false
  14561. */
  14562. canCreate(gamepadInfo: any): boolean;
  14563. /**
  14564. * Creates a new instance of the Gamepad.
  14565. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14566. * @returns the new gamepad instance
  14567. */
  14568. create(gamepadInfo: any): Gamepad;
  14569. }
  14570. /**
  14571. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14572. */
  14573. export class PoseEnabledControllerHelper {
  14574. /** @hidden */
  14575. static _ControllerFactories: _GamePadFactory[];
  14576. /** @hidden */
  14577. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14578. /**
  14579. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14580. * @param vrGamepad the gamepad to initialized
  14581. * @returns a vr controller of the type the gamepad identified as
  14582. */
  14583. static InitiateController(vrGamepad: any): Gamepad;
  14584. }
  14585. /**
  14586. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14587. */
  14588. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14589. /**
  14590. * If the controller is used in a webXR session
  14591. */
  14592. isXR: boolean;
  14593. private _deviceRoomPosition;
  14594. private _deviceRoomRotationQuaternion;
  14595. /**
  14596. * The device position in babylon space
  14597. */
  14598. devicePosition: Vector3;
  14599. /**
  14600. * The device rotation in babylon space
  14601. */
  14602. deviceRotationQuaternion: Quaternion;
  14603. /**
  14604. * The scale factor of the device in babylon space
  14605. */
  14606. deviceScaleFactor: number;
  14607. /**
  14608. * (Likely devicePosition should be used instead) The device position in its room space
  14609. */
  14610. position: Vector3;
  14611. /**
  14612. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14613. */
  14614. rotationQuaternion: Quaternion;
  14615. /**
  14616. * The type of controller (Eg. Windows mixed reality)
  14617. */
  14618. controllerType: PoseEnabledControllerType;
  14619. protected _calculatedPosition: Vector3;
  14620. private _calculatedRotation;
  14621. /**
  14622. * The raw pose from the device
  14623. */
  14624. rawPose: DevicePose;
  14625. private _trackPosition;
  14626. private _maxRotationDistFromHeadset;
  14627. private _draggedRoomRotation;
  14628. /**
  14629. * @hidden
  14630. */
  14631. _disableTrackPosition(fixedPosition: Vector3): void;
  14632. /**
  14633. * Internal, the mesh attached to the controller
  14634. * @hidden
  14635. */
  14636. _mesh: Nullable<AbstractMesh>;
  14637. private _poseControlledCamera;
  14638. private _leftHandSystemQuaternion;
  14639. /**
  14640. * Internal, matrix used to convert room space to babylon space
  14641. * @hidden
  14642. */
  14643. _deviceToWorld: Matrix;
  14644. /**
  14645. * Node to be used when casting a ray from the controller
  14646. * @hidden
  14647. */
  14648. _pointingPoseNode: Nullable<TransformNode>;
  14649. /**
  14650. * Name of the child mesh that can be used to cast a ray from the controller
  14651. */
  14652. static readonly POINTING_POSE: string;
  14653. /**
  14654. * Creates a new PoseEnabledController from a gamepad
  14655. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14656. */
  14657. constructor(browserGamepad: any);
  14658. private _workingMatrix;
  14659. /**
  14660. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14661. */
  14662. update(): void;
  14663. /**
  14664. * Updates only the pose device and mesh without doing any button event checking
  14665. */
  14666. protected _updatePoseAndMesh(): void;
  14667. /**
  14668. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14669. * @param poseData raw pose fromthe device
  14670. */
  14671. updateFromDevice(poseData: DevicePose): void;
  14672. /**
  14673. * @hidden
  14674. */
  14675. _meshAttachedObservable: Observable<AbstractMesh>;
  14676. /**
  14677. * Attaches a mesh to the controller
  14678. * @param mesh the mesh to be attached
  14679. */
  14680. attachToMesh(mesh: AbstractMesh): void;
  14681. /**
  14682. * Attaches the controllers mesh to a camera
  14683. * @param camera the camera the mesh should be attached to
  14684. */
  14685. attachToPoseControlledCamera(camera: TargetCamera): void;
  14686. /**
  14687. * Disposes of the controller
  14688. */
  14689. dispose(): void;
  14690. /**
  14691. * The mesh that is attached to the controller
  14692. */
  14693. readonly mesh: Nullable<AbstractMesh>;
  14694. /**
  14695. * Gets the ray of the controller in the direction the controller is pointing
  14696. * @param length the length the resulting ray should be
  14697. * @returns a ray in the direction the controller is pointing
  14698. */
  14699. getForwardRay(length?: number): Ray;
  14700. }
  14701. }
  14702. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14703. import { Observable } from "babylonjs/Misc/observable";
  14704. import { Scene } from "babylonjs/scene";
  14705. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14706. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14707. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14708. import { Nullable } from "babylonjs/types";
  14709. /**
  14710. * Defines the WebVRController object that represents controllers tracked in 3D space
  14711. */
  14712. export abstract class WebVRController extends PoseEnabledController {
  14713. /**
  14714. * Internal, the default controller model for the controller
  14715. */
  14716. protected _defaultModel: Nullable<AbstractMesh>;
  14717. /**
  14718. * Fired when the trigger state has changed
  14719. */
  14720. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14721. /**
  14722. * Fired when the main button state has changed
  14723. */
  14724. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14725. /**
  14726. * Fired when the secondary button state has changed
  14727. */
  14728. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14729. /**
  14730. * Fired when the pad state has changed
  14731. */
  14732. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14733. /**
  14734. * Fired when controllers stick values have changed
  14735. */
  14736. onPadValuesChangedObservable: Observable<StickValues>;
  14737. /**
  14738. * Array of button availible on the controller
  14739. */
  14740. protected _buttons: Array<MutableGamepadButton>;
  14741. private _onButtonStateChange;
  14742. /**
  14743. * Fired when a controller button's state has changed
  14744. * @param callback the callback containing the button that was modified
  14745. */
  14746. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14747. /**
  14748. * X and Y axis corresponding to the controllers joystick
  14749. */
  14750. pad: StickValues;
  14751. /**
  14752. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14753. */
  14754. hand: string;
  14755. /**
  14756. * The default controller model for the controller
  14757. */
  14758. readonly defaultModel: Nullable<AbstractMesh>;
  14759. /**
  14760. * Creates a new WebVRController from a gamepad
  14761. * @param vrGamepad the gamepad that the WebVRController should be created from
  14762. */
  14763. constructor(vrGamepad: any);
  14764. /**
  14765. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14766. */
  14767. update(): void;
  14768. /**
  14769. * Function to be called when a button is modified
  14770. */
  14771. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14772. /**
  14773. * Loads a mesh and attaches it to the controller
  14774. * @param scene the scene the mesh should be added to
  14775. * @param meshLoaded callback for when the mesh has been loaded
  14776. */
  14777. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14778. private _setButtonValue;
  14779. private _changes;
  14780. private _checkChanges;
  14781. /**
  14782. * Disposes of th webVRCOntroller
  14783. */
  14784. dispose(): void;
  14785. }
  14786. }
  14787. declare module "babylonjs/Lights/hemisphericLight" {
  14788. import { Nullable } from "babylonjs/types";
  14789. import { Scene } from "babylonjs/scene";
  14790. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14791. import { Color3 } from "babylonjs/Maths/math.color";
  14792. import { Effect } from "babylonjs/Materials/effect";
  14793. import { Light } from "babylonjs/Lights/light";
  14794. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14795. /**
  14796. * The HemisphericLight simulates the ambient environment light,
  14797. * so the passed direction is the light reflection direction, not the incoming direction.
  14798. */
  14799. export class HemisphericLight extends Light {
  14800. /**
  14801. * The groundColor is the light in the opposite direction to the one specified during creation.
  14802. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  14803. */
  14804. groundColor: Color3;
  14805. /**
  14806. * The light reflection direction, not the incoming direction.
  14807. */
  14808. direction: Vector3;
  14809. /**
  14810. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14811. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14812. * The HemisphericLight can't cast shadows.
  14813. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14814. * @param name The friendly name of the light
  14815. * @param direction The direction of the light reflection
  14816. * @param scene The scene the light belongs to
  14817. */
  14818. constructor(name: string, direction: Vector3, scene: Scene);
  14819. protected _buildUniformLayout(): void;
  14820. /**
  14821. * Returns the string "HemisphericLight".
  14822. * @return The class name
  14823. */
  14824. getClassName(): string;
  14825. /**
  14826. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14827. * Returns the updated direction.
  14828. * @param target The target the direction should point to
  14829. * @return The computed direction
  14830. */
  14831. setDirectionToTarget(target: Vector3): Vector3;
  14832. /**
  14833. * Returns the shadow generator associated to the light.
  14834. * @returns Always null for hemispheric lights because it does not support shadows.
  14835. */
  14836. getShadowGenerator(): Nullable<IShadowGenerator>;
  14837. /**
  14838. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14839. * @param effect The effect to update
  14840. * @param lightIndex The index of the light in the effect to update
  14841. * @returns The hemispheric light
  14842. */
  14843. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14844. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14845. /**
  14846. * Computes the world matrix of the node
  14847. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14848. * @param useWasUpdatedFlag defines a reserved property
  14849. * @returns the world matrix
  14850. */
  14851. computeWorldMatrix(): Matrix;
  14852. /**
  14853. * Returns the integer 3.
  14854. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14855. */
  14856. getTypeID(): number;
  14857. /**
  14858. * Prepares the list of defines specific to the light type.
  14859. * @param defines the list of defines
  14860. * @param lightIndex defines the index of the light for the effect
  14861. */
  14862. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14863. }
  14864. }
  14865. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14866. /** @hidden */
  14867. export var vrMultiviewToSingleviewPixelShader: {
  14868. name: string;
  14869. shader: string;
  14870. };
  14871. }
  14872. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14873. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14874. import { Scene } from "babylonjs/scene";
  14875. /**
  14876. * Renders to multiple views with a single draw call
  14877. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14878. */
  14879. export class MultiviewRenderTarget extends RenderTargetTexture {
  14880. /**
  14881. * Creates a multiview render target
  14882. * @param scene scene used with the render target
  14883. * @param size the size of the render target (used for each view)
  14884. */
  14885. constructor(scene: Scene, size?: number | {
  14886. width: number;
  14887. height: number;
  14888. } | {
  14889. ratio: number;
  14890. });
  14891. /**
  14892. * @hidden
  14893. * @param faceIndex the face index, if its a cube texture
  14894. */
  14895. _bindFrameBuffer(faceIndex?: number): void;
  14896. /**
  14897. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14898. * @returns the view count
  14899. */
  14900. getViewCount(): number;
  14901. }
  14902. }
  14903. declare module "babylonjs/Maths/math.frustum" {
  14904. import { Matrix } from "babylonjs/Maths/math.vector";
  14905. import { DeepImmutable } from "babylonjs/types";
  14906. import { Plane } from "babylonjs/Maths/math.plane";
  14907. /**
  14908. * Represents a camera frustum
  14909. */
  14910. export class Frustum {
  14911. /**
  14912. * Gets the planes representing the frustum
  14913. * @param transform matrix to be applied to the returned planes
  14914. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14915. */
  14916. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14917. /**
  14918. * Gets the near frustum plane transformed by the transform matrix
  14919. * @param transform transformation matrix to be applied to the resulting frustum plane
  14920. * @param frustumPlane the resuling frustum plane
  14921. */
  14922. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14923. /**
  14924. * Gets the far frustum plane transformed by the transform matrix
  14925. * @param transform transformation matrix to be applied to the resulting frustum plane
  14926. * @param frustumPlane the resuling frustum plane
  14927. */
  14928. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14929. /**
  14930. * Gets the left frustum plane transformed by the transform matrix
  14931. * @param transform transformation matrix to be applied to the resulting frustum plane
  14932. * @param frustumPlane the resuling frustum plane
  14933. */
  14934. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14935. /**
  14936. * Gets the right frustum plane transformed by the transform matrix
  14937. * @param transform transformation matrix to be applied to the resulting frustum plane
  14938. * @param frustumPlane the resuling frustum plane
  14939. */
  14940. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14941. /**
  14942. * Gets the top frustum plane transformed by the transform matrix
  14943. * @param transform transformation matrix to be applied to the resulting frustum plane
  14944. * @param frustumPlane the resuling frustum plane
  14945. */
  14946. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14947. /**
  14948. * Gets the bottom frustum plane transformed by the transform matrix
  14949. * @param transform transformation matrix to be applied to the resulting frustum plane
  14950. * @param frustumPlane the resuling frustum plane
  14951. */
  14952. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14953. /**
  14954. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14955. * @param transform transformation matrix to be applied to the resulting frustum planes
  14956. * @param frustumPlanes the resuling frustum planes
  14957. */
  14958. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14959. }
  14960. }
  14961. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14962. import { Camera } from "babylonjs/Cameras/camera";
  14963. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14964. import { Nullable } from "babylonjs/types";
  14965. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14966. import { Matrix } from "babylonjs/Maths/math.vector";
  14967. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14968. module "babylonjs/Engines/engine" {
  14969. interface Engine {
  14970. /**
  14971. * Creates a new multiview render target
  14972. * @param width defines the width of the texture
  14973. * @param height defines the height of the texture
  14974. * @returns the created multiview texture
  14975. */
  14976. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14977. /**
  14978. * Binds a multiview framebuffer to be drawn to
  14979. * @param multiviewTexture texture to bind
  14980. */
  14981. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14982. }
  14983. }
  14984. module "babylonjs/Cameras/camera" {
  14985. interface Camera {
  14986. /**
  14987. * @hidden
  14988. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14989. */
  14990. _useMultiviewToSingleView: boolean;
  14991. /**
  14992. * @hidden
  14993. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  14994. */
  14995. _multiviewTexture: Nullable<RenderTargetTexture>;
  14996. /**
  14997. * @hidden
  14998. * ensures the multiview texture of the camera exists and has the specified width/height
  14999. * @param width height to set on the multiview texture
  15000. * @param height width to set on the multiview texture
  15001. */
  15002. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15003. }
  15004. }
  15005. module "babylonjs/scene" {
  15006. interface Scene {
  15007. /** @hidden */
  15008. _transformMatrixR: Matrix;
  15009. /** @hidden */
  15010. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15011. /** @hidden */
  15012. _createMultiviewUbo(): void;
  15013. /** @hidden */
  15014. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15015. /** @hidden */
  15016. _renderMultiviewToSingleView(camera: Camera): void;
  15017. }
  15018. }
  15019. }
  15020. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15021. import { Camera } from "babylonjs/Cameras/camera";
  15022. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15023. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15024. import "babylonjs/Engines/Extensions/engine.multiview";
  15025. /**
  15026. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15027. * This will not be used for webXR as it supports displaying texture arrays directly
  15028. */
  15029. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15030. /**
  15031. * Initializes a VRMultiviewToSingleview
  15032. * @param name name of the post process
  15033. * @param camera camera to be applied to
  15034. * @param scaleFactor scaling factor to the size of the output texture
  15035. */
  15036. constructor(name: string, camera: Camera, scaleFactor: number);
  15037. }
  15038. }
  15039. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15040. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15041. import { Nullable } from "babylonjs/types";
  15042. import { Size } from "babylonjs/Maths/math.size";
  15043. import { Observable } from "babylonjs/Misc/observable";
  15044. module "babylonjs/Engines/engine" {
  15045. interface Engine {
  15046. /** @hidden */
  15047. _vrDisplay: any;
  15048. /** @hidden */
  15049. _vrSupported: boolean;
  15050. /** @hidden */
  15051. _oldSize: Size;
  15052. /** @hidden */
  15053. _oldHardwareScaleFactor: number;
  15054. /** @hidden */
  15055. _vrExclusivePointerMode: boolean;
  15056. /** @hidden */
  15057. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15058. /** @hidden */
  15059. _onVRDisplayPointerRestricted: () => void;
  15060. /** @hidden */
  15061. _onVRDisplayPointerUnrestricted: () => void;
  15062. /** @hidden */
  15063. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15064. /** @hidden */
  15065. _onVrDisplayDisconnect: Nullable<() => void>;
  15066. /** @hidden */
  15067. _onVrDisplayPresentChange: Nullable<() => void>;
  15068. /**
  15069. * Observable signaled when VR display mode changes
  15070. */
  15071. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15072. /**
  15073. * Observable signaled when VR request present is complete
  15074. */
  15075. onVRRequestPresentComplete: Observable<boolean>;
  15076. /**
  15077. * Observable signaled when VR request present starts
  15078. */
  15079. onVRRequestPresentStart: Observable<Engine>;
  15080. /**
  15081. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15082. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15083. */
  15084. isInVRExclusivePointerMode: boolean;
  15085. /**
  15086. * Gets a boolean indicating if a webVR device was detected
  15087. * @returns true if a webVR device was detected
  15088. */
  15089. isVRDevicePresent(): boolean;
  15090. /**
  15091. * Gets the current webVR device
  15092. * @returns the current webVR device (or null)
  15093. */
  15094. getVRDevice(): any;
  15095. /**
  15096. * Initializes a webVR display and starts listening to display change events
  15097. * The onVRDisplayChangedObservable will be notified upon these changes
  15098. * @returns A promise containing a VRDisplay and if vr is supported
  15099. */
  15100. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15101. /** @hidden */
  15102. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /**
  15104. * Call this function to switch to webVR mode
  15105. * Will do nothing if webVR is not supported or if there is no webVR device
  15106. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15107. */
  15108. enableVR(): void;
  15109. /** @hidden */
  15110. _onVRFullScreenTriggered(): void;
  15111. }
  15112. }
  15113. }
  15114. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15115. import { Nullable } from "babylonjs/types";
  15116. import { Observable } from "babylonjs/Misc/observable";
  15117. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15118. import { Scene } from "babylonjs/scene";
  15119. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15120. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15121. import { Node } from "babylonjs/node";
  15122. import { Ray } from "babylonjs/Culling/ray";
  15123. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15124. import "babylonjs/Engines/Extensions/engine.webVR";
  15125. /**
  15126. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15127. * IMPORTANT!! The data is right-hand data.
  15128. * @export
  15129. * @interface DevicePose
  15130. */
  15131. export interface DevicePose {
  15132. /**
  15133. * The position of the device, values in array are [x,y,z].
  15134. */
  15135. readonly position: Nullable<Float32Array>;
  15136. /**
  15137. * The linearVelocity of the device, values in array are [x,y,z].
  15138. */
  15139. readonly linearVelocity: Nullable<Float32Array>;
  15140. /**
  15141. * The linearAcceleration of the device, values in array are [x,y,z].
  15142. */
  15143. readonly linearAcceleration: Nullable<Float32Array>;
  15144. /**
  15145. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15146. */
  15147. readonly orientation: Nullable<Float32Array>;
  15148. /**
  15149. * The angularVelocity of the device, values in array are [x,y,z].
  15150. */
  15151. readonly angularVelocity: Nullable<Float32Array>;
  15152. /**
  15153. * The angularAcceleration of the device, values in array are [x,y,z].
  15154. */
  15155. readonly angularAcceleration: Nullable<Float32Array>;
  15156. }
  15157. /**
  15158. * Interface representing a pose controlled object in Babylon.
  15159. * A pose controlled object has both regular pose values as well as pose values
  15160. * from an external device such as a VR head mounted display
  15161. */
  15162. export interface PoseControlled {
  15163. /**
  15164. * The position of the object in babylon space.
  15165. */
  15166. position: Vector3;
  15167. /**
  15168. * The rotation quaternion of the object in babylon space.
  15169. */
  15170. rotationQuaternion: Quaternion;
  15171. /**
  15172. * The position of the device in babylon space.
  15173. */
  15174. devicePosition?: Vector3;
  15175. /**
  15176. * The rotation quaternion of the device in babylon space.
  15177. */
  15178. deviceRotationQuaternion: Quaternion;
  15179. /**
  15180. * The raw pose coming from the device.
  15181. */
  15182. rawPose: Nullable<DevicePose>;
  15183. /**
  15184. * The scale of the device to be used when translating from device space to babylon space.
  15185. */
  15186. deviceScaleFactor: number;
  15187. /**
  15188. * Updates the poseControlled values based on the input device pose.
  15189. * @param poseData the pose data to update the object with
  15190. */
  15191. updateFromDevice(poseData: DevicePose): void;
  15192. }
  15193. /**
  15194. * Set of options to customize the webVRCamera
  15195. */
  15196. export interface WebVROptions {
  15197. /**
  15198. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15199. */
  15200. trackPosition?: boolean;
  15201. /**
  15202. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15203. */
  15204. positionScale?: number;
  15205. /**
  15206. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15207. */
  15208. displayName?: string;
  15209. /**
  15210. * Should the native controller meshes be initialized. (default: true)
  15211. */
  15212. controllerMeshes?: boolean;
  15213. /**
  15214. * Creating a default HemiLight only on controllers. (default: true)
  15215. */
  15216. defaultLightingOnControllers?: boolean;
  15217. /**
  15218. * If you don't want to use the default VR button of the helper. (default: false)
  15219. */
  15220. useCustomVRButton?: boolean;
  15221. /**
  15222. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15223. */
  15224. customVRButton?: HTMLButtonElement;
  15225. /**
  15226. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15227. */
  15228. rayLength?: number;
  15229. /**
  15230. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15231. */
  15232. defaultHeight?: number;
  15233. /**
  15234. * If multiview should be used if availible (default: false)
  15235. */
  15236. useMultiview?: boolean;
  15237. }
  15238. /**
  15239. * This represents a WebVR camera.
  15240. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15241. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15242. */
  15243. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15244. private webVROptions;
  15245. /**
  15246. * @hidden
  15247. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15248. */
  15249. _vrDevice: any;
  15250. /**
  15251. * The rawPose of the vrDevice.
  15252. */
  15253. rawPose: Nullable<DevicePose>;
  15254. private _onVREnabled;
  15255. private _specsVersion;
  15256. private _attached;
  15257. private _frameData;
  15258. protected _descendants: Array<Node>;
  15259. private _deviceRoomPosition;
  15260. /** @hidden */
  15261. _deviceRoomRotationQuaternion: Quaternion;
  15262. private _standingMatrix;
  15263. /**
  15264. * Represents device position in babylon space.
  15265. */
  15266. devicePosition: Vector3;
  15267. /**
  15268. * Represents device rotation in babylon space.
  15269. */
  15270. deviceRotationQuaternion: Quaternion;
  15271. /**
  15272. * The scale of the device to be used when translating from device space to babylon space.
  15273. */
  15274. deviceScaleFactor: number;
  15275. private _deviceToWorld;
  15276. private _worldToDevice;
  15277. /**
  15278. * References to the webVR controllers for the vrDevice.
  15279. */
  15280. controllers: Array<WebVRController>;
  15281. /**
  15282. * Emits an event when a controller is attached.
  15283. */
  15284. onControllersAttachedObservable: Observable<WebVRController[]>;
  15285. /**
  15286. * Emits an event when a controller's mesh has been loaded;
  15287. */
  15288. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15289. /**
  15290. * Emits an event when the HMD's pose has been updated.
  15291. */
  15292. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15293. private _poseSet;
  15294. /**
  15295. * If the rig cameras be used as parent instead of this camera.
  15296. */
  15297. rigParenting: boolean;
  15298. private _lightOnControllers;
  15299. private _defaultHeight?;
  15300. /**
  15301. * Instantiates a WebVRFreeCamera.
  15302. * @param name The name of the WebVRFreeCamera
  15303. * @param position The starting anchor position for the camera
  15304. * @param scene The scene the camera belongs to
  15305. * @param webVROptions a set of customizable options for the webVRCamera
  15306. */
  15307. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15308. /**
  15309. * Gets the device distance from the ground in meters.
  15310. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  15311. */
  15312. deviceDistanceToRoomGround(): number;
  15313. /**
  15314. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15315. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15316. */
  15317. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15318. /**
  15319. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15320. * @returns A promise with a boolean set to if the standing matrix is supported.
  15321. */
  15322. useStandingMatrixAsync(): Promise<boolean>;
  15323. /**
  15324. * Disposes the camera
  15325. */
  15326. dispose(): void;
  15327. /**
  15328. * Gets a vrController by name.
  15329. * @param name The name of the controller to retreive
  15330. * @returns the controller matching the name specified or null if not found
  15331. */
  15332. getControllerByName(name: string): Nullable<WebVRController>;
  15333. private _leftController;
  15334. /**
  15335. * The controller corresponding to the users left hand.
  15336. */
  15337. readonly leftController: Nullable<WebVRController>;
  15338. private _rightController;
  15339. /**
  15340. * The controller corresponding to the users right hand.
  15341. */
  15342. readonly rightController: Nullable<WebVRController>;
  15343. /**
  15344. * Casts a ray forward from the vrCamera's gaze.
  15345. * @param length Length of the ray (default: 100)
  15346. * @returns the ray corresponding to the gaze
  15347. */
  15348. getForwardRay(length?: number): Ray;
  15349. /**
  15350. * @hidden
  15351. * Updates the camera based on device's frame data
  15352. */
  15353. _checkInputs(): void;
  15354. /**
  15355. * Updates the poseControlled values based on the input device pose.
  15356. * @param poseData Pose coming from the device
  15357. */
  15358. updateFromDevice(poseData: DevicePose): void;
  15359. private _htmlElementAttached;
  15360. private _detachIfAttached;
  15361. /**
  15362. * WebVR's attach control will start broadcasting frames to the device.
  15363. * Note that in certain browsers (chrome for example) this function must be called
  15364. * within a user-interaction callback. Example:
  15365. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15366. *
  15367. * @param element html element to attach the vrDevice to
  15368. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15369. */
  15370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15371. /**
  15372. * Detaches the camera from the html element and disables VR
  15373. *
  15374. * @param element html element to detach from
  15375. */
  15376. detachControl(element: HTMLElement): void;
  15377. /**
  15378. * @returns the name of this class
  15379. */
  15380. getClassName(): string;
  15381. /**
  15382. * Calls resetPose on the vrDisplay
  15383. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15384. */
  15385. resetToCurrentRotation(): void;
  15386. /**
  15387. * @hidden
  15388. * Updates the rig cameras (left and right eye)
  15389. */
  15390. _updateRigCameras(): void;
  15391. private _workingVector;
  15392. private _oneVector;
  15393. private _workingMatrix;
  15394. private updateCacheCalled;
  15395. private _correctPositionIfNotTrackPosition;
  15396. /**
  15397. * @hidden
  15398. * Updates the cached values of the camera
  15399. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15400. */
  15401. _updateCache(ignoreParentClass?: boolean): void;
  15402. /**
  15403. * @hidden
  15404. * Get current device position in babylon world
  15405. */
  15406. _computeDevicePosition(): void;
  15407. /**
  15408. * Updates the current device position and rotation in the babylon world
  15409. */
  15410. update(): void;
  15411. /**
  15412. * @hidden
  15413. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15414. * @returns an identity matrix
  15415. */
  15416. _getViewMatrix(): Matrix;
  15417. private _tmpMatrix;
  15418. /**
  15419. * This function is called by the two RIG cameras.
  15420. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15421. * @hidden
  15422. */
  15423. _getWebVRViewMatrix(): Matrix;
  15424. /** @hidden */
  15425. _getWebVRProjectionMatrix(): Matrix;
  15426. private _onGamepadConnectedObserver;
  15427. private _onGamepadDisconnectedObserver;
  15428. private _updateCacheWhenTrackingDisabledObserver;
  15429. /**
  15430. * Initializes the controllers and their meshes
  15431. */
  15432. initControllers(): void;
  15433. }
  15434. }
  15435. declare module "babylonjs/PostProcesses/postProcess" {
  15436. import { Nullable } from "babylonjs/types";
  15437. import { SmartArray } from "babylonjs/Misc/smartArray";
  15438. import { Observable } from "babylonjs/Misc/observable";
  15439. import { Vector2 } from "babylonjs/Maths/math.vector";
  15440. import { Camera } from "babylonjs/Cameras/camera";
  15441. import { Effect } from "babylonjs/Materials/effect";
  15442. import "babylonjs/Shaders/postprocess.vertex";
  15443. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15444. import { Engine } from "babylonjs/Engines/engine";
  15445. import { Color4 } from "babylonjs/Maths/math.color";
  15446. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15448. /**
  15449. * Size options for a post process
  15450. */
  15451. export type PostProcessOptions = {
  15452. width: number;
  15453. height: number;
  15454. };
  15455. /**
  15456. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15457. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15458. */
  15459. export class PostProcess {
  15460. /** Name of the PostProcess. */
  15461. name: string;
  15462. /**
  15463. * Gets or sets the unique id of the post process
  15464. */
  15465. uniqueId: number;
  15466. /**
  15467. * Width of the texture to apply the post process on
  15468. */
  15469. width: number;
  15470. /**
  15471. * Height of the texture to apply the post process on
  15472. */
  15473. height: number;
  15474. /**
  15475. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15476. * @hidden
  15477. */
  15478. _outputTexture: Nullable<InternalTexture>;
  15479. /**
  15480. * Sampling mode used by the shader
  15481. * See https://doc.babylonjs.com/classes/3.1/texture
  15482. */
  15483. renderTargetSamplingMode: number;
  15484. /**
  15485. * Clear color to use when screen clearing
  15486. */
  15487. clearColor: Color4;
  15488. /**
  15489. * If the buffer needs to be cleared before applying the post process. (default: true)
  15490. * Should be set to false if shader will overwrite all previous pixels.
  15491. */
  15492. autoClear: boolean;
  15493. /**
  15494. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15495. */
  15496. alphaMode: number;
  15497. /**
  15498. * Sets the setAlphaBlendConstants of the babylon engine
  15499. */
  15500. alphaConstants: Color4;
  15501. /**
  15502. * Animations to be used for the post processing
  15503. */
  15504. animations: import("babylonjs/Animations/animation").Animation[];
  15505. /**
  15506. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15507. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15508. */
  15509. enablePixelPerfectMode: boolean;
  15510. /**
  15511. * Force the postprocess to be applied without taking in account viewport
  15512. */
  15513. forceFullscreenViewport: boolean;
  15514. /**
  15515. * List of inspectable custom properties (used by the Inspector)
  15516. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15517. */
  15518. inspectableCustomProperties: IInspectable[];
  15519. /**
  15520. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15521. *
  15522. * | Value | Type | Description |
  15523. * | ----- | ----------------------------------- | ----------- |
  15524. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15525. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15526. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15527. *
  15528. */
  15529. scaleMode: number;
  15530. /**
  15531. * Force textures to be a power of two (default: false)
  15532. */
  15533. alwaysForcePOT: boolean;
  15534. private _samples;
  15535. /**
  15536. * Number of sample textures (default: 1)
  15537. */
  15538. samples: number;
  15539. /**
  15540. * Modify the scale of the post process to be the same as the viewport (default: false)
  15541. */
  15542. adaptScaleToCurrentViewport: boolean;
  15543. private _camera;
  15544. private _scene;
  15545. private _engine;
  15546. private _options;
  15547. private _reusable;
  15548. private _textureType;
  15549. /**
  15550. * Smart array of input and output textures for the post process.
  15551. * @hidden
  15552. */
  15553. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15554. /**
  15555. * The index in _textures that corresponds to the output texture.
  15556. * @hidden
  15557. */
  15558. _currentRenderTextureInd: number;
  15559. private _effect;
  15560. private _samplers;
  15561. private _fragmentUrl;
  15562. private _vertexUrl;
  15563. private _parameters;
  15564. private _scaleRatio;
  15565. protected _indexParameters: any;
  15566. private _shareOutputWithPostProcess;
  15567. private _texelSize;
  15568. private _forcedOutputTexture;
  15569. /**
  15570. * Returns the fragment url or shader name used in the post process.
  15571. * @returns the fragment url or name in the shader store.
  15572. */
  15573. getEffectName(): string;
  15574. /**
  15575. * An event triggered when the postprocess is activated.
  15576. */
  15577. onActivateObservable: Observable<Camera>;
  15578. private _onActivateObserver;
  15579. /**
  15580. * A function that is added to the onActivateObservable
  15581. */
  15582. onActivate: Nullable<(camera: Camera) => void>;
  15583. /**
  15584. * An event triggered when the postprocess changes its size.
  15585. */
  15586. onSizeChangedObservable: Observable<PostProcess>;
  15587. private _onSizeChangedObserver;
  15588. /**
  15589. * A function that is added to the onSizeChangedObservable
  15590. */
  15591. onSizeChanged: (postProcess: PostProcess) => void;
  15592. /**
  15593. * An event triggered when the postprocess applies its effect.
  15594. */
  15595. onApplyObservable: Observable<Effect>;
  15596. private _onApplyObserver;
  15597. /**
  15598. * A function that is added to the onApplyObservable
  15599. */
  15600. onApply: (effect: Effect) => void;
  15601. /**
  15602. * An event triggered before rendering the postprocess
  15603. */
  15604. onBeforeRenderObservable: Observable<Effect>;
  15605. private _onBeforeRenderObserver;
  15606. /**
  15607. * A function that is added to the onBeforeRenderObservable
  15608. */
  15609. onBeforeRender: (effect: Effect) => void;
  15610. /**
  15611. * An event triggered after rendering the postprocess
  15612. */
  15613. onAfterRenderObservable: Observable<Effect>;
  15614. private _onAfterRenderObserver;
  15615. /**
  15616. * A function that is added to the onAfterRenderObservable
  15617. */
  15618. onAfterRender: (efect: Effect) => void;
  15619. /**
  15620. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  15621. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15622. */
  15623. inputTexture: InternalTexture;
  15624. /**
  15625. * Gets the camera which post process is applied to.
  15626. * @returns The camera the post process is applied to.
  15627. */
  15628. getCamera(): Camera;
  15629. /**
  15630. * Gets the texel size of the postprocess.
  15631. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15632. */
  15633. readonly texelSize: Vector2;
  15634. /**
  15635. * Creates a new instance PostProcess
  15636. * @param name The name of the PostProcess.
  15637. * @param fragmentUrl The url of the fragment shader to be used.
  15638. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15639. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15640. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15641. * @param camera The camera to apply the render pass to.
  15642. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15643. * @param engine The engine which the post process will be applied. (default: current engine)
  15644. * @param reusable If the post process can be reused on the same frame. (default: false)
  15645. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15646. * @param textureType Type of textures used when performing the post process. (default: 0)
  15647. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15648. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15649. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15650. */
  15651. constructor(
  15652. /** Name of the PostProcess. */
  15653. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean);
  15654. /**
  15655. * Gets a string idenfifying the name of the class
  15656. * @returns "PostProcess" string
  15657. */
  15658. getClassName(): string;
  15659. /**
  15660. * Gets the engine which this post process belongs to.
  15661. * @returns The engine the post process was enabled with.
  15662. */
  15663. getEngine(): Engine;
  15664. /**
  15665. * The effect that is created when initializing the post process.
  15666. * @returns The created effect corresponding the the postprocess.
  15667. */
  15668. getEffect(): Effect;
  15669. /**
  15670. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15671. * @param postProcess The post process to share the output with.
  15672. * @returns This post process.
  15673. */
  15674. shareOutputWith(postProcess: PostProcess): PostProcess;
  15675. /**
  15676. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15677. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15678. */
  15679. useOwnOutput(): void;
  15680. /**
  15681. * Updates the effect with the current post process compile time values and recompiles the shader.
  15682. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15683. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15684. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15685. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15686. * @param onCompiled Called when the shader has been compiled.
  15687. * @param onError Called if there is an error when compiling a shader.
  15688. */
  15689. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15690. /**
  15691. * The post process is reusable if it can be used multiple times within one frame.
  15692. * @returns If the post process is reusable
  15693. */
  15694. isReusable(): boolean;
  15695. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15696. markTextureDirty(): void;
  15697. /**
  15698. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15699. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  15700. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15701. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15702. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15703. * @returns The target texture that was bound to be written to.
  15704. */
  15705. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15706. /**
  15707. * If the post process is supported.
  15708. */
  15709. readonly isSupported: boolean;
  15710. /**
  15711. * The aspect ratio of the output texture.
  15712. */
  15713. readonly aspectRatio: number;
  15714. /**
  15715. * Get a value indicating if the post-process is ready to be used
  15716. * @returns true if the post-process is ready (shader is compiled)
  15717. */
  15718. isReady(): boolean;
  15719. /**
  15720. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15721. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15722. */
  15723. apply(): Nullable<Effect>;
  15724. private _disposeTextures;
  15725. /**
  15726. * Disposes the post process.
  15727. * @param camera The camera to dispose the post process on.
  15728. */
  15729. dispose(camera?: Camera): void;
  15730. }
  15731. }
  15732. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15733. /** @hidden */
  15734. export var kernelBlurVaryingDeclaration: {
  15735. name: string;
  15736. shader: string;
  15737. };
  15738. }
  15739. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15740. /** @hidden */
  15741. export var kernelBlurFragment: {
  15742. name: string;
  15743. shader: string;
  15744. };
  15745. }
  15746. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15747. /** @hidden */
  15748. export var kernelBlurFragment2: {
  15749. name: string;
  15750. shader: string;
  15751. };
  15752. }
  15753. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15754. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15755. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15757. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15758. /** @hidden */
  15759. export var kernelBlurPixelShader: {
  15760. name: string;
  15761. shader: string;
  15762. };
  15763. }
  15764. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15765. /** @hidden */
  15766. export var kernelBlurVertex: {
  15767. name: string;
  15768. shader: string;
  15769. };
  15770. }
  15771. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15772. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15773. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15774. /** @hidden */
  15775. export var kernelBlurVertexShader: {
  15776. name: string;
  15777. shader: string;
  15778. };
  15779. }
  15780. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15781. import { Vector2 } from "babylonjs/Maths/math.vector";
  15782. import { Nullable } from "babylonjs/types";
  15783. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15784. import { Camera } from "babylonjs/Cameras/camera";
  15785. import { Effect } from "babylonjs/Materials/effect";
  15786. import { Engine } from "babylonjs/Engines/engine";
  15787. import "babylonjs/Shaders/kernelBlur.fragment";
  15788. import "babylonjs/Shaders/kernelBlur.vertex";
  15789. /**
  15790. * The Blur Post Process which blurs an image based on a kernel and direction.
  15791. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15792. */
  15793. export class BlurPostProcess extends PostProcess {
  15794. /** The direction in which to blur the image. */
  15795. direction: Vector2;
  15796. private blockCompilation;
  15797. protected _kernel: number;
  15798. protected _idealKernel: number;
  15799. protected _packedFloat: boolean;
  15800. private _staticDefines;
  15801. /**
  15802. * Sets the length in pixels of the blur sample region
  15803. */
  15804. /**
  15805. * Gets the length in pixels of the blur sample region
  15806. */
  15807. kernel: number;
  15808. /**
  15809. * Sets wether or not the blur needs to unpack/repack floats
  15810. */
  15811. /**
  15812. * Gets wether or not the blur is unpacking/repacking floats
  15813. */
  15814. packedFloat: boolean;
  15815. /**
  15816. * Creates a new instance BlurPostProcess
  15817. * @param name The name of the effect.
  15818. * @param direction The direction in which to blur the image.
  15819. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  15820. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15821. * @param camera The camera to apply the render pass to.
  15822. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15823. * @param engine The engine which the post process will be applied. (default: current engine)
  15824. * @param reusable If the post process can be reused on the same frame. (default: false)
  15825. * @param textureType Type of textures used when performing the post process. (default: 0)
  15826. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  15827. */
  15828. constructor(name: string,
  15829. /** The direction in which to blur the image. */
  15830. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15831. /**
  15832. * Updates the effect with the current post process compile time values and recompiles the shader.
  15833. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15834. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15835. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15836. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  15837. * @param onCompiled Called when the shader has been compiled.
  15838. * @param onError Called if there is an error when compiling a shader.
  15839. */
  15840. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15841. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. /**
  15843. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15844. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15845. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15846. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15847. * The gaps between physical kernels are compensated for in the weighting of the samples
  15848. * @param idealKernel Ideal blur kernel.
  15849. * @return Nearest best kernel.
  15850. */
  15851. protected _nearestBestKernel(idealKernel: number): number;
  15852. /**
  15853. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15854. * @param x The point on the Gaussian distribution to sample.
  15855. * @return the value of the Gaussian function at x.
  15856. */
  15857. protected _gaussianWeight(x: number): number;
  15858. /**
  15859. * Generates a string that can be used as a floating point number in GLSL.
  15860. * @param x Value to print.
  15861. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15862. * @return GLSL float string.
  15863. */
  15864. protected _glslFloat(x: number, decimalFigures?: number): string;
  15865. }
  15866. }
  15867. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15868. import { Scene } from "babylonjs/scene";
  15869. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15870. import { Plane } from "babylonjs/Maths/math.plane";
  15871. /**
  15872. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15873. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15874. * You can then easily use it as a reflectionTexture on a flat surface.
  15875. * In case the surface is not a plane, please consider relying on reflection probes.
  15876. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15877. */
  15878. export class MirrorTexture extends RenderTargetTexture {
  15879. private scene;
  15880. /**
  15881. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15882. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  15883. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15884. */
  15885. mirrorPlane: Plane;
  15886. /**
  15887. * Define the blur ratio used to blur the reflection if needed.
  15888. */
  15889. blurRatio: number;
  15890. /**
  15891. * Define the adaptive blur kernel used to blur the reflection if needed.
  15892. * This will autocompute the closest best match for the `blurKernel`
  15893. */
  15894. adaptiveBlurKernel: number;
  15895. /**
  15896. * Define the blur kernel used to blur the reflection if needed.
  15897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15898. */
  15899. blurKernel: number;
  15900. /**
  15901. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15902. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15903. */
  15904. blurKernelX: number;
  15905. /**
  15906. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15907. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15908. */
  15909. blurKernelY: number;
  15910. private _autoComputeBlurKernel;
  15911. protected _onRatioRescale(): void;
  15912. private _updateGammaSpace;
  15913. private _imageProcessingConfigChangeObserver;
  15914. private _transformMatrix;
  15915. private _mirrorMatrix;
  15916. private _savedViewMatrix;
  15917. private _blurX;
  15918. private _blurY;
  15919. private _adaptiveBlurKernel;
  15920. private _blurKernelX;
  15921. private _blurKernelY;
  15922. private _blurRatio;
  15923. /**
  15924. * Instantiates a Mirror Texture.
  15925. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15926. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15927. * You can then easily use it as a reflectionTexture on a flat surface.
  15928. * In case the surface is not a plane, please consider relying on reflection probes.
  15929. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15930. * @param name
  15931. * @param size
  15932. * @param scene
  15933. * @param generateMipMaps
  15934. * @param type
  15935. * @param samplingMode
  15936. * @param generateDepthBuffer
  15937. */
  15938. constructor(name: string, size: number | {
  15939. width: number;
  15940. height: number;
  15941. } | {
  15942. ratio: number;
  15943. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15944. private _preparePostProcesses;
  15945. /**
  15946. * Clone the mirror texture.
  15947. * @returns the cloned texture
  15948. */
  15949. clone(): MirrorTexture;
  15950. /**
  15951. * Serialize the texture to a JSON representation you could use in Parse later on
  15952. * @returns the serialized JSON representation
  15953. */
  15954. serialize(): any;
  15955. /**
  15956. * Dispose the texture and release its associated resources.
  15957. */
  15958. dispose(): void;
  15959. }
  15960. }
  15961. declare module "babylonjs/Materials/Textures/texture" {
  15962. import { Observable } from "babylonjs/Misc/observable";
  15963. import { Nullable } from "babylonjs/types";
  15964. import { Matrix } from "babylonjs/Maths/math.vector";
  15965. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15966. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15967. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15968. import { Scene } from "babylonjs/scene";
  15969. /**
  15970. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15971. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15972. */
  15973. export class Texture extends BaseTexture {
  15974. /**
  15975. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15976. */
  15977. static SerializeBuffers: boolean;
  15978. /** @hidden */
  15979. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15980. /** @hidden */
  15981. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15982. /** @hidden */
  15983. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15984. /** nearest is mag = nearest and min = nearest and mip = linear */
  15985. static readonly NEAREST_SAMPLINGMODE: number;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15988. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15989. static readonly BILINEAR_SAMPLINGMODE: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15992. /** Trilinear is mag = linear and min = linear and mip = linear */
  15993. static readonly TRILINEAR_SAMPLINGMODE: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15996. /** mag = nearest and min = nearest and mip = nearest */
  15997. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15998. /** mag = nearest and min = linear and mip = nearest */
  15999. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = linear */
  16001. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16002. /** mag = nearest and min = linear and mip = none */
  16003. static readonly NEAREST_LINEAR: number;
  16004. /** mag = nearest and min = nearest and mip = none */
  16005. static readonly NEAREST_NEAREST: number;
  16006. /** mag = linear and min = nearest and mip = nearest */
  16007. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16008. /** mag = linear and min = nearest and mip = linear */
  16009. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16010. /** mag = linear and min = linear and mip = none */
  16011. static readonly LINEAR_LINEAR: number;
  16012. /** mag = linear and min = nearest and mip = none */
  16013. static readonly LINEAR_NEAREST: number;
  16014. /** Explicit coordinates mode */
  16015. static readonly EXPLICIT_MODE: number;
  16016. /** Spherical coordinates mode */
  16017. static readonly SPHERICAL_MODE: number;
  16018. /** Planar coordinates mode */
  16019. static readonly PLANAR_MODE: number;
  16020. /** Cubic coordinates mode */
  16021. static readonly CUBIC_MODE: number;
  16022. /** Projection coordinates mode */
  16023. static readonly PROJECTION_MODE: number;
  16024. /** Inverse Cubic coordinates mode */
  16025. static readonly SKYBOX_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly INVCUBIC_MODE: number;
  16028. /** Equirectangular coordinates mode */
  16029. static readonly EQUIRECTANGULAR_MODE: number;
  16030. /** Equirectangular Fixed coordinates mode */
  16031. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed Mirrored coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16034. /** Texture is not repeating outside of 0..1 UVs */
  16035. static readonly CLAMP_ADDRESSMODE: number;
  16036. /** Texture is repeating outside of 0..1 UVs */
  16037. static readonly WRAP_ADDRESSMODE: number;
  16038. /** Texture is repeating and mirrored */
  16039. static readonly MIRROR_ADDRESSMODE: number;
  16040. /**
  16041. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  16042. */
  16043. static UseSerializedUrlIfAny: boolean;
  16044. /**
  16045. * Define the url of the texture.
  16046. */
  16047. url: Nullable<string>;
  16048. /**
  16049. * Define an offset on the texture to offset the u coordinates of the UVs
  16050. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16051. */
  16052. uOffset: number;
  16053. /**
  16054. * Define an offset on the texture to offset the v coordinates of the UVs
  16055. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16056. */
  16057. vOffset: number;
  16058. /**
  16059. * Define an offset on the texture to scale the u coordinates of the UVs
  16060. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16061. */
  16062. uScale: number;
  16063. /**
  16064. * Define an offset on the texture to scale the v coordinates of the UVs
  16065. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16066. */
  16067. vScale: number;
  16068. /**
  16069. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16070. * @see http://doc.babylonjs.com/how_to/more_materials
  16071. */
  16072. uAng: number;
  16073. /**
  16074. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16075. * @see http://doc.babylonjs.com/how_to/more_materials
  16076. */
  16077. vAng: number;
  16078. /**
  16079. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16080. * @see http://doc.babylonjs.com/how_to/more_materials
  16081. */
  16082. wAng: number;
  16083. /**
  16084. * Defines the center of rotation (U)
  16085. */
  16086. uRotationCenter: number;
  16087. /**
  16088. * Defines the center of rotation (V)
  16089. */
  16090. vRotationCenter: number;
  16091. /**
  16092. * Defines the center of rotation (W)
  16093. */
  16094. wRotationCenter: number;
  16095. /**
  16096. * Are mip maps generated for this texture or not.
  16097. */
  16098. readonly noMipmap: boolean;
  16099. /**
  16100. * List of inspectable custom properties (used by the Inspector)
  16101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16102. */
  16103. inspectableCustomProperties: Nullable<IInspectable[]>;
  16104. private _noMipmap;
  16105. /** @hidden */
  16106. _invertY: boolean;
  16107. private _rowGenerationMatrix;
  16108. private _cachedTextureMatrix;
  16109. private _projectionModeMatrix;
  16110. private _t0;
  16111. private _t1;
  16112. private _t2;
  16113. private _cachedUOffset;
  16114. private _cachedVOffset;
  16115. private _cachedUScale;
  16116. private _cachedVScale;
  16117. private _cachedUAng;
  16118. private _cachedVAng;
  16119. private _cachedWAng;
  16120. private _cachedProjectionMatrixId;
  16121. private _cachedCoordinatesMode;
  16122. /** @hidden */
  16123. protected _initialSamplingMode: number;
  16124. /** @hidden */
  16125. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16126. private _deleteBuffer;
  16127. protected _format: Nullable<number>;
  16128. private _delayedOnLoad;
  16129. private _delayedOnError;
  16130. /**
  16131. * Observable triggered once the texture has been loaded.
  16132. */
  16133. onLoadObservable: Observable<Texture>;
  16134. protected _isBlocking: boolean;
  16135. /**
  16136. * Is the texture preventing material to render while loading.
  16137. * If false, a default texture will be used instead of the loading one during the preparation step.
  16138. */
  16139. isBlocking: boolean;
  16140. /**
  16141. * Get the current sampling mode associated with the texture.
  16142. */
  16143. readonly samplingMode: number;
  16144. /**
  16145. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16146. */
  16147. readonly invertY: boolean;
  16148. /**
  16149. * Instantiates a new texture.
  16150. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16151. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16152. * @param url define the url of the picture to load as a texture
  16153. * @param scene define the scene or engine the texture will belong to
  16154. * @param noMipmap define if the texture will require mip maps or not
  16155. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16156. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16157. * @param onLoad define a callback triggered when the texture has been loaded
  16158. * @param onError define a callback triggered when an error occurred during the loading session
  16159. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16160. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16161. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16162. */
  16163. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  16164. /**
  16165. * Update the url (and optional buffer) of this texture if url was null during construction.
  16166. * @param url the url of the texture
  16167. * @param buffer the buffer of the texture (defaults to null)
  16168. * @param onLoad callback called when the texture is loaded (defaults to null)
  16169. */
  16170. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16171. /**
  16172. * Finish the loading sequence of a texture flagged as delayed load.
  16173. * @hidden
  16174. */
  16175. delayLoad(): void;
  16176. private _prepareRowForTextureGeneration;
  16177. /**
  16178. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16179. * @returns the transform matrix of the texture.
  16180. */
  16181. getTextureMatrix(): Matrix;
  16182. /**
  16183. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16184. * @returns The reflection texture transform
  16185. */
  16186. getReflectionTextureMatrix(): Matrix;
  16187. /**
  16188. * Clones the texture.
  16189. * @returns the cloned texture
  16190. */
  16191. clone(): Texture;
  16192. /**
  16193. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16194. * @returns The JSON representation of the texture
  16195. */
  16196. serialize(): any;
  16197. /**
  16198. * Get the current class name of the texture useful for serialization or dynamic coding.
  16199. * @returns "Texture"
  16200. */
  16201. getClassName(): string;
  16202. /**
  16203. * Dispose the texture and release its associated resources.
  16204. */
  16205. dispose(): void;
  16206. /**
  16207. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16208. * @param parsedTexture Define the JSON representation of the texture
  16209. * @param scene Define the scene the parsed texture should be instantiated in
  16210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16211. * @returns The parsed texture if successful
  16212. */
  16213. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16214. /**
  16215. * Creates a texture from its base 64 representation.
  16216. * @param data Define the base64 payload without the data: prefix
  16217. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16218. * @param scene Define the scene the texture should belong to
  16219. * @param noMipmap Forces the texture to not create mip map information if true
  16220. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16221. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16222. * @param onLoad define a callback triggered when the texture has been loaded
  16223. * @param onError define a callback triggered when an error occurred during the loading session
  16224. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16225. * @returns the created texture
  16226. */
  16227. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16228. /**
  16229. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16230. * @param data Define the base64 payload without the data: prefix
  16231. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16232. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16233. * @param scene Define the scene the texture should belong to
  16234. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16235. * @param noMipmap Forces the texture to not create mip map information if true
  16236. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16237. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16238. * @param onLoad define a callback triggered when the texture has been loaded
  16239. * @param onError define a callback triggered when an error occurred during the loading session
  16240. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16241. * @returns the created texture
  16242. */
  16243. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  16244. }
  16245. }
  16246. declare module "babylonjs/PostProcesses/postProcessManager" {
  16247. import { Nullable } from "babylonjs/types";
  16248. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16249. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16250. import { Scene } from "babylonjs/scene";
  16251. /**
  16252. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16253. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16254. */
  16255. export class PostProcessManager {
  16256. private _scene;
  16257. private _indexBuffer;
  16258. private _vertexBuffers;
  16259. /**
  16260. * Creates a new instance PostProcess
  16261. * @param scene The scene that the post process is associated with.
  16262. */
  16263. constructor(scene: Scene);
  16264. private _prepareBuffers;
  16265. private _buildIndexBuffer;
  16266. /**
  16267. * Rebuilds the vertex buffers of the manager.
  16268. * @hidden
  16269. */
  16270. _rebuild(): void;
  16271. /**
  16272. * Prepares a frame to be run through a post process.
  16273. * @param sourceTexture The input texture to the post procesess. (default: null)
  16274. * @param postProcesses An array of post processes to be run. (default: null)
  16275. * @returns True if the post processes were able to be run.
  16276. * @hidden
  16277. */
  16278. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16279. /**
  16280. * Manually render a set of post processes to a texture.
  16281. * @param postProcesses An array of post processes to be run.
  16282. * @param targetTexture The target texture to render to.
  16283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16285. * @param lodLevel defines which lod of the texture to render to
  16286. */
  16287. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16288. /**
  16289. * Finalize the result of the output of the postprocesses.
  16290. * @param doNotPresent If true the result will not be displayed to the screen.
  16291. * @param targetTexture The target texture to render to.
  16292. * @param faceIndex The index of the face to bind the target texture to.
  16293. * @param postProcesses The array of post processes to render.
  16294. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16295. * @hidden
  16296. */
  16297. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16298. /**
  16299. * Disposes of the post process manager.
  16300. */
  16301. dispose(): void;
  16302. }
  16303. }
  16304. declare module "babylonjs/Misc/gradients" {
  16305. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16306. /** Interface used by value gradients (color, factor, ...) */
  16307. export interface IValueGradient {
  16308. /**
  16309. * Gets or sets the gradient value (between 0 and 1)
  16310. */
  16311. gradient: number;
  16312. }
  16313. /** Class used to store color4 gradient */
  16314. export class ColorGradient implements IValueGradient {
  16315. /**
  16316. * Gets or sets the gradient value (between 0 and 1)
  16317. */
  16318. gradient: number;
  16319. /**
  16320. * Gets or sets first associated color
  16321. */
  16322. color1: Color4;
  16323. /**
  16324. * Gets or sets second associated color
  16325. */
  16326. color2?: Color4;
  16327. /**
  16328. * Will get a color picked randomly between color1 and color2.
  16329. * If color2 is undefined then color1 will be used
  16330. * @param result defines the target Color4 to store the result in
  16331. */
  16332. getColorToRef(result: Color4): void;
  16333. }
  16334. /** Class used to store color 3 gradient */
  16335. export class Color3Gradient implements IValueGradient {
  16336. /**
  16337. * Gets or sets the gradient value (between 0 and 1)
  16338. */
  16339. gradient: number;
  16340. /**
  16341. * Gets or sets the associated color
  16342. */
  16343. color: Color3;
  16344. }
  16345. /** Class used to store factor gradient */
  16346. export class FactorGradient implements IValueGradient {
  16347. /**
  16348. * Gets or sets the gradient value (between 0 and 1)
  16349. */
  16350. gradient: number;
  16351. /**
  16352. * Gets or sets first associated factor
  16353. */
  16354. factor1: number;
  16355. /**
  16356. * Gets or sets second associated factor
  16357. */
  16358. factor2?: number;
  16359. /**
  16360. * Will get a number picked randomly between factor1 and factor2.
  16361. * If factor2 is undefined then factor1 will be used
  16362. * @returns the picked number
  16363. */
  16364. getFactor(): number;
  16365. }
  16366. /**
  16367. * Helper used to simplify some generic gradient tasks
  16368. */
  16369. export class GradientHelper {
  16370. /**
  16371. * Gets the current gradient from an array of IValueGradient
  16372. * @param ratio defines the current ratio to get
  16373. * @param gradients defines the array of IValueGradient
  16374. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16375. */
  16376. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16377. }
  16378. }
  16379. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16380. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16381. import { Nullable } from "babylonjs/types";
  16382. module "babylonjs/Engines/thinEngine" {
  16383. interface ThinEngine {
  16384. /**
  16385. * Creates a dynamic texture
  16386. * @param width defines the width of the texture
  16387. * @param height defines the height of the texture
  16388. * @param generateMipMaps defines if the engine should generate the mip levels
  16389. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16390. * @returns the dynamic texture inside an InternalTexture
  16391. */
  16392. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16393. /**
  16394. * Update the content of a dynamic texture
  16395. * @param texture defines the texture to update
  16396. * @param canvas defines the canvas containing the source
  16397. * @param invertY defines if data must be stored with Y axis inverted
  16398. * @param premulAlpha defines if alpha is stored as premultiplied
  16399. * @param format defines the format of the data
  16400. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16401. */
  16402. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16403. }
  16404. }
  16405. }
  16406. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16407. import { Scene } from "babylonjs/scene";
  16408. import { Texture } from "babylonjs/Materials/Textures/texture";
  16409. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16410. /**
  16411. * A class extending Texture allowing drawing on a texture
  16412. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16413. */
  16414. export class DynamicTexture extends Texture {
  16415. private _generateMipMaps;
  16416. private _canvas;
  16417. private _context;
  16418. private _engine;
  16419. /**
  16420. * Creates a DynamicTexture
  16421. * @param name defines the name of the texture
  16422. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  16423. * @param scene defines the scene where you want the texture
  16424. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16425. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16426. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16427. */
  16428. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16429. /**
  16430. * Get the current class name of the texture useful for serialization or dynamic coding.
  16431. * @returns "DynamicTexture"
  16432. */
  16433. getClassName(): string;
  16434. /**
  16435. * Gets the current state of canRescale
  16436. */
  16437. readonly canRescale: boolean;
  16438. private _recreate;
  16439. /**
  16440. * Scales the texture
  16441. * @param ratio the scale factor to apply to both width and height
  16442. */
  16443. scale(ratio: number): void;
  16444. /**
  16445. * Resizes the texture
  16446. * @param width the new width
  16447. * @param height the new height
  16448. */
  16449. scaleTo(width: number, height: number): void;
  16450. /**
  16451. * Gets the context of the canvas used by the texture
  16452. * @returns the canvas context of the dynamic texture
  16453. */
  16454. getContext(): CanvasRenderingContext2D;
  16455. /**
  16456. * Clears the texture
  16457. */
  16458. clear(): void;
  16459. /**
  16460. * Updates the texture
  16461. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16462. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16463. */
  16464. update(invertY?: boolean, premulAlpha?: boolean): void;
  16465. /**
  16466. * Draws text onto the texture
  16467. * @param text defines the text to be drawn
  16468. * @param x defines the placement of the text from the left
  16469. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16470. * @param font defines the font to be used with font-style, font-size, font-name
  16471. * @param color defines the color used for the text
  16472. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16473. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16474. * @param update defines whether texture is immediately update (default is true)
  16475. */
  16476. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16477. /**
  16478. * Clones the texture
  16479. * @returns the clone of the texture.
  16480. */
  16481. clone(): DynamicTexture;
  16482. /**
  16483. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16484. * @returns a serialized dynamic texture object
  16485. */
  16486. serialize(): any;
  16487. /** @hidden */
  16488. _rebuild(): void;
  16489. }
  16490. }
  16491. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16492. import { Scene } from "babylonjs/scene";
  16493. import { ISceneComponent } from "babylonjs/sceneComponent";
  16494. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16495. module "babylonjs/abstractScene" {
  16496. interface AbstractScene {
  16497. /**
  16498. * The list of procedural textures added to the scene
  16499. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16500. */
  16501. proceduralTextures: Array<ProceduralTexture>;
  16502. }
  16503. }
  16504. /**
  16505. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16506. * in a given scene.
  16507. */
  16508. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16509. /**
  16510. * The component name helpfull to identify the component in the list of scene components.
  16511. */
  16512. readonly name: string;
  16513. /**
  16514. * The scene the component belongs to.
  16515. */
  16516. scene: Scene;
  16517. /**
  16518. * Creates a new instance of the component for the given scene
  16519. * @param scene Defines the scene to register the component in
  16520. */
  16521. constructor(scene: Scene);
  16522. /**
  16523. * Registers the component in a given scene
  16524. */
  16525. register(): void;
  16526. /**
  16527. * Rebuilds the elements related to this component in case of
  16528. * context lost for instance.
  16529. */
  16530. rebuild(): void;
  16531. /**
  16532. * Disposes the component and the associated ressources.
  16533. */
  16534. dispose(): void;
  16535. private _beforeClear;
  16536. }
  16537. }
  16538. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16539. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16540. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16541. module "babylonjs/Engines/thinEngine" {
  16542. interface ThinEngine {
  16543. /**
  16544. * Creates a new render target cube texture
  16545. * @param size defines the size of the texture
  16546. * @param options defines the options used to create the texture
  16547. * @returns a new render target cube texture stored in an InternalTexture
  16548. */
  16549. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16550. }
  16551. }
  16552. }
  16553. declare module "babylonjs/Shaders/procedural.vertex" {
  16554. /** @hidden */
  16555. export var proceduralVertexShader: {
  16556. name: string;
  16557. shader: string;
  16558. };
  16559. }
  16560. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16561. import { Observable } from "babylonjs/Misc/observable";
  16562. import { Nullable } from "babylonjs/types";
  16563. import { Scene } from "babylonjs/scene";
  16564. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16565. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16566. import { Effect } from "babylonjs/Materials/effect";
  16567. import { Texture } from "babylonjs/Materials/Textures/texture";
  16568. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16569. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16570. import "babylonjs/Shaders/procedural.vertex";
  16571. /**
  16572. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  16573. * This is the base class of any Procedural texture and contains most of the shareable code.
  16574. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16575. */
  16576. export class ProceduralTexture extends Texture {
  16577. isCube: boolean;
  16578. /**
  16579. * Define if the texture is enabled or not (disabled texture will not render)
  16580. */
  16581. isEnabled: boolean;
  16582. /**
  16583. * Define if the texture must be cleared before rendering (default is true)
  16584. */
  16585. autoClear: boolean;
  16586. /**
  16587. * Callback called when the texture is generated
  16588. */
  16589. onGenerated: () => void;
  16590. /**
  16591. * Event raised when the texture is generated
  16592. */
  16593. onGeneratedObservable: Observable<ProceduralTexture>;
  16594. /** @hidden */
  16595. _generateMipMaps: boolean;
  16596. /** @hidden **/
  16597. _effect: Effect;
  16598. /** @hidden */
  16599. _textures: {
  16600. [key: string]: Texture;
  16601. };
  16602. private _size;
  16603. private _currentRefreshId;
  16604. private _refreshRate;
  16605. private _vertexBuffers;
  16606. private _indexBuffer;
  16607. private _uniforms;
  16608. private _samplers;
  16609. private _fragment;
  16610. private _floats;
  16611. private _ints;
  16612. private _floatsArrays;
  16613. private _colors3;
  16614. private _colors4;
  16615. private _vectors2;
  16616. private _vectors3;
  16617. private _matrices;
  16618. private _fallbackTexture;
  16619. private _fallbackTextureUsed;
  16620. private _engine;
  16621. private _cachedDefines;
  16622. private _contentUpdateId;
  16623. private _contentData;
  16624. /**
  16625. * Instantiates a new procedural texture.
  16626. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  16627. * This is the base class of any Procedural texture and contains most of the shareable code.
  16628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16629. * @param name Define the name of the texture
  16630. * @param size Define the size of the texture to create
  16631. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16632. * @param scene Define the scene the texture belongs to
  16633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16634. * @param generateMipMaps Define if the texture should creates mip maps or not
  16635. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16636. */
  16637. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16638. /**
  16639. * The effect that is created when initializing the post process.
  16640. * @returns The created effect corresponding the the postprocess.
  16641. */
  16642. getEffect(): Effect;
  16643. /**
  16644. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16645. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16646. */
  16647. getContent(): Nullable<ArrayBufferView>;
  16648. private _createIndexBuffer;
  16649. /** @hidden */
  16650. _rebuild(): void;
  16651. /**
  16652. * Resets the texture in order to recreate its associated resources.
  16653. * This can be called in case of context loss
  16654. */
  16655. reset(): void;
  16656. protected _getDefines(): string;
  16657. /**
  16658. * Is the texture ready to be used ? (rendered at least once)
  16659. * @returns true if ready, otherwise, false.
  16660. */
  16661. isReady(): boolean;
  16662. /**
  16663. * Resets the refresh counter of the texture and start bak from scratch.
  16664. * Could be useful to regenerate the texture if it is setup to render only once.
  16665. */
  16666. resetRefreshCounter(): void;
  16667. /**
  16668. * Set the fragment shader to use in order to render the texture.
  16669. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16670. */
  16671. setFragment(fragment: any): void;
  16672. /**
  16673. * Define the refresh rate of the texture or the rendering frequency.
  16674. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16675. */
  16676. refreshRate: number;
  16677. /** @hidden */
  16678. _shouldRender(): boolean;
  16679. /**
  16680. * Get the size the texture is rendering at.
  16681. * @returns the size (texture is always squared)
  16682. */
  16683. getRenderSize(): number;
  16684. /**
  16685. * Resize the texture to new value.
  16686. * @param size Define the new size the texture should have
  16687. * @param generateMipMaps Define whether the new texture should create mip maps
  16688. */
  16689. resize(size: number, generateMipMaps: boolean): void;
  16690. private _checkUniform;
  16691. /**
  16692. * Set a texture in the shader program used to render.
  16693. * @param name Define the name of the uniform samplers as defined in the shader
  16694. * @param texture Define the texture to bind to this sampler
  16695. * @return the texture itself allowing "fluent" like uniform updates
  16696. */
  16697. setTexture(name: string, texture: Texture): ProceduralTexture;
  16698. /**
  16699. * Set a float in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the texture itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloat(name: string, value: number): ProceduralTexture;
  16705. /**
  16706. * Set a int in the shader.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the texture itself allowing "fluent" like uniform updates
  16710. */
  16711. setInt(name: string, value: number): ProceduralTexture;
  16712. /**
  16713. * Set an array of floats in the shader.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the texture itself allowing "fluent" like uniform updates
  16717. */
  16718. setFloats(name: string, value: number[]): ProceduralTexture;
  16719. /**
  16720. * Set a vec3 in the shader from a Color3.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the texture itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor3(name: string, value: Color3): ProceduralTexture;
  16726. /**
  16727. * Set a vec4 in the shader from a Color4.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the texture itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4(name: string, value: Color4): ProceduralTexture;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the texture itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ProceduralTexture;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the texture itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ProceduralTexture;
  16747. /**
  16748. * Set a mat4 in the shader from a MAtrix.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the texture itself allowing "fluent" like uniform updates
  16752. */
  16753. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16754. /**
  16755. * Render the texture to its associated render target.
  16756. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16757. */
  16758. render(useCameraPostProcess?: boolean): void;
  16759. /**
  16760. * Clone the texture.
  16761. * @returns the cloned texture
  16762. */
  16763. clone(): ProceduralTexture;
  16764. /**
  16765. * Dispose the texture and release its asoociated resources.
  16766. */
  16767. dispose(): void;
  16768. }
  16769. }
  16770. declare module "babylonjs/Particles/baseParticleSystem" {
  16771. import { Nullable } from "babylonjs/types";
  16772. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16774. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16775. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16776. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16777. import { Scene } from "babylonjs/scene";
  16778. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16779. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16780. import { Texture } from "babylonjs/Materials/Textures/texture";
  16781. import { Color4 } from "babylonjs/Maths/math.color";
  16782. import { Animation } from "babylonjs/Animations/animation";
  16783. /**
  16784. * This represents the base class for particle system in Babylon.
  16785. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  16786. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16787. * @example https://doc.babylonjs.com/babylon101/particles
  16788. */
  16789. export class BaseParticleSystem {
  16790. /**
  16791. * Source color is added to the destination color without alpha affecting the result
  16792. */
  16793. static BLENDMODE_ONEONE: number;
  16794. /**
  16795. * Blend current color and particle color using particle’s alpha
  16796. */
  16797. static BLENDMODE_STANDARD: number;
  16798. /**
  16799. * Add current color and particle color multiplied by particle’s alpha
  16800. */
  16801. static BLENDMODE_ADD: number;
  16802. /**
  16803. * Multiply current color with particle color
  16804. */
  16805. static BLENDMODE_MULTIPLY: number;
  16806. /**
  16807. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16808. */
  16809. static BLENDMODE_MULTIPLYADD: number;
  16810. /**
  16811. * List of animations used by the particle system.
  16812. */
  16813. animations: Animation[];
  16814. /**
  16815. * The id of the Particle system.
  16816. */
  16817. id: string;
  16818. /**
  16819. * The friendly name of the Particle system.
  16820. */
  16821. name: string;
  16822. /**
  16823. * The rendering group used by the Particle system to chose when to render.
  16824. */
  16825. renderingGroupId: number;
  16826. /**
  16827. * The emitter represents the Mesh or position we are attaching the particle system to.
  16828. */
  16829. emitter: Nullable<AbstractMesh | Vector3>;
  16830. /**
  16831. * The maximum number of particles to emit per frame
  16832. */
  16833. emitRate: number;
  16834. /**
  16835. * If you want to launch only a few particles at once, that can be done, as well.
  16836. */
  16837. manualEmitCount: number;
  16838. /**
  16839. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16840. */
  16841. updateSpeed: number;
  16842. /**
  16843. * The amount of time the particle system is running (depends of the overall update speed).
  16844. */
  16845. targetStopDuration: number;
  16846. /**
  16847. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16848. */
  16849. disposeOnStop: boolean;
  16850. /**
  16851. * Minimum power of emitting particles.
  16852. */
  16853. minEmitPower: number;
  16854. /**
  16855. * Maximum power of emitting particles.
  16856. */
  16857. maxEmitPower: number;
  16858. /**
  16859. * Minimum life time of emitting particles.
  16860. */
  16861. minLifeTime: number;
  16862. /**
  16863. * Maximum life time of emitting particles.
  16864. */
  16865. maxLifeTime: number;
  16866. /**
  16867. * Minimum Size of emitting particles.
  16868. */
  16869. minSize: number;
  16870. /**
  16871. * Maximum Size of emitting particles.
  16872. */
  16873. maxSize: number;
  16874. /**
  16875. * Minimum scale of emitting particles on X axis.
  16876. */
  16877. minScaleX: number;
  16878. /**
  16879. * Maximum scale of emitting particles on X axis.
  16880. */
  16881. maxScaleX: number;
  16882. /**
  16883. * Minimum scale of emitting particles on Y axis.
  16884. */
  16885. minScaleY: number;
  16886. /**
  16887. * Maximum scale of emitting particles on Y axis.
  16888. */
  16889. maxScaleY: number;
  16890. /**
  16891. * Gets or sets the minimal initial rotation in radians.
  16892. */
  16893. minInitialRotation: number;
  16894. /**
  16895. * Gets or sets the maximal initial rotation in radians.
  16896. */
  16897. maxInitialRotation: number;
  16898. /**
  16899. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16900. */
  16901. minAngularSpeed: number;
  16902. /**
  16903. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. maxAngularSpeed: number;
  16906. /**
  16907. * The texture used to render each particle. (this can be a spritesheet)
  16908. */
  16909. particleTexture: Nullable<Texture>;
  16910. /**
  16911. * The layer mask we are rendering the particles through.
  16912. */
  16913. layerMask: number;
  16914. /**
  16915. * This can help using your own shader to render the particle system.
  16916. * The according effect will be created
  16917. */
  16918. customShader: any;
  16919. /**
  16920. * By default particle system starts as soon as they are created. This prevents the
  16921. * automatic start to happen and let you decide when to start emitting particles.
  16922. */
  16923. preventAutoStart: boolean;
  16924. private _noiseTexture;
  16925. /**
  16926. * Gets or sets a texture used to add random noise to particle positions
  16927. */
  16928. noiseTexture: Nullable<ProceduralTexture>;
  16929. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16930. noiseStrength: Vector3;
  16931. /**
  16932. * Callback triggered when the particle animation is ending.
  16933. */
  16934. onAnimationEnd: Nullable<() => void>;
  16935. /**
  16936. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16937. */
  16938. blendMode: number;
  16939. /**
  16940. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16941. * to override the particles.
  16942. */
  16943. forceDepthWrite: boolean;
  16944. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  16945. preWarmCycles: number;
  16946. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16947. preWarmStepOffset: number;
  16948. /**
  16949. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  16950. */
  16951. spriteCellChangeSpeed: number;
  16952. /**
  16953. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16954. */
  16955. startSpriteCellID: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16958. */
  16959. endSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16962. */
  16963. spriteCellWidth: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16966. */
  16967. spriteCellHeight: number;
  16968. /**
  16969. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16970. */
  16971. spriteRandomStartCell: boolean;
  16972. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16973. translationPivot: Vector2;
  16974. /** @hidden */
  16975. protected _isAnimationSheetEnabled: boolean;
  16976. /**
  16977. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16978. */
  16979. beginAnimationOnStart: boolean;
  16980. /**
  16981. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16982. */
  16983. beginAnimationFrom: number;
  16984. /**
  16985. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationTo: number;
  16988. /**
  16989. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationLoop: boolean;
  16992. /**
  16993. * Gets or sets a world offset applied to all particles
  16994. */
  16995. worldOffset: Vector3;
  16996. /**
  16997. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16998. */
  16999. isAnimationSheetEnabled: boolean;
  17000. /**
  17001. * Get hosting scene
  17002. * @returns the scene
  17003. */
  17004. getScene(): Scene;
  17005. /**
  17006. * You can use gravity if you want to give an orientation to your particles.
  17007. */
  17008. gravity: Vector3;
  17009. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17010. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17011. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17012. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17013. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17014. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17015. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17016. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17017. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17018. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17019. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17020. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17021. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17022. /**
  17023. * Defines the delay in milliseconds before starting the system (0 by default)
  17024. */
  17025. startDelay: number;
  17026. /**
  17027. * Gets the current list of drag gradients.
  17028. * You must use addDragGradient and removeDragGradient to udpate this list
  17029. * @returns the list of drag gradients
  17030. */
  17031. getDragGradients(): Nullable<Array<FactorGradient>>;
  17032. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17033. limitVelocityDamping: number;
  17034. /**
  17035. * Gets the current list of limit velocity gradients.
  17036. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17037. * @returns the list of limit velocity gradients
  17038. */
  17039. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17040. /**
  17041. * Gets the current list of color gradients.
  17042. * You must use addColorGradient and removeColorGradient to udpate this list
  17043. * @returns the list of color gradients
  17044. */
  17045. getColorGradients(): Nullable<Array<ColorGradient>>;
  17046. /**
  17047. * Gets the current list of size gradients.
  17048. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17049. * @returns the list of size gradients
  17050. */
  17051. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17052. /**
  17053. * Gets the current list of color remap gradients.
  17054. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17055. * @returns the list of color remap gradients
  17056. */
  17057. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17058. /**
  17059. * Gets the current list of alpha remap gradients.
  17060. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17061. * @returns the list of alpha remap gradients
  17062. */
  17063. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17064. /**
  17065. * Gets the current list of life time gradients.
  17066. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17067. * @returns the list of life time gradients
  17068. */
  17069. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17070. /**
  17071. * Gets the current list of angular speed gradients.
  17072. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17073. * @returns the list of angular speed gradients
  17074. */
  17075. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17076. /**
  17077. * Gets the current list of velocity gradients.
  17078. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17079. * @returns the list of velocity gradients
  17080. */
  17081. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17082. /**
  17083. * Gets the current list of start size gradients.
  17084. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17085. * @returns the list of start size gradients
  17086. */
  17087. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17088. /**
  17089. * Gets the current list of emit rate gradients.
  17090. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17091. * @returns the list of emit rate gradients
  17092. */
  17093. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17094. /**
  17095. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17096. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17097. */
  17098. direction1: Vector3;
  17099. /**
  17100. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17101. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17102. */
  17103. direction2: Vector3;
  17104. /**
  17105. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17106. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17107. */
  17108. minEmitBox: Vector3;
  17109. /**
  17110. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  17111. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17112. */
  17113. maxEmitBox: Vector3;
  17114. /**
  17115. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17116. */
  17117. color1: Color4;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color2: Color4;
  17122. /**
  17123. * Color the particle will have at the end of its lifetime
  17124. */
  17125. colorDead: Color4;
  17126. /**
  17127. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17128. */
  17129. textureMask: Color4;
  17130. /**
  17131. * The particle emitter type defines the emitter used by the particle system.
  17132. * It can be for example box, sphere, or cone...
  17133. */
  17134. particleEmitterType: IParticleEmitterType;
  17135. /** @hidden */
  17136. _isSubEmitter: boolean;
  17137. /**
  17138. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17139. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17140. */
  17141. billboardMode: number;
  17142. protected _isBillboardBased: boolean;
  17143. /**
  17144. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17145. */
  17146. isBillboardBased: boolean;
  17147. /**
  17148. * The scene the particle system belongs to.
  17149. */
  17150. protected _scene: Scene;
  17151. /**
  17152. * Local cache of defines for image processing.
  17153. */
  17154. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17155. /**
  17156. * Default configuration related to image processing available in the standard Material.
  17157. */
  17158. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17159. /**
  17160. * Gets the image processing configuration used either in this material.
  17161. */
  17162. /**
  17163. * Sets the Default image processing configuration used either in the this material.
  17164. *
  17165. * If sets to null, the scene one is in use.
  17166. */
  17167. imageProcessingConfiguration: ImageProcessingConfiguration;
  17168. /**
  17169. * Attaches a new image processing configuration to the Standard Material.
  17170. * @param configuration
  17171. */
  17172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17173. /** @hidden */
  17174. protected _reset(): void;
  17175. /** @hidden */
  17176. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17177. /**
  17178. * Instantiates a particle system.
  17179. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17180. * @param name The name of the particle system
  17181. */
  17182. constructor(name: string);
  17183. /**
  17184. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17185. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17186. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17187. * @returns the emitter
  17188. */
  17189. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17190. /**
  17191. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17192. * @param radius The radius of the hemisphere to emit from
  17193. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17194. * @returns the emitter
  17195. */
  17196. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17197. /**
  17198. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17199. * @param radius The radius of the sphere to emit from
  17200. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17201. * @returns the emitter
  17202. */
  17203. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17204. /**
  17205. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17206. * @param radius The radius of the sphere to emit from
  17207. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17208. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17209. * @returns the emitter
  17210. */
  17211. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17212. /**
  17213. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17214. * @param radius The radius of the emission cylinder
  17215. * @param height The height of the emission cylinder
  17216. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17217. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17218. * @returns the emitter
  17219. */
  17220. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17221. /**
  17222. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17223. * @param radius The radius of the cylinder to emit from
  17224. * @param height The height of the emission cylinder
  17225. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17226. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17227. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17228. * @returns the emitter
  17229. */
  17230. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17231. /**
  17232. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17233. * @param radius The radius of the cone to emit from
  17234. * @param angle The base angle of the cone
  17235. * @returns the emitter
  17236. */
  17237. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17238. /**
  17239. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17240. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17241. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17242. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17243. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17244. * @returns the emitter
  17245. */
  17246. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17247. }
  17248. }
  17249. declare module "babylonjs/Particles/subEmitter" {
  17250. import { Scene } from "babylonjs/scene";
  17251. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17252. /**
  17253. * Type of sub emitter
  17254. */
  17255. export enum SubEmitterType {
  17256. /**
  17257. * Attached to the particle over it's lifetime
  17258. */
  17259. ATTACHED = 0,
  17260. /**
  17261. * Created when the particle dies
  17262. */
  17263. END = 1
  17264. }
  17265. /**
  17266. * Sub emitter class used to emit particles from an existing particle
  17267. */
  17268. export class SubEmitter {
  17269. /**
  17270. * the particle system to be used by the sub emitter
  17271. */
  17272. particleSystem: ParticleSystem;
  17273. /**
  17274. * Type of the submitter (Default: END)
  17275. */
  17276. type: SubEmitterType;
  17277. /**
  17278. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  17279. * Note: This only is supported when using an emitter of type Mesh
  17280. */
  17281. inheritDirection: boolean;
  17282. /**
  17283. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17284. */
  17285. inheritedVelocityAmount: number;
  17286. /**
  17287. * Creates a sub emitter
  17288. * @param particleSystem the particle system to be used by the sub emitter
  17289. */
  17290. constructor(
  17291. /**
  17292. * the particle system to be used by the sub emitter
  17293. */
  17294. particleSystem: ParticleSystem);
  17295. /**
  17296. * Clones the sub emitter
  17297. * @returns the cloned sub emitter
  17298. */
  17299. clone(): SubEmitter;
  17300. /**
  17301. * Serialize current object to a JSON object
  17302. * @returns the serialized object
  17303. */
  17304. serialize(): any;
  17305. /** @hidden */
  17306. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17307. /**
  17308. * Creates a new SubEmitter from a serialized JSON version
  17309. * @param serializationObject defines the JSON object to read from
  17310. * @param scene defines the hosting scene
  17311. * @param rootUrl defines the rootUrl for data loading
  17312. * @returns a new SubEmitter
  17313. */
  17314. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17315. /** Release associated resources */
  17316. dispose(): void;
  17317. }
  17318. }
  17319. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17320. /** @hidden */
  17321. export var clipPlaneFragmentDeclaration: {
  17322. name: string;
  17323. shader: string;
  17324. };
  17325. }
  17326. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17327. /** @hidden */
  17328. export var imageProcessingDeclaration: {
  17329. name: string;
  17330. shader: string;
  17331. };
  17332. }
  17333. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17334. /** @hidden */
  17335. export var imageProcessingFunctions: {
  17336. name: string;
  17337. shader: string;
  17338. };
  17339. }
  17340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17341. /** @hidden */
  17342. export var clipPlaneFragment: {
  17343. name: string;
  17344. shader: string;
  17345. };
  17346. }
  17347. declare module "babylonjs/Shaders/particles.fragment" {
  17348. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17349. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17350. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17351. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17353. /** @hidden */
  17354. export var particlesPixelShader: {
  17355. name: string;
  17356. shader: string;
  17357. };
  17358. }
  17359. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17360. /** @hidden */
  17361. export var clipPlaneVertexDeclaration: {
  17362. name: string;
  17363. shader: string;
  17364. };
  17365. }
  17366. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17367. /** @hidden */
  17368. export var clipPlaneVertex: {
  17369. name: string;
  17370. shader: string;
  17371. };
  17372. }
  17373. declare module "babylonjs/Shaders/particles.vertex" {
  17374. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17376. /** @hidden */
  17377. export var particlesVertexShader: {
  17378. name: string;
  17379. shader: string;
  17380. };
  17381. }
  17382. declare module "babylonjs/Particles/particleSystem" {
  17383. import { Nullable } from "babylonjs/types";
  17384. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17385. import { Observable } from "babylonjs/Misc/observable";
  17386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17387. import { Effect } from "babylonjs/Materials/effect";
  17388. import { Scene, IDisposable } from "babylonjs/scene";
  17389. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17390. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17391. import { Particle } from "babylonjs/Particles/particle";
  17392. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17394. import "babylonjs/Shaders/particles.fragment";
  17395. import "babylonjs/Shaders/particles.vertex";
  17396. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17397. /**
  17398. * This represents a particle system in Babylon.
  17399. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17400. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17401. * @example https://doc.babylonjs.com/babylon101/particles
  17402. */
  17403. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17404. /**
  17405. * Billboard mode will only apply to Y axis
  17406. */
  17407. static readonly BILLBOARDMODE_Y: number;
  17408. /**
  17409. * Billboard mode will apply to all axes
  17410. */
  17411. static readonly BILLBOARDMODE_ALL: number;
  17412. /**
  17413. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17414. */
  17415. static readonly BILLBOARDMODE_STRETCHED: number;
  17416. /**
  17417. * This function can be defined to provide custom update for active particles.
  17418. * This function will be called instead of regular update (age, position, color, etc.).
  17419. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17420. */
  17421. updateFunction: (particles: Particle[]) => void;
  17422. private _emitterWorldMatrix;
  17423. /**
  17424. * This function can be defined to specify initial direction for every new particle.
  17425. * It by default use the emitterType defined function
  17426. */
  17427. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17428. /**
  17429. * This function can be defined to specify initial position for every new particle.
  17430. * It by default use the emitterType defined function
  17431. */
  17432. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17433. /**
  17434. * @hidden
  17435. */
  17436. _inheritedVelocityOffset: Vector3;
  17437. /**
  17438. * An event triggered when the system is disposed
  17439. */
  17440. onDisposeObservable: Observable<ParticleSystem>;
  17441. private _onDisposeObserver;
  17442. /**
  17443. * Sets a callback that will be triggered when the system is disposed
  17444. */
  17445. onDispose: () => void;
  17446. private _particles;
  17447. private _epsilon;
  17448. private _capacity;
  17449. private _stockParticles;
  17450. private _newPartsExcess;
  17451. private _vertexData;
  17452. private _vertexBuffer;
  17453. private _vertexBuffers;
  17454. private _spriteBuffer;
  17455. private _indexBuffer;
  17456. private _effect;
  17457. private _customEffect;
  17458. private _cachedDefines;
  17459. private _scaledColorStep;
  17460. private _colorDiff;
  17461. private _scaledDirection;
  17462. private _scaledGravity;
  17463. private _currentRenderId;
  17464. private _alive;
  17465. private _useInstancing;
  17466. private _started;
  17467. private _stopped;
  17468. private _actualFrame;
  17469. private _scaledUpdateSpeed;
  17470. private _vertexBufferSize;
  17471. /** @hidden */
  17472. _currentEmitRateGradient: Nullable<FactorGradient>;
  17473. /** @hidden */
  17474. _currentEmitRate1: number;
  17475. /** @hidden */
  17476. _currentEmitRate2: number;
  17477. /** @hidden */
  17478. _currentStartSizeGradient: Nullable<FactorGradient>;
  17479. /** @hidden */
  17480. _currentStartSize1: number;
  17481. /** @hidden */
  17482. _currentStartSize2: number;
  17483. private readonly _rawTextureWidth;
  17484. private _rampGradientsTexture;
  17485. private _useRampGradients;
  17486. /** Gets or sets a boolean indicating that ramp gradients must be used
  17487. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17488. */
  17489. useRampGradients: boolean;
  17490. /**
  17491. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  17492. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  17493. */
  17494. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17495. private _subEmitters;
  17496. /**
  17497. * @hidden
  17498. * If the particle systems emitter should be disposed when the particle system is disposed
  17499. */
  17500. _disposeEmitterOnDispose: boolean;
  17501. /**
  17502. * The current active Sub-systems, this property is used by the root particle system only.
  17503. */
  17504. activeSubSystems: Array<ParticleSystem>;
  17505. private _rootParticleSystem;
  17506. /**
  17507. * Gets the current list of active particles
  17508. */
  17509. readonly particles: Particle[];
  17510. /**
  17511. * Returns the string "ParticleSystem"
  17512. * @returns a string containing the class name
  17513. */
  17514. getClassName(): string;
  17515. /**
  17516. * Instantiates a particle system.
  17517. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  17518. * @param name The name of the particle system
  17519. * @param capacity The max number of particles alive at the same time
  17520. * @param scene The scene the particle system belongs to
  17521. * @param customEffect a custom effect used to change the way particles are rendered by default
  17522. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17523. * @param epsilon Offset used to render the particles
  17524. */
  17525. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17526. private _addFactorGradient;
  17527. private _removeFactorGradient;
  17528. /**
  17529. * Adds a new life time gradient
  17530. * @param gradient defines the gradient to use (between 0 and 1)
  17531. * @param factor defines the life time factor to affect to the specified gradient
  17532. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17533. * @returns the current particle system
  17534. */
  17535. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17536. /**
  17537. * Remove a specific life time gradient
  17538. * @param gradient defines the gradient to remove
  17539. * @returns the current particle system
  17540. */
  17541. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17542. /**
  17543. * Adds a new size gradient
  17544. * @param gradient defines the gradient to use (between 0 and 1)
  17545. * @param factor defines the size factor to affect to the specified gradient
  17546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17547. * @returns the current particle system
  17548. */
  17549. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17550. /**
  17551. * Remove a specific size gradient
  17552. * @param gradient defines the gradient to remove
  17553. * @returns the current particle system
  17554. */
  17555. removeSizeGradient(gradient: number): IParticleSystem;
  17556. /**
  17557. * Adds a new color remap gradient
  17558. * @param gradient defines the gradient to use (between 0 and 1)
  17559. * @param min defines the color remap minimal range
  17560. * @param max defines the color remap maximal range
  17561. * @returns the current particle system
  17562. */
  17563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17564. /**
  17565. * Remove a specific color remap gradient
  17566. * @param gradient defines the gradient to remove
  17567. * @returns the current particle system
  17568. */
  17569. removeColorRemapGradient(gradient: number): IParticleSystem;
  17570. /**
  17571. * Adds a new alpha remap gradient
  17572. * @param gradient defines the gradient to use (between 0 and 1)
  17573. * @param min defines the alpha remap minimal range
  17574. * @param max defines the alpha remap maximal range
  17575. * @returns the current particle system
  17576. */
  17577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17578. /**
  17579. * Remove a specific alpha remap gradient
  17580. * @param gradient defines the gradient to remove
  17581. * @returns the current particle system
  17582. */
  17583. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17584. /**
  17585. * Adds a new angular speed gradient
  17586. * @param gradient defines the gradient to use (between 0 and 1)
  17587. * @param factor defines the angular speed to affect to the specified gradient
  17588. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17589. * @returns the current particle system
  17590. */
  17591. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17592. /**
  17593. * Remove a specific angular speed gradient
  17594. * @param gradient defines the gradient to remove
  17595. * @returns the current particle system
  17596. */
  17597. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17598. /**
  17599. * Adds a new velocity gradient
  17600. * @param gradient defines the gradient to use (between 0 and 1)
  17601. * @param factor defines the velocity to affect to the specified gradient
  17602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17603. * @returns the current particle system
  17604. */
  17605. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17606. /**
  17607. * Remove a specific velocity gradient
  17608. * @param gradient defines the gradient to remove
  17609. * @returns the current particle system
  17610. */
  17611. removeVelocityGradient(gradient: number): IParticleSystem;
  17612. /**
  17613. * Adds a new limit velocity gradient
  17614. * @param gradient defines the gradient to use (between 0 and 1)
  17615. * @param factor defines the limit velocity value to affect to the specified gradient
  17616. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17617. * @returns the current particle system
  17618. */
  17619. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17620. /**
  17621. * Remove a specific limit velocity gradient
  17622. * @param gradient defines the gradient to remove
  17623. * @returns the current particle system
  17624. */
  17625. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17626. /**
  17627. * Adds a new drag gradient
  17628. * @param gradient defines the gradient to use (between 0 and 1)
  17629. * @param factor defines the drag value to affect to the specified gradient
  17630. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17631. * @returns the current particle system
  17632. */
  17633. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17634. /**
  17635. * Remove a specific drag gradient
  17636. * @param gradient defines the gradient to remove
  17637. * @returns the current particle system
  17638. */
  17639. removeDragGradient(gradient: number): IParticleSystem;
  17640. /**
  17641. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17642. * @param gradient defines the gradient to use (between 0 and 1)
  17643. * @param factor defines the emit rate value to affect to the specified gradient
  17644. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17645. * @returns the current particle system
  17646. */
  17647. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17648. /**
  17649. * Remove a specific emit rate gradient
  17650. * @param gradient defines the gradient to remove
  17651. * @returns the current particle system
  17652. */
  17653. removeEmitRateGradient(gradient: number): IParticleSystem;
  17654. /**
  17655. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17656. * @param gradient defines the gradient to use (between 0 and 1)
  17657. * @param factor defines the start size value to affect to the specified gradient
  17658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17659. * @returns the current particle system
  17660. */
  17661. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17662. /**
  17663. * Remove a specific start size gradient
  17664. * @param gradient defines the gradient to remove
  17665. * @returns the current particle system
  17666. */
  17667. removeStartSizeGradient(gradient: number): IParticleSystem;
  17668. private _createRampGradientTexture;
  17669. /**
  17670. * Gets the current list of ramp gradients.
  17671. * You must use addRampGradient and removeRampGradient to udpate this list
  17672. * @returns the list of ramp gradients
  17673. */
  17674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17675. /**
  17676. * Adds a new ramp gradient used to remap particle colors
  17677. * @param gradient defines the gradient to use (between 0 and 1)
  17678. * @param color defines the color to affect to the specified gradient
  17679. * @returns the current particle system
  17680. */
  17681. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17682. /**
  17683. * Remove a specific ramp gradient
  17684. * @param gradient defines the gradient to remove
  17685. * @returns the current particle system
  17686. */
  17687. removeRampGradient(gradient: number): ParticleSystem;
  17688. /**
  17689. * Adds a new color gradient
  17690. * @param gradient defines the gradient to use (between 0 and 1)
  17691. * @param color1 defines the color to affect to the specified gradient
  17692. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17693. * @returns this particle system
  17694. */
  17695. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17696. /**
  17697. * Remove a specific color gradient
  17698. * @param gradient defines the gradient to remove
  17699. * @returns this particle system
  17700. */
  17701. removeColorGradient(gradient: number): IParticleSystem;
  17702. private _fetchR;
  17703. protected _reset(): void;
  17704. private _resetEffect;
  17705. private _createVertexBuffers;
  17706. private _createIndexBuffer;
  17707. /**
  17708. * Gets the maximum number of particles active at the same time.
  17709. * @returns The max number of active particles.
  17710. */
  17711. getCapacity(): number;
  17712. /**
  17713. * Gets whether there are still active particles in the system.
  17714. * @returns True if it is alive, otherwise false.
  17715. */
  17716. isAlive(): boolean;
  17717. /**
  17718. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17719. * @returns True if it has been started, otherwise false.
  17720. */
  17721. isStarted(): boolean;
  17722. private _prepareSubEmitterInternalArray;
  17723. /**
  17724. * Starts the particle system and begins to emit
  17725. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17726. */
  17727. start(delay?: number): void;
  17728. /**
  17729. * Stops the particle system.
  17730. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  17731. */
  17732. stop(stopSubEmitters?: boolean): void;
  17733. /**
  17734. * Remove all active particles
  17735. */
  17736. reset(): void;
  17737. /**
  17738. * @hidden (for internal use only)
  17739. */
  17740. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17741. /**
  17742. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17743. * Its lifetime will start back at 0.
  17744. */
  17745. recycleParticle: (particle: Particle) => void;
  17746. private _stopSubEmitters;
  17747. private _createParticle;
  17748. private _removeFromRoot;
  17749. private _emitFromParticle;
  17750. private _update;
  17751. /** @hidden */
  17752. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17753. /** @hidden */
  17754. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17755. /** @hidden */
  17756. private _getEffect;
  17757. /**
  17758. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17759. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17760. */
  17761. animate(preWarmOnly?: boolean): void;
  17762. private _appendParticleVertices;
  17763. /**
  17764. * Rebuilds the particle system.
  17765. */
  17766. rebuild(): void;
  17767. /**
  17768. * Is this system ready to be used/rendered
  17769. * @return true if the system is ready
  17770. */
  17771. isReady(): boolean;
  17772. private _render;
  17773. /**
  17774. * Renders the particle system in its current state.
  17775. * @returns the current number of particles
  17776. */
  17777. render(): number;
  17778. /**
  17779. * Disposes the particle system and free the associated resources
  17780. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17781. */
  17782. dispose(disposeTexture?: boolean): void;
  17783. /**
  17784. * Clones the particle system.
  17785. * @param name The name of the cloned object
  17786. * @param newEmitter The new emitter to use
  17787. * @returns the cloned particle system
  17788. */
  17789. clone(name: string, newEmitter: any): ParticleSystem;
  17790. /**
  17791. * Serializes the particle system to a JSON object.
  17792. * @returns the JSON object
  17793. */
  17794. serialize(): any;
  17795. /** @hidden */
  17796. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17797. /** @hidden */
  17798. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17799. /**
  17800. * Parses a JSON object to create a particle system.
  17801. * @param parsedParticleSystem The JSON object to parse
  17802. * @param scene The scene to create the particle system in
  17803. * @param rootUrl The root url to use to load external dependencies like texture
  17804. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17805. * @returns the Parsed particle system
  17806. */
  17807. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17808. }
  17809. }
  17810. declare module "babylonjs/Particles/particle" {
  17811. import { Nullable } from "babylonjs/types";
  17812. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17813. import { Color4 } from "babylonjs/Maths/math.color";
  17814. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17815. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17816. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17817. /**
  17818. * A particle represents one of the element emitted by a particle system.
  17819. * This is mainly define by its coordinates, direction, velocity and age.
  17820. */
  17821. export class Particle {
  17822. /**
  17823. * The particle system the particle belongs to.
  17824. */
  17825. particleSystem: ParticleSystem;
  17826. private static _Count;
  17827. /**
  17828. * Unique ID of the particle
  17829. */
  17830. id: number;
  17831. /**
  17832. * The world position of the particle in the scene.
  17833. */
  17834. position: Vector3;
  17835. /**
  17836. * The world direction of the particle in the scene.
  17837. */
  17838. direction: Vector3;
  17839. /**
  17840. * The color of the particle.
  17841. */
  17842. color: Color4;
  17843. /**
  17844. * The color change of the particle per step.
  17845. */
  17846. colorStep: Color4;
  17847. /**
  17848. * Defines how long will the life of the particle be.
  17849. */
  17850. lifeTime: number;
  17851. /**
  17852. * The current age of the particle.
  17853. */
  17854. age: number;
  17855. /**
  17856. * The current size of the particle.
  17857. */
  17858. size: number;
  17859. /**
  17860. * The current scale of the particle.
  17861. */
  17862. scale: Vector2;
  17863. /**
  17864. * The current angle of the particle.
  17865. */
  17866. angle: number;
  17867. /**
  17868. * Defines how fast is the angle changing.
  17869. */
  17870. angularSpeed: number;
  17871. /**
  17872. * Defines the cell index used by the particle to be rendered from a sprite.
  17873. */
  17874. cellIndex: number;
  17875. /**
  17876. * The information required to support color remapping
  17877. */
  17878. remapData: Vector4;
  17879. /** @hidden */
  17880. _randomCellOffset?: number;
  17881. /** @hidden */
  17882. _initialDirection: Nullable<Vector3>;
  17883. /** @hidden */
  17884. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17885. /** @hidden */
  17886. _initialStartSpriteCellID: number;
  17887. /** @hidden */
  17888. _initialEndSpriteCellID: number;
  17889. /** @hidden */
  17890. _currentColorGradient: Nullable<ColorGradient>;
  17891. /** @hidden */
  17892. _currentColor1: Color4;
  17893. /** @hidden */
  17894. _currentColor2: Color4;
  17895. /** @hidden */
  17896. _currentSizeGradient: Nullable<FactorGradient>;
  17897. /** @hidden */
  17898. _currentSize1: number;
  17899. /** @hidden */
  17900. _currentSize2: number;
  17901. /** @hidden */
  17902. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17903. /** @hidden */
  17904. _currentAngularSpeed1: number;
  17905. /** @hidden */
  17906. _currentAngularSpeed2: number;
  17907. /** @hidden */
  17908. _currentVelocityGradient: Nullable<FactorGradient>;
  17909. /** @hidden */
  17910. _currentVelocity1: number;
  17911. /** @hidden */
  17912. _currentVelocity2: number;
  17913. /** @hidden */
  17914. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17915. /** @hidden */
  17916. _currentLimitVelocity1: number;
  17917. /** @hidden */
  17918. _currentLimitVelocity2: number;
  17919. /** @hidden */
  17920. _currentDragGradient: Nullable<FactorGradient>;
  17921. /** @hidden */
  17922. _currentDrag1: number;
  17923. /** @hidden */
  17924. _currentDrag2: number;
  17925. /** @hidden */
  17926. _randomNoiseCoordinates1: Vector3;
  17927. /** @hidden */
  17928. _randomNoiseCoordinates2: Vector3;
  17929. /**
  17930. * Creates a new instance Particle
  17931. * @param particleSystem the particle system the particle belongs to
  17932. */
  17933. constructor(
  17934. /**
  17935. * The particle system the particle belongs to.
  17936. */
  17937. particleSystem: ParticleSystem);
  17938. private updateCellInfoFromSystem;
  17939. /**
  17940. * Defines how the sprite cell index is updated for the particle
  17941. */
  17942. updateCellIndex(): void;
  17943. /** @hidden */
  17944. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17945. /** @hidden */
  17946. _inheritParticleInfoToSubEmitters(): void;
  17947. /** @hidden */
  17948. _reset(): void;
  17949. /**
  17950. * Copy the properties of particle to another one.
  17951. * @param other the particle to copy the information to.
  17952. */
  17953. copyTo(other: Particle): void;
  17954. }
  17955. }
  17956. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17957. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17958. import { Effect } from "babylonjs/Materials/effect";
  17959. import { Particle } from "babylonjs/Particles/particle";
  17960. /**
  17961. * Particle emitter represents a volume emitting particles.
  17962. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17963. */
  17964. export interface IParticleEmitterType {
  17965. /**
  17966. * Called by the particle System when the direction is computed for the created particle.
  17967. * @param worldMatrix is the world matrix of the particle system
  17968. * @param directionToUpdate is the direction vector to update with the result
  17969. * @param particle is the particle we are computed the direction for
  17970. */
  17971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17972. /**
  17973. * Called by the particle System when the position is computed for the created particle.
  17974. * @param worldMatrix is the world matrix of the particle system
  17975. * @param positionToUpdate is the position vector to update with the result
  17976. * @param particle is the particle we are computed the position for
  17977. */
  17978. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17979. /**
  17980. * Clones the current emitter and returns a copy of it
  17981. * @returns the new emitter
  17982. */
  17983. clone(): IParticleEmitterType;
  17984. /**
  17985. * Called by the GPUParticleSystem to setup the update shader
  17986. * @param effect defines the update shader
  17987. */
  17988. applyToShader(effect: Effect): void;
  17989. /**
  17990. * Returns a string to use to update the GPU particles update shader
  17991. * @returns the effect defines string
  17992. */
  17993. getEffectDefines(): string;
  17994. /**
  17995. * Returns a string representing the class name
  17996. * @returns a string containing the class name
  17997. */
  17998. getClassName(): string;
  17999. /**
  18000. * Serializes the particle system to a JSON object.
  18001. * @returns the JSON object
  18002. */
  18003. serialize(): any;
  18004. /**
  18005. * Parse properties from a JSON object
  18006. * @param serializationObject defines the JSON object
  18007. */
  18008. parse(serializationObject: any): void;
  18009. }
  18010. }
  18011. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18012. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18013. import { Effect } from "babylonjs/Materials/effect";
  18014. import { Particle } from "babylonjs/Particles/particle";
  18015. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18016. /**
  18017. * Particle emitter emitting particles from the inside of a box.
  18018. * It emits the particles randomly between 2 given directions.
  18019. */
  18020. export class BoxParticleEmitter implements IParticleEmitterType {
  18021. /**
  18022. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18023. */
  18024. direction1: Vector3;
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction2: Vector3;
  18029. /**
  18030. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18031. */
  18032. minEmitBox: Vector3;
  18033. /**
  18034. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  18035. */
  18036. maxEmitBox: Vector3;
  18037. /**
  18038. * Creates a new instance BoxParticleEmitter
  18039. */
  18040. constructor();
  18041. /**
  18042. * Called by the particle System when the direction is computed for the created particle.
  18043. * @param worldMatrix is the world matrix of the particle system
  18044. * @param directionToUpdate is the direction vector to update with the result
  18045. * @param particle is the particle we are computed the direction for
  18046. */
  18047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18048. /**
  18049. * Called by the particle System when the position is computed for the created particle.
  18050. * @param worldMatrix is the world matrix of the particle system
  18051. * @param positionToUpdate is the position vector to update with the result
  18052. * @param particle is the particle we are computed the position for
  18053. */
  18054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18055. /**
  18056. * Clones the current emitter and returns a copy of it
  18057. * @returns the new emitter
  18058. */
  18059. clone(): BoxParticleEmitter;
  18060. /**
  18061. * Called by the GPUParticleSystem to setup the update shader
  18062. * @param effect defines the update shader
  18063. */
  18064. applyToShader(effect: Effect): void;
  18065. /**
  18066. * Returns a string to use to update the GPU particles update shader
  18067. * @returns a string containng the defines string
  18068. */
  18069. getEffectDefines(): string;
  18070. /**
  18071. * Returns the string "BoxParticleEmitter"
  18072. * @returns a string containing the class name
  18073. */
  18074. getClassName(): string;
  18075. /**
  18076. * Serializes the particle system to a JSON object.
  18077. * @returns the JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Parse properties from a JSON object
  18082. * @param serializationObject defines the JSON object
  18083. */
  18084. parse(serializationObject: any): void;
  18085. }
  18086. }
  18087. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18088. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18089. import { Effect } from "babylonjs/Materials/effect";
  18090. import { Particle } from "babylonjs/Particles/particle";
  18091. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18092. /**
  18093. * Particle emitter emitting particles from the inside of a cone.
  18094. * It emits the particles alongside the cone volume from the base to the particle.
  18095. * The emission direction might be randomized.
  18096. */
  18097. export class ConeParticleEmitter implements IParticleEmitterType {
  18098. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18099. directionRandomizer: number;
  18100. private _radius;
  18101. private _angle;
  18102. private _height;
  18103. /**
  18104. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18105. */
  18106. radiusRange: number;
  18107. /**
  18108. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. heightRange: number;
  18111. /**
  18112. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18113. */
  18114. emitFromSpawnPointOnly: boolean;
  18115. /**
  18116. * Gets or sets the radius of the emission cone
  18117. */
  18118. radius: number;
  18119. /**
  18120. * Gets or sets the angle of the emission cone
  18121. */
  18122. angle: number;
  18123. private _buildHeight;
  18124. /**
  18125. * Creates a new instance ConeParticleEmitter
  18126. * @param radius the radius of the emission cone (1 by default)
  18127. * @param angle the cone base angle (PI by default)
  18128. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18129. */
  18130. constructor(radius?: number, angle?: number,
  18131. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18132. directionRandomizer?: number);
  18133. /**
  18134. * Called by the particle System when the direction is computed for the created particle.
  18135. * @param worldMatrix is the world matrix of the particle system
  18136. * @param directionToUpdate is the direction vector to update with the result
  18137. * @param particle is the particle we are computed the direction for
  18138. */
  18139. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18140. /**
  18141. * Called by the particle System when the position is computed for the created particle.
  18142. * @param worldMatrix is the world matrix of the particle system
  18143. * @param positionToUpdate is the position vector to update with the result
  18144. * @param particle is the particle we are computed the position for
  18145. */
  18146. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18147. /**
  18148. * Clones the current emitter and returns a copy of it
  18149. * @returns the new emitter
  18150. */
  18151. clone(): ConeParticleEmitter;
  18152. /**
  18153. * Called by the GPUParticleSystem to setup the update shader
  18154. * @param effect defines the update shader
  18155. */
  18156. applyToShader(effect: Effect): void;
  18157. /**
  18158. * Returns a string to use to update the GPU particles update shader
  18159. * @returns a string containng the defines string
  18160. */
  18161. getEffectDefines(): string;
  18162. /**
  18163. * Returns the string "ConeParticleEmitter"
  18164. * @returns a string containing the class name
  18165. */
  18166. getClassName(): string;
  18167. /**
  18168. * Serializes the particle system to a JSON object.
  18169. * @returns the JSON object
  18170. */
  18171. serialize(): any;
  18172. /**
  18173. * Parse properties from a JSON object
  18174. * @param serializationObject defines the JSON object
  18175. */
  18176. parse(serializationObject: any): void;
  18177. }
  18178. }
  18179. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18180. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18181. import { Effect } from "babylonjs/Materials/effect";
  18182. import { Particle } from "babylonjs/Particles/particle";
  18183. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18184. /**
  18185. * Particle emitter emitting particles from the inside of a cylinder.
  18186. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18187. */
  18188. export class CylinderParticleEmitter implements IParticleEmitterType {
  18189. /**
  18190. * The radius of the emission cylinder.
  18191. */
  18192. radius: number;
  18193. /**
  18194. * The height of the emission cylinder.
  18195. */
  18196. height: number;
  18197. /**
  18198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18199. */
  18200. radiusRange: number;
  18201. /**
  18202. * How much to randomize the particle direction [0-1].
  18203. */
  18204. directionRandomizer: number;
  18205. /**
  18206. * Creates a new instance CylinderParticleEmitter
  18207. * @param radius the radius of the emission cylinder (1 by default)
  18208. * @param height the height of the emission cylinder (1 by default)
  18209. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18210. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18211. */
  18212. constructor(
  18213. /**
  18214. * The radius of the emission cylinder.
  18215. */
  18216. radius?: number,
  18217. /**
  18218. * The height of the emission cylinder.
  18219. */
  18220. height?: number,
  18221. /**
  18222. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18223. */
  18224. radiusRange?: number,
  18225. /**
  18226. * How much to randomize the particle direction [0-1].
  18227. */
  18228. directionRandomizer?: number);
  18229. /**
  18230. * Called by the particle System when the direction is computed for the created particle.
  18231. * @param worldMatrix is the world matrix of the particle system
  18232. * @param directionToUpdate is the direction vector to update with the result
  18233. * @param particle is the particle we are computed the direction for
  18234. */
  18235. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18236. /**
  18237. * Called by the particle System when the position is computed for the created particle.
  18238. * @param worldMatrix is the world matrix of the particle system
  18239. * @param positionToUpdate is the position vector to update with the result
  18240. * @param particle is the particle we are computed the position for
  18241. */
  18242. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18243. /**
  18244. * Clones the current emitter and returns a copy of it
  18245. * @returns the new emitter
  18246. */
  18247. clone(): CylinderParticleEmitter;
  18248. /**
  18249. * Called by the GPUParticleSystem to setup the update shader
  18250. * @param effect defines the update shader
  18251. */
  18252. applyToShader(effect: Effect): void;
  18253. /**
  18254. * Returns a string to use to update the GPU particles update shader
  18255. * @returns a string containng the defines string
  18256. */
  18257. getEffectDefines(): string;
  18258. /**
  18259. * Returns the string "CylinderParticleEmitter"
  18260. * @returns a string containing the class name
  18261. */
  18262. getClassName(): string;
  18263. /**
  18264. * Serializes the particle system to a JSON object.
  18265. * @returns the JSON object
  18266. */
  18267. serialize(): any;
  18268. /**
  18269. * Parse properties from a JSON object
  18270. * @param serializationObject defines the JSON object
  18271. */
  18272. parse(serializationObject: any): void;
  18273. }
  18274. /**
  18275. * Particle emitter emitting particles from the inside of a cylinder.
  18276. * It emits the particles randomly between two vectors.
  18277. */
  18278. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18279. /**
  18280. * The min limit of the emission direction.
  18281. */
  18282. direction1: Vector3;
  18283. /**
  18284. * The max limit of the emission direction.
  18285. */
  18286. direction2: Vector3;
  18287. /**
  18288. * Creates a new instance CylinderDirectedParticleEmitter
  18289. * @param radius the radius of the emission cylinder (1 by default)
  18290. * @param height the height of the emission cylinder (1 by default)
  18291. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18292. * @param direction1 the min limit of the emission direction (up vector by default)
  18293. * @param direction2 the max limit of the emission direction (up vector by default)
  18294. */
  18295. constructor(radius?: number, height?: number, radiusRange?: number,
  18296. /**
  18297. * The min limit of the emission direction.
  18298. */
  18299. direction1?: Vector3,
  18300. /**
  18301. * The max limit of the emission direction.
  18302. */
  18303. direction2?: Vector3);
  18304. /**
  18305. * Called by the particle System when the direction is computed for the created particle.
  18306. * @param worldMatrix is the world matrix of the particle system
  18307. * @param directionToUpdate is the direction vector to update with the result
  18308. * @param particle is the particle we are computed the direction for
  18309. */
  18310. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18311. /**
  18312. * Clones the current emitter and returns a copy of it
  18313. * @returns the new emitter
  18314. */
  18315. clone(): CylinderDirectedParticleEmitter;
  18316. /**
  18317. * Called by the GPUParticleSystem to setup the update shader
  18318. * @param effect defines the update shader
  18319. */
  18320. applyToShader(effect: Effect): void;
  18321. /**
  18322. * Returns a string to use to update the GPU particles update shader
  18323. * @returns a string containng the defines string
  18324. */
  18325. getEffectDefines(): string;
  18326. /**
  18327. * Returns the string "CylinderDirectedParticleEmitter"
  18328. * @returns a string containing the class name
  18329. */
  18330. getClassName(): string;
  18331. /**
  18332. * Serializes the particle system to a JSON object.
  18333. * @returns the JSON object
  18334. */
  18335. serialize(): any;
  18336. /**
  18337. * Parse properties from a JSON object
  18338. * @param serializationObject defines the JSON object
  18339. */
  18340. parse(serializationObject: any): void;
  18341. }
  18342. }
  18343. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18344. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18345. import { Effect } from "babylonjs/Materials/effect";
  18346. import { Particle } from "babylonjs/Particles/particle";
  18347. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18348. /**
  18349. * Particle emitter emitting particles from the inside of a hemisphere.
  18350. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18351. */
  18352. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18353. /**
  18354. * The radius of the emission hemisphere.
  18355. */
  18356. radius: number;
  18357. /**
  18358. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18359. */
  18360. radiusRange: number;
  18361. /**
  18362. * How much to randomize the particle direction [0-1].
  18363. */
  18364. directionRandomizer: number;
  18365. /**
  18366. * Creates a new instance HemisphericParticleEmitter
  18367. * @param radius the radius of the emission hemisphere (1 by default)
  18368. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18369. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18370. */
  18371. constructor(
  18372. /**
  18373. * The radius of the emission hemisphere.
  18374. */
  18375. radius?: number,
  18376. /**
  18377. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18378. */
  18379. radiusRange?: number,
  18380. /**
  18381. * How much to randomize the particle direction [0-1].
  18382. */
  18383. directionRandomizer?: number);
  18384. /**
  18385. * Called by the particle System when the direction is computed for the created particle.
  18386. * @param worldMatrix is the world matrix of the particle system
  18387. * @param directionToUpdate is the direction vector to update with the result
  18388. * @param particle is the particle we are computed the direction for
  18389. */
  18390. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18391. /**
  18392. * Called by the particle System when the position is computed for the created particle.
  18393. * @param worldMatrix is the world matrix of the particle system
  18394. * @param positionToUpdate is the position vector to update with the result
  18395. * @param particle is the particle we are computed the position for
  18396. */
  18397. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18398. /**
  18399. * Clones the current emitter and returns a copy of it
  18400. * @returns the new emitter
  18401. */
  18402. clone(): HemisphericParticleEmitter;
  18403. /**
  18404. * Called by the GPUParticleSystem to setup the update shader
  18405. * @param effect defines the update shader
  18406. */
  18407. applyToShader(effect: Effect): void;
  18408. /**
  18409. * Returns a string to use to update the GPU particles update shader
  18410. * @returns a string containng the defines string
  18411. */
  18412. getEffectDefines(): string;
  18413. /**
  18414. * Returns the string "HemisphericParticleEmitter"
  18415. * @returns a string containing the class name
  18416. */
  18417. getClassName(): string;
  18418. /**
  18419. * Serializes the particle system to a JSON object.
  18420. * @returns the JSON object
  18421. */
  18422. serialize(): any;
  18423. /**
  18424. * Parse properties from a JSON object
  18425. * @param serializationObject defines the JSON object
  18426. */
  18427. parse(serializationObject: any): void;
  18428. }
  18429. }
  18430. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18431. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18432. import { Effect } from "babylonjs/Materials/effect";
  18433. import { Particle } from "babylonjs/Particles/particle";
  18434. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18435. /**
  18436. * Particle emitter emitting particles from a point.
  18437. * It emits the particles randomly between 2 given directions.
  18438. */
  18439. export class PointParticleEmitter implements IParticleEmitterType {
  18440. /**
  18441. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18442. */
  18443. direction1: Vector3;
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction2: Vector3;
  18448. /**
  18449. * Creates a new instance PointParticleEmitter
  18450. */
  18451. constructor();
  18452. /**
  18453. * Called by the particle System when the direction is computed for the created particle.
  18454. * @param worldMatrix is the world matrix of the particle system
  18455. * @param directionToUpdate is the direction vector to update with the result
  18456. * @param particle is the particle we are computed the direction for
  18457. */
  18458. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18459. /**
  18460. * Called by the particle System when the position is computed for the created particle.
  18461. * @param worldMatrix is the world matrix of the particle system
  18462. * @param positionToUpdate is the position vector to update with the result
  18463. * @param particle is the particle we are computed the position for
  18464. */
  18465. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18466. /**
  18467. * Clones the current emitter and returns a copy of it
  18468. * @returns the new emitter
  18469. */
  18470. clone(): PointParticleEmitter;
  18471. /**
  18472. * Called by the GPUParticleSystem to setup the update shader
  18473. * @param effect defines the update shader
  18474. */
  18475. applyToShader(effect: Effect): void;
  18476. /**
  18477. * Returns a string to use to update the GPU particles update shader
  18478. * @returns a string containng the defines string
  18479. */
  18480. getEffectDefines(): string;
  18481. /**
  18482. * Returns the string "PointParticleEmitter"
  18483. * @returns a string containing the class name
  18484. */
  18485. getClassName(): string;
  18486. /**
  18487. * Serializes the particle system to a JSON object.
  18488. * @returns the JSON object
  18489. */
  18490. serialize(): any;
  18491. /**
  18492. * Parse properties from a JSON object
  18493. * @param serializationObject defines the JSON object
  18494. */
  18495. parse(serializationObject: any): void;
  18496. }
  18497. }
  18498. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18499. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18500. import { Effect } from "babylonjs/Materials/effect";
  18501. import { Particle } from "babylonjs/Particles/particle";
  18502. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18503. /**
  18504. * Particle emitter emitting particles from the inside of a sphere.
  18505. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18506. */
  18507. export class SphereParticleEmitter implements IParticleEmitterType {
  18508. /**
  18509. * The radius of the emission sphere.
  18510. */
  18511. radius: number;
  18512. /**
  18513. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18514. */
  18515. radiusRange: number;
  18516. /**
  18517. * How much to randomize the particle direction [0-1].
  18518. */
  18519. directionRandomizer: number;
  18520. /**
  18521. * Creates a new instance SphereParticleEmitter
  18522. * @param radius the radius of the emission sphere (1 by default)
  18523. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18524. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18525. */
  18526. constructor(
  18527. /**
  18528. * The radius of the emission sphere.
  18529. */
  18530. radius?: number,
  18531. /**
  18532. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18533. */
  18534. radiusRange?: number,
  18535. /**
  18536. * How much to randomize the particle direction [0-1].
  18537. */
  18538. directionRandomizer?: number);
  18539. /**
  18540. * Called by the particle System when the direction is computed for the created particle.
  18541. * @param worldMatrix is the world matrix of the particle system
  18542. * @param directionToUpdate is the direction vector to update with the result
  18543. * @param particle is the particle we are computed the direction for
  18544. */
  18545. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18546. /**
  18547. * Called by the particle System when the position is computed for the created particle.
  18548. * @param worldMatrix is the world matrix of the particle system
  18549. * @param positionToUpdate is the position vector to update with the result
  18550. * @param particle is the particle we are computed the position for
  18551. */
  18552. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18553. /**
  18554. * Clones the current emitter and returns a copy of it
  18555. * @returns the new emitter
  18556. */
  18557. clone(): SphereParticleEmitter;
  18558. /**
  18559. * Called by the GPUParticleSystem to setup the update shader
  18560. * @param effect defines the update shader
  18561. */
  18562. applyToShader(effect: Effect): void;
  18563. /**
  18564. * Returns a string to use to update the GPU particles update shader
  18565. * @returns a string containng the defines string
  18566. */
  18567. getEffectDefines(): string;
  18568. /**
  18569. * Returns the string "SphereParticleEmitter"
  18570. * @returns a string containing the class name
  18571. */
  18572. getClassName(): string;
  18573. /**
  18574. * Serializes the particle system to a JSON object.
  18575. * @returns the JSON object
  18576. */
  18577. serialize(): any;
  18578. /**
  18579. * Parse properties from a JSON object
  18580. * @param serializationObject defines the JSON object
  18581. */
  18582. parse(serializationObject: any): void;
  18583. }
  18584. /**
  18585. * Particle emitter emitting particles from the inside of a sphere.
  18586. * It emits the particles randomly between two vectors.
  18587. */
  18588. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18589. /**
  18590. * The min limit of the emission direction.
  18591. */
  18592. direction1: Vector3;
  18593. /**
  18594. * The max limit of the emission direction.
  18595. */
  18596. direction2: Vector3;
  18597. /**
  18598. * Creates a new instance SphereDirectedParticleEmitter
  18599. * @param radius the radius of the emission sphere (1 by default)
  18600. * @param direction1 the min limit of the emission direction (up vector by default)
  18601. * @param direction2 the max limit of the emission direction (up vector by default)
  18602. */
  18603. constructor(radius?: number,
  18604. /**
  18605. * The min limit of the emission direction.
  18606. */
  18607. direction1?: Vector3,
  18608. /**
  18609. * The max limit of the emission direction.
  18610. */
  18611. direction2?: Vector3);
  18612. /**
  18613. * Called by the particle System when the direction is computed for the created particle.
  18614. * @param worldMatrix is the world matrix of the particle system
  18615. * @param directionToUpdate is the direction vector to update with the result
  18616. * @param particle is the particle we are computed the direction for
  18617. */
  18618. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18619. /**
  18620. * Clones the current emitter and returns a copy of it
  18621. * @returns the new emitter
  18622. */
  18623. clone(): SphereDirectedParticleEmitter;
  18624. /**
  18625. * Called by the GPUParticleSystem to setup the update shader
  18626. * @param effect defines the update shader
  18627. */
  18628. applyToShader(effect: Effect): void;
  18629. /**
  18630. * Returns a string to use to update the GPU particles update shader
  18631. * @returns a string containng the defines string
  18632. */
  18633. getEffectDefines(): string;
  18634. /**
  18635. * Returns the string "SphereDirectedParticleEmitter"
  18636. * @returns a string containing the class name
  18637. */
  18638. getClassName(): string;
  18639. /**
  18640. * Serializes the particle system to a JSON object.
  18641. * @returns the JSON object
  18642. */
  18643. serialize(): any;
  18644. /**
  18645. * Parse properties from a JSON object
  18646. * @param serializationObject defines the JSON object
  18647. */
  18648. parse(serializationObject: any): void;
  18649. }
  18650. }
  18651. declare module "babylonjs/Particles/EmitterTypes/index" {
  18652. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18653. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18654. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18655. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18656. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18657. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18659. }
  18660. declare module "babylonjs/Particles/IParticleSystem" {
  18661. import { Nullable } from "babylonjs/types";
  18662. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18663. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18665. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18666. import { Texture } from "babylonjs/Materials/Textures/texture";
  18667. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18668. import { Scene } from "babylonjs/scene";
  18669. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18670. import { Animation } from "babylonjs/Animations/animation";
  18671. /**
  18672. * Interface representing a particle system in Babylon.js.
  18673. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18674. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18675. */
  18676. export interface IParticleSystem {
  18677. /**
  18678. * List of animations used by the particle system.
  18679. */
  18680. animations: Animation[];
  18681. /**
  18682. * The id of the Particle system.
  18683. */
  18684. id: string;
  18685. /**
  18686. * The name of the Particle system.
  18687. */
  18688. name: string;
  18689. /**
  18690. * The emitter represents the Mesh or position we are attaching the particle system to.
  18691. */
  18692. emitter: Nullable<AbstractMesh | Vector3>;
  18693. /**
  18694. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18695. */
  18696. isBillboardBased: boolean;
  18697. /**
  18698. * The rendering group used by the Particle system to chose when to render.
  18699. */
  18700. renderingGroupId: number;
  18701. /**
  18702. * The layer mask we are rendering the particles through.
  18703. */
  18704. layerMask: number;
  18705. /**
  18706. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18707. */
  18708. updateSpeed: number;
  18709. /**
  18710. * The amount of time the particle system is running (depends of the overall update speed).
  18711. */
  18712. targetStopDuration: number;
  18713. /**
  18714. * The texture used to render each particle. (this can be a spritesheet)
  18715. */
  18716. particleTexture: Nullable<Texture>;
  18717. /**
  18718. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18719. */
  18720. blendMode: number;
  18721. /**
  18722. * Minimum life time of emitting particles.
  18723. */
  18724. minLifeTime: number;
  18725. /**
  18726. * Maximum life time of emitting particles.
  18727. */
  18728. maxLifeTime: number;
  18729. /**
  18730. * Minimum Size of emitting particles.
  18731. */
  18732. minSize: number;
  18733. /**
  18734. * Maximum Size of emitting particles.
  18735. */
  18736. maxSize: number;
  18737. /**
  18738. * Minimum scale of emitting particles on X axis.
  18739. */
  18740. minScaleX: number;
  18741. /**
  18742. * Maximum scale of emitting particles on X axis.
  18743. */
  18744. maxScaleX: number;
  18745. /**
  18746. * Minimum scale of emitting particles on Y axis.
  18747. */
  18748. minScaleY: number;
  18749. /**
  18750. * Maximum scale of emitting particles on Y axis.
  18751. */
  18752. maxScaleY: number;
  18753. /**
  18754. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18755. */
  18756. color1: Color4;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color2: Color4;
  18761. /**
  18762. * Color the particle will have at the end of its lifetime.
  18763. */
  18764. colorDead: Color4;
  18765. /**
  18766. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18767. */
  18768. emitRate: number;
  18769. /**
  18770. * You can use gravity if you want to give an orientation to your particles.
  18771. */
  18772. gravity: Vector3;
  18773. /**
  18774. * Minimum power of emitting particles.
  18775. */
  18776. minEmitPower: number;
  18777. /**
  18778. * Maximum power of emitting particles.
  18779. */
  18780. maxEmitPower: number;
  18781. /**
  18782. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18783. */
  18784. minAngularSpeed: number;
  18785. /**
  18786. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. maxAngularSpeed: number;
  18789. /**
  18790. * Gets or sets the minimal initial rotation in radians.
  18791. */
  18792. minInitialRotation: number;
  18793. /**
  18794. * Gets or sets the maximal initial rotation in radians.
  18795. */
  18796. maxInitialRotation: number;
  18797. /**
  18798. * The particle emitter type defines the emitter used by the particle system.
  18799. * It can be for example box, sphere, or cone...
  18800. */
  18801. particleEmitterType: Nullable<IParticleEmitterType>;
  18802. /**
  18803. * Defines the delay in milliseconds before starting the system (0 by default)
  18804. */
  18805. startDelay: number;
  18806. /**
  18807. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  18808. */
  18809. preWarmCycles: number;
  18810. /**
  18811. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18812. */
  18813. preWarmStepOffset: number;
  18814. /**
  18815. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  18816. */
  18817. spriteCellChangeSpeed: number;
  18818. /**
  18819. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18820. */
  18821. startSpriteCellID: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18824. */
  18825. endSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18828. */
  18829. spriteCellWidth: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18832. */
  18833. spriteCellHeight: number;
  18834. /**
  18835. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18836. */
  18837. spriteRandomStartCell: boolean;
  18838. /**
  18839. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18840. */
  18841. isAnimationSheetEnabled: boolean;
  18842. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18843. translationPivot: Vector2;
  18844. /**
  18845. * Gets or sets a texture used to add random noise to particle positions
  18846. */
  18847. noiseTexture: Nullable<BaseTexture>;
  18848. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18849. noiseStrength: Vector3;
  18850. /**
  18851. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18852. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18853. */
  18854. billboardMode: number;
  18855. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18856. limitVelocityDamping: number;
  18857. /**
  18858. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18859. */
  18860. beginAnimationOnStart: boolean;
  18861. /**
  18862. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18863. */
  18864. beginAnimationFrom: number;
  18865. /**
  18866. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationTo: number;
  18869. /**
  18870. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationLoop: boolean;
  18873. /**
  18874. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18875. */
  18876. disposeOnStop: boolean;
  18877. /**
  18878. * Gets the maximum number of particles active at the same time.
  18879. * @returns The max number of active particles.
  18880. */
  18881. getCapacity(): number;
  18882. /**
  18883. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18884. * @returns True if it has been started, otherwise false.
  18885. */
  18886. isStarted(): boolean;
  18887. /**
  18888. * Animates the particle system for this frame.
  18889. */
  18890. animate(): void;
  18891. /**
  18892. * Renders the particle system in its current state.
  18893. * @returns the current number of particles
  18894. */
  18895. render(): number;
  18896. /**
  18897. * Dispose the particle system and frees its associated resources.
  18898. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18899. */
  18900. dispose(disposeTexture?: boolean): void;
  18901. /**
  18902. * Clones the particle system.
  18903. * @param name The name of the cloned object
  18904. * @param newEmitter The new emitter to use
  18905. * @returns the cloned particle system
  18906. */
  18907. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18908. /**
  18909. * Serializes the particle system to a JSON object.
  18910. * @returns the JSON object
  18911. */
  18912. serialize(): any;
  18913. /**
  18914. * Rebuild the particle system
  18915. */
  18916. rebuild(): void;
  18917. /**
  18918. * Starts the particle system and begins to emit
  18919. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18920. */
  18921. start(delay?: number): void;
  18922. /**
  18923. * Stops the particle system.
  18924. */
  18925. stop(): void;
  18926. /**
  18927. * Remove all active particles
  18928. */
  18929. reset(): void;
  18930. /**
  18931. * Is this system ready to be used/rendered
  18932. * @return true if the system is ready
  18933. */
  18934. isReady(): boolean;
  18935. /**
  18936. * Adds a new color gradient
  18937. * @param gradient defines the gradient to use (between 0 and 1)
  18938. * @param color1 defines the color to affect to the specified gradient
  18939. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18940. * @returns the current particle system
  18941. */
  18942. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18943. /**
  18944. * Remove a specific color gradient
  18945. * @param gradient defines the gradient to remove
  18946. * @returns the current particle system
  18947. */
  18948. removeColorGradient(gradient: number): IParticleSystem;
  18949. /**
  18950. * Adds a new size gradient
  18951. * @param gradient defines the gradient to use (between 0 and 1)
  18952. * @param factor defines the size factor to affect to the specified gradient
  18953. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18954. * @returns the current particle system
  18955. */
  18956. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18957. /**
  18958. * Remove a specific size gradient
  18959. * @param gradient defines the gradient to remove
  18960. * @returns the current particle system
  18961. */
  18962. removeSizeGradient(gradient: number): IParticleSystem;
  18963. /**
  18964. * Gets the current list of color gradients.
  18965. * You must use addColorGradient and removeColorGradient to udpate this list
  18966. * @returns the list of color gradients
  18967. */
  18968. getColorGradients(): Nullable<Array<ColorGradient>>;
  18969. /**
  18970. * Gets the current list of size gradients.
  18971. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18972. * @returns the list of size gradients
  18973. */
  18974. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18975. /**
  18976. * Gets the current list of angular speed gradients.
  18977. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18978. * @returns the list of angular speed gradients
  18979. */
  18980. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18981. /**
  18982. * Adds a new angular speed gradient
  18983. * @param gradient defines the gradient to use (between 0 and 1)
  18984. * @param factor defines the angular speed to affect to the specified gradient
  18985. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18986. * @returns the current particle system
  18987. */
  18988. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18989. /**
  18990. * Remove a specific angular speed gradient
  18991. * @param gradient defines the gradient to remove
  18992. * @returns the current particle system
  18993. */
  18994. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18995. /**
  18996. * Gets the current list of velocity gradients.
  18997. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18998. * @returns the list of velocity gradients
  18999. */
  19000. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19001. /**
  19002. * Adds a new velocity gradient
  19003. * @param gradient defines the gradient to use (between 0 and 1)
  19004. * @param factor defines the velocity to affect to the specified gradient
  19005. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19006. * @returns the current particle system
  19007. */
  19008. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19009. /**
  19010. * Remove a specific velocity gradient
  19011. * @param gradient defines the gradient to remove
  19012. * @returns the current particle system
  19013. */
  19014. removeVelocityGradient(gradient: number): IParticleSystem;
  19015. /**
  19016. * Gets the current list of limit velocity gradients.
  19017. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19018. * @returns the list of limit velocity gradients
  19019. */
  19020. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19021. /**
  19022. * Adds a new limit velocity gradient
  19023. * @param gradient defines the gradient to use (between 0 and 1)
  19024. * @param factor defines the limit velocity to affect to the specified gradient
  19025. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19026. * @returns the current particle system
  19027. */
  19028. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19029. /**
  19030. * Remove a specific limit velocity gradient
  19031. * @param gradient defines the gradient to remove
  19032. * @returns the current particle system
  19033. */
  19034. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19035. /**
  19036. * Adds a new drag gradient
  19037. * @param gradient defines the gradient to use (between 0 and 1)
  19038. * @param factor defines the drag to affect to the specified gradient
  19039. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19040. * @returns the current particle system
  19041. */
  19042. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19043. /**
  19044. * Remove a specific drag gradient
  19045. * @param gradient defines the gradient to remove
  19046. * @returns the current particle system
  19047. */
  19048. removeDragGradient(gradient: number): IParticleSystem;
  19049. /**
  19050. * Gets the current list of drag gradients.
  19051. * You must use addDragGradient and removeDragGradient to udpate this list
  19052. * @returns the list of drag gradients
  19053. */
  19054. getDragGradients(): Nullable<Array<FactorGradient>>;
  19055. /**
  19056. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19057. * @param gradient defines the gradient to use (between 0 and 1)
  19058. * @param factor defines the emit rate to affect to the specified gradient
  19059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19060. * @returns the current particle system
  19061. */
  19062. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19063. /**
  19064. * Remove a specific emit rate gradient
  19065. * @param gradient defines the gradient to remove
  19066. * @returns the current particle system
  19067. */
  19068. removeEmitRateGradient(gradient: number): IParticleSystem;
  19069. /**
  19070. * Gets the current list of emit rate gradients.
  19071. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19072. * @returns the list of emit rate gradients
  19073. */
  19074. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19075. /**
  19076. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19077. * @param gradient defines the gradient to use (between 0 and 1)
  19078. * @param factor defines the start size to affect to the specified gradient
  19079. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19080. * @returns the current particle system
  19081. */
  19082. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19083. /**
  19084. * Remove a specific start size gradient
  19085. * @param gradient defines the gradient to remove
  19086. * @returns the current particle system
  19087. */
  19088. removeStartSizeGradient(gradient: number): IParticleSystem;
  19089. /**
  19090. * Gets the current list of start size gradients.
  19091. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19092. * @returns the list of start size gradients
  19093. */
  19094. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19095. /**
  19096. * Adds a new life time gradient
  19097. * @param gradient defines the gradient to use (between 0 and 1)
  19098. * @param factor defines the life time factor to affect to the specified gradient
  19099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19100. * @returns the current particle system
  19101. */
  19102. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19103. /**
  19104. * Remove a specific life time gradient
  19105. * @param gradient defines the gradient to remove
  19106. * @returns the current particle system
  19107. */
  19108. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19109. /**
  19110. * Gets the current list of life time gradients.
  19111. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19112. * @returns the list of life time gradients
  19113. */
  19114. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19115. /**
  19116. * Gets the current list of color gradients.
  19117. * You must use addColorGradient and removeColorGradient to udpate this list
  19118. * @returns the list of color gradients
  19119. */
  19120. getColorGradients(): Nullable<Array<ColorGradient>>;
  19121. /**
  19122. * Adds a new ramp gradient used to remap particle colors
  19123. * @param gradient defines the gradient to use (between 0 and 1)
  19124. * @param color defines the color to affect to the specified gradient
  19125. * @returns the current particle system
  19126. */
  19127. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19128. /**
  19129. * Gets the current list of ramp gradients.
  19130. * You must use addRampGradient and removeRampGradient to udpate this list
  19131. * @returns the list of ramp gradients
  19132. */
  19133. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19134. /** Gets or sets a boolean indicating that ramp gradients must be used
  19135. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19136. */
  19137. useRampGradients: boolean;
  19138. /**
  19139. * Adds a new color remap gradient
  19140. * @param gradient defines the gradient to use (between 0 and 1)
  19141. * @param min defines the color remap minimal range
  19142. * @param max defines the color remap maximal range
  19143. * @returns the current particle system
  19144. */
  19145. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of color remap gradients.
  19148. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19149. * @returns the list of color remap gradients
  19150. */
  19151. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new alpha remap gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param min defines the alpha remap minimal range
  19156. * @param max defines the alpha remap maximal range
  19157. * @returns the current particle system
  19158. */
  19159. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19160. /**
  19161. * Gets the current list of alpha remap gradients.
  19162. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19163. * @returns the list of alpha remap gradients
  19164. */
  19165. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19166. /**
  19167. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19168. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19169. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19170. * @returns the emitter
  19171. */
  19172. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19173. /**
  19174. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19175. * @param radius The radius of the hemisphere to emit from
  19176. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19177. * @returns the emitter
  19178. */
  19179. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19180. /**
  19181. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19182. * @param radius The radius of the sphere to emit from
  19183. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19184. * @returns the emitter
  19185. */
  19186. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19187. /**
  19188. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19189. * @param radius The radius of the sphere to emit from
  19190. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19191. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19192. * @returns the emitter
  19193. */
  19194. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19195. /**
  19196. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19197. * @param radius The radius of the emission cylinder
  19198. * @param height The height of the emission cylinder
  19199. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19200. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19201. * @returns the emitter
  19202. */
  19203. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19204. /**
  19205. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19206. * @param radius The radius of the cylinder to emit from
  19207. * @param height The height of the emission cylinder
  19208. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19209. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19210. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19211. * @returns the emitter
  19212. */
  19213. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19214. /**
  19215. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19216. * @param radius The radius of the cone to emit from
  19217. * @param angle The base angle of the cone
  19218. * @returns the emitter
  19219. */
  19220. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19221. /**
  19222. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19223. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19224. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19225. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19226. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19227. * @returns the emitter
  19228. */
  19229. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19230. /**
  19231. * Get hosting scene
  19232. * @returns the scene
  19233. */
  19234. getScene(): Scene;
  19235. }
  19236. }
  19237. declare module "babylonjs/Meshes/instancedMesh" {
  19238. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19240. import { Camera } from "babylonjs/Cameras/camera";
  19241. import { Node } from "babylonjs/node";
  19242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19243. import { Mesh } from "babylonjs/Meshes/mesh";
  19244. import { Material } from "babylonjs/Materials/material";
  19245. import { Skeleton } from "babylonjs/Bones/skeleton";
  19246. import { Light } from "babylonjs/Lights/light";
  19247. /**
  19248. * Creates an instance based on a source mesh.
  19249. */
  19250. export class InstancedMesh extends AbstractMesh {
  19251. private _sourceMesh;
  19252. private _currentLOD;
  19253. /** @hidden */
  19254. _indexInSourceMeshInstanceArray: number;
  19255. constructor(name: string, source: Mesh);
  19256. /**
  19257. * Returns the string "InstancedMesh".
  19258. */
  19259. getClassName(): string;
  19260. /** Gets the list of lights affecting that mesh */
  19261. readonly lightSources: Light[];
  19262. _resyncLightSources(): void;
  19263. _resyncLighSource(light: Light): void;
  19264. _removeLightSource(light: Light, dispose: boolean): void;
  19265. /**
  19266. * If the source mesh receives shadows
  19267. */
  19268. readonly receiveShadows: boolean;
  19269. /**
  19270. * The material of the source mesh
  19271. */
  19272. readonly material: Nullable<Material>;
  19273. /**
  19274. * Visibility of the source mesh
  19275. */
  19276. readonly visibility: number;
  19277. /**
  19278. * Skeleton of the source mesh
  19279. */
  19280. readonly skeleton: Nullable<Skeleton>;
  19281. /**
  19282. * Rendering ground id of the source mesh
  19283. */
  19284. renderingGroupId: number;
  19285. /**
  19286. * Returns the total number of vertices (integer).
  19287. */
  19288. getTotalVertices(): number;
  19289. /**
  19290. * Returns a positive integer : the total number of indices in this mesh geometry.
  19291. * @returns the numner of indices or zero if the mesh has no geometry.
  19292. */
  19293. getTotalIndices(): number;
  19294. /**
  19295. * The source mesh of the instance
  19296. */
  19297. readonly sourceMesh: Mesh;
  19298. /**
  19299. * Is this node ready to be used/rendered
  19300. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19301. * @return {boolean} is it ready
  19302. */
  19303. isReady(completeCheck?: boolean): boolean;
  19304. /**
  19305. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19306. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19307. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  19308. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19309. */
  19310. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19311. /**
  19312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19314. * The `data` are either a numeric array either a Float32Array.
  19315. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19316. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  19317. * Note that a new underlying VertexBuffer object is created each call.
  19318. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19319. *
  19320. * Possible `kind` values :
  19321. * - VertexBuffer.PositionKind
  19322. * - VertexBuffer.UVKind
  19323. * - VertexBuffer.UV2Kind
  19324. * - VertexBuffer.UV3Kind
  19325. * - VertexBuffer.UV4Kind
  19326. * - VertexBuffer.UV5Kind
  19327. * - VertexBuffer.UV6Kind
  19328. * - VertexBuffer.ColorKind
  19329. * - VertexBuffer.MatricesIndicesKind
  19330. * - VertexBuffer.MatricesIndicesExtraKind
  19331. * - VertexBuffer.MatricesWeightsKind
  19332. * - VertexBuffer.MatricesWeightsExtraKind
  19333. *
  19334. * Returns the Mesh.
  19335. */
  19336. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19337. /**
  19338. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19339. * If the mesh has no geometry, it is simply returned as it is.
  19340. * The `data` are either a numeric array either a Float32Array.
  19341. * No new underlying VertexBuffer object is created.
  19342. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19343. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19344. *
  19345. * Possible `kind` values :
  19346. * - VertexBuffer.PositionKind
  19347. * - VertexBuffer.UVKind
  19348. * - VertexBuffer.UV2Kind
  19349. * - VertexBuffer.UV3Kind
  19350. * - VertexBuffer.UV4Kind
  19351. * - VertexBuffer.UV5Kind
  19352. * - VertexBuffer.UV6Kind
  19353. * - VertexBuffer.ColorKind
  19354. * - VertexBuffer.MatricesIndicesKind
  19355. * - VertexBuffer.MatricesIndicesExtraKind
  19356. * - VertexBuffer.MatricesWeightsKind
  19357. * - VertexBuffer.MatricesWeightsExtraKind
  19358. *
  19359. * Returns the Mesh.
  19360. */
  19361. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19362. /**
  19363. * Sets the mesh indices.
  19364. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19365. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19366. * This method creates a new index buffer each call.
  19367. * Returns the Mesh.
  19368. */
  19369. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19370. /**
  19371. * Boolean : True if the mesh owns the requested kind of data.
  19372. */
  19373. isVerticesDataPresent(kind: string): boolean;
  19374. /**
  19375. * Returns an array of indices (IndicesArray).
  19376. */
  19377. getIndices(): Nullable<IndicesArray>;
  19378. readonly _positions: Nullable<Vector3[]>;
  19379. /**
  19380. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19381. * This means the mesh underlying bounding box and sphere are recomputed.
  19382. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19383. * @returns the current mesh
  19384. */
  19385. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19386. /** @hidden */
  19387. _preActivate(): InstancedMesh;
  19388. /** @hidden */
  19389. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19390. /** @hidden */
  19391. _postActivate(): void;
  19392. getWorldMatrix(): Matrix;
  19393. readonly isAnInstance: boolean;
  19394. /**
  19395. * Returns the current associated LOD AbstractMesh.
  19396. */
  19397. getLOD(camera: Camera): AbstractMesh;
  19398. /** @hidden */
  19399. _syncSubMeshes(): InstancedMesh;
  19400. /** @hidden */
  19401. _generatePointsArray(): boolean;
  19402. /**
  19403. * Creates a new InstancedMesh from the current mesh.
  19404. * - name (string) : the cloned mesh name
  19405. * - newParent (optional Node) : the optional Node to parent the clone to.
  19406. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19407. *
  19408. * Returns the clone.
  19409. */
  19410. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19411. /**
  19412. * Disposes the InstancedMesh.
  19413. * Returns nothing.
  19414. */
  19415. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19416. }
  19417. }
  19418. declare module "babylonjs/Materials/shaderMaterial" {
  19419. import { Scene } from "babylonjs/scene";
  19420. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19422. import { Mesh } from "babylonjs/Meshes/mesh";
  19423. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19424. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19425. import { Texture } from "babylonjs/Materials/Textures/texture";
  19426. import { Material } from "babylonjs/Materials/material";
  19427. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19428. /**
  19429. * Defines the options associated with the creation of a shader material.
  19430. */
  19431. export interface IShaderMaterialOptions {
  19432. /**
  19433. * Does the material work in alpha blend mode
  19434. */
  19435. needAlphaBlending: boolean;
  19436. /**
  19437. * Does the material work in alpha test mode
  19438. */
  19439. needAlphaTesting: boolean;
  19440. /**
  19441. * The list of attribute names used in the shader
  19442. */
  19443. attributes: string[];
  19444. /**
  19445. * The list of unifrom names used in the shader
  19446. */
  19447. uniforms: string[];
  19448. /**
  19449. * The list of UBO names used in the shader
  19450. */
  19451. uniformBuffers: string[];
  19452. /**
  19453. * The list of sampler names used in the shader
  19454. */
  19455. samplers: string[];
  19456. /**
  19457. * The list of defines used in the shader
  19458. */
  19459. defines: string[];
  19460. }
  19461. /**
  19462. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19463. *
  19464. * This returned material effects how the mesh will look based on the code in the shaders.
  19465. *
  19466. * @see http://doc.babylonjs.com/how_to/shader_material
  19467. */
  19468. export class ShaderMaterial extends Material {
  19469. private _shaderPath;
  19470. private _options;
  19471. private _textures;
  19472. private _textureArrays;
  19473. private _floats;
  19474. private _ints;
  19475. private _floatsArrays;
  19476. private _colors3;
  19477. private _colors3Arrays;
  19478. private _colors4;
  19479. private _colors4Arrays;
  19480. private _vectors2;
  19481. private _vectors3;
  19482. private _vectors4;
  19483. private _matrices;
  19484. private _matrices3x3;
  19485. private _matrices2x2;
  19486. private _vectors2Arrays;
  19487. private _vectors3Arrays;
  19488. private _vectors4Arrays;
  19489. private _cachedWorldViewMatrix;
  19490. private _cachedWorldViewProjectionMatrix;
  19491. private _renderId;
  19492. /**
  19493. * Instantiate a new shader material.
  19494. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  19495. * This returned material effects how the mesh will look based on the code in the shaders.
  19496. * @see http://doc.babylonjs.com/how_to/shader_material
  19497. * @param name Define the name of the material in the scene
  19498. * @param scene Define the scene the material belongs to
  19499. * @param shaderPath Defines the route to the shader code in one of three ways:
  19500. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19501. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19502. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19503. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19504. * @param options Define the options used to create the shader
  19505. */
  19506. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19507. /**
  19508. * Gets the options used to compile the shader.
  19509. * They can be modified to trigger a new compilation
  19510. */
  19511. readonly options: IShaderMaterialOptions;
  19512. /**
  19513. * Gets the current class name of the material e.g. "ShaderMaterial"
  19514. * Mainly use in serialization.
  19515. * @returns the class name
  19516. */
  19517. getClassName(): string;
  19518. /**
  19519. * Specifies if the material will require alpha blending
  19520. * @returns a boolean specifying if alpha blending is needed
  19521. */
  19522. needAlphaBlending(): boolean;
  19523. /**
  19524. * Specifies if this material should be rendered in alpha test mode
  19525. * @returns a boolean specifying if an alpha test is needed.
  19526. */
  19527. needAlphaTesting(): boolean;
  19528. private _checkUniform;
  19529. /**
  19530. * Set a texture in the shader.
  19531. * @param name Define the name of the uniform samplers as defined in the shader
  19532. * @param texture Define the texture to bind to this sampler
  19533. * @return the material itself allowing "fluent" like uniform updates
  19534. */
  19535. setTexture(name: string, texture: Texture): ShaderMaterial;
  19536. /**
  19537. * Set a texture array in the shader.
  19538. * @param name Define the name of the uniform sampler array as defined in the shader
  19539. * @param textures Define the list of textures to bind to this sampler
  19540. * @return the material itself allowing "fluent" like uniform updates
  19541. */
  19542. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19543. /**
  19544. * Set a float in the shader.
  19545. * @param name Define the name of the uniform as defined in the shader
  19546. * @param value Define the value to give to the uniform
  19547. * @return the material itself allowing "fluent" like uniform updates
  19548. */
  19549. setFloat(name: string, value: number): ShaderMaterial;
  19550. /**
  19551. * Set a int in the shader.
  19552. * @param name Define the name of the uniform as defined in the shader
  19553. * @param value Define the value to give to the uniform
  19554. * @return the material itself allowing "fluent" like uniform updates
  19555. */
  19556. setInt(name: string, value: number): ShaderMaterial;
  19557. /**
  19558. * Set an array of floats in the shader.
  19559. * @param name Define the name of the uniform as defined in the shader
  19560. * @param value Define the value to give to the uniform
  19561. * @return the material itself allowing "fluent" like uniform updates
  19562. */
  19563. setFloats(name: string, value: number[]): ShaderMaterial;
  19564. /**
  19565. * Set a vec3 in the shader from a Color3.
  19566. * @param name Define the name of the uniform as defined in the shader
  19567. * @param value Define the value to give to the uniform
  19568. * @return the material itself allowing "fluent" like uniform updates
  19569. */
  19570. setColor3(name: string, value: Color3): ShaderMaterial;
  19571. /**
  19572. * Set a vec3 array in the shader from a Color3 array.
  19573. * @param name Define the name of the uniform as defined in the shader
  19574. * @param value Define the value to give to the uniform
  19575. * @return the material itself allowing "fluent" like uniform updates
  19576. */
  19577. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19578. /**
  19579. * Set a vec4 in the shader from a Color4.
  19580. * @param name Define the name of the uniform as defined in the shader
  19581. * @param value Define the value to give to the uniform
  19582. * @return the material itself allowing "fluent" like uniform updates
  19583. */
  19584. setColor4(name: string, value: Color4): ShaderMaterial;
  19585. /**
  19586. * Set a vec4 array in the shader from a Color4 array.
  19587. * @param name Define the name of the uniform as defined in the shader
  19588. * @param value Define the value to give to the uniform
  19589. * @return the material itself allowing "fluent" like uniform updates
  19590. */
  19591. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19592. /**
  19593. * Set a vec2 in the shader from a Vector2.
  19594. * @param name Define the name of the uniform as defined in the shader
  19595. * @param value Define the value to give to the uniform
  19596. * @return the material itself allowing "fluent" like uniform updates
  19597. */
  19598. setVector2(name: string, value: Vector2): ShaderMaterial;
  19599. /**
  19600. * Set a vec3 in the shader from a Vector3.
  19601. * @param name Define the name of the uniform as defined in the shader
  19602. * @param value Define the value to give to the uniform
  19603. * @return the material itself allowing "fluent" like uniform updates
  19604. */
  19605. setVector3(name: string, value: Vector3): ShaderMaterial;
  19606. /**
  19607. * Set a vec4 in the shader from a Vector4.
  19608. * @param name Define the name of the uniform as defined in the shader
  19609. * @param value Define the value to give to the uniform
  19610. * @return the material itself allowing "fluent" like uniform updates
  19611. */
  19612. setVector4(name: string, value: Vector4): ShaderMaterial;
  19613. /**
  19614. * Set a mat4 in the shader from a Matrix.
  19615. * @param name Define the name of the uniform as defined in the shader
  19616. * @param value Define the value to give to the uniform
  19617. * @return the material itself allowing "fluent" like uniform updates
  19618. */
  19619. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19620. /**
  19621. * Set a mat3 in the shader from a Float32Array.
  19622. * @param name Define the name of the uniform as defined in the shader
  19623. * @param value Define the value to give to the uniform
  19624. * @return the material itself allowing "fluent" like uniform updates
  19625. */
  19626. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19627. /**
  19628. * Set a mat2 in the shader from a Float32Array.
  19629. * @param name Define the name of the uniform as defined in the shader
  19630. * @param value Define the value to give to the uniform
  19631. * @return the material itself allowing "fluent" like uniform updates
  19632. */
  19633. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19634. /**
  19635. * Set a vec2 array in the shader from a number array.
  19636. * @param name Define the name of the uniform as defined in the shader
  19637. * @param value Define the value to give to the uniform
  19638. * @return the material itself allowing "fluent" like uniform updates
  19639. */
  19640. setArray2(name: string, value: number[]): ShaderMaterial;
  19641. /**
  19642. * Set a vec3 array in the shader from a number array.
  19643. * @param name Define the name of the uniform as defined in the shader
  19644. * @param value Define the value to give to the uniform
  19645. * @return the material itself allowing "fluent" like uniform updates
  19646. */
  19647. setArray3(name: string, value: number[]): ShaderMaterial;
  19648. /**
  19649. * Set a vec4 array in the shader from a number array.
  19650. * @param name Define the name of the uniform as defined in the shader
  19651. * @param value Define the value to give to the uniform
  19652. * @return the material itself allowing "fluent" like uniform updates
  19653. */
  19654. setArray4(name: string, value: number[]): ShaderMaterial;
  19655. private _checkCache;
  19656. /**
  19657. * Specifies that the submesh is ready to be used
  19658. * @param mesh defines the mesh to check
  19659. * @param subMesh defines which submesh to check
  19660. * @param useInstances specifies that instances should be used
  19661. * @returns a boolean indicating that the submesh is ready or not
  19662. */
  19663. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19664. /**
  19665. * Checks if the material is ready to render the requested mesh
  19666. * @param mesh Define the mesh to render
  19667. * @param useInstances Define whether or not the material is used with instances
  19668. * @returns true if ready, otherwise false
  19669. */
  19670. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19671. /**
  19672. * Binds the world matrix to the material
  19673. * @param world defines the world transformation matrix
  19674. */
  19675. bindOnlyWorldMatrix(world: Matrix): void;
  19676. /**
  19677. * Binds the material to the mesh
  19678. * @param world defines the world transformation matrix
  19679. * @param mesh defines the mesh to bind the material to
  19680. */
  19681. bind(world: Matrix, mesh?: Mesh): void;
  19682. /**
  19683. * Gets the active textures from the material
  19684. * @returns an array of textures
  19685. */
  19686. getActiveTextures(): BaseTexture[];
  19687. /**
  19688. * Specifies if the material uses a texture
  19689. * @param texture defines the texture to check against the material
  19690. * @returns a boolean specifying if the material uses the texture
  19691. */
  19692. hasTexture(texture: BaseTexture): boolean;
  19693. /**
  19694. * Makes a duplicate of the material, and gives it a new name
  19695. * @param name defines the new name for the duplicated material
  19696. * @returns the cloned material
  19697. */
  19698. clone(name: string): ShaderMaterial;
  19699. /**
  19700. * Disposes the material
  19701. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19702. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19703. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19704. */
  19705. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19706. /**
  19707. * Serializes this material in a JSON representation
  19708. * @returns the serialized material object
  19709. */
  19710. serialize(): any;
  19711. /**
  19712. * Creates a shader material from parsed shader material data
  19713. * @param source defines the JSON represnetation of the material
  19714. * @param scene defines the hosting scene
  19715. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19716. * @returns a new material
  19717. */
  19718. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19719. }
  19720. }
  19721. declare module "babylonjs/Shaders/color.fragment" {
  19722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19723. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19724. /** @hidden */
  19725. export var colorPixelShader: {
  19726. name: string;
  19727. shader: string;
  19728. };
  19729. }
  19730. declare module "babylonjs/Shaders/color.vertex" {
  19731. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19733. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19734. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19735. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19737. /** @hidden */
  19738. export var colorVertexShader: {
  19739. name: string;
  19740. shader: string;
  19741. };
  19742. }
  19743. declare module "babylonjs/Meshes/linesMesh" {
  19744. import { Nullable } from "babylonjs/types";
  19745. import { Scene } from "babylonjs/scene";
  19746. import { Color3 } from "babylonjs/Maths/math.color";
  19747. import { Node } from "babylonjs/node";
  19748. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19749. import { Mesh } from "babylonjs/Meshes/mesh";
  19750. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19751. import { Effect } from "babylonjs/Materials/effect";
  19752. import { Material } from "babylonjs/Materials/material";
  19753. import "babylonjs/Shaders/color.fragment";
  19754. import "babylonjs/Shaders/color.vertex";
  19755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19756. /**
  19757. * Line mesh
  19758. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19759. */
  19760. export class LinesMesh extends Mesh {
  19761. /**
  19762. * If vertex color should be applied to the mesh
  19763. */
  19764. readonly useVertexColor?: boolean | undefined;
  19765. /**
  19766. * If vertex alpha should be applied to the mesh
  19767. */
  19768. readonly useVertexAlpha?: boolean | undefined;
  19769. /**
  19770. * Color of the line (Default: White)
  19771. */
  19772. color: Color3;
  19773. /**
  19774. * Alpha of the line (Default: 1)
  19775. */
  19776. alpha: number;
  19777. /**
  19778. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19779. * This margin is expressed in world space coordinates, so its value may vary.
  19780. * Default value is 0.1
  19781. */
  19782. intersectionThreshold: number;
  19783. private _colorShader;
  19784. private color4;
  19785. /**
  19786. * Creates a new LinesMesh
  19787. * @param name defines the name
  19788. * @param scene defines the hosting scene
  19789. * @param parent defines the parent mesh if any
  19790. * @param source defines the optional source LinesMesh used to clone data from
  19791. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19792. * When false, achieved by calling a clone(), also passing False.
  19793. * This will make creation of children, recursive.
  19794. * @param useVertexColor defines if this LinesMesh supports vertex color
  19795. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19796. */
  19797. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19798. /**
  19799. * If vertex color should be applied to the mesh
  19800. */
  19801. useVertexColor?: boolean | undefined,
  19802. /**
  19803. * If vertex alpha should be applied to the mesh
  19804. */
  19805. useVertexAlpha?: boolean | undefined);
  19806. private _addClipPlaneDefine;
  19807. private _removeClipPlaneDefine;
  19808. isReady(): boolean;
  19809. /**
  19810. * Returns the string "LineMesh"
  19811. */
  19812. getClassName(): string;
  19813. /**
  19814. * @hidden
  19815. */
  19816. /**
  19817. * @hidden
  19818. */
  19819. material: Material;
  19820. /**
  19821. * @hidden
  19822. */
  19823. readonly checkCollisions: boolean;
  19824. /** @hidden */
  19825. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19826. /** @hidden */
  19827. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19828. /**
  19829. * Disposes of the line mesh
  19830. * @param doNotRecurse If children should be disposed
  19831. */
  19832. dispose(doNotRecurse?: boolean): void;
  19833. /**
  19834. * Returns a new LineMesh object cloned from the current one.
  19835. */
  19836. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19837. /**
  19838. * Creates a new InstancedLinesMesh object from the mesh model.
  19839. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19840. * @param name defines the name of the new instance
  19841. * @returns a new InstancedLinesMesh
  19842. */
  19843. createInstance(name: string): InstancedLinesMesh;
  19844. }
  19845. /**
  19846. * Creates an instance based on a source LinesMesh
  19847. */
  19848. export class InstancedLinesMesh extends InstancedMesh {
  19849. /**
  19850. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19851. * This margin is expressed in world space coordinates, so its value may vary.
  19852. * Initilized with the intersectionThreshold value of the source LinesMesh
  19853. */
  19854. intersectionThreshold: number;
  19855. constructor(name: string, source: LinesMesh);
  19856. /**
  19857. * Returns the string "InstancedLinesMesh".
  19858. */
  19859. getClassName(): string;
  19860. }
  19861. }
  19862. declare module "babylonjs/Shaders/line.fragment" {
  19863. /** @hidden */
  19864. export var linePixelShader: {
  19865. name: string;
  19866. shader: string;
  19867. };
  19868. }
  19869. declare module "babylonjs/Shaders/line.vertex" {
  19870. /** @hidden */
  19871. export var lineVertexShader: {
  19872. name: string;
  19873. shader: string;
  19874. };
  19875. }
  19876. declare module "babylonjs/Rendering/edgesRenderer" {
  19877. import { Nullable } from "babylonjs/types";
  19878. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19880. import { Vector3 } from "babylonjs/Maths/math.vector";
  19881. import { IDisposable } from "babylonjs/scene";
  19882. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19883. import "babylonjs/Shaders/line.fragment";
  19884. import "babylonjs/Shaders/line.vertex";
  19885. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19886. module "babylonjs/Meshes/abstractMesh" {
  19887. interface AbstractMesh {
  19888. /**
  19889. * Gets the edgesRenderer associated with the mesh
  19890. */
  19891. edgesRenderer: Nullable<EdgesRenderer>;
  19892. }
  19893. }
  19894. module "babylonjs/Meshes/linesMesh" {
  19895. interface LinesMesh {
  19896. /**
  19897. * Enables the edge rendering mode on the mesh.
  19898. * This mode makes the mesh edges visible
  19899. * @param epsilon defines the maximal distance between two angles to detect a face
  19900. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19901. * @returns the currentAbstractMesh
  19902. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19903. */
  19904. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19905. }
  19906. }
  19907. module "babylonjs/Meshes/linesMesh" {
  19908. interface InstancedLinesMesh {
  19909. /**
  19910. * Enables the edge rendering mode on the mesh.
  19911. * This mode makes the mesh edges visible
  19912. * @param epsilon defines the maximal distance between two angles to detect a face
  19913. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19914. * @returns the current InstancedLinesMesh
  19915. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19916. */
  19917. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19918. }
  19919. }
  19920. /**
  19921. * Defines the minimum contract an Edges renderer should follow.
  19922. */
  19923. export interface IEdgesRenderer extends IDisposable {
  19924. /**
  19925. * Gets or sets a boolean indicating if the edgesRenderer is active
  19926. */
  19927. isEnabled: boolean;
  19928. /**
  19929. * Renders the edges of the attached mesh,
  19930. */
  19931. render(): void;
  19932. /**
  19933. * Checks wether or not the edges renderer is ready to render.
  19934. * @return true if ready, otherwise false.
  19935. */
  19936. isReady(): boolean;
  19937. }
  19938. /**
  19939. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19940. */
  19941. export class EdgesRenderer implements IEdgesRenderer {
  19942. /**
  19943. * Define the size of the edges with an orthographic camera
  19944. */
  19945. edgesWidthScalerForOrthographic: number;
  19946. /**
  19947. * Define the size of the edges with a perspective camera
  19948. */
  19949. edgesWidthScalerForPerspective: number;
  19950. protected _source: AbstractMesh;
  19951. protected _linesPositions: number[];
  19952. protected _linesNormals: number[];
  19953. protected _linesIndices: number[];
  19954. protected _epsilon: number;
  19955. protected _indicesCount: number;
  19956. protected _lineShader: ShaderMaterial;
  19957. protected _ib: DataBuffer;
  19958. protected _buffers: {
  19959. [key: string]: Nullable<VertexBuffer>;
  19960. };
  19961. protected _checkVerticesInsteadOfIndices: boolean;
  19962. private _meshRebuildObserver;
  19963. private _meshDisposeObserver;
  19964. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19965. isEnabled: boolean;
  19966. /**
  19967. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19968. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19969. * @param source Mesh used to create edges
  19970. * @param epsilon sum of angles in adjacency to check for edge
  19971. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19972. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19973. */
  19974. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19975. protected _prepareRessources(): void;
  19976. /** @hidden */
  19977. _rebuild(): void;
  19978. /**
  19979. * Releases the required resources for the edges renderer
  19980. */
  19981. dispose(): void;
  19982. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19983. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19984. /**
  19985. * Checks if the pair of p0 and p1 is en edge
  19986. * @param faceIndex
  19987. * @param edge
  19988. * @param faceNormals
  19989. * @param p0
  19990. * @param p1
  19991. * @private
  19992. */
  19993. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19994. /**
  19995. * push line into the position, normal and index buffer
  19996. * @protected
  19997. */
  19998. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  19999. /**
  20000. * Generates lines edges from adjacencjes
  20001. * @private
  20002. */
  20003. _generateEdgesLines(): void;
  20004. /**
  20005. * Checks wether or not the edges renderer is ready to render.
  20006. * @return true if ready, otherwise false.
  20007. */
  20008. isReady(): boolean;
  20009. /**
  20010. * Renders the edges of the attached mesh,
  20011. */
  20012. render(): void;
  20013. }
  20014. /**
  20015. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20016. */
  20017. export class LineEdgesRenderer extends EdgesRenderer {
  20018. /**
  20019. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20020. * @param source LineMesh used to generate edges
  20021. * @param epsilon not important (specified angle for edge detection)
  20022. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20023. */
  20024. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20025. /**
  20026. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20027. */
  20028. _generateEdgesLines(): void;
  20029. }
  20030. }
  20031. declare module "babylonjs/Rendering/renderingGroup" {
  20032. import { SmartArray } from "babylonjs/Misc/smartArray";
  20033. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20034. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20035. import { Nullable } from "babylonjs/types";
  20036. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20037. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20038. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20039. import { Material } from "babylonjs/Materials/material";
  20040. import { Scene } from "babylonjs/scene";
  20041. /**
  20042. * This represents the object necessary to create a rendering group.
  20043. * This is exclusively used and created by the rendering manager.
  20044. * To modify the behavior, you use the available helpers in your scene or meshes.
  20045. * @hidden
  20046. */
  20047. export class RenderingGroup {
  20048. index: number;
  20049. private static _zeroVector;
  20050. private _scene;
  20051. private _opaqueSubMeshes;
  20052. private _transparentSubMeshes;
  20053. private _alphaTestSubMeshes;
  20054. private _depthOnlySubMeshes;
  20055. private _particleSystems;
  20056. private _spriteManagers;
  20057. private _opaqueSortCompareFn;
  20058. private _alphaTestSortCompareFn;
  20059. private _transparentSortCompareFn;
  20060. private _renderOpaque;
  20061. private _renderAlphaTest;
  20062. private _renderTransparent;
  20063. /** @hidden */
  20064. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20065. onBeforeTransparentRendering: () => void;
  20066. /**
  20067. * Set the opaque sort comparison function.
  20068. * If null the sub meshes will be render in the order they were created
  20069. */
  20070. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20071. /**
  20072. * Set the alpha test sort comparison function.
  20073. * If null the sub meshes will be render in the order they were created
  20074. */
  20075. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20076. /**
  20077. * Set the transparent sort comparison function.
  20078. * If null the sub meshes will be render in the order they were created
  20079. */
  20080. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20081. /**
  20082. * Creates a new rendering group.
  20083. * @param index The rendering group index
  20084. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20085. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20086. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20087. */
  20088. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  20089. /**
  20090. * Render all the sub meshes contained in the group.
  20091. * @param customRenderFunction Used to override the default render behaviour of the group.
  20092. * @returns true if rendered some submeshes.
  20093. */
  20094. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20095. /**
  20096. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20097. * @param subMeshes The submeshes to render
  20098. */
  20099. private renderOpaqueSorted;
  20100. /**
  20101. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20102. * @param subMeshes The submeshes to render
  20103. */
  20104. private renderAlphaTestSorted;
  20105. /**
  20106. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20107. * @param subMeshes The submeshes to render
  20108. */
  20109. private renderTransparentSorted;
  20110. /**
  20111. * Renders the submeshes in a specified order.
  20112. * @param subMeshes The submeshes to sort before render
  20113. * @param sortCompareFn The comparison function use to sort
  20114. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20115. * @param transparent Specifies to activate blending if true
  20116. */
  20117. private static renderSorted;
  20118. /**
  20119. * Renders the submeshes in the order they were dispatched (no sort applied).
  20120. * @param subMeshes The submeshes to render
  20121. */
  20122. private static renderUnsorted;
  20123. /**
  20124. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20125. * are rendered back to front if in the same alpha index.
  20126. *
  20127. * @param a The first submesh
  20128. * @param b The second submesh
  20129. * @returns The result of the comparison
  20130. */
  20131. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20132. /**
  20133. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20134. * are rendered back to front.
  20135. *
  20136. * @param a The first submesh
  20137. * @param b The second submesh
  20138. * @returns The result of the comparison
  20139. */
  20140. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20141. /**
  20142. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20143. * are rendered front to back (prevent overdraw).
  20144. *
  20145. * @param a The first submesh
  20146. * @param b The second submesh
  20147. * @returns The result of the comparison
  20148. */
  20149. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20150. /**
  20151. * Resets the different lists of submeshes to prepare a new frame.
  20152. */
  20153. prepare(): void;
  20154. dispose(): void;
  20155. /**
  20156. * Inserts the submesh in its correct queue depending on its material.
  20157. * @param subMesh The submesh to dispatch
  20158. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20159. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20160. */
  20161. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20162. dispatchSprites(spriteManager: ISpriteManager): void;
  20163. dispatchParticles(particleSystem: IParticleSystem): void;
  20164. private _renderParticles;
  20165. private _renderSprites;
  20166. }
  20167. }
  20168. declare module "babylonjs/Rendering/renderingManager" {
  20169. import { Nullable } from "babylonjs/types";
  20170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20171. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20172. import { SmartArray } from "babylonjs/Misc/smartArray";
  20173. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20174. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20175. import { Material } from "babylonjs/Materials/material";
  20176. import { Scene } from "babylonjs/scene";
  20177. import { Camera } from "babylonjs/Cameras/camera";
  20178. /**
  20179. * Interface describing the different options available in the rendering manager
  20180. * regarding Auto Clear between groups.
  20181. */
  20182. export interface IRenderingManagerAutoClearSetup {
  20183. /**
  20184. * Defines whether or not autoclear is enable.
  20185. */
  20186. autoClear: boolean;
  20187. /**
  20188. * Defines whether or not to autoclear the depth buffer.
  20189. */
  20190. depth: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the stencil buffer.
  20193. */
  20194. stencil: boolean;
  20195. }
  20196. /**
  20197. * This class is used by the onRenderingGroupObservable
  20198. */
  20199. export class RenderingGroupInfo {
  20200. /**
  20201. * The Scene that being rendered
  20202. */
  20203. scene: Scene;
  20204. /**
  20205. * The camera currently used for the rendering pass
  20206. */
  20207. camera: Nullable<Camera>;
  20208. /**
  20209. * The ID of the renderingGroup being processed
  20210. */
  20211. renderingGroupId: number;
  20212. }
  20213. /**
  20214. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20215. * It is enable to manage the different groups as well as the different necessary sort functions.
  20216. * This should not be used directly aside of the few static configurations
  20217. */
  20218. export class RenderingManager {
  20219. /**
  20220. * The max id used for rendering groups (not included)
  20221. */
  20222. static MAX_RENDERINGGROUPS: number;
  20223. /**
  20224. * The min id used for rendering groups (included)
  20225. */
  20226. static MIN_RENDERINGGROUPS: number;
  20227. /**
  20228. * Used to globally prevent autoclearing scenes.
  20229. */
  20230. static AUTOCLEAR: boolean;
  20231. /**
  20232. * @hidden
  20233. */
  20234. _useSceneAutoClearSetup: boolean;
  20235. private _scene;
  20236. private _renderingGroups;
  20237. private _depthStencilBufferAlreadyCleaned;
  20238. private _autoClearDepthStencil;
  20239. private _customOpaqueSortCompareFn;
  20240. private _customAlphaTestSortCompareFn;
  20241. private _customTransparentSortCompareFn;
  20242. private _renderingGroupInfo;
  20243. /**
  20244. * Instantiates a new rendering group for a particular scene
  20245. * @param scene Defines the scene the groups belongs to
  20246. */
  20247. constructor(scene: Scene);
  20248. private _clearDepthStencilBuffer;
  20249. /**
  20250. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20251. * @hidden
  20252. */
  20253. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20254. /**
  20255. * Resets the different information of the group to prepare a new frame
  20256. * @hidden
  20257. */
  20258. reset(): void;
  20259. /**
  20260. * Dispose and release the group and its associated resources.
  20261. * @hidden
  20262. */
  20263. dispose(): void;
  20264. /**
  20265. * Clear the info related to rendering groups preventing retention points during dispose.
  20266. */
  20267. freeRenderingGroups(): void;
  20268. private _prepareRenderingGroup;
  20269. /**
  20270. * Add a sprite manager to the rendering manager in order to render it this frame.
  20271. * @param spriteManager Define the sprite manager to render
  20272. */
  20273. dispatchSprites(spriteManager: ISpriteManager): void;
  20274. /**
  20275. * Add a particle system to the rendering manager in order to render it this frame.
  20276. * @param particleSystem Define the particle system to render
  20277. */
  20278. dispatchParticles(particleSystem: IParticleSystem): void;
  20279. /**
  20280. * Add a submesh to the manager in order to render it this frame
  20281. * @param subMesh The submesh to dispatch
  20282. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20283. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20284. */
  20285. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20286. /**
  20287. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20288. * This allowed control for front to back rendering or reversly depending of the special needs.
  20289. *
  20290. * @param renderingGroupId The rendering group id corresponding to its index
  20291. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20292. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20293. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20294. */
  20295. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20296. /**
  20297. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20298. *
  20299. * @param renderingGroupId The rendering group id corresponding to its index
  20300. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20301. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20302. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20303. */
  20304. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20305. /**
  20306. * Gets the current auto clear configuration for one rendering group of the rendering
  20307. * manager.
  20308. * @param index the rendering group index to get the information for
  20309. * @returns The auto clear setup for the requested rendering group
  20310. */
  20311. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20312. }
  20313. }
  20314. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20315. import { Observable } from "babylonjs/Misc/observable";
  20316. import { SmartArray } from "babylonjs/Misc/smartArray";
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Camera } from "babylonjs/Cameras/camera";
  20319. import { Scene } from "babylonjs/scene";
  20320. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20321. import { Color4 } from "babylonjs/Maths/math.color";
  20322. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20324. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20325. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20326. import { Texture } from "babylonjs/Materials/Textures/texture";
  20327. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20328. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20329. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20330. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20331. import { Engine } from "babylonjs/Engines/engine";
  20332. /**
  20333. * This Helps creating a texture that will be created from a camera in your scene.
  20334. * It is basically a dynamic texture that could be used to create special effects for instance.
  20335. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20336. */
  20337. export class RenderTargetTexture extends Texture {
  20338. isCube: boolean;
  20339. /**
  20340. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20341. */
  20342. static readonly REFRESHRATE_RENDER_ONCE: number;
  20343. /**
  20344. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20347. /**
  20348. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20349. * the central point of your effect and can save a lot of performances.
  20350. */
  20351. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20352. /**
  20353. * Use this predicate to dynamically define the list of mesh you want to render.
  20354. * If set, the renderList property will be overwritten.
  20355. */
  20356. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20357. private _renderList;
  20358. /**
  20359. * Use this list to define the list of mesh you want to render.
  20360. */
  20361. renderList: Nullable<Array<AbstractMesh>>;
  20362. private _hookArray;
  20363. /**
  20364. * Define if particles should be rendered in your texture.
  20365. */
  20366. renderParticles: boolean;
  20367. /**
  20368. * Define if sprites should be rendered in your texture.
  20369. */
  20370. renderSprites: boolean;
  20371. /**
  20372. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20373. */
  20374. coordinatesMode: number;
  20375. /**
  20376. * Define the camera used to render the texture.
  20377. */
  20378. activeCamera: Nullable<Camera>;
  20379. /**
  20380. * Override the render function of the texture with your own one.
  20381. */
  20382. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20383. /**
  20384. * Define if camera post processes should be use while rendering the texture.
  20385. */
  20386. useCameraPostProcesses: boolean;
  20387. /**
  20388. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20389. */
  20390. ignoreCameraViewport: boolean;
  20391. private _postProcessManager;
  20392. private _postProcesses;
  20393. private _resizeObserver;
  20394. /**
  20395. * An event triggered when the texture is unbind.
  20396. */
  20397. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20402. private _onAfterUnbindObserver;
  20403. /**
  20404. * Set a after unbind callback in the texture.
  20405. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20406. */
  20407. onAfterUnbind: () => void;
  20408. /**
  20409. * An event triggered before rendering the texture
  20410. */
  20411. onBeforeRenderObservable: Observable<number>;
  20412. private _onBeforeRenderObserver;
  20413. /**
  20414. * Set a before render callback in the texture.
  20415. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20416. */
  20417. onBeforeRender: (faceIndex: number) => void;
  20418. /**
  20419. * An event triggered after rendering the texture
  20420. */
  20421. onAfterRenderObservable: Observable<number>;
  20422. private _onAfterRenderObserver;
  20423. /**
  20424. * Set a after render callback in the texture.
  20425. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20426. */
  20427. onAfterRender: (faceIndex: number) => void;
  20428. /**
  20429. * An event triggered after the texture clear
  20430. */
  20431. onClearObservable: Observable<Engine>;
  20432. private _onClearObserver;
  20433. /**
  20434. * Set a clear callback in the texture.
  20435. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20436. */
  20437. onClear: (Engine: Engine) => void;
  20438. /**
  20439. * An event triggered when the texture is resized.
  20440. */
  20441. onResizeObservable: Observable<RenderTargetTexture>;
  20442. /**
  20443. * Define the clear color of the Render Target if it should be different from the scene.
  20444. */
  20445. clearColor: Color4;
  20446. protected _size: number | {
  20447. width: number;
  20448. height: number;
  20449. };
  20450. protected _initialSizeParameter: number | {
  20451. width: number;
  20452. height: number;
  20453. } | {
  20454. ratio: number;
  20455. };
  20456. protected _sizeRatio: Nullable<number>;
  20457. /** @hidden */
  20458. _generateMipMaps: boolean;
  20459. protected _renderingManager: RenderingManager;
  20460. /** @hidden */
  20461. _waitingRenderList: string[];
  20462. protected _doNotChangeAspectRatio: boolean;
  20463. protected _currentRefreshId: number;
  20464. protected _refreshRate: number;
  20465. protected _textureMatrix: Matrix;
  20466. protected _samples: number;
  20467. protected _renderTargetOptions: RenderTargetCreationOptions;
  20468. /**
  20469. * Gets render target creation options that were used.
  20470. */
  20471. readonly renderTargetOptions: RenderTargetCreationOptions;
  20472. protected _engine: Engine;
  20473. protected _onRatioRescale(): void;
  20474. /**
  20475. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20476. * It must define where the camera used to render the texture is set
  20477. */
  20478. boundingBoxPosition: Vector3;
  20479. private _boundingBoxSize;
  20480. /**
  20481. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20482. * When defined, the cubemap will switch to local mode
  20483. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20484. * @example https://www.babylonjs-playground.com/#RNASML
  20485. */
  20486. boundingBoxSize: Vector3;
  20487. /**
  20488. * In case the RTT has been created with a depth texture, get the associated
  20489. * depth texture.
  20490. * Otherwise, return null.
  20491. */
  20492. depthStencilTexture: Nullable<InternalTexture>;
  20493. /**
  20494. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20495. * or used a shadow, depth texture...
  20496. * @param name The friendly name of the texture
  20497. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  20498. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20499. * @param generateMipMaps True if mip maps need to be generated after render.
  20500. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20501. * @param type The type of the buffer in the RTT (int, half float, float...)
  20502. * @param isCube True if a cube texture needs to be created
  20503. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20504. * @param generateDepthBuffer True to generate a depth buffer
  20505. * @param generateStencilBuffer True to generate a stencil buffer
  20506. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20507. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20508. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20509. */
  20510. constructor(name: string, size: number | {
  20511. width: number;
  20512. height: number;
  20513. } | {
  20514. ratio: number;
  20515. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20516. /**
  20517. * Creates a depth stencil texture.
  20518. * This is only available in WebGL 2 or with the depth texture extension available.
  20519. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20520. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20521. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20522. */
  20523. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20524. private _processSizeParameter;
  20525. /**
  20526. * Define the number of samples to use in case of MSAA.
  20527. * It defaults to one meaning no MSAA has been enabled.
  20528. */
  20529. samples: number;
  20530. /**
  20531. * Resets the refresh counter of the texture and start bak from scratch.
  20532. * Could be useful to regenerate the texture if it is setup to render only once.
  20533. */
  20534. resetRefreshCounter(): void;
  20535. /**
  20536. * Define the refresh rate of the texture or the rendering frequency.
  20537. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20538. */
  20539. refreshRate: number;
  20540. /**
  20541. * Adds a post process to the render target rendering passes.
  20542. * @param postProcess define the post process to add
  20543. */
  20544. addPostProcess(postProcess: PostProcess): void;
  20545. /**
  20546. * Clear all the post processes attached to the render target
  20547. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20548. */
  20549. clearPostProcesses(dispose?: boolean): void;
  20550. /**
  20551. * Remove one of the post process from the list of attached post processes to the texture
  20552. * @param postProcess define the post process to remove from the list
  20553. */
  20554. removePostProcess(postProcess: PostProcess): void;
  20555. /** @hidden */
  20556. _shouldRender(): boolean;
  20557. /**
  20558. * Gets the actual render size of the texture.
  20559. * @returns the width of the render size
  20560. */
  20561. getRenderSize(): number;
  20562. /**
  20563. * Gets the actual render width of the texture.
  20564. * @returns the width of the render size
  20565. */
  20566. getRenderWidth(): number;
  20567. /**
  20568. * Gets the actual render height of the texture.
  20569. * @returns the height of the render size
  20570. */
  20571. getRenderHeight(): number;
  20572. /**
  20573. * Get if the texture can be rescaled or not.
  20574. */
  20575. readonly canRescale: boolean;
  20576. /**
  20577. * Resize the texture using a ratio.
  20578. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20579. */
  20580. scale(ratio: number): void;
  20581. /**
  20582. * Get the texture reflection matrix used to rotate/transform the reflection.
  20583. * @returns the reflection matrix
  20584. */
  20585. getReflectionTextureMatrix(): Matrix;
  20586. /**
  20587. * Resize the texture to a new desired size.
  20588. * Be carrefull as it will recreate all the data in the new texture.
  20589. * @param size Define the new size. It can be:
  20590. * - a number for squared texture,
  20591. * - an object containing { width: number, height: number }
  20592. * - or an object containing a ratio { ratio: number }
  20593. */
  20594. resize(size: number | {
  20595. width: number;
  20596. height: number;
  20597. } | {
  20598. ratio: number;
  20599. }): void;
  20600. /**
  20601. * Renders all the objects from the render list into the texture.
  20602. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20603. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20604. */
  20605. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20606. private _bestReflectionRenderTargetDimension;
  20607. /**
  20608. * @hidden
  20609. * @param faceIndex face index to bind to if this is a cubetexture
  20610. */
  20611. _bindFrameBuffer(faceIndex?: number): void;
  20612. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20613. private renderToTarget;
  20614. /**
  20615. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20616. * This allowed control for front to back rendering or reversly depending of the special needs.
  20617. *
  20618. * @param renderingGroupId The rendering group id corresponding to its index
  20619. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20620. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20621. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20622. */
  20623. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  20624. /**
  20625. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20626. *
  20627. * @param renderingGroupId The rendering group id corresponding to its index
  20628. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20629. */
  20630. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20631. /**
  20632. * Clones the texture.
  20633. * @returns the cloned texture
  20634. */
  20635. clone(): RenderTargetTexture;
  20636. /**
  20637. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20638. * @returns The JSON representation of the texture
  20639. */
  20640. serialize(): any;
  20641. /**
  20642. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20643. */
  20644. disposeFramebufferObjects(): void;
  20645. /**
  20646. * Dispose the texture and release its associated resources.
  20647. */
  20648. dispose(): void;
  20649. /** @hidden */
  20650. _rebuild(): void;
  20651. /**
  20652. * Clear the info related to rendering groups preventing retention point in material dispose.
  20653. */
  20654. freeRenderingGroups(): void;
  20655. /**
  20656. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20657. * @returns the view count
  20658. */
  20659. getViewCount(): number;
  20660. }
  20661. }
  20662. declare module "babylonjs/Materials/material" {
  20663. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20664. import { SmartArray } from "babylonjs/Misc/smartArray";
  20665. import { Observable } from "babylonjs/Misc/observable";
  20666. import { Nullable } from "babylonjs/types";
  20667. import { Scene } from "babylonjs/scene";
  20668. import { Matrix } from "babylonjs/Maths/math.vector";
  20669. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20670. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20671. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20672. import { Effect } from "babylonjs/Materials/effect";
  20673. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20674. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20675. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20676. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20677. import { Mesh } from "babylonjs/Meshes/mesh";
  20678. import { Animation } from "babylonjs/Animations/animation";
  20679. /**
  20680. * Base class for the main features of a material in Babylon.js
  20681. */
  20682. export class Material implements IAnimatable {
  20683. /**
  20684. * Returns the triangle fill mode
  20685. */
  20686. static readonly TriangleFillMode: number;
  20687. /**
  20688. * Returns the wireframe mode
  20689. */
  20690. static readonly WireFrameFillMode: number;
  20691. /**
  20692. * Returns the point fill mode
  20693. */
  20694. static readonly PointFillMode: number;
  20695. /**
  20696. * Returns the point list draw mode
  20697. */
  20698. static readonly PointListDrawMode: number;
  20699. /**
  20700. * Returns the line list draw mode
  20701. */
  20702. static readonly LineListDrawMode: number;
  20703. /**
  20704. * Returns the line loop draw mode
  20705. */
  20706. static readonly LineLoopDrawMode: number;
  20707. /**
  20708. * Returns the line strip draw mode
  20709. */
  20710. static readonly LineStripDrawMode: number;
  20711. /**
  20712. * Returns the triangle strip draw mode
  20713. */
  20714. static readonly TriangleStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle fan draw mode
  20717. */
  20718. static readonly TriangleFanDrawMode: number;
  20719. /**
  20720. * Stores the clock-wise side orientation
  20721. */
  20722. static readonly ClockWiseSideOrientation: number;
  20723. /**
  20724. * Stores the counter clock-wise side orientation
  20725. */
  20726. static readonly CounterClockWiseSideOrientation: number;
  20727. /**
  20728. * The dirty texture flag value
  20729. */
  20730. static readonly TextureDirtyFlag: number;
  20731. /**
  20732. * The dirty light flag value
  20733. */
  20734. static readonly LightDirtyFlag: number;
  20735. /**
  20736. * The dirty fresnel flag value
  20737. */
  20738. static readonly FresnelDirtyFlag: number;
  20739. /**
  20740. * The dirty attribute flag value
  20741. */
  20742. static readonly AttributesDirtyFlag: number;
  20743. /**
  20744. * The dirty misc flag value
  20745. */
  20746. static readonly MiscDirtyFlag: number;
  20747. /**
  20748. * The all dirty flag value
  20749. */
  20750. static readonly AllDirtyFlag: number;
  20751. /**
  20752. * The ID of the material
  20753. */
  20754. id: string;
  20755. /**
  20756. * Gets or sets the unique id of the material
  20757. */
  20758. uniqueId: number;
  20759. /**
  20760. * The name of the material
  20761. */
  20762. name: string;
  20763. /**
  20764. * Gets or sets user defined metadata
  20765. */
  20766. metadata: any;
  20767. /**
  20768. * For internal use only. Please do not use.
  20769. */
  20770. reservedDataStore: any;
  20771. /**
  20772. * Specifies if the ready state should be checked on each call
  20773. */
  20774. checkReadyOnEveryCall: boolean;
  20775. /**
  20776. * Specifies if the ready state should be checked once
  20777. */
  20778. checkReadyOnlyOnce: boolean;
  20779. /**
  20780. * The state of the material
  20781. */
  20782. state: string;
  20783. /**
  20784. * The alpha value of the material
  20785. */
  20786. protected _alpha: number;
  20787. /**
  20788. * List of inspectable custom properties (used by the Inspector)
  20789. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20790. */
  20791. inspectableCustomProperties: IInspectable[];
  20792. /**
  20793. * Sets the alpha value of the material
  20794. */
  20795. /**
  20796. * Gets the alpha value of the material
  20797. */
  20798. alpha: number;
  20799. /**
  20800. * Specifies if back face culling is enabled
  20801. */
  20802. protected _backFaceCulling: boolean;
  20803. /**
  20804. * Sets the back-face culling state
  20805. */
  20806. /**
  20807. * Gets the back-face culling state
  20808. */
  20809. backFaceCulling: boolean;
  20810. /**
  20811. * Stores the value for side orientation
  20812. */
  20813. sideOrientation: number;
  20814. /**
  20815. * Callback triggered when the material is compiled
  20816. */
  20817. onCompiled: Nullable<(effect: Effect) => void>;
  20818. /**
  20819. * Callback triggered when an error occurs
  20820. */
  20821. onError: Nullable<(effect: Effect, errors: string) => void>;
  20822. /**
  20823. * Callback triggered to get the render target textures
  20824. */
  20825. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20826. /**
  20827. * Gets a boolean indicating that current material needs to register RTT
  20828. */
  20829. readonly hasRenderTargetTextures: boolean;
  20830. /**
  20831. * Specifies if the material should be serialized
  20832. */
  20833. doNotSerialize: boolean;
  20834. /**
  20835. * @hidden
  20836. */
  20837. _storeEffectOnSubMeshes: boolean;
  20838. /**
  20839. * Stores the animations for the material
  20840. */
  20841. animations: Nullable<Array<Animation>>;
  20842. /**
  20843. * An event triggered when the material is disposed
  20844. */
  20845. onDisposeObservable: Observable<Material>;
  20846. /**
  20847. * An observer which watches for dispose events
  20848. */
  20849. private _onDisposeObserver;
  20850. private _onUnBindObservable;
  20851. /**
  20852. * Called during a dispose event
  20853. */
  20854. onDispose: () => void;
  20855. private _onBindObservable;
  20856. /**
  20857. * An event triggered when the material is bound
  20858. */
  20859. readonly onBindObservable: Observable<AbstractMesh>;
  20860. /**
  20861. * An observer which watches for bind events
  20862. */
  20863. private _onBindObserver;
  20864. /**
  20865. * Called during a bind event
  20866. */
  20867. onBind: (Mesh: AbstractMesh) => void;
  20868. /**
  20869. * An event triggered when the material is unbound
  20870. */
  20871. readonly onUnBindObservable: Observable<Material>;
  20872. /**
  20873. * Stores the value of the alpha mode
  20874. */
  20875. private _alphaMode;
  20876. /**
  20877. * Sets the value of the alpha mode.
  20878. *
  20879. * | Value | Type | Description |
  20880. * | --- | --- | --- |
  20881. * | 0 | ALPHA_DISABLE | |
  20882. * | 1 | ALPHA_ADD | |
  20883. * | 2 | ALPHA_COMBINE | |
  20884. * | 3 | ALPHA_SUBTRACT | |
  20885. * | 4 | ALPHA_MULTIPLY | |
  20886. * | 5 | ALPHA_MAXIMIZED | |
  20887. * | 6 | ALPHA_ONEONE | |
  20888. * | 7 | ALPHA_PREMULTIPLIED | |
  20889. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20890. * | 9 | ALPHA_INTERPOLATE | |
  20891. * | 10 | ALPHA_SCREENMODE | |
  20892. *
  20893. */
  20894. /**
  20895. * Gets the value of the alpha mode
  20896. */
  20897. alphaMode: number;
  20898. /**
  20899. * Stores the state of the need depth pre-pass value
  20900. */
  20901. private _needDepthPrePass;
  20902. /**
  20903. * Sets the need depth pre-pass value
  20904. */
  20905. /**
  20906. * Gets the depth pre-pass value
  20907. */
  20908. needDepthPrePass: boolean;
  20909. /**
  20910. * Specifies if depth writing should be disabled
  20911. */
  20912. disableDepthWrite: boolean;
  20913. /**
  20914. * Specifies if depth writing should be forced
  20915. */
  20916. forceDepthWrite: boolean;
  20917. /**
  20918. * Specifies if there should be a separate pass for culling
  20919. */
  20920. separateCullingPass: boolean;
  20921. /**
  20922. * Stores the state specifing if fog should be enabled
  20923. */
  20924. private _fogEnabled;
  20925. /**
  20926. * Sets the state for enabling fog
  20927. */
  20928. /**
  20929. * Gets the value of the fog enabled state
  20930. */
  20931. fogEnabled: boolean;
  20932. /**
  20933. * Stores the size of points
  20934. */
  20935. pointSize: number;
  20936. /**
  20937. * Stores the z offset value
  20938. */
  20939. zOffset: number;
  20940. /**
  20941. * Gets a value specifying if wireframe mode is enabled
  20942. */
  20943. /**
  20944. * Sets the state of wireframe mode
  20945. */
  20946. wireframe: boolean;
  20947. /**
  20948. * Gets the value specifying if point clouds are enabled
  20949. */
  20950. /**
  20951. * Sets the state of point cloud mode
  20952. */
  20953. pointsCloud: boolean;
  20954. /**
  20955. * Gets the material fill mode
  20956. */
  20957. /**
  20958. * Sets the material fill mode
  20959. */
  20960. fillMode: number;
  20961. /**
  20962. * @hidden
  20963. * Stores the effects for the material
  20964. */
  20965. _effect: Nullable<Effect>;
  20966. /**
  20967. * @hidden
  20968. * Specifies if the material was previously ready
  20969. */
  20970. _wasPreviouslyReady: boolean;
  20971. /**
  20972. * Specifies if uniform buffers should be used
  20973. */
  20974. private _useUBO;
  20975. /**
  20976. * Stores a reference to the scene
  20977. */
  20978. private _scene;
  20979. /**
  20980. * Stores the fill mode state
  20981. */
  20982. private _fillMode;
  20983. /**
  20984. * Specifies if the depth write state should be cached
  20985. */
  20986. private _cachedDepthWriteState;
  20987. /**
  20988. * Stores the uniform buffer
  20989. */
  20990. protected _uniformBuffer: UniformBuffer;
  20991. /** @hidden */
  20992. _indexInSceneMaterialArray: number;
  20993. /** @hidden */
  20994. meshMap: Nullable<{
  20995. [id: string]: AbstractMesh | undefined;
  20996. }>;
  20997. /**
  20998. * Creates a material instance
  20999. * @param name defines the name of the material
  21000. * @param scene defines the scene to reference
  21001. * @param doNotAdd specifies if the material should be added to the scene
  21002. */
  21003. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21004. /**
  21005. * Returns a string representation of the current material
  21006. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21007. * @returns a string with material information
  21008. */
  21009. toString(fullDetails?: boolean): string;
  21010. /**
  21011. * Gets the class name of the material
  21012. * @returns a string with the class name of the material
  21013. */
  21014. getClassName(): string;
  21015. /**
  21016. * Specifies if updates for the material been locked
  21017. */
  21018. readonly isFrozen: boolean;
  21019. /**
  21020. * Locks updates for the material
  21021. */
  21022. freeze(): void;
  21023. /**
  21024. * Unlocks updates for the material
  21025. */
  21026. unfreeze(): void;
  21027. /**
  21028. * Specifies if the material is ready to be used
  21029. * @param mesh defines the mesh to check
  21030. * @param useInstances specifies if instances should be used
  21031. * @returns a boolean indicating if the material is ready to be used
  21032. */
  21033. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21034. /**
  21035. * Specifies that the submesh is ready to be used
  21036. * @param mesh defines the mesh to check
  21037. * @param subMesh defines which submesh to check
  21038. * @param useInstances specifies that instances should be used
  21039. * @returns a boolean indicating that the submesh is ready or not
  21040. */
  21041. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21042. /**
  21043. * Returns the material effect
  21044. * @returns the effect associated with the material
  21045. */
  21046. getEffect(): Nullable<Effect>;
  21047. /**
  21048. * Returns the current scene
  21049. * @returns a Scene
  21050. */
  21051. getScene(): Scene;
  21052. /**
  21053. * Specifies if the material will require alpha blending
  21054. * @returns a boolean specifying if alpha blending is needed
  21055. */
  21056. needAlphaBlending(): boolean;
  21057. /**
  21058. * Specifies if the mesh will require alpha blending
  21059. * @param mesh defines the mesh to check
  21060. * @returns a boolean specifying if alpha blending is needed for the mesh
  21061. */
  21062. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21063. /**
  21064. * Specifies if this material should be rendered in alpha test mode
  21065. * @returns a boolean specifying if an alpha test is needed.
  21066. */
  21067. needAlphaTesting(): boolean;
  21068. /**
  21069. * Gets the texture used for the alpha test
  21070. * @returns the texture to use for alpha testing
  21071. */
  21072. getAlphaTestTexture(): Nullable<BaseTexture>;
  21073. /**
  21074. * Marks the material to indicate that it needs to be re-calculated
  21075. */
  21076. markDirty(): void;
  21077. /** @hidden */
  21078. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21079. /**
  21080. * Binds the material to the mesh
  21081. * @param world defines the world transformation matrix
  21082. * @param mesh defines the mesh to bind the material to
  21083. */
  21084. bind(world: Matrix, mesh?: Mesh): void;
  21085. /**
  21086. * Binds the submesh to the material
  21087. * @param world defines the world transformation matrix
  21088. * @param mesh defines the mesh containing the submesh
  21089. * @param subMesh defines the submesh to bind the material to
  21090. */
  21091. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21092. /**
  21093. * Binds the world matrix to the material
  21094. * @param world defines the world transformation matrix
  21095. */
  21096. bindOnlyWorldMatrix(world: Matrix): void;
  21097. /**
  21098. * Binds the scene's uniform buffer to the effect.
  21099. * @param effect defines the effect to bind to the scene uniform buffer
  21100. * @param sceneUbo defines the uniform buffer storing scene data
  21101. */
  21102. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21103. /**
  21104. * Binds the view matrix to the effect
  21105. * @param effect defines the effect to bind the view matrix to
  21106. */
  21107. bindView(effect: Effect): void;
  21108. /**
  21109. * Binds the view projection matrix to the effect
  21110. * @param effect defines the effect to bind the view projection matrix to
  21111. */
  21112. bindViewProjection(effect: Effect): void;
  21113. /**
  21114. * Specifies if material alpha testing should be turned on for the mesh
  21115. * @param mesh defines the mesh to check
  21116. */
  21117. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21118. /**
  21119. * Processes to execute after binding the material to a mesh
  21120. * @param mesh defines the rendered mesh
  21121. */
  21122. protected _afterBind(mesh?: Mesh): void;
  21123. /**
  21124. * Unbinds the material from the mesh
  21125. */
  21126. unbind(): void;
  21127. /**
  21128. * Gets the active textures from the material
  21129. * @returns an array of textures
  21130. */
  21131. getActiveTextures(): BaseTexture[];
  21132. /**
  21133. * Specifies if the material uses a texture
  21134. * @param texture defines the texture to check against the material
  21135. * @returns a boolean specifying if the material uses the texture
  21136. */
  21137. hasTexture(texture: BaseTexture): boolean;
  21138. /**
  21139. * Makes a duplicate of the material, and gives it a new name
  21140. * @param name defines the new name for the duplicated material
  21141. * @returns the cloned material
  21142. */
  21143. clone(name: string): Nullable<Material>;
  21144. /**
  21145. * Gets the meshes bound to the material
  21146. * @returns an array of meshes bound to the material
  21147. */
  21148. getBindedMeshes(): AbstractMesh[];
  21149. /**
  21150. * Force shader compilation
  21151. * @param mesh defines the mesh associated with this material
  21152. * @param onCompiled defines a function to execute once the material is compiled
  21153. * @param options defines the options to configure the compilation
  21154. * @param onError defines a function to execute if the material fails compiling
  21155. */
  21156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21157. clipPlane: boolean;
  21158. }>, onError?: (reason: string) => void): void;
  21159. /**
  21160. * Force shader compilation
  21161. * @param mesh defines the mesh that will use this material
  21162. * @param options defines additional options for compiling the shaders
  21163. * @returns a promise that resolves when the compilation completes
  21164. */
  21165. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21166. clipPlane: boolean;
  21167. }>): Promise<void>;
  21168. private static readonly _AllDirtyCallBack;
  21169. private static readonly _ImageProcessingDirtyCallBack;
  21170. private static readonly _TextureDirtyCallBack;
  21171. private static readonly _FresnelDirtyCallBack;
  21172. private static readonly _MiscDirtyCallBack;
  21173. private static readonly _LightsDirtyCallBack;
  21174. private static readonly _AttributeDirtyCallBack;
  21175. private static _FresnelAndMiscDirtyCallBack;
  21176. private static _TextureAndMiscDirtyCallBack;
  21177. private static readonly _DirtyCallbackArray;
  21178. private static readonly _RunDirtyCallBacks;
  21179. /**
  21180. * Marks a define in the material to indicate that it needs to be re-computed
  21181. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21182. */
  21183. markAsDirty(flag: number): void;
  21184. /**
  21185. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21186. * @param func defines a function which checks material defines against the submeshes
  21187. */
  21188. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21189. /**
  21190. * Indicates that we need to re-calculated for all submeshes
  21191. */
  21192. protected _markAllSubMeshesAsAllDirty(): void;
  21193. /**
  21194. * Indicates that image processing needs to be re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21197. /**
  21198. * Indicates that textures need to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsTexturesDirty(): void;
  21201. /**
  21202. * Indicates that fresnel needs to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsFresnelDirty(): void;
  21205. /**
  21206. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21209. /**
  21210. * Indicates that lights need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsLightsDirty(): void;
  21213. /**
  21214. * Indicates that attributes need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsAttributesDirty(): void;
  21217. /**
  21218. * Indicates that misc needs to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsMiscDirty(): void;
  21221. /**
  21222. * Indicates that textures and misc need to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21225. /**
  21226. * Disposes the material
  21227. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21228. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21229. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21230. */
  21231. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21232. /** @hidden */
  21233. private releaseVertexArrayObject;
  21234. /**
  21235. * Serializes this material
  21236. * @returns the serialized material object
  21237. */
  21238. serialize(): any;
  21239. /**
  21240. * Creates a material from parsed material data
  21241. * @param parsedMaterial defines parsed material data
  21242. * @param scene defines the hosting scene
  21243. * @param rootUrl defines the root URL to use to load textures
  21244. * @returns a new material
  21245. */
  21246. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21247. }
  21248. }
  21249. declare module "babylonjs/Materials/multiMaterial" {
  21250. import { Nullable } from "babylonjs/types";
  21251. import { Scene } from "babylonjs/scene";
  21252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21253. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21254. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21255. import { Material } from "babylonjs/Materials/material";
  21256. /**
  21257. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21258. * separate meshes. This can be use to improve performances.
  21259. * @see http://doc.babylonjs.com/how_to/multi_materials
  21260. */
  21261. export class MultiMaterial extends Material {
  21262. private _subMaterials;
  21263. /**
  21264. * Gets or Sets the list of Materials used within the multi material.
  21265. * They need to be ordered according to the submeshes order in the associated mesh
  21266. */
  21267. subMaterials: Nullable<Material>[];
  21268. /**
  21269. * Function used to align with Node.getChildren()
  21270. * @returns the list of Materials used within the multi material
  21271. */
  21272. getChildren(): Nullable<Material>[];
  21273. /**
  21274. * Instantiates a new Multi Material
  21275. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21276. * separate meshes. This can be use to improve performances.
  21277. * @see http://doc.babylonjs.com/how_to/multi_materials
  21278. * @param name Define the name in the scene
  21279. * @param scene Define the scene the material belongs to
  21280. */
  21281. constructor(name: string, scene: Scene);
  21282. private _hookArray;
  21283. /**
  21284. * Get one of the submaterial by its index in the submaterials array
  21285. * @param index The index to look the sub material at
  21286. * @returns The Material if the index has been defined
  21287. */
  21288. getSubMaterial(index: number): Nullable<Material>;
  21289. /**
  21290. * Get the list of active textures for the whole sub materials list.
  21291. * @returns All the textures that will be used during the rendering
  21292. */
  21293. getActiveTextures(): BaseTexture[];
  21294. /**
  21295. * Gets the current class name of the material e.g. "MultiMaterial"
  21296. * Mainly use in serialization.
  21297. * @returns the class name
  21298. */
  21299. getClassName(): string;
  21300. /**
  21301. * Checks if the material is ready to render the requested sub mesh
  21302. * @param mesh Define the mesh the submesh belongs to
  21303. * @param subMesh Define the sub mesh to look readyness for
  21304. * @param useInstances Define whether or not the material is used with instances
  21305. * @returns true if ready, otherwise false
  21306. */
  21307. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21308. /**
  21309. * Clones the current material and its related sub materials
  21310. * @param name Define the name of the newly cloned material
  21311. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21312. * @returns the cloned material
  21313. */
  21314. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21315. /**
  21316. * Serializes the materials into a JSON representation.
  21317. * @returns the JSON representation
  21318. */
  21319. serialize(): any;
  21320. /**
  21321. * Dispose the material and release its associated resources
  21322. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  21323. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  21324. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  21325. */
  21326. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21327. /**
  21328. * Creates a MultiMaterial from parsed MultiMaterial data.
  21329. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21330. * @param scene defines the hosting scene
  21331. * @returns a new MultiMaterial
  21332. */
  21333. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21334. }
  21335. }
  21336. declare module "babylonjs/Meshes/subMesh" {
  21337. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21338. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21339. import { Engine } from "babylonjs/Engines/engine";
  21340. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21341. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21342. import { Effect } from "babylonjs/Materials/effect";
  21343. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21344. import { Plane } from "babylonjs/Maths/math.plane";
  21345. import { Collider } from "babylonjs/Collisions/collider";
  21346. import { Material } from "babylonjs/Materials/material";
  21347. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21348. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21349. import { Mesh } from "babylonjs/Meshes/mesh";
  21350. import { Ray } from "babylonjs/Culling/ray";
  21351. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21352. /**
  21353. * Base class for submeshes
  21354. */
  21355. export class BaseSubMesh {
  21356. /** @hidden */
  21357. _materialDefines: Nullable<MaterialDefines>;
  21358. /** @hidden */
  21359. _materialEffect: Nullable<Effect>;
  21360. /**
  21361. * Gets associated effect
  21362. */
  21363. readonly effect: Nullable<Effect>;
  21364. /**
  21365. * Sets associated effect (effect used to render this submesh)
  21366. * @param effect defines the effect to associate with
  21367. * @param defines defines the set of defines used to compile this effect
  21368. */
  21369. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21370. }
  21371. /**
  21372. * Defines a subdivision inside a mesh
  21373. */
  21374. export class SubMesh extends BaseSubMesh implements ICullable {
  21375. /** the material index to use */
  21376. materialIndex: number;
  21377. /** vertex index start */
  21378. verticesStart: number;
  21379. /** vertices count */
  21380. verticesCount: number;
  21381. /** index start */
  21382. indexStart: number;
  21383. /** indices count */
  21384. indexCount: number;
  21385. /** @hidden */
  21386. _linesIndexCount: number;
  21387. private _mesh;
  21388. private _renderingMesh;
  21389. private _boundingInfo;
  21390. private _linesIndexBuffer;
  21391. /** @hidden */
  21392. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21393. /** @hidden */
  21394. _trianglePlanes: Plane[];
  21395. /** @hidden */
  21396. _lastColliderTransformMatrix: Nullable<Matrix>;
  21397. /** @hidden */
  21398. _renderId: number;
  21399. /** @hidden */
  21400. _alphaIndex: number;
  21401. /** @hidden */
  21402. _distanceToCamera: number;
  21403. /** @hidden */
  21404. _id: number;
  21405. private _currentMaterial;
  21406. /**
  21407. * Add a new submesh to a mesh
  21408. * @param materialIndex defines the material index to use
  21409. * @param verticesStart defines vertex index start
  21410. * @param verticesCount defines vertices count
  21411. * @param indexStart defines index start
  21412. * @param indexCount defines indices count
  21413. * @param mesh defines the parent mesh
  21414. * @param renderingMesh defines an optional rendering mesh
  21415. * @param createBoundingBox defines if bounding box should be created for this submesh
  21416. * @returns the new submesh
  21417. */
  21418. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21419. /**
  21420. * Creates a new submesh
  21421. * @param materialIndex defines the material index to use
  21422. * @param verticesStart defines vertex index start
  21423. * @param verticesCount defines vertices count
  21424. * @param indexStart defines index start
  21425. * @param indexCount defines indices count
  21426. * @param mesh defines the parent mesh
  21427. * @param renderingMesh defines an optional rendering mesh
  21428. * @param createBoundingBox defines if bounding box should be created for this submesh
  21429. */
  21430. constructor(
  21431. /** the material index to use */
  21432. materialIndex: number,
  21433. /** vertex index start */
  21434. verticesStart: number,
  21435. /** vertices count */
  21436. verticesCount: number,
  21437. /** index start */
  21438. indexStart: number,
  21439. /** indices count */
  21440. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21441. /**
  21442. * Returns true if this submesh covers the entire parent mesh
  21443. * @ignorenaming
  21444. */
  21445. readonly IsGlobal: boolean;
  21446. /**
  21447. * Returns the submesh BoudingInfo object
  21448. * @returns current bounding info (or mesh's one if the submesh is global)
  21449. */
  21450. getBoundingInfo(): BoundingInfo;
  21451. /**
  21452. * Sets the submesh BoundingInfo
  21453. * @param boundingInfo defines the new bounding info to use
  21454. * @returns the SubMesh
  21455. */
  21456. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21457. /**
  21458. * Returns the mesh of the current submesh
  21459. * @return the parent mesh
  21460. */
  21461. getMesh(): AbstractMesh;
  21462. /**
  21463. * Returns the rendering mesh of the submesh
  21464. * @returns the rendering mesh (could be different from parent mesh)
  21465. */
  21466. getRenderingMesh(): Mesh;
  21467. /**
  21468. * Returns the submesh material
  21469. * @returns null or the current material
  21470. */
  21471. getMaterial(): Nullable<Material>;
  21472. /**
  21473. * Sets a new updated BoundingInfo object to the submesh
  21474. * @param data defines an optional position array to use to determine the bounding info
  21475. * @returns the SubMesh
  21476. */
  21477. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21478. /** @hidden */
  21479. _checkCollision(collider: Collider): boolean;
  21480. /**
  21481. * Updates the submesh BoundingInfo
  21482. * @param world defines the world matrix to use to update the bounding info
  21483. * @returns the submesh
  21484. */
  21485. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21486. /**
  21487. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21488. * @param frustumPlanes defines the frustum planes
  21489. * @returns true if the submesh is intersecting with the frustum
  21490. */
  21491. isInFrustum(frustumPlanes: Plane[]): boolean;
  21492. /**
  21493. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21494. * @param frustumPlanes defines the frustum planes
  21495. * @returns true if the submesh is inside the frustum
  21496. */
  21497. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21498. /**
  21499. * Renders the submesh
  21500. * @param enableAlphaMode defines if alpha needs to be used
  21501. * @returns the submesh
  21502. */
  21503. render(enableAlphaMode: boolean): SubMesh;
  21504. /**
  21505. * @hidden
  21506. */
  21507. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21508. /**
  21509. * Checks if the submesh intersects with a ray
  21510. * @param ray defines the ray to test
  21511. * @returns true is the passed ray intersects the submesh bounding box
  21512. */
  21513. canIntersects(ray: Ray): boolean;
  21514. /**
  21515. * Intersects current submesh with a ray
  21516. * @param ray defines the ray to test
  21517. * @param positions defines mesh's positions array
  21518. * @param indices defines mesh's indices array
  21519. * @param fastCheck defines if only bounding info should be used
  21520. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21521. * @returns intersection info or null if no intersection
  21522. */
  21523. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21524. /** @hidden */
  21525. private _intersectLines;
  21526. /** @hidden */
  21527. private _intersectUnIndexedLines;
  21528. /** @hidden */
  21529. private _intersectTriangles;
  21530. /** @hidden */
  21531. private _intersectUnIndexedTriangles;
  21532. /** @hidden */
  21533. _rebuild(): void;
  21534. /**
  21535. * Creates a new submesh from the passed mesh
  21536. * @param newMesh defines the new hosting mesh
  21537. * @param newRenderingMesh defines an optional rendering mesh
  21538. * @returns the new submesh
  21539. */
  21540. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21541. /**
  21542. * Release associated resources
  21543. */
  21544. dispose(): void;
  21545. /**
  21546. * Gets the class name
  21547. * @returns the string "SubMesh".
  21548. */
  21549. getClassName(): string;
  21550. /**
  21551. * Creates a new submesh from indices data
  21552. * @param materialIndex the index of the main mesh material
  21553. * @param startIndex the index where to start the copy in the mesh indices array
  21554. * @param indexCount the number of indices to copy then from the startIndex
  21555. * @param mesh the main mesh to create the submesh from
  21556. * @param renderingMesh the optional rendering mesh
  21557. * @returns a new submesh
  21558. */
  21559. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21560. }
  21561. }
  21562. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21563. /**
  21564. * Class used to represent data loading progression
  21565. */
  21566. export class SceneLoaderFlags {
  21567. private static _ForceFullSceneLoadingForIncremental;
  21568. private static _ShowLoadingScreen;
  21569. private static _CleanBoneMatrixWeights;
  21570. private static _loggingLevel;
  21571. /**
  21572. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21573. */
  21574. static ForceFullSceneLoadingForIncremental: boolean;
  21575. /**
  21576. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21577. */
  21578. static ShowLoadingScreen: boolean;
  21579. /**
  21580. * Defines the current logging level (while loading the scene)
  21581. * @ignorenaming
  21582. */
  21583. static loggingLevel: number;
  21584. /**
  21585. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21586. */
  21587. static CleanBoneMatrixWeights: boolean;
  21588. }
  21589. }
  21590. declare module "babylonjs/Meshes/geometry" {
  21591. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21594. import { Engine } from "babylonjs/Engines/engine";
  21595. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21596. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21597. import { Effect } from "babylonjs/Materials/effect";
  21598. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21599. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21600. import { Mesh } from "babylonjs/Meshes/mesh";
  21601. /**
  21602. * Class used to store geometry data (vertex buffers + index buffer)
  21603. */
  21604. export class Geometry implements IGetSetVerticesData {
  21605. /**
  21606. * Gets or sets the ID of the geometry
  21607. */
  21608. id: string;
  21609. /**
  21610. * Gets or sets the unique ID of the geometry
  21611. */
  21612. uniqueId: number;
  21613. /**
  21614. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21615. */
  21616. delayLoadState: number;
  21617. /**
  21618. * Gets the file containing the data to load when running in delay load state
  21619. */
  21620. delayLoadingFile: Nullable<string>;
  21621. /**
  21622. * Callback called when the geometry is updated
  21623. */
  21624. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21625. private _scene;
  21626. private _engine;
  21627. private _meshes;
  21628. private _totalVertices;
  21629. /** @hidden */
  21630. _indices: IndicesArray;
  21631. /** @hidden */
  21632. _vertexBuffers: {
  21633. [key: string]: VertexBuffer;
  21634. };
  21635. private _isDisposed;
  21636. private _extend;
  21637. private _boundingBias;
  21638. /** @hidden */
  21639. _delayInfo: Array<string>;
  21640. private _indexBuffer;
  21641. private _indexBufferIsUpdatable;
  21642. /** @hidden */
  21643. _boundingInfo: Nullable<BoundingInfo>;
  21644. /** @hidden */
  21645. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21646. /** @hidden */
  21647. _softwareSkinningFrameId: number;
  21648. private _vertexArrayObjects;
  21649. private _updatable;
  21650. /** @hidden */
  21651. _positions: Nullable<Vector3[]>;
  21652. /**
  21653. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21654. */
  21655. /**
  21656. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  21657. */
  21658. boundingBias: Vector2;
  21659. /**
  21660. * Static function used to attach a new empty geometry to a mesh
  21661. * @param mesh defines the mesh to attach the geometry to
  21662. * @returns the new Geometry
  21663. */
  21664. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21665. /**
  21666. * Creates a new geometry
  21667. * @param id defines the unique ID
  21668. * @param scene defines the hosting scene
  21669. * @param vertexData defines the VertexData used to get geometry data
  21670. * @param updatable defines if geometry must be updatable (false by default)
  21671. * @param mesh defines the mesh that will be associated with the geometry
  21672. */
  21673. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21674. /**
  21675. * Gets the current extend of the geometry
  21676. */
  21677. readonly extend: {
  21678. minimum: Vector3;
  21679. maximum: Vector3;
  21680. };
  21681. /**
  21682. * Gets the hosting scene
  21683. * @returns the hosting Scene
  21684. */
  21685. getScene(): Scene;
  21686. /**
  21687. * Gets the hosting engine
  21688. * @returns the hosting Engine
  21689. */
  21690. getEngine(): Engine;
  21691. /**
  21692. * Defines if the geometry is ready to use
  21693. * @returns true if the geometry is ready to be used
  21694. */
  21695. isReady(): boolean;
  21696. /**
  21697. * Gets a value indicating that the geometry should not be serialized
  21698. */
  21699. readonly doNotSerialize: boolean;
  21700. /** @hidden */
  21701. _rebuild(): void;
  21702. /**
  21703. * Affects all geometry data in one call
  21704. * @param vertexData defines the geometry data
  21705. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21706. */
  21707. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21708. /**
  21709. * Set specific vertex data
  21710. * @param kind defines the data kind (Position, normal, etc...)
  21711. * @param data defines the vertex data to use
  21712. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21713. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21714. */
  21715. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21716. /**
  21717. * Removes a specific vertex data
  21718. * @param kind defines the data kind (Position, normal, etc...)
  21719. */
  21720. removeVerticesData(kind: string): void;
  21721. /**
  21722. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21723. * @param buffer defines the vertex buffer to use
  21724. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21725. */
  21726. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21727. /**
  21728. * Update a specific vertex buffer
  21729. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21730. * It will do nothing if the buffer is not updatable
  21731. * @param kind defines the data kind (Position, normal, etc...)
  21732. * @param data defines the data to use
  21733. * @param offset defines the offset in the target buffer where to store the data
  21734. * @param useBytes set to true if the offset is in bytes
  21735. */
  21736. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21737. /**
  21738. * Update a specific vertex buffer
  21739. * This function will create a new buffer if the current one is not updatable
  21740. * @param kind defines the data kind (Position, normal, etc...)
  21741. * @param data defines the data to use
  21742. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21743. */
  21744. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21745. private _updateBoundingInfo;
  21746. /** @hidden */
  21747. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21748. /**
  21749. * Gets total number of vertices
  21750. * @returns the total number of vertices
  21751. */
  21752. getTotalVertices(): number;
  21753. /**
  21754. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21755. * @param kind defines the data kind (Position, normal, etc...)
  21756. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21757. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21758. * @returns a float array containing vertex data
  21759. */
  21760. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21761. /**
  21762. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21763. * @param kind defines the data kind (Position, normal, etc...)
  21764. * @returns true if the vertex buffer with the specified kind is updatable
  21765. */
  21766. isVertexBufferUpdatable(kind: string): boolean;
  21767. /**
  21768. * Gets a specific vertex buffer
  21769. * @param kind defines the data kind (Position, normal, etc...)
  21770. * @returns a VertexBuffer
  21771. */
  21772. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21773. /**
  21774. * Returns all vertex buffers
  21775. * @return an object holding all vertex buffers indexed by kind
  21776. */
  21777. getVertexBuffers(): Nullable<{
  21778. [key: string]: VertexBuffer;
  21779. }>;
  21780. /**
  21781. * Gets a boolean indicating if specific vertex buffer is present
  21782. * @param kind defines the data kind (Position, normal, etc...)
  21783. * @returns true if data is present
  21784. */
  21785. isVerticesDataPresent(kind: string): boolean;
  21786. /**
  21787. * Gets a list of all attached data kinds (Position, normal, etc...)
  21788. * @returns a list of string containing all kinds
  21789. */
  21790. getVerticesDataKinds(): string[];
  21791. /**
  21792. * Update index buffer
  21793. * @param indices defines the indices to store in the index buffer
  21794. * @param offset defines the offset in the target buffer where to store the data
  21795. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  21796. */
  21797. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21798. /**
  21799. * Creates a new index buffer
  21800. * @param indices defines the indices to store in the index buffer
  21801. * @param totalVertices defines the total number of vertices (could be null)
  21802. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21803. */
  21804. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21805. /**
  21806. * Return the total number of indices
  21807. * @returns the total number of indices
  21808. */
  21809. getTotalIndices(): number;
  21810. /**
  21811. * Gets the index buffer array
  21812. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21813. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21814. * @returns the index buffer array
  21815. */
  21816. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21817. /**
  21818. * Gets the index buffer
  21819. * @return the index buffer
  21820. */
  21821. getIndexBuffer(): Nullable<DataBuffer>;
  21822. /** @hidden */
  21823. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21824. /**
  21825. * Release the associated resources for a specific mesh
  21826. * @param mesh defines the source mesh
  21827. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21828. */
  21829. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21830. /**
  21831. * Apply current geometry to a given mesh
  21832. * @param mesh defines the mesh to apply geometry to
  21833. */
  21834. applyToMesh(mesh: Mesh): void;
  21835. private _updateExtend;
  21836. private _applyToMesh;
  21837. private notifyUpdate;
  21838. /**
  21839. * Load the geometry if it was flagged as delay loaded
  21840. * @param scene defines the hosting scene
  21841. * @param onLoaded defines a callback called when the geometry is loaded
  21842. */
  21843. load(scene: Scene, onLoaded?: () => void): void;
  21844. private _queueLoad;
  21845. /**
  21846. * Invert the geometry to move from a right handed system to a left handed one.
  21847. */
  21848. toLeftHanded(): void;
  21849. /** @hidden */
  21850. _resetPointsArrayCache(): void;
  21851. /** @hidden */
  21852. _generatePointsArray(): boolean;
  21853. /**
  21854. * Gets a value indicating if the geometry is disposed
  21855. * @returns true if the geometry was disposed
  21856. */
  21857. isDisposed(): boolean;
  21858. private _disposeVertexArrayObjects;
  21859. /**
  21860. * Free all associated resources
  21861. */
  21862. dispose(): void;
  21863. /**
  21864. * Clone the current geometry into a new geometry
  21865. * @param id defines the unique ID of the new geometry
  21866. * @returns a new geometry object
  21867. */
  21868. copy(id: string): Geometry;
  21869. /**
  21870. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21871. * @return a JSON representation of the current geometry data (without the vertices data)
  21872. */
  21873. serialize(): any;
  21874. private toNumberArray;
  21875. /**
  21876. * Serialize all vertices data into a JSON oject
  21877. * @returns a JSON representation of the current geometry data
  21878. */
  21879. serializeVerticeData(): any;
  21880. /**
  21881. * Extracts a clone of a mesh geometry
  21882. * @param mesh defines the source mesh
  21883. * @param id defines the unique ID of the new geometry object
  21884. * @returns the new geometry object
  21885. */
  21886. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21887. /**
  21888. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21889. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21890. * Be aware Math.random() could cause collisions, but:
  21891. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  21892. * @returns a string containing a new GUID
  21893. */
  21894. static RandomId(): string;
  21895. /** @hidden */
  21896. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21897. private static _CleanMatricesWeights;
  21898. /**
  21899. * Create a new geometry from persisted data (Using .babylon file format)
  21900. * @param parsedVertexData defines the persisted data
  21901. * @param scene defines the hosting scene
  21902. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21903. * @returns the new geometry object
  21904. */
  21905. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21906. }
  21907. }
  21908. declare module "babylonjs/Meshes/mesh.vertexData" {
  21909. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21910. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21912. import { Geometry } from "babylonjs/Meshes/geometry";
  21913. import { Mesh } from "babylonjs/Meshes/mesh";
  21914. /**
  21915. * Define an interface for all classes that will get and set the data on vertices
  21916. */
  21917. export interface IGetSetVerticesData {
  21918. /**
  21919. * Gets a boolean indicating if specific vertex data is present
  21920. * @param kind defines the vertex data kind to use
  21921. * @returns true is data kind is present
  21922. */
  21923. isVerticesDataPresent(kind: string): boolean;
  21924. /**
  21925. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21926. * @param kind defines the data kind (Position, normal, etc...)
  21927. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21928. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21929. * @returns a float array containing vertex data
  21930. */
  21931. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21932. /**
  21933. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21934. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  21935. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21936. * @returns the indices array or an empty array if the mesh has no geometry
  21937. */
  21938. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21939. /**
  21940. * Set specific vertex data
  21941. * @param kind defines the data kind (Position, normal, etc...)
  21942. * @param data defines the vertex data to use
  21943. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21944. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21945. */
  21946. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21947. /**
  21948. * Update a specific associated vertex buffer
  21949. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21950. * - VertexBuffer.PositionKind
  21951. * - VertexBuffer.UVKind
  21952. * - VertexBuffer.UV2Kind
  21953. * - VertexBuffer.UV3Kind
  21954. * - VertexBuffer.UV4Kind
  21955. * - VertexBuffer.UV5Kind
  21956. * - VertexBuffer.UV6Kind
  21957. * - VertexBuffer.ColorKind
  21958. * - VertexBuffer.MatricesIndicesKind
  21959. * - VertexBuffer.MatricesIndicesExtraKind
  21960. * - VertexBuffer.MatricesWeightsKind
  21961. * - VertexBuffer.MatricesWeightsExtraKind
  21962. * @param data defines the data source
  21963. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21964. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  21965. */
  21966. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21967. /**
  21968. * Creates a new index buffer
  21969. * @param indices defines the indices to store in the index buffer
  21970. * @param totalVertices defines the total number of vertices (could be null)
  21971. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21972. */
  21973. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21974. }
  21975. /**
  21976. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21977. */
  21978. export class VertexData {
  21979. /**
  21980. * Mesh side orientation : usually the external or front surface
  21981. */
  21982. static readonly FRONTSIDE: number;
  21983. /**
  21984. * Mesh side orientation : usually the internal or back surface
  21985. */
  21986. static readonly BACKSIDE: number;
  21987. /**
  21988. * Mesh side orientation : both internal and external or front and back surfaces
  21989. */
  21990. static readonly DOUBLESIDE: number;
  21991. /**
  21992. * Mesh side orientation : by default, `FRONTSIDE`
  21993. */
  21994. static readonly DEFAULTSIDE: number;
  21995. /**
  21996. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  21997. */
  21998. positions: Nullable<FloatArray>;
  21999. /**
  22000. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22001. */
  22002. normals: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. tangents: Nullable<FloatArray>;
  22007. /**
  22008. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22009. */
  22010. uvs: Nullable<FloatArray>;
  22011. /**
  22012. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs2: Nullable<FloatArray>;
  22015. /**
  22016. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs3: Nullable<FloatArray>;
  22019. /**
  22020. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs4: Nullable<FloatArray>;
  22023. /**
  22024. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs5: Nullable<FloatArray>;
  22027. /**
  22028. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs6: Nullable<FloatArray>;
  22031. /**
  22032. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22033. */
  22034. colors: Nullable<FloatArray>;
  22035. /**
  22036. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22037. */
  22038. matricesIndices: Nullable<FloatArray>;
  22039. /**
  22040. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22041. */
  22042. matricesWeights: Nullable<FloatArray>;
  22043. /**
  22044. * An array extending the number of possible indices
  22045. */
  22046. matricesIndicesExtra: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible weights when the number of indices is extended
  22049. */
  22050. matricesWeightsExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22053. */
  22054. indices: Nullable<IndicesArray>;
  22055. /**
  22056. * Uses the passed data array to set the set the values for the specified kind of data
  22057. * @param data a linear array of floating numbers
  22058. * @param kind the type of data that is being set, eg positions, colors etc
  22059. */
  22060. set(data: FloatArray, kind: string): void;
  22061. /**
  22062. * Associates the vertexData to the passed Mesh.
  22063. * Sets it as updatable or not (default `false`)
  22064. * @param mesh the mesh the vertexData is applied to
  22065. * @param updatable when used and having the value true allows new data to update the vertexData
  22066. * @returns the VertexData
  22067. */
  22068. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22069. /**
  22070. * Associates the vertexData to the passed Geometry.
  22071. * Sets it as updatable or not (default `false`)
  22072. * @param geometry the geometry the vertexData is applied to
  22073. * @param updatable when used and having the value true allows new data to update the vertexData
  22074. * @returns VertexData
  22075. */
  22076. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22077. /**
  22078. * Updates the associated mesh
  22079. * @param mesh the mesh to be updated
  22080. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22081. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22082. * @returns VertexData
  22083. */
  22084. updateMesh(mesh: Mesh): VertexData;
  22085. /**
  22086. * Updates the associated geometry
  22087. * @param geometry the geometry to be updated
  22088. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22089. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22090. * @returns VertexData.
  22091. */
  22092. updateGeometry(geometry: Geometry): VertexData;
  22093. private _applyTo;
  22094. private _update;
  22095. /**
  22096. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22097. * @param matrix the transforming matrix
  22098. * @returns the VertexData
  22099. */
  22100. transform(matrix: Matrix): VertexData;
  22101. /**
  22102. * Merges the passed VertexData into the current one
  22103. * @param other the VertexData to be merged into the current one
  22104. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22105. * @returns the modified VertexData
  22106. */
  22107. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22108. private _mergeElement;
  22109. private _validate;
  22110. /**
  22111. * Serializes the VertexData
  22112. * @returns a serialized object
  22113. */
  22114. serialize(): any;
  22115. /**
  22116. * Extracts the vertexData from a mesh
  22117. * @param mesh the mesh from which to extract the VertexData
  22118. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22119. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22120. * @returns the object VertexData associated to the passed mesh
  22121. */
  22122. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22123. /**
  22124. * Extracts the vertexData from the geometry
  22125. * @param geometry the geometry from which to extract the VertexData
  22126. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22127. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22128. * @returns the object VertexData associated to the passed mesh
  22129. */
  22130. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22131. private static _ExtractFrom;
  22132. /**
  22133. * Creates the VertexData for a Ribbon
  22134. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22135. * * pathArray array of paths, each of which an array of successive Vector3
  22136. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22137. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22138. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22139. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22140. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22141. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22142. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22143. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22144. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22145. * @returns the VertexData of the ribbon
  22146. */
  22147. static CreateRibbon(options: {
  22148. pathArray: Vector3[][];
  22149. closeArray?: boolean;
  22150. closePath?: boolean;
  22151. offset?: number;
  22152. sideOrientation?: number;
  22153. frontUVs?: Vector4;
  22154. backUVs?: Vector4;
  22155. invertUV?: boolean;
  22156. uvs?: Vector2[];
  22157. colors?: Color4[];
  22158. }): VertexData;
  22159. /**
  22160. * Creates the VertexData for a box
  22161. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22162. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22163. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22164. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22165. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22166. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22167. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22168. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22169. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22170. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22171. * @returns the VertexData of the box
  22172. */
  22173. static CreateBox(options: {
  22174. size?: number;
  22175. width?: number;
  22176. height?: number;
  22177. depth?: number;
  22178. faceUV?: Vector4[];
  22179. faceColors?: Color4[];
  22180. sideOrientation?: number;
  22181. frontUVs?: Vector4;
  22182. backUVs?: Vector4;
  22183. }): VertexData;
  22184. /**
  22185. * Creates the VertexData for a tiled box
  22186. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22187. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22188. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22189. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22190. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22191. * @returns the VertexData of the box
  22192. */
  22193. static CreateTiledBox(options: {
  22194. pattern?: number;
  22195. width?: number;
  22196. height?: number;
  22197. depth?: number;
  22198. tileSize?: number;
  22199. tileWidth?: number;
  22200. tileHeight?: number;
  22201. alignHorizontal?: number;
  22202. alignVertical?: number;
  22203. faceUV?: Vector4[];
  22204. faceColors?: Color4[];
  22205. sideOrientation?: number;
  22206. }): VertexData;
  22207. /**
  22208. * Creates the VertexData for a tiled plane
  22209. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22210. * * pattern a limited pattern arrangement depending on the number
  22211. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22212. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22213. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22215. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22216. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22217. * @returns the VertexData of the tiled plane
  22218. */
  22219. static CreateTiledPlane(options: {
  22220. pattern?: number;
  22221. tileSize?: number;
  22222. tileWidth?: number;
  22223. tileHeight?: number;
  22224. size?: number;
  22225. width?: number;
  22226. height?: number;
  22227. alignHorizontal?: number;
  22228. alignVertical?: number;
  22229. sideOrientation?: number;
  22230. frontUVs?: Vector4;
  22231. backUVs?: Vector4;
  22232. }): VertexData;
  22233. /**
  22234. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22235. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22236. * * segments sets the number of horizontal strips optional, default 32
  22237. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22238. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22239. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22240. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22241. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22242. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22244. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22245. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22246. * @returns the VertexData of the ellipsoid
  22247. */
  22248. static CreateSphere(options: {
  22249. segments?: number;
  22250. diameter?: number;
  22251. diameterX?: number;
  22252. diameterY?: number;
  22253. diameterZ?: number;
  22254. arc?: number;
  22255. slice?: number;
  22256. sideOrientation?: number;
  22257. frontUVs?: Vector4;
  22258. backUVs?: Vector4;
  22259. }): VertexData;
  22260. /**
  22261. * Creates the VertexData for a cylinder, cone or prism
  22262. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22263. * * height sets the height (y direction) of the cylinder, optional, default 2
  22264. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22265. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22266. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22267. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22268. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22269. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  22270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22271. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22272. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22273. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22274. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22275. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22276. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22277. * @returns the VertexData of the cylinder, cone or prism
  22278. */
  22279. static CreateCylinder(options: {
  22280. height?: number;
  22281. diameterTop?: number;
  22282. diameterBottom?: number;
  22283. diameter?: number;
  22284. tessellation?: number;
  22285. subdivisions?: number;
  22286. arc?: number;
  22287. faceColors?: Color4[];
  22288. faceUV?: Vector4[];
  22289. hasRings?: boolean;
  22290. enclose?: boolean;
  22291. sideOrientation?: number;
  22292. frontUVs?: Vector4;
  22293. backUVs?: Vector4;
  22294. }): VertexData;
  22295. /**
  22296. * Creates the VertexData for a torus
  22297. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22298. * * diameter the diameter of the torus, optional default 1
  22299. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22300. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22301. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22302. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22303. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22304. * @returns the VertexData of the torus
  22305. */
  22306. static CreateTorus(options: {
  22307. diameter?: number;
  22308. thickness?: number;
  22309. tessellation?: number;
  22310. sideOrientation?: number;
  22311. frontUVs?: Vector4;
  22312. backUVs?: Vector4;
  22313. }): VertexData;
  22314. /**
  22315. * Creates the VertexData of the LineSystem
  22316. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22317. * - lines an array of lines, each line being an array of successive Vector3
  22318. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22319. * @returns the VertexData of the LineSystem
  22320. */
  22321. static CreateLineSystem(options: {
  22322. lines: Vector3[][];
  22323. colors?: Nullable<Color4[][]>;
  22324. }): VertexData;
  22325. /**
  22326. * Create the VertexData for a DashedLines
  22327. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22328. * - points an array successive Vector3
  22329. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22330. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22331. * - dashNb the intended total number of dashes, optional, default 200
  22332. * @returns the VertexData for the DashedLines
  22333. */
  22334. static CreateDashedLines(options: {
  22335. points: Vector3[];
  22336. dashSize?: number;
  22337. gapSize?: number;
  22338. dashNb?: number;
  22339. }): VertexData;
  22340. /**
  22341. * Creates the VertexData for a Ground
  22342. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22343. * - width the width (x direction) of the ground, optional, default 1
  22344. * - height the height (z direction) of the ground, optional, default 1
  22345. * - subdivisions the number of subdivisions per side, optional, default 1
  22346. * @returns the VertexData of the Ground
  22347. */
  22348. static CreateGround(options: {
  22349. width?: number;
  22350. height?: number;
  22351. subdivisions?: number;
  22352. subdivisionsX?: number;
  22353. subdivisionsY?: number;
  22354. }): VertexData;
  22355. /**
  22356. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22357. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22358. * * xmin the ground minimum X coordinate, optional, default -1
  22359. * * zmin the ground minimum Z coordinate, optional, default -1
  22360. * * xmax the ground maximum X coordinate, optional, default 1
  22361. * * zmax the ground maximum Z coordinate, optional, default 1
  22362. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  22363. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  22364. * @returns the VertexData of the TiledGround
  22365. */
  22366. static CreateTiledGround(options: {
  22367. xmin: number;
  22368. zmin: number;
  22369. xmax: number;
  22370. zmax: number;
  22371. subdivisions?: {
  22372. w: number;
  22373. h: number;
  22374. };
  22375. precision?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. }): VertexData;
  22380. /**
  22381. * Creates the VertexData of the Ground designed from a heightmap
  22382. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22383. * * width the width (x direction) of the ground
  22384. * * height the height (z direction) of the ground
  22385. * * subdivisions the number of subdivisions per side
  22386. * * minHeight the minimum altitude on the ground, optional, default 0
  22387. * * maxHeight the maximum altitude on the ground, optional default 1
  22388. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22389. * * buffer the array holding the image color data
  22390. * * bufferWidth the width of image
  22391. * * bufferHeight the height of image
  22392. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22393. * @returns the VertexData of the Ground designed from a heightmap
  22394. */
  22395. static CreateGroundFromHeightMap(options: {
  22396. width: number;
  22397. height: number;
  22398. subdivisions: number;
  22399. minHeight: number;
  22400. maxHeight: number;
  22401. colorFilter: Color3;
  22402. buffer: Uint8Array;
  22403. bufferWidth: number;
  22404. bufferHeight: number;
  22405. alphaFilter: number;
  22406. }): VertexData;
  22407. /**
  22408. * Creates the VertexData for a Plane
  22409. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22410. * * size sets the width and height of the plane to the value of size, optional default 1
  22411. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22412. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22414. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22415. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22416. * @returns the VertexData of the box
  22417. */
  22418. static CreatePlane(options: {
  22419. size?: number;
  22420. width?: number;
  22421. height?: number;
  22422. sideOrientation?: number;
  22423. frontUVs?: Vector4;
  22424. backUVs?: Vector4;
  22425. }): VertexData;
  22426. /**
  22427. * Creates the VertexData of the Disc or regular Polygon
  22428. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22429. * * radius the radius of the disc, optional default 0.5
  22430. * * tessellation the number of polygon sides, optional, default 64
  22431. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  22432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22433. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22434. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22435. * @returns the VertexData of the box
  22436. */
  22437. static CreateDisc(options: {
  22438. radius?: number;
  22439. tessellation?: number;
  22440. arc?: number;
  22441. sideOrientation?: number;
  22442. frontUVs?: Vector4;
  22443. backUVs?: Vector4;
  22444. }): VertexData;
  22445. /**
  22446. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22447. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22448. * @param polygon a mesh built from polygonTriangulation.build()
  22449. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22450. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22451. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22452. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22453. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22454. * @returns the VertexData of the Polygon
  22455. */
  22456. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22457. /**
  22458. * Creates the VertexData of the IcoSphere
  22459. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22460. * * radius the radius of the IcoSphere, optional default 1
  22461. * * radiusX allows stretching in the x direction, optional, default radius
  22462. * * radiusY allows stretching in the y direction, optional, default radius
  22463. * * radiusZ allows stretching in the z direction, optional, default radius
  22464. * * flat when true creates a flat shaded mesh, optional, default true
  22465. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22466. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22467. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22468. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22469. * @returns the VertexData of the IcoSphere
  22470. */
  22471. static CreateIcoSphere(options: {
  22472. radius?: number;
  22473. radiusX?: number;
  22474. radiusY?: number;
  22475. radiusZ?: number;
  22476. flat?: boolean;
  22477. subdivisions?: number;
  22478. sideOrientation?: number;
  22479. frontUVs?: Vector4;
  22480. backUVs?: Vector4;
  22481. }): VertexData;
  22482. /**
  22483. * Creates the VertexData for a Polyhedron
  22484. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22485. * * type provided types are:
  22486. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22487. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  22488. * * size the size of the IcoSphere, optional default 1
  22489. * * sizeX allows stretching in the x direction, optional, default size
  22490. * * sizeY allows stretching in the y direction, optional, default size
  22491. * * sizeZ allows stretching in the z direction, optional, default size
  22492. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  22493. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22494. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22495. * * flat when true creates a flat shaded mesh, optional, default true
  22496. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22497. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22498. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22499. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22500. * @returns the VertexData of the Polyhedron
  22501. */
  22502. static CreatePolyhedron(options: {
  22503. type?: number;
  22504. size?: number;
  22505. sizeX?: number;
  22506. sizeY?: number;
  22507. sizeZ?: number;
  22508. custom?: any;
  22509. faceUV?: Vector4[];
  22510. faceColors?: Color4[];
  22511. flat?: boolean;
  22512. sideOrientation?: number;
  22513. frontUVs?: Vector4;
  22514. backUVs?: Vector4;
  22515. }): VertexData;
  22516. /**
  22517. * Creates the VertexData for a TorusKnot
  22518. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22519. * * radius the radius of the torus knot, optional, default 2
  22520. * * tube the thickness of the tube, optional, default 0.5
  22521. * * radialSegments the number of sides on each tube segments, optional, default 32
  22522. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22523. * * p the number of windings around the z axis, optional, default 2
  22524. * * q the number of windings around the x axis, optional, default 3
  22525. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22526. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22527. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22528. * @returns the VertexData of the Torus Knot
  22529. */
  22530. static CreateTorusKnot(options: {
  22531. radius?: number;
  22532. tube?: number;
  22533. radialSegments?: number;
  22534. tubularSegments?: number;
  22535. p?: number;
  22536. q?: number;
  22537. sideOrientation?: number;
  22538. frontUVs?: Vector4;
  22539. backUVs?: Vector4;
  22540. }): VertexData;
  22541. /**
  22542. * Compute normals for given positions and indices
  22543. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22544. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22545. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22546. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22547. * * facetNormals : optional array of facet normals (vector3)
  22548. * * facetPositions : optional array of facet positions (vector3)
  22549. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22550. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22551. * * bInfo : optional bounding info, required for facetPartitioning computation
  22552. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22553. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22554. * * useRightHandedSystem: optional boolean to for right handed system computation
  22555. * * depthSort : optional boolean to enable the facet depth sort computation
  22556. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22557. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22558. */
  22559. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22560. facetNormals?: any;
  22561. facetPositions?: any;
  22562. facetPartitioning?: any;
  22563. ratio?: number;
  22564. bInfo?: any;
  22565. bbSize?: Vector3;
  22566. subDiv?: any;
  22567. useRightHandedSystem?: boolean;
  22568. depthSort?: boolean;
  22569. distanceTo?: Vector3;
  22570. depthSortedFacets?: any;
  22571. }): void;
  22572. /** @hidden */
  22573. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22574. /**
  22575. * Applies VertexData created from the imported parameters to the geometry
  22576. * @param parsedVertexData the parsed data from an imported file
  22577. * @param geometry the geometry to apply the VertexData to
  22578. */
  22579. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22580. }
  22581. }
  22582. declare module "babylonjs/Morph/morphTarget" {
  22583. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22584. import { Observable } from "babylonjs/Misc/observable";
  22585. import { Nullable, FloatArray } from "babylonjs/types";
  22586. import { Scene } from "babylonjs/scene";
  22587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22588. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22589. /**
  22590. * Defines a target to use with MorphTargetManager
  22591. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22592. */
  22593. export class MorphTarget implements IAnimatable {
  22594. /** defines the name of the target */
  22595. name: string;
  22596. /**
  22597. * Gets or sets the list of animations
  22598. */
  22599. animations: import("babylonjs/Animations/animation").Animation[];
  22600. private _scene;
  22601. private _positions;
  22602. private _normals;
  22603. private _tangents;
  22604. private _uvs;
  22605. private _influence;
  22606. /**
  22607. * Observable raised when the influence changes
  22608. */
  22609. onInfluenceChanged: Observable<boolean>;
  22610. /** @hidden */
  22611. _onDataLayoutChanged: Observable<void>;
  22612. /**
  22613. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22614. */
  22615. influence: number;
  22616. /**
  22617. * Gets or sets the id of the morph Target
  22618. */
  22619. id: string;
  22620. private _animationPropertiesOverride;
  22621. /**
  22622. * Gets or sets the animation properties override
  22623. */
  22624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22625. /**
  22626. * Creates a new MorphTarget
  22627. * @param name defines the name of the target
  22628. * @param influence defines the influence to use
  22629. * @param scene defines the scene the morphtarget belongs to
  22630. */
  22631. constructor(
  22632. /** defines the name of the target */
  22633. name: string, influence?: number, scene?: Nullable<Scene>);
  22634. /**
  22635. * Gets a boolean defining if the target contains position data
  22636. */
  22637. readonly hasPositions: boolean;
  22638. /**
  22639. * Gets a boolean defining if the target contains normal data
  22640. */
  22641. readonly hasNormals: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains tangent data
  22644. */
  22645. readonly hasTangents: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains texture coordinates data
  22648. */
  22649. readonly hasUVs: boolean;
  22650. /**
  22651. * Affects position data to this target
  22652. * @param data defines the position data to use
  22653. */
  22654. setPositions(data: Nullable<FloatArray>): void;
  22655. /**
  22656. * Gets the position data stored in this target
  22657. * @returns a FloatArray containing the position data (or null if not present)
  22658. */
  22659. getPositions(): Nullable<FloatArray>;
  22660. /**
  22661. * Affects normal data to this target
  22662. * @param data defines the normal data to use
  22663. */
  22664. setNormals(data: Nullable<FloatArray>): void;
  22665. /**
  22666. * Gets the normal data stored in this target
  22667. * @returns a FloatArray containing the normal data (or null if not present)
  22668. */
  22669. getNormals(): Nullable<FloatArray>;
  22670. /**
  22671. * Affects tangent data to this target
  22672. * @param data defines the tangent data to use
  22673. */
  22674. setTangents(data: Nullable<FloatArray>): void;
  22675. /**
  22676. * Gets the tangent data stored in this target
  22677. * @returns a FloatArray containing the tangent data (or null if not present)
  22678. */
  22679. getTangents(): Nullable<FloatArray>;
  22680. /**
  22681. * Affects texture coordinates data to this target
  22682. * @param data defines the texture coordinates data to use
  22683. */
  22684. setUVs(data: Nullable<FloatArray>): void;
  22685. /**
  22686. * Gets the texture coordinates data stored in this target
  22687. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22688. */
  22689. getUVs(): Nullable<FloatArray>;
  22690. /**
  22691. * Serializes the current target into a Serialization object
  22692. * @returns the serialized object
  22693. */
  22694. serialize(): any;
  22695. /**
  22696. * Returns the string "MorphTarget"
  22697. * @returns "MorphTarget"
  22698. */
  22699. getClassName(): string;
  22700. /**
  22701. * Creates a new target from serialized data
  22702. * @param serializationObject defines the serialized data to use
  22703. * @returns a new MorphTarget
  22704. */
  22705. static Parse(serializationObject: any): MorphTarget;
  22706. /**
  22707. * Creates a MorphTarget from mesh data
  22708. * @param mesh defines the source mesh
  22709. * @param name defines the name to use for the new target
  22710. * @param influence defines the influence to attach to the target
  22711. * @returns a new MorphTarget
  22712. */
  22713. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22714. }
  22715. }
  22716. declare module "babylonjs/Morph/morphTargetManager" {
  22717. import { Nullable } from "babylonjs/types";
  22718. import { Scene } from "babylonjs/scene";
  22719. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22720. /**
  22721. * This class is used to deform meshes using morphing between different targets
  22722. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22723. */
  22724. export class MorphTargetManager {
  22725. private _targets;
  22726. private _targetInfluenceChangedObservers;
  22727. private _targetDataLayoutChangedObservers;
  22728. private _activeTargets;
  22729. private _scene;
  22730. private _influences;
  22731. private _supportsNormals;
  22732. private _supportsTangents;
  22733. private _supportsUVs;
  22734. private _vertexCount;
  22735. private _uniqueId;
  22736. private _tempInfluences;
  22737. /**
  22738. * Gets or sets a boolean indicating if normals must be morphed
  22739. */
  22740. enableNormalMorphing: boolean;
  22741. /**
  22742. * Gets or sets a boolean indicating if tangents must be morphed
  22743. */
  22744. enableTangentMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if UV must be morphed
  22747. */
  22748. enableUVMorphing: boolean;
  22749. /**
  22750. * Creates a new MorphTargetManager
  22751. * @param scene defines the current scene
  22752. */
  22753. constructor(scene?: Nullable<Scene>);
  22754. /**
  22755. * Gets the unique ID of this manager
  22756. */
  22757. readonly uniqueId: number;
  22758. /**
  22759. * Gets the number of vertices handled by this manager
  22760. */
  22761. readonly vertexCount: number;
  22762. /**
  22763. * Gets a boolean indicating if this manager supports morphing of normals
  22764. */
  22765. readonly supportsNormals: boolean;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of tangents
  22768. */
  22769. readonly supportsTangents: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22772. */
  22773. readonly supportsUVs: boolean;
  22774. /**
  22775. * Gets the number of targets stored in this manager
  22776. */
  22777. readonly numTargets: number;
  22778. /**
  22779. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22780. */
  22781. readonly numInfluencers: number;
  22782. /**
  22783. * Gets the list of influences (one per target)
  22784. */
  22785. readonly influences: Float32Array;
  22786. /**
  22787. * Gets the active target at specified index. An active target is a target with an influence > 0
  22788. * @param index defines the index to check
  22789. * @returns the requested target
  22790. */
  22791. getActiveTarget(index: number): MorphTarget;
  22792. /**
  22793. * Gets the target at specified index
  22794. * @param index defines the index to check
  22795. * @returns the requested target
  22796. */
  22797. getTarget(index: number): MorphTarget;
  22798. /**
  22799. * Add a new target to this manager
  22800. * @param target defines the target to add
  22801. */
  22802. addTarget(target: MorphTarget): void;
  22803. /**
  22804. * Removes a target from the manager
  22805. * @param target defines the target to remove
  22806. */
  22807. removeTarget(target: MorphTarget): void;
  22808. /**
  22809. * Serializes the current manager into a Serialization object
  22810. * @returns the serialized object
  22811. */
  22812. serialize(): any;
  22813. private _syncActiveTargets;
  22814. /**
  22815. * Syncrhonize the targets with all the meshes using this morph target manager
  22816. */
  22817. synchronize(): void;
  22818. /**
  22819. * Creates a new MorphTargetManager from serialized data
  22820. * @param serializationObject defines the serialized data
  22821. * @param scene defines the hosting scene
  22822. * @returns the new MorphTargetManager
  22823. */
  22824. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22825. }
  22826. }
  22827. declare module "babylonjs/Meshes/meshLODLevel" {
  22828. import { Mesh } from "babylonjs/Meshes/mesh";
  22829. import { Nullable } from "babylonjs/types";
  22830. /**
  22831. * Class used to represent a specific level of detail of a mesh
  22832. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22833. */
  22834. export class MeshLODLevel {
  22835. /** Defines the distance where this level should start being displayed */
  22836. distance: number;
  22837. /** Defines the mesh to use to render this level */
  22838. mesh: Nullable<Mesh>;
  22839. /**
  22840. * Creates a new LOD level
  22841. * @param distance defines the distance where this level should star being displayed
  22842. * @param mesh defines the mesh to use to render this level
  22843. */
  22844. constructor(
  22845. /** Defines the distance where this level should start being displayed */
  22846. distance: number,
  22847. /** Defines the mesh to use to render this level */
  22848. mesh: Nullable<Mesh>);
  22849. }
  22850. }
  22851. declare module "babylonjs/Meshes/groundMesh" {
  22852. import { Scene } from "babylonjs/scene";
  22853. import { Vector3 } from "babylonjs/Maths/math.vector";
  22854. import { Mesh } from "babylonjs/Meshes/mesh";
  22855. /**
  22856. * Mesh representing the gorund
  22857. */
  22858. export class GroundMesh extends Mesh {
  22859. /** If octree should be generated */
  22860. generateOctree: boolean;
  22861. private _heightQuads;
  22862. /** @hidden */
  22863. _subdivisionsX: number;
  22864. /** @hidden */
  22865. _subdivisionsY: number;
  22866. /** @hidden */
  22867. _width: number;
  22868. /** @hidden */
  22869. _height: number;
  22870. /** @hidden */
  22871. _minX: number;
  22872. /** @hidden */
  22873. _maxX: number;
  22874. /** @hidden */
  22875. _minZ: number;
  22876. /** @hidden */
  22877. _maxZ: number;
  22878. constructor(name: string, scene: Scene);
  22879. /**
  22880. * "GroundMesh"
  22881. * @returns "GroundMesh"
  22882. */
  22883. getClassName(): string;
  22884. /**
  22885. * The minimum of x and y subdivisions
  22886. */
  22887. readonly subdivisions: number;
  22888. /**
  22889. * X subdivisions
  22890. */
  22891. readonly subdivisionsX: number;
  22892. /**
  22893. * Y subdivisions
  22894. */
  22895. readonly subdivisionsY: number;
  22896. /**
  22897. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22898. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22899. * @param chunksCount the number of subdivisions for x and y
  22900. * @param octreeBlocksSize (Default: 32)
  22901. */
  22902. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22903. /**
  22904. * Returns a height (y) value in the Worl system :
  22905. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22906. * @param x x coordinate
  22907. * @param z z coordinate
  22908. * @returns the ground y position if (x, z) are outside the ground surface.
  22909. */
  22910. getHeightAtCoordinates(x: number, z: number): number;
  22911. /**
  22912. * Returns a normalized vector (Vector3) orthogonal to the ground
  22913. * at the ground coordinates (x, z) expressed in the World system.
  22914. * @param x x coordinate
  22915. * @param z z coordinate
  22916. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22917. */
  22918. getNormalAtCoordinates(x: number, z: number): Vector3;
  22919. /**
  22920. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22921. * at the ground coordinates (x, z) expressed in the World system.
  22922. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22923. * @param x x coordinate
  22924. * @param z z coordinate
  22925. * @param ref vector to store the result
  22926. * @returns the GroundMesh.
  22927. */
  22928. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22929. /**
  22930. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22931. * if the ground has been updated.
  22932. * This can be used in the render loop.
  22933. * @returns the GroundMesh.
  22934. */
  22935. updateCoordinateHeights(): GroundMesh;
  22936. private _getFacetAt;
  22937. private _initHeightQuads;
  22938. private _computeHeightQuads;
  22939. /**
  22940. * Serializes this ground mesh
  22941. * @param serializationObject object to write serialization to
  22942. */
  22943. serialize(serializationObject: any): void;
  22944. /**
  22945. * Parses a serialized ground mesh
  22946. * @param parsedMesh the serialized mesh
  22947. * @param scene the scene to create the ground mesh in
  22948. * @returns the created ground mesh
  22949. */
  22950. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22951. }
  22952. }
  22953. declare module "babylonjs/Physics/physicsJoint" {
  22954. import { Vector3 } from "babylonjs/Maths/math.vector";
  22955. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22956. /**
  22957. * Interface for Physics-Joint data
  22958. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22959. */
  22960. export interface PhysicsJointData {
  22961. /**
  22962. * The main pivot of the joint
  22963. */
  22964. mainPivot?: Vector3;
  22965. /**
  22966. * The connected pivot of the joint
  22967. */
  22968. connectedPivot?: Vector3;
  22969. /**
  22970. * The main axis of the joint
  22971. */
  22972. mainAxis?: Vector3;
  22973. /**
  22974. * The connected axis of the joint
  22975. */
  22976. connectedAxis?: Vector3;
  22977. /**
  22978. * The collision of the joint
  22979. */
  22980. collision?: boolean;
  22981. /**
  22982. * Native Oimo/Cannon/Energy data
  22983. */
  22984. nativeParams?: any;
  22985. }
  22986. /**
  22987. * This is a holder class for the physics joint created by the physics plugin
  22988. * It holds a set of functions to control the underlying joint
  22989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22990. */
  22991. export class PhysicsJoint {
  22992. /**
  22993. * The type of the physics joint
  22994. */
  22995. type: number;
  22996. /**
  22997. * The data for the physics joint
  22998. */
  22999. jointData: PhysicsJointData;
  23000. private _physicsJoint;
  23001. protected _physicsPlugin: IPhysicsEnginePlugin;
  23002. /**
  23003. * Initializes the physics joint
  23004. * @param type The type of the physics joint
  23005. * @param jointData The data for the physics joint
  23006. */
  23007. constructor(
  23008. /**
  23009. * The type of the physics joint
  23010. */
  23011. type: number,
  23012. /**
  23013. * The data for the physics joint
  23014. */
  23015. jointData: PhysicsJointData);
  23016. /**
  23017. * Gets the physics joint
  23018. */
  23019. /**
  23020. * Sets the physics joint
  23021. */
  23022. physicsJoint: any;
  23023. /**
  23024. * Sets the physics plugin
  23025. */
  23026. physicsPlugin: IPhysicsEnginePlugin;
  23027. /**
  23028. * Execute a function that is physics-plugin specific.
  23029. * @param {Function} func the function that will be executed.
  23030. * It accepts two parameters: the physics world and the physics joint
  23031. */
  23032. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23033. /**
  23034. * Distance-Joint type
  23035. */
  23036. static DistanceJoint: number;
  23037. /**
  23038. * Hinge-Joint type
  23039. */
  23040. static HingeJoint: number;
  23041. /**
  23042. * Ball-and-Socket joint type
  23043. */
  23044. static BallAndSocketJoint: number;
  23045. /**
  23046. * Wheel-Joint type
  23047. */
  23048. static WheelJoint: number;
  23049. /**
  23050. * Slider-Joint type
  23051. */
  23052. static SliderJoint: number;
  23053. /**
  23054. * Prismatic-Joint type
  23055. */
  23056. static PrismaticJoint: number;
  23057. /**
  23058. * Universal-Joint type
  23059. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23060. */
  23061. static UniversalJoint: number;
  23062. /**
  23063. * Hinge-Joint 2 type
  23064. */
  23065. static Hinge2Joint: number;
  23066. /**
  23067. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23068. */
  23069. static PointToPointJoint: number;
  23070. /**
  23071. * Spring-Joint type
  23072. */
  23073. static SpringJoint: number;
  23074. /**
  23075. * Lock-Joint type
  23076. */
  23077. static LockJoint: number;
  23078. }
  23079. /**
  23080. * A class representing a physics distance joint
  23081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23082. */
  23083. export class DistanceJoint extends PhysicsJoint {
  23084. /**
  23085. *
  23086. * @param jointData The data for the Distance-Joint
  23087. */
  23088. constructor(jointData: DistanceJointData);
  23089. /**
  23090. * Update the predefined distance.
  23091. * @param maxDistance The maximum preferred distance
  23092. * @param minDistance The minimum preferred distance
  23093. */
  23094. updateDistance(maxDistance: number, minDistance?: number): void;
  23095. }
  23096. /**
  23097. * Represents a Motor-Enabled Joint
  23098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23099. */
  23100. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23101. /**
  23102. * Initializes the Motor-Enabled Joint
  23103. * @param type The type of the joint
  23104. * @param jointData The physica joint data for the joint
  23105. */
  23106. constructor(type: number, jointData: PhysicsJointData);
  23107. /**
  23108. * Set the motor values.
  23109. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23110. * @param force the force to apply
  23111. * @param maxForce max force for this motor.
  23112. */
  23113. setMotor(force?: number, maxForce?: number): void;
  23114. /**
  23115. * Set the motor's limits.
  23116. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23117. * @param upperLimit The upper limit of the motor
  23118. * @param lowerLimit The lower limit of the motor
  23119. */
  23120. setLimit(upperLimit: number, lowerLimit?: number): void;
  23121. }
  23122. /**
  23123. * This class represents a single physics Hinge-Joint
  23124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23125. */
  23126. export class HingeJoint extends MotorEnabledJoint {
  23127. /**
  23128. * Initializes the Hinge-Joint
  23129. * @param jointData The joint data for the Hinge-Joint
  23130. */
  23131. constructor(jointData: PhysicsJointData);
  23132. /**
  23133. * Set the motor values.
  23134. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23135. * @param {number} force the force to apply
  23136. * @param {number} maxForce max force for this motor.
  23137. */
  23138. setMotor(force?: number, maxForce?: number): void;
  23139. /**
  23140. * Set the motor's limits.
  23141. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23142. * @param upperLimit The upper limit of the motor
  23143. * @param lowerLimit The lower limit of the motor
  23144. */
  23145. setLimit(upperLimit: number, lowerLimit?: number): void;
  23146. }
  23147. /**
  23148. * This class represents a dual hinge physics joint (same as wheel joint)
  23149. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23150. */
  23151. export class Hinge2Joint extends MotorEnabledJoint {
  23152. /**
  23153. * Initializes the Hinge2-Joint
  23154. * @param jointData The joint data for the Hinge2-Joint
  23155. */
  23156. constructor(jointData: PhysicsJointData);
  23157. /**
  23158. * Set the motor values.
  23159. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23160. * @param {number} targetSpeed the speed the motor is to reach
  23161. * @param {number} maxForce max force for this motor.
  23162. * @param {motorIndex} the motor's index, 0 or 1.
  23163. */
  23164. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23165. /**
  23166. * Set the motor limits.
  23167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23168. * @param {number} upperLimit the upper limit
  23169. * @param {number} lowerLimit lower limit
  23170. * @param {motorIndex} the motor's index, 0 or 1.
  23171. */
  23172. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23173. }
  23174. /**
  23175. * Interface for a motor enabled joint
  23176. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23177. */
  23178. export interface IMotorEnabledJoint {
  23179. /**
  23180. * Physics joint
  23181. */
  23182. physicsJoint: any;
  23183. /**
  23184. * Sets the motor of the motor-enabled joint
  23185. * @param force The force of the motor
  23186. * @param maxForce The maximum force of the motor
  23187. * @param motorIndex The index of the motor
  23188. */
  23189. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23190. /**
  23191. * Sets the limit of the motor
  23192. * @param upperLimit The upper limit of the motor
  23193. * @param lowerLimit The lower limit of the motor
  23194. * @param motorIndex The index of the motor
  23195. */
  23196. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23197. }
  23198. /**
  23199. * Joint data for a Distance-Joint
  23200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23201. */
  23202. export interface DistanceJointData extends PhysicsJointData {
  23203. /**
  23204. * Max distance the 2 joint objects can be apart
  23205. */
  23206. maxDistance: number;
  23207. }
  23208. /**
  23209. * Joint data from a spring joint
  23210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23211. */
  23212. export interface SpringJointData extends PhysicsJointData {
  23213. /**
  23214. * Length of the spring
  23215. */
  23216. length: number;
  23217. /**
  23218. * Stiffness of the spring
  23219. */
  23220. stiffness: number;
  23221. /**
  23222. * Damping of the spring
  23223. */
  23224. damping: number;
  23225. /** this callback will be called when applying the force to the impostors. */
  23226. forceApplicationCallback: () => void;
  23227. }
  23228. }
  23229. declare module "babylonjs/Physics/physicsRaycastResult" {
  23230. import { Vector3 } from "babylonjs/Maths/math.vector";
  23231. /**
  23232. * Holds the data for the raycast result
  23233. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23234. */
  23235. export class PhysicsRaycastResult {
  23236. private _hasHit;
  23237. private _hitDistance;
  23238. private _hitNormalWorld;
  23239. private _hitPointWorld;
  23240. private _rayFromWorld;
  23241. private _rayToWorld;
  23242. /**
  23243. * Gets if there was a hit
  23244. */
  23245. readonly hasHit: boolean;
  23246. /**
  23247. * Gets the distance from the hit
  23248. */
  23249. readonly hitDistance: number;
  23250. /**
  23251. * Gets the hit normal/direction in the world
  23252. */
  23253. readonly hitNormalWorld: Vector3;
  23254. /**
  23255. * Gets the hit point in the world
  23256. */
  23257. readonly hitPointWorld: Vector3;
  23258. /**
  23259. * Gets the ray "start point" of the ray in the world
  23260. */
  23261. readonly rayFromWorld: Vector3;
  23262. /**
  23263. * Gets the ray "end point" of the ray in the world
  23264. */
  23265. readonly rayToWorld: Vector3;
  23266. /**
  23267. * Sets the hit data (normal & point in world space)
  23268. * @param hitNormalWorld defines the normal in world space
  23269. * @param hitPointWorld defines the point in world space
  23270. */
  23271. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23272. /**
  23273. * Sets the distance from the start point to the hit point
  23274. * @param distance
  23275. */
  23276. setHitDistance(distance: number): void;
  23277. /**
  23278. * Calculates the distance manually
  23279. */
  23280. calculateHitDistance(): void;
  23281. /**
  23282. * Resets all the values to default
  23283. * @param from The from point on world space
  23284. * @param to The to point on world space
  23285. */
  23286. reset(from?: Vector3, to?: Vector3): void;
  23287. }
  23288. /**
  23289. * Interface for the size containing width and height
  23290. */
  23291. interface IXYZ {
  23292. /**
  23293. * X
  23294. */
  23295. x: number;
  23296. /**
  23297. * Y
  23298. */
  23299. y: number;
  23300. /**
  23301. * Z
  23302. */
  23303. z: number;
  23304. }
  23305. }
  23306. declare module "babylonjs/Physics/IPhysicsEngine" {
  23307. import { Nullable } from "babylonjs/types";
  23308. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23310. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23311. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23312. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23313. /**
  23314. * Interface used to describe a physics joint
  23315. */
  23316. export interface PhysicsImpostorJoint {
  23317. /** Defines the main impostor to which the joint is linked */
  23318. mainImpostor: PhysicsImpostor;
  23319. /** Defines the impostor that is connected to the main impostor using this joint */
  23320. connectedImpostor: PhysicsImpostor;
  23321. /** Defines the joint itself */
  23322. joint: PhysicsJoint;
  23323. }
  23324. /** @hidden */
  23325. export interface IPhysicsEnginePlugin {
  23326. world: any;
  23327. name: string;
  23328. setGravity(gravity: Vector3): void;
  23329. setTimeStep(timeStep: number): void;
  23330. getTimeStep(): number;
  23331. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23332. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23333. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23334. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23335. removePhysicsBody(impostor: PhysicsImpostor): void;
  23336. generateJoint(joint: PhysicsImpostorJoint): void;
  23337. removeJoint(joint: PhysicsImpostorJoint): void;
  23338. isSupported(): boolean;
  23339. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23340. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23342. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23343. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23344. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23345. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23346. getBodyMass(impostor: PhysicsImpostor): number;
  23347. getBodyFriction(impostor: PhysicsImpostor): number;
  23348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23349. getBodyRestitution(impostor: PhysicsImpostor): number;
  23350. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23351. getBodyPressure?(impostor: PhysicsImpostor): number;
  23352. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23353. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23354. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23355. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23356. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23357. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23358. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23359. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23360. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23361. sleepBody(impostor: PhysicsImpostor): void;
  23362. wakeUpBody(impostor: PhysicsImpostor): void;
  23363. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23364. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23365. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23366. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23367. getRadius(impostor: PhysicsImpostor): number;
  23368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23370. dispose(): void;
  23371. }
  23372. /**
  23373. * Interface used to define a physics engine
  23374. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23375. */
  23376. export interface IPhysicsEngine {
  23377. /**
  23378. * Gets the gravity vector used by the simulation
  23379. */
  23380. gravity: Vector3;
  23381. /**
  23382. * Sets the gravity vector used by the simulation
  23383. * @param gravity defines the gravity vector to use
  23384. */
  23385. setGravity(gravity: Vector3): void;
  23386. /**
  23387. * Set the time step of the physics engine.
  23388. * Default is 1/60.
  23389. * To slow it down, enter 1/600 for example.
  23390. * To speed it up, 1/30
  23391. * @param newTimeStep the new timestep to apply to this world.
  23392. */
  23393. setTimeStep(newTimeStep: number): void;
  23394. /**
  23395. * Get the time step of the physics engine.
  23396. * @returns the current time step
  23397. */
  23398. getTimeStep(): number;
  23399. /**
  23400. * Release all resources
  23401. */
  23402. dispose(): void;
  23403. /**
  23404. * Gets the name of the current physics plugin
  23405. * @returns the name of the plugin
  23406. */
  23407. getPhysicsPluginName(): string;
  23408. /**
  23409. * Adding a new impostor for the impostor tracking.
  23410. * This will be done by the impostor itself.
  23411. * @param impostor the impostor to add
  23412. */
  23413. addImpostor(impostor: PhysicsImpostor): void;
  23414. /**
  23415. * Remove an impostor from the engine.
  23416. * This impostor and its mesh will not longer be updated by the physics engine.
  23417. * @param impostor the impostor to remove
  23418. */
  23419. removeImpostor(impostor: PhysicsImpostor): void;
  23420. /**
  23421. * Add a joint to the physics engine
  23422. * @param mainImpostor defines the main impostor to which the joint is added.
  23423. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23424. * @param joint defines the joint that will connect both impostors.
  23425. */
  23426. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23427. /**
  23428. * Removes a joint from the simulation
  23429. * @param mainImpostor defines the impostor used with the joint
  23430. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23431. * @param joint defines the joint to remove
  23432. */
  23433. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23434. /**
  23435. * Gets the current plugin used to run the simulation
  23436. * @returns current plugin
  23437. */
  23438. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23439. /**
  23440. * Gets the list of physic impostors
  23441. * @returns an array of PhysicsImpostor
  23442. */
  23443. getImpostors(): Array<PhysicsImpostor>;
  23444. /**
  23445. * Gets the impostor for a physics enabled object
  23446. * @param object defines the object impersonated by the impostor
  23447. * @returns the PhysicsImpostor or null if not found
  23448. */
  23449. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23450. /**
  23451. * Gets the impostor for a physics body object
  23452. * @param body defines physics body used by the impostor
  23453. * @returns the PhysicsImpostor or null if not found
  23454. */
  23455. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23456. /**
  23457. * Does a raycast in the physics world
  23458. * @param from when should the ray start?
  23459. * @param to when should the ray end?
  23460. * @returns PhysicsRaycastResult
  23461. */
  23462. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23463. /**
  23464. * Called by the scene. No need to call it.
  23465. * @param delta defines the timespam between frames
  23466. */
  23467. _step(delta: number): void;
  23468. }
  23469. }
  23470. declare module "babylonjs/Physics/physicsImpostor" {
  23471. import { Nullable, IndicesArray } from "babylonjs/types";
  23472. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23473. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23475. import { Scene } from "babylonjs/scene";
  23476. import { Bone } from "babylonjs/Bones/bone";
  23477. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23478. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23479. import { Space } from "babylonjs/Maths/math.axis";
  23480. /**
  23481. * The interface for the physics imposter parameters
  23482. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23483. */
  23484. export interface PhysicsImpostorParameters {
  23485. /**
  23486. * The mass of the physics imposter
  23487. */
  23488. mass: number;
  23489. /**
  23490. * The friction of the physics imposter
  23491. */
  23492. friction?: number;
  23493. /**
  23494. * The coefficient of restitution of the physics imposter
  23495. */
  23496. restitution?: number;
  23497. /**
  23498. * The native options of the physics imposter
  23499. */
  23500. nativeOptions?: any;
  23501. /**
  23502. * Specifies if the parent should be ignored
  23503. */
  23504. ignoreParent?: boolean;
  23505. /**
  23506. * Specifies if bi-directional transformations should be disabled
  23507. */
  23508. disableBidirectionalTransformation?: boolean;
  23509. /**
  23510. * The pressure inside the physics imposter, soft object only
  23511. */
  23512. pressure?: number;
  23513. /**
  23514. * The stiffness the physics imposter, soft object only
  23515. */
  23516. stiffness?: number;
  23517. /**
  23518. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23519. */
  23520. velocityIterations?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23523. */
  23524. positionIterations?: number;
  23525. /**
  23526. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23527. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23528. * Add to fix multiple points
  23529. */
  23530. fixedPoints?: number;
  23531. /**
  23532. * The collision margin around a soft object
  23533. */
  23534. margin?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. damping?: number;
  23539. /**
  23540. * The path for a rope based on an extrusion
  23541. */
  23542. path?: any;
  23543. /**
  23544. * The shape of an extrusion used for a rope based on an extrusion
  23545. */
  23546. shape?: any;
  23547. }
  23548. /**
  23549. * Interface for a physics-enabled object
  23550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23551. */
  23552. export interface IPhysicsEnabledObject {
  23553. /**
  23554. * The position of the physics-enabled object
  23555. */
  23556. position: Vector3;
  23557. /**
  23558. * The rotation of the physics-enabled object
  23559. */
  23560. rotationQuaternion: Nullable<Quaternion>;
  23561. /**
  23562. * The scale of the physics-enabled object
  23563. */
  23564. scaling: Vector3;
  23565. /**
  23566. * The rotation of the physics-enabled object
  23567. */
  23568. rotation?: Vector3;
  23569. /**
  23570. * The parent of the physics-enabled object
  23571. */
  23572. parent?: any;
  23573. /**
  23574. * The bounding info of the physics-enabled object
  23575. * @returns The bounding info of the physics-enabled object
  23576. */
  23577. getBoundingInfo(): BoundingInfo;
  23578. /**
  23579. * Computes the world matrix
  23580. * @param force Specifies if the world matrix should be computed by force
  23581. * @returns A world matrix
  23582. */
  23583. computeWorldMatrix(force: boolean): Matrix;
  23584. /**
  23585. * Gets the world matrix
  23586. * @returns A world matrix
  23587. */
  23588. getWorldMatrix?(): Matrix;
  23589. /**
  23590. * Gets the child meshes
  23591. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23592. * @returns An array of abstract meshes
  23593. */
  23594. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23595. /**
  23596. * Gets the vertex data
  23597. * @param kind The type of vertex data
  23598. * @returns A nullable array of numbers, or a float32 array
  23599. */
  23600. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23601. /**
  23602. * Gets the indices from the mesh
  23603. * @returns A nullable array of index arrays
  23604. */
  23605. getIndices?(): Nullable<IndicesArray>;
  23606. /**
  23607. * Gets the scene from the mesh
  23608. * @returns the indices array or null
  23609. */
  23610. getScene?(): Scene;
  23611. /**
  23612. * Gets the absolute position from the mesh
  23613. * @returns the absolute position
  23614. */
  23615. getAbsolutePosition(): Vector3;
  23616. /**
  23617. * Gets the absolute pivot point from the mesh
  23618. * @returns the absolute pivot point
  23619. */
  23620. getAbsolutePivotPoint(): Vector3;
  23621. /**
  23622. * Rotates the mesh
  23623. * @param axis The axis of rotation
  23624. * @param amount The amount of rotation
  23625. * @param space The space of the rotation
  23626. * @returns The rotation transform node
  23627. */
  23628. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23629. /**
  23630. * Translates the mesh
  23631. * @param axis The axis of translation
  23632. * @param distance The distance of translation
  23633. * @param space The space of the translation
  23634. * @returns The transform node
  23635. */
  23636. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23637. /**
  23638. * Sets the absolute position of the mesh
  23639. * @param absolutePosition The absolute position of the mesh
  23640. * @returns The transform node
  23641. */
  23642. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23643. /**
  23644. * Gets the class name of the mesh
  23645. * @returns The class name
  23646. */
  23647. getClassName(): string;
  23648. }
  23649. /**
  23650. * Represents a physics imposter
  23651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23652. */
  23653. export class PhysicsImpostor {
  23654. /**
  23655. * The physics-enabled object used as the physics imposter
  23656. */
  23657. object: IPhysicsEnabledObject;
  23658. /**
  23659. * The type of the physics imposter
  23660. */
  23661. type: number;
  23662. private _options;
  23663. private _scene?;
  23664. /**
  23665. * The default object size of the imposter
  23666. */
  23667. static DEFAULT_OBJECT_SIZE: Vector3;
  23668. /**
  23669. * The identity quaternion of the imposter
  23670. */
  23671. static IDENTITY_QUATERNION: Quaternion;
  23672. /** @hidden */
  23673. _pluginData: any;
  23674. private _physicsEngine;
  23675. private _physicsBody;
  23676. private _bodyUpdateRequired;
  23677. private _onBeforePhysicsStepCallbacks;
  23678. private _onAfterPhysicsStepCallbacks;
  23679. /** @hidden */
  23680. _onPhysicsCollideCallbacks: Array<{
  23681. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23682. otherImpostors: Array<PhysicsImpostor>;
  23683. }>;
  23684. private _deltaPosition;
  23685. private _deltaRotation;
  23686. private _deltaRotationConjugated;
  23687. /** @hidden */
  23688. _isFromLine: boolean;
  23689. private _parent;
  23690. private _isDisposed;
  23691. private static _tmpVecs;
  23692. private static _tmpQuat;
  23693. /**
  23694. * Specifies if the physics imposter is disposed
  23695. */
  23696. readonly isDisposed: boolean;
  23697. /**
  23698. * Gets the mass of the physics imposter
  23699. */
  23700. mass: number;
  23701. /**
  23702. * Gets the coefficient of friction
  23703. */
  23704. /**
  23705. * Sets the coefficient of friction
  23706. */
  23707. friction: number;
  23708. /**
  23709. * Gets the coefficient of restitution
  23710. */
  23711. /**
  23712. * Sets the coefficient of restitution
  23713. */
  23714. restitution: number;
  23715. /**
  23716. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23717. */
  23718. /**
  23719. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23720. */
  23721. pressure: number;
  23722. /**
  23723. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. /**
  23726. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23727. */
  23728. stiffness: number;
  23729. /**
  23730. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. /**
  23733. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23734. */
  23735. velocityIterations: number;
  23736. /**
  23737. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. /**
  23740. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23741. */
  23742. positionIterations: number;
  23743. /**
  23744. * The unique id of the physics imposter
  23745. * set by the physics engine when adding this impostor to the array
  23746. */
  23747. uniqueId: number;
  23748. /**
  23749. * @hidden
  23750. */
  23751. soft: boolean;
  23752. /**
  23753. * @hidden
  23754. */
  23755. segments: number;
  23756. private _joints;
  23757. /**
  23758. * Initializes the physics imposter
  23759. * @param object The physics-enabled object used as the physics imposter
  23760. * @param type The type of the physics imposter
  23761. * @param _options The options for the physics imposter
  23762. * @param _scene The Babylon scene
  23763. */
  23764. constructor(
  23765. /**
  23766. * The physics-enabled object used as the physics imposter
  23767. */
  23768. object: IPhysicsEnabledObject,
  23769. /**
  23770. * The type of the physics imposter
  23771. */
  23772. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23773. /**
  23774. * This function will completly initialize this impostor.
  23775. * It will create a new body - but only if this mesh has no parent.
  23776. * If it has, this impostor will not be used other than to define the impostor
  23777. * of the child mesh.
  23778. * @hidden
  23779. */
  23780. _init(): void;
  23781. private _getPhysicsParent;
  23782. /**
  23783. * Should a new body be generated.
  23784. * @returns boolean specifying if body initialization is required
  23785. */
  23786. isBodyInitRequired(): boolean;
  23787. /**
  23788. * Sets the updated scaling
  23789. * @param updated Specifies if the scaling is updated
  23790. */
  23791. setScalingUpdated(): void;
  23792. /**
  23793. * Force a regeneration of this or the parent's impostor's body.
  23794. * Use under cautious - This will remove all joints already implemented.
  23795. */
  23796. forceUpdate(): void;
  23797. /**
  23798. * Gets the body that holds this impostor. Either its own, or its parent.
  23799. */
  23800. /**
  23801. * Set the physics body. Used mainly by the physics engine/plugin
  23802. */
  23803. physicsBody: any;
  23804. /**
  23805. * Get the parent of the physics imposter
  23806. * @returns Physics imposter or null
  23807. */
  23808. /**
  23809. * Sets the parent of the physics imposter
  23810. */
  23811. parent: Nullable<PhysicsImpostor>;
  23812. /**
  23813. * Resets the update flags
  23814. */
  23815. resetUpdateFlags(): void;
  23816. /**
  23817. * Gets the object extend size
  23818. * @returns the object extend size
  23819. */
  23820. getObjectExtendSize(): Vector3;
  23821. /**
  23822. * Gets the object center
  23823. * @returns The object center
  23824. */
  23825. getObjectCenter(): Vector3;
  23826. /**
  23827. * Get a specific parametes from the options parameter
  23828. * @param paramName The object parameter name
  23829. * @returns The object parameter
  23830. */
  23831. getParam(paramName: string): any;
  23832. /**
  23833. * Sets a specific parameter in the options given to the physics plugin
  23834. * @param paramName The parameter name
  23835. * @param value The value of the parameter
  23836. */
  23837. setParam(paramName: string, value: number): void;
  23838. /**
  23839. * Specifically change the body's mass option. Won't recreate the physics body object
  23840. * @param mass The mass of the physics imposter
  23841. */
  23842. setMass(mass: number): void;
  23843. /**
  23844. * Gets the linear velocity
  23845. * @returns linear velocity or null
  23846. */
  23847. getLinearVelocity(): Nullable<Vector3>;
  23848. /**
  23849. * Sets the linear velocity
  23850. * @param velocity linear velocity or null
  23851. */
  23852. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23853. /**
  23854. * Gets the angular velocity
  23855. * @returns angular velocity or null
  23856. */
  23857. getAngularVelocity(): Nullable<Vector3>;
  23858. /**
  23859. * Sets the angular velocity
  23860. * @param velocity The velocity or null
  23861. */
  23862. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23863. /**
  23864. * Execute a function with the physics plugin native code
  23865. * Provide a function the will have two variables - the world object and the physics body object
  23866. * @param func The function to execute with the physics plugin native code
  23867. */
  23868. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23869. /**
  23870. * Register a function that will be executed before the physics world is stepping forward
  23871. * @param func The function to execute before the physics world is stepped forward
  23872. */
  23873. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23874. /**
  23875. * Unregister a function that will be executed before the physics world is stepping forward
  23876. * @param func The function to execute before the physics world is stepped forward
  23877. */
  23878. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23879. /**
  23880. * Register a function that will be executed after the physics step
  23881. * @param func The function to execute after physics step
  23882. */
  23883. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23884. /**
  23885. * Unregisters a function that will be executed after the physics step
  23886. * @param func The function to execute after physics step
  23887. */
  23888. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23889. /**
  23890. * register a function that will be executed when this impostor collides against a different body
  23891. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23892. * @param func Callback that is executed on collision
  23893. */
  23894. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23895. /**
  23896. * Unregisters the physics imposter on contact
  23897. * @param collideAgainst The physics object to collide against
  23898. * @param func Callback to execute on collision
  23899. */
  23900. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23901. private _tmpQuat;
  23902. private _tmpQuat2;
  23903. /**
  23904. * Get the parent rotation
  23905. * @returns The parent rotation
  23906. */
  23907. getParentsRotation(): Quaternion;
  23908. /**
  23909. * this function is executed by the physics engine.
  23910. */
  23911. beforeStep: () => void;
  23912. /**
  23913. * this function is executed by the physics engine
  23914. */
  23915. afterStep: () => void;
  23916. /**
  23917. * Legacy collision detection event support
  23918. */
  23919. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23920. /**
  23921. * event and body object due to cannon's event-based architecture.
  23922. */
  23923. onCollide: (e: {
  23924. body: any;
  23925. }) => void;
  23926. /**
  23927. * Apply a force
  23928. * @param force The force to apply
  23929. * @param contactPoint The contact point for the force
  23930. * @returns The physics imposter
  23931. */
  23932. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23933. /**
  23934. * Apply an impulse
  23935. * @param force The impulse force
  23936. * @param contactPoint The contact point for the impulse force
  23937. * @returns The physics imposter
  23938. */
  23939. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23940. /**
  23941. * A help function to create a joint
  23942. * @param otherImpostor A physics imposter used to create a joint
  23943. * @param jointType The type of joint
  23944. * @param jointData The data for the joint
  23945. * @returns The physics imposter
  23946. */
  23947. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23948. /**
  23949. * Add a joint to this impostor with a different impostor
  23950. * @param otherImpostor A physics imposter used to add a joint
  23951. * @param joint The joint to add
  23952. * @returns The physics imposter
  23953. */
  23954. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23955. /**
  23956. * Add an anchor to a cloth impostor
  23957. * @param otherImpostor rigid impostor to anchor to
  23958. * @param width ratio across width from 0 to 1
  23959. * @param height ratio up height from 0 to 1
  23960. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23961. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23962. * @returns impostor the soft imposter
  23963. */
  23964. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23965. /**
  23966. * Add a hook to a rope impostor
  23967. * @param otherImpostor rigid impostor to anchor to
  23968. * @param length ratio across rope from 0 to 1
  23969. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23970. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23971. * @returns impostor the rope imposter
  23972. */
  23973. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23974. /**
  23975. * Will keep this body still, in a sleep mode.
  23976. * @returns the physics imposter
  23977. */
  23978. sleep(): PhysicsImpostor;
  23979. /**
  23980. * Wake the body up.
  23981. * @returns The physics imposter
  23982. */
  23983. wakeUp(): PhysicsImpostor;
  23984. /**
  23985. * Clones the physics imposter
  23986. * @param newObject The physics imposter clones to this physics-enabled object
  23987. * @returns A nullable physics imposter
  23988. */
  23989. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23990. /**
  23991. * Disposes the physics imposter
  23992. */
  23993. dispose(): void;
  23994. /**
  23995. * Sets the delta position
  23996. * @param position The delta position amount
  23997. */
  23998. setDeltaPosition(position: Vector3): void;
  23999. /**
  24000. * Sets the delta rotation
  24001. * @param rotation The delta rotation amount
  24002. */
  24003. setDeltaRotation(rotation: Quaternion): void;
  24004. /**
  24005. * Gets the box size of the physics imposter and stores the result in the input parameter
  24006. * @param result Stores the box size
  24007. * @returns The physics imposter
  24008. */
  24009. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24010. /**
  24011. * Gets the radius of the physics imposter
  24012. * @returns Radius of the physics imposter
  24013. */
  24014. getRadius(): number;
  24015. /**
  24016. * Sync a bone with this impostor
  24017. * @param bone The bone to sync to the impostor.
  24018. * @param boneMesh The mesh that the bone is influencing.
  24019. * @param jointPivot The pivot of the joint / bone in local space.
  24020. * @param distToJoint Optional distance from the impostor to the joint.
  24021. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24022. */
  24023. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24024. /**
  24025. * Sync impostor to a bone
  24026. * @param bone The bone that the impostor will be synced to.
  24027. * @param boneMesh The mesh that the bone is influencing.
  24028. * @param jointPivot The pivot of the joint / bone in local space.
  24029. * @param distToJoint Optional distance from the impostor to the joint.
  24030. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24031. * @param boneAxis Optional vector3 axis the bone is aligned with
  24032. */
  24033. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24034. /**
  24035. * No-Imposter type
  24036. */
  24037. static NoImpostor: number;
  24038. /**
  24039. * Sphere-Imposter type
  24040. */
  24041. static SphereImpostor: number;
  24042. /**
  24043. * Box-Imposter type
  24044. */
  24045. static BoxImpostor: number;
  24046. /**
  24047. * Plane-Imposter type
  24048. */
  24049. static PlaneImpostor: number;
  24050. /**
  24051. * Mesh-imposter type
  24052. */
  24053. static MeshImpostor: number;
  24054. /**
  24055. * Capsule-Impostor type (Ammo.js plugin only)
  24056. */
  24057. static CapsuleImpostor: number;
  24058. /**
  24059. * Cylinder-Imposter type
  24060. */
  24061. static CylinderImpostor: number;
  24062. /**
  24063. * Particle-Imposter type
  24064. */
  24065. static ParticleImpostor: number;
  24066. /**
  24067. * Heightmap-Imposter type
  24068. */
  24069. static HeightmapImpostor: number;
  24070. /**
  24071. * ConvexHull-Impostor type (Ammo.js plugin only)
  24072. */
  24073. static ConvexHullImpostor: number;
  24074. /**
  24075. * Rope-Imposter type
  24076. */
  24077. static RopeImpostor: number;
  24078. /**
  24079. * Cloth-Imposter type
  24080. */
  24081. static ClothImpostor: number;
  24082. /**
  24083. * Softbody-Imposter type
  24084. */
  24085. static SoftbodyImpostor: number;
  24086. }
  24087. }
  24088. declare module "babylonjs/Meshes/mesh" {
  24089. import { Observable } from "babylonjs/Misc/observable";
  24090. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24091. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24092. import { Camera } from "babylonjs/Cameras/camera";
  24093. import { Scene } from "babylonjs/scene";
  24094. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24095. import { Color4 } from "babylonjs/Maths/math.color";
  24096. import { Engine } from "babylonjs/Engines/engine";
  24097. import { Node } from "babylonjs/node";
  24098. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24099. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24100. import { Buffer } from "babylonjs/Meshes/buffer";
  24101. import { Geometry } from "babylonjs/Meshes/geometry";
  24102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24103. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24104. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24105. import { Effect } from "babylonjs/Materials/effect";
  24106. import { Material } from "babylonjs/Materials/material";
  24107. import { Skeleton } from "babylonjs/Bones/skeleton";
  24108. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24109. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24110. import { Path3D } from "babylonjs/Maths/math.path";
  24111. import { Plane } from "babylonjs/Maths/math.plane";
  24112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24113. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24114. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24115. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24116. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24117. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24118. /**
  24119. * @hidden
  24120. **/
  24121. export class _CreationDataStorage {
  24122. closePath?: boolean;
  24123. closeArray?: boolean;
  24124. idx: number[];
  24125. dashSize: number;
  24126. gapSize: number;
  24127. path3D: Path3D;
  24128. pathArray: Vector3[][];
  24129. arc: number;
  24130. radius: number;
  24131. cap: number;
  24132. tessellation: number;
  24133. }
  24134. /**
  24135. * @hidden
  24136. **/
  24137. class _InstanceDataStorage {
  24138. visibleInstances: any;
  24139. batchCache: _InstancesBatch;
  24140. instancesBufferSize: number;
  24141. instancesBuffer: Nullable<Buffer>;
  24142. instancesData: Float32Array;
  24143. overridenInstanceCount: number;
  24144. isFrozen: boolean;
  24145. previousBatch: Nullable<_InstancesBatch>;
  24146. hardwareInstancedRendering: boolean;
  24147. sideOrientation: number;
  24148. }
  24149. /**
  24150. * @hidden
  24151. **/
  24152. export class _InstancesBatch {
  24153. mustReturn: boolean;
  24154. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24155. renderSelf: boolean[];
  24156. hardwareInstancedRendering: boolean[];
  24157. }
  24158. /**
  24159. * Class used to represent renderable models
  24160. */
  24161. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24162. /**
  24163. * Mesh side orientation : usually the external or front surface
  24164. */
  24165. static readonly FRONTSIDE: number;
  24166. /**
  24167. * Mesh side orientation : usually the internal or back surface
  24168. */
  24169. static readonly BACKSIDE: number;
  24170. /**
  24171. * Mesh side orientation : both internal and external or front and back surfaces
  24172. */
  24173. static readonly DOUBLESIDE: number;
  24174. /**
  24175. * Mesh side orientation : by default, `FRONTSIDE`
  24176. */
  24177. static readonly DEFAULTSIDE: number;
  24178. /**
  24179. * Mesh cap setting : no cap
  24180. */
  24181. static readonly NO_CAP: number;
  24182. /**
  24183. * Mesh cap setting : one cap at the beginning of the mesh
  24184. */
  24185. static readonly CAP_START: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the end of the mesh
  24188. */
  24189. static readonly CAP_END: number;
  24190. /**
  24191. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24192. */
  24193. static readonly CAP_ALL: number;
  24194. /**
  24195. * Mesh pattern setting : no flip or rotate
  24196. */
  24197. static readonly NO_FLIP: number;
  24198. /**
  24199. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24200. */
  24201. static readonly FLIP_TILE: number;
  24202. /**
  24203. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24204. */
  24205. static readonly ROTATE_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24208. */
  24209. static readonly FLIP_ROW: number;
  24210. /**
  24211. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24212. */
  24213. static readonly ROTATE_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24216. */
  24217. static readonly FLIP_N_ROTATE_TILE: number;
  24218. /**
  24219. * Mesh pattern setting : rotate pattern and rotate
  24220. */
  24221. static readonly FLIP_N_ROTATE_ROW: number;
  24222. /**
  24223. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24224. */
  24225. static readonly CENTER: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles on left
  24228. */
  24229. static readonly LEFT: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on right
  24232. */
  24233. static readonly RIGHT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on top
  24236. */
  24237. static readonly TOP: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on bottom
  24240. */
  24241. static readonly BOTTOM: number;
  24242. /**
  24243. * Gets the default side orientation.
  24244. * @param orientation the orientation to value to attempt to get
  24245. * @returns the default orientation
  24246. * @hidden
  24247. */
  24248. static _GetDefaultSideOrientation(orientation?: number): number;
  24249. private _internalMeshDataInfo;
  24250. /**
  24251. * An event triggered before rendering the mesh
  24252. */
  24253. readonly onBeforeRenderObservable: Observable<Mesh>;
  24254. /**
  24255. * An event triggered before binding the mesh
  24256. */
  24257. readonly onBeforeBindObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered after rendering the mesh
  24260. */
  24261. readonly onAfterRenderObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered before drawing the mesh
  24264. */
  24265. readonly onBeforeDrawObservable: Observable<Mesh>;
  24266. private _onBeforeDrawObserver;
  24267. /**
  24268. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24269. */
  24270. onBeforeDraw: () => void;
  24271. readonly hasInstances: boolean;
  24272. /**
  24273. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24274. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24275. */
  24276. delayLoadState: number;
  24277. /**
  24278. * Gets the list of instances created from this mesh
  24279. * it is not supposed to be modified manually.
  24280. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24281. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24282. */
  24283. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24284. /**
  24285. * Gets the file containing delay loading data for this mesh
  24286. */
  24287. delayLoadingFile: string;
  24288. /** @hidden */
  24289. _binaryInfo: any;
  24290. /**
  24291. * User defined function used to change how LOD level selection is done
  24292. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24293. */
  24294. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24295. /**
  24296. * Gets or sets the morph target manager
  24297. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24298. */
  24299. morphTargetManager: Nullable<MorphTargetManager>;
  24300. /** @hidden */
  24301. _creationDataStorage: Nullable<_CreationDataStorage>;
  24302. /** @hidden */
  24303. _geometry: Nullable<Geometry>;
  24304. /** @hidden */
  24305. _delayInfo: Array<string>;
  24306. /** @hidden */
  24307. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24308. /** @hidden */
  24309. _instanceDataStorage: _InstanceDataStorage;
  24310. private _effectiveMaterial;
  24311. /** @hidden */
  24312. _shouldGenerateFlatShading: boolean;
  24313. /** @hidden */
  24314. _originalBuilderSideOrientation: number;
  24315. /**
  24316. * Use this property to change the original side orientation defined at construction time
  24317. */
  24318. overrideMaterialSideOrientation: Nullable<number>;
  24319. /**
  24320. * Gets the source mesh (the one used to clone this one from)
  24321. */
  24322. readonly source: Nullable<Mesh>;
  24323. /**
  24324. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24325. */
  24326. isUnIndexed: boolean;
  24327. /**
  24328. * @constructor
  24329. * @param name The value used by scene.getMeshByName() to do a lookup.
  24330. * @param scene The scene to add this mesh to.
  24331. * @param parent The parent of this mesh, if it has one
  24332. * @param source An optional Mesh from which geometry is shared, cloned.
  24333. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24334. * When false, achieved by calling a clone(), also passing False.
  24335. * This will make creation of children, recursive.
  24336. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24337. */
  24338. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24339. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24340. /**
  24341. * Gets the class name
  24342. * @returns the string "Mesh".
  24343. */
  24344. getClassName(): string;
  24345. /** @hidden */
  24346. readonly _isMesh: boolean;
  24347. /**
  24348. * Returns a description of this mesh
  24349. * @param fullDetails define if full details about this mesh must be used
  24350. * @returns a descriptive string representing this mesh
  24351. */
  24352. toString(fullDetails?: boolean): string;
  24353. /** @hidden */
  24354. _unBindEffect(): void;
  24355. /**
  24356. * Gets a boolean indicating if this mesh has LOD
  24357. */
  24358. readonly hasLODLevels: boolean;
  24359. /**
  24360. * Gets the list of MeshLODLevel associated with the current mesh
  24361. * @returns an array of MeshLODLevel
  24362. */
  24363. getLODLevels(): MeshLODLevel[];
  24364. private _sortLODLevels;
  24365. /**
  24366. * Add a mesh as LOD level triggered at the given distance.
  24367. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24368. * @param distance The distance from the center of the object to show this level
  24369. * @param mesh The mesh to be added as LOD level (can be null)
  24370. * @return This mesh (for chaining)
  24371. */
  24372. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24373. /**
  24374. * Returns the LOD level mesh at the passed distance or null if not found.
  24375. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24376. * @param distance The distance from the center of the object to show this level
  24377. * @returns a Mesh or `null`
  24378. */
  24379. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24380. /**
  24381. * Remove a mesh from the LOD array
  24382. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24383. * @param mesh defines the mesh to be removed
  24384. * @return This mesh (for chaining)
  24385. */
  24386. removeLODLevel(mesh: Mesh): Mesh;
  24387. /**
  24388. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24389. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24390. * @param camera defines the camera to use to compute distance
  24391. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24392. * @return This mesh (for chaining)
  24393. */
  24394. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24395. /**
  24396. * Gets the mesh internal Geometry object
  24397. */
  24398. readonly geometry: Nullable<Geometry>;
  24399. /**
  24400. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24401. * @returns the total number of vertices
  24402. */
  24403. getTotalVertices(): number;
  24404. /**
  24405. * Returns the content of an associated vertex buffer
  24406. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24407. * - VertexBuffer.PositionKind
  24408. * - VertexBuffer.UVKind
  24409. * - VertexBuffer.UV2Kind
  24410. * - VertexBuffer.UV3Kind
  24411. * - VertexBuffer.UV4Kind
  24412. * - VertexBuffer.UV5Kind
  24413. * - VertexBuffer.UV6Kind
  24414. * - VertexBuffer.ColorKind
  24415. * - VertexBuffer.MatricesIndicesKind
  24416. * - VertexBuffer.MatricesIndicesExtraKind
  24417. * - VertexBuffer.MatricesWeightsKind
  24418. * - VertexBuffer.MatricesWeightsExtraKind
  24419. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  24420. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24421. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24422. */
  24423. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24424. /**
  24425. * Returns the mesh VertexBuffer object from the requested `kind`
  24426. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24427. * - VertexBuffer.PositionKind
  24428. * - VertexBuffer.NormalKind
  24429. * - VertexBuffer.UVKind
  24430. * - VertexBuffer.UV2Kind
  24431. * - VertexBuffer.UV3Kind
  24432. * - VertexBuffer.UV4Kind
  24433. * - VertexBuffer.UV5Kind
  24434. * - VertexBuffer.UV6Kind
  24435. * - VertexBuffer.ColorKind
  24436. * - VertexBuffer.MatricesIndicesKind
  24437. * - VertexBuffer.MatricesIndicesExtraKind
  24438. * - VertexBuffer.MatricesWeightsKind
  24439. * - VertexBuffer.MatricesWeightsExtraKind
  24440. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24441. */
  24442. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24443. /**
  24444. * Tests if a specific vertex buffer is associated with this mesh
  24445. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24446. * - VertexBuffer.PositionKind
  24447. * - VertexBuffer.NormalKind
  24448. * - VertexBuffer.UVKind
  24449. * - VertexBuffer.UV2Kind
  24450. * - VertexBuffer.UV3Kind
  24451. * - VertexBuffer.UV4Kind
  24452. * - VertexBuffer.UV5Kind
  24453. * - VertexBuffer.UV6Kind
  24454. * - VertexBuffer.ColorKind
  24455. * - VertexBuffer.MatricesIndicesKind
  24456. * - VertexBuffer.MatricesIndicesExtraKind
  24457. * - VertexBuffer.MatricesWeightsKind
  24458. * - VertexBuffer.MatricesWeightsExtraKind
  24459. * @returns a boolean
  24460. */
  24461. isVerticesDataPresent(kind: string): boolean;
  24462. /**
  24463. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24464. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24465. * - VertexBuffer.PositionKind
  24466. * - VertexBuffer.UVKind
  24467. * - VertexBuffer.UV2Kind
  24468. * - VertexBuffer.UV3Kind
  24469. * - VertexBuffer.UV4Kind
  24470. * - VertexBuffer.UV5Kind
  24471. * - VertexBuffer.UV6Kind
  24472. * - VertexBuffer.ColorKind
  24473. * - VertexBuffer.MatricesIndicesKind
  24474. * - VertexBuffer.MatricesIndicesExtraKind
  24475. * - VertexBuffer.MatricesWeightsKind
  24476. * - VertexBuffer.MatricesWeightsExtraKind
  24477. * @returns a boolean
  24478. */
  24479. isVertexBufferUpdatable(kind: string): boolean;
  24480. /**
  24481. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24482. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24483. * - VertexBuffer.PositionKind
  24484. * - VertexBuffer.NormalKind
  24485. * - VertexBuffer.UVKind
  24486. * - VertexBuffer.UV2Kind
  24487. * - VertexBuffer.UV3Kind
  24488. * - VertexBuffer.UV4Kind
  24489. * - VertexBuffer.UV5Kind
  24490. * - VertexBuffer.UV6Kind
  24491. * - VertexBuffer.ColorKind
  24492. * - VertexBuffer.MatricesIndicesKind
  24493. * - VertexBuffer.MatricesIndicesExtraKind
  24494. * - VertexBuffer.MatricesWeightsKind
  24495. * - VertexBuffer.MatricesWeightsExtraKind
  24496. * @returns an array of strings
  24497. */
  24498. getVerticesDataKinds(): string[];
  24499. /**
  24500. * Returns a positive integer : the total number of indices in this mesh geometry.
  24501. * @returns the numner of indices or zero if the mesh has no geometry.
  24502. */
  24503. getTotalIndices(): number;
  24504. /**
  24505. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24506. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  24507. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24508. * @returns the indices array or an empty array if the mesh has no geometry
  24509. */
  24510. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24511. readonly isBlocked: boolean;
  24512. /**
  24513. * Determine if the current mesh is ready to be rendered
  24514. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24515. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24516. * @returns true if all associated assets are ready (material, textures, shaders)
  24517. */
  24518. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24519. /**
  24520. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  24521. */
  24522. readonly areNormalsFrozen: boolean;
  24523. /**
  24524. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  24525. * @returns the current mesh
  24526. */
  24527. freezeNormals(): Mesh;
  24528. /**
  24529. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  24530. * @returns the current mesh
  24531. */
  24532. unfreezeNormals(): Mesh;
  24533. /**
  24534. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24535. */
  24536. overridenInstanceCount: number;
  24537. /** @hidden */
  24538. _preActivate(): Mesh;
  24539. /** @hidden */
  24540. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24541. /** @hidden */
  24542. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24543. /**
  24544. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24545. * This means the mesh underlying bounding box and sphere are recomputed.
  24546. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24547. * @returns the current mesh
  24548. */
  24549. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24550. /** @hidden */
  24551. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24552. /**
  24553. * This function will subdivide the mesh into multiple submeshes
  24554. * @param count defines the expected number of submeshes
  24555. */
  24556. subdivide(count: number): void;
  24557. /**
  24558. * Copy a FloatArray into a specific associated vertex buffer
  24559. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24560. * - VertexBuffer.PositionKind
  24561. * - VertexBuffer.UVKind
  24562. * - VertexBuffer.UV2Kind
  24563. * - VertexBuffer.UV3Kind
  24564. * - VertexBuffer.UV4Kind
  24565. * - VertexBuffer.UV5Kind
  24566. * - VertexBuffer.UV6Kind
  24567. * - VertexBuffer.ColorKind
  24568. * - VertexBuffer.MatricesIndicesKind
  24569. * - VertexBuffer.MatricesIndicesExtraKind
  24570. * - VertexBuffer.MatricesWeightsKind
  24571. * - VertexBuffer.MatricesWeightsExtraKind
  24572. * @param data defines the data source
  24573. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24574. * @param stride defines the data stride size (can be null)
  24575. * @returns the current mesh
  24576. */
  24577. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24578. /**
  24579. * Flags an associated vertex buffer as updatable
  24580. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24581. * - VertexBuffer.PositionKind
  24582. * - VertexBuffer.UVKind
  24583. * - VertexBuffer.UV2Kind
  24584. * - VertexBuffer.UV3Kind
  24585. * - VertexBuffer.UV4Kind
  24586. * - VertexBuffer.UV5Kind
  24587. * - VertexBuffer.UV6Kind
  24588. * - VertexBuffer.ColorKind
  24589. * - VertexBuffer.MatricesIndicesKind
  24590. * - VertexBuffer.MatricesIndicesExtraKind
  24591. * - VertexBuffer.MatricesWeightsKind
  24592. * - VertexBuffer.MatricesWeightsExtraKind
  24593. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24594. */
  24595. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24596. /**
  24597. * Sets the mesh global Vertex Buffer
  24598. * @param buffer defines the buffer to use
  24599. * @returns the current mesh
  24600. */
  24601. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24602. /**
  24603. * Update a specific associated vertex buffer
  24604. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24605. * - VertexBuffer.PositionKind
  24606. * - VertexBuffer.UVKind
  24607. * - VertexBuffer.UV2Kind
  24608. * - VertexBuffer.UV3Kind
  24609. * - VertexBuffer.UV4Kind
  24610. * - VertexBuffer.UV5Kind
  24611. * - VertexBuffer.UV6Kind
  24612. * - VertexBuffer.ColorKind
  24613. * - VertexBuffer.MatricesIndicesKind
  24614. * - VertexBuffer.MatricesIndicesExtraKind
  24615. * - VertexBuffer.MatricesWeightsKind
  24616. * - VertexBuffer.MatricesWeightsExtraKind
  24617. * @param data defines the data source
  24618. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24619. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  24620. * @returns the current mesh
  24621. */
  24622. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24623. /**
  24624. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24625. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24626. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24627. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24628. * @returns the current mesh
  24629. */
  24630. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24631. /**
  24632. * Creates a un-shared specific occurence of the geometry for the mesh.
  24633. * @returns the current mesh
  24634. */
  24635. makeGeometryUnique(): Mesh;
  24636. /**
  24637. * Set the index buffer of this mesh
  24638. * @param indices defines the source data
  24639. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24640. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24641. * @returns the current mesh
  24642. */
  24643. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24644. /**
  24645. * Update the current index buffer
  24646. * @param indices defines the source data
  24647. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24648. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  24649. * @returns the current mesh
  24650. */
  24651. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24652. /**
  24653. * Invert the geometry to move from a right handed system to a left handed one.
  24654. * @returns the current mesh
  24655. */
  24656. toLeftHanded(): Mesh;
  24657. /** @hidden */
  24658. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24659. /** @hidden */
  24660. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24661. /**
  24662. * Registers for this mesh a javascript function called just before the rendering process
  24663. * @param func defines the function to call before rendering this mesh
  24664. * @returns the current mesh
  24665. */
  24666. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24667. /**
  24668. * Disposes a previously registered javascript function called before the rendering
  24669. * @param func defines the function to remove
  24670. * @returns the current mesh
  24671. */
  24672. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24673. /**
  24674. * Registers for this mesh a javascript function called just after the rendering is complete
  24675. * @param func defines the function to call after rendering this mesh
  24676. * @returns the current mesh
  24677. */
  24678. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24679. /**
  24680. * Disposes a previously registered javascript function called after the rendering.
  24681. * @param func defines the function to remove
  24682. * @returns the current mesh
  24683. */
  24684. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24685. /** @hidden */
  24686. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24687. /** @hidden */
  24688. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24689. /** @hidden */
  24690. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24691. /** @hidden */
  24692. _rebuild(): void;
  24693. /** @hidden */
  24694. _freeze(): void;
  24695. /** @hidden */
  24696. _unFreeze(): void;
  24697. /**
  24698. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  24699. * @param subMesh defines the subMesh to render
  24700. * @param enableAlphaMode defines if alpha mode can be changed
  24701. * @returns the current mesh
  24702. */
  24703. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24704. private _onBeforeDraw;
  24705. /**
  24706. * Renormalize the mesh and patch it up if there are no weights
  24707. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24708. * However in the case of zero weights then we set just a single influence to 1.
  24709. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24710. */
  24711. cleanMatrixWeights(): void;
  24712. private normalizeSkinFourWeights;
  24713. private normalizeSkinWeightsAndExtra;
  24714. /**
  24715. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24716. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24717. * the user know there was an issue with importing the mesh
  24718. * @returns a validation object with skinned, valid and report string
  24719. */
  24720. validateSkinning(): {
  24721. skinned: boolean;
  24722. valid: boolean;
  24723. report: string;
  24724. };
  24725. /** @hidden */
  24726. _checkDelayState(): Mesh;
  24727. private _queueLoad;
  24728. /**
  24729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24730. * A mesh is in the frustum if its bounding box intersects the frustum
  24731. * @param frustumPlanes defines the frustum to test
  24732. * @returns true if the mesh is in the frustum planes
  24733. */
  24734. isInFrustum(frustumPlanes: Plane[]): boolean;
  24735. /**
  24736. * Sets the mesh material by the material or multiMaterial `id` property
  24737. * @param id is a string identifying the material or the multiMaterial
  24738. * @returns the current mesh
  24739. */
  24740. setMaterialByID(id: string): Mesh;
  24741. /**
  24742. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24743. * @returns an array of IAnimatable
  24744. */
  24745. getAnimatables(): IAnimatable[];
  24746. /**
  24747. * Modifies the mesh geometry according to the passed transformation matrix.
  24748. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24749. * The mesh normals are modified using the same transformation.
  24750. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24751. * @param transform defines the transform matrix to use
  24752. * @see http://doc.babylonjs.com/resources/baking_transformations
  24753. * @returns the current mesh
  24754. */
  24755. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24756. /**
  24757. * Modifies the mesh geometry according to its own current World Matrix.
  24758. * The mesh World Matrix is then reset.
  24759. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24760. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24761. * @see http://doc.babylonjs.com/resources/baking_transformations
  24762. * @returns the current mesh
  24763. */
  24764. bakeCurrentTransformIntoVertices(): Mesh;
  24765. /** @hidden */
  24766. readonly _positions: Nullable<Vector3[]>;
  24767. /** @hidden */
  24768. _resetPointsArrayCache(): Mesh;
  24769. /** @hidden */
  24770. _generatePointsArray(): boolean;
  24771. /**
  24772. * Returns a new Mesh object generated from the current mesh properties.
  24773. * This method must not get confused with createInstance()
  24774. * @param name is a string, the name given to the new mesh
  24775. * @param newParent can be any Node object (default `null`)
  24776. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24777. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24778. * @returns a new mesh
  24779. */
  24780. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24781. /**
  24782. * Releases resources associated with this mesh.
  24783. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24784. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24785. */
  24786. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24787. /**
  24788. * Modifies the mesh geometry according to a displacement map.
  24789. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24790. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24791. * @param url is a string, the URL from the image file is to be downloaded.
  24792. * @param minHeight is the lower limit of the displacement.
  24793. * @param maxHeight is the upper limit of the displacement.
  24794. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24795. * @param uvOffset is an optional vector2 used to offset UV.
  24796. * @param uvScale is an optional vector2 used to scale UV.
  24797. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24798. * @returns the Mesh.
  24799. */
  24800. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24801. /**
  24802. * Modifies the mesh geometry according to a displacementMap buffer.
  24803. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  24804. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24805. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24806. * @param heightMapWidth is the width of the buffer image.
  24807. * @param heightMapHeight is the height of the buffer image.
  24808. * @param minHeight is the lower limit of the displacement.
  24809. * @param maxHeight is the upper limit of the displacement.
  24810. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  24811. * @param uvOffset is an optional vector2 used to offset UV.
  24812. * @param uvScale is an optional vector2 used to scale UV.
  24813. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  24814. * @returns the Mesh.
  24815. */
  24816. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24817. /**
  24818. * Modify the mesh to get a flat shading rendering.
  24819. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24820. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24821. * @returns current mesh
  24822. */
  24823. convertToFlatShadedMesh(): Mesh;
  24824. /**
  24825. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24826. * In other words, more vertices, no more indices and a single bigger VBO.
  24827. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24828. * @returns current mesh
  24829. */
  24830. convertToUnIndexedMesh(): Mesh;
  24831. /**
  24832. * Inverses facet orientations.
  24833. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24834. * @param flipNormals will also inverts the normals
  24835. * @returns current mesh
  24836. */
  24837. flipFaces(flipNormals?: boolean): Mesh;
  24838. /**
  24839. * Increase the number of facets and hence vertices in a mesh
  24840. * Vertex normals are interpolated from existing vertex normals
  24841. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24842. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24843. */
  24844. increaseVertices(numberPerEdge: number): void;
  24845. /**
  24846. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24847. * This will undo any application of covertToFlatShadedMesh
  24848. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24849. */
  24850. forceSharedVertices(): void;
  24851. /** @hidden */
  24852. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24853. /** @hidden */
  24854. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24855. /**
  24856. * Creates a new InstancedMesh object from the mesh model.
  24857. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24858. * @param name defines the name of the new instance
  24859. * @returns a new InstancedMesh
  24860. */
  24861. createInstance(name: string): InstancedMesh;
  24862. /**
  24863. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24864. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24865. * @returns the current mesh
  24866. */
  24867. synchronizeInstances(): Mesh;
  24868. /**
  24869. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24870. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24871. * This should be used together with the simplification to avoid disappearing triangles.
  24872. * @param successCallback an optional success callback to be called after the optimization finished.
  24873. * @returns the current mesh
  24874. */
  24875. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24876. /**
  24877. * Serialize current mesh
  24878. * @param serializationObject defines the object which will receive the serialization data
  24879. */
  24880. serialize(serializationObject: any): void;
  24881. /** @hidden */
  24882. _syncGeometryWithMorphTargetManager(): void;
  24883. /** @hidden */
  24884. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24885. /**
  24886. * Returns a new Mesh object parsed from the source provided.
  24887. * @param parsedMesh is the source
  24888. * @param scene defines the hosting scene
  24889. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24890. * @returns a new Mesh
  24891. */
  24892. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24893. /**
  24894. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24895. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24896. * @param name defines the name of the mesh to create
  24897. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24898. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24899. * @param closePath creates a seam between the first and the last points of each path of the path array
  24900. * @param offset is taken in account only if the `pathArray` is containing a single path
  24901. * @param scene defines the hosting scene
  24902. * @param updatable defines if the mesh must be flagged as updatable
  24903. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24904. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  24905. * @returns a new Mesh
  24906. */
  24907. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24908. /**
  24909. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24910. * @param name defines the name of the mesh to create
  24911. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24912. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  24913. * @param scene defines the hosting scene
  24914. * @param updatable defines if the mesh must be flagged as updatable
  24915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24916. * @returns a new Mesh
  24917. */
  24918. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24919. /**
  24920. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24921. * @param name defines the name of the mesh to create
  24922. * @param size sets the size (float) of each box side (default 1)
  24923. * @param scene defines the hosting scene
  24924. * @param updatable defines if the mesh must be flagged as updatable
  24925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24926. * @returns a new Mesh
  24927. */
  24928. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24929. /**
  24930. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24931. * @param name defines the name of the mesh to create
  24932. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24933. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24934. * @param scene defines the hosting scene
  24935. * @param updatable defines if the mesh must be flagged as updatable
  24936. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24937. * @returns a new Mesh
  24938. */
  24939. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24940. /**
  24941. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24942. * @param name defines the name of the mesh to create
  24943. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24944. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24945. * @param scene defines the hosting scene
  24946. * @returns a new Mesh
  24947. */
  24948. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24949. /**
  24950. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24951. * @param name defines the name of the mesh to create
  24952. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24953. * @param diameterTop set the top cap diameter (floats, default 1)
  24954. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24955. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24956. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24957. * @param scene defines the hosting scene
  24958. * @param updatable defines if the mesh must be flagged as updatable
  24959. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24960. * @returns a new Mesh
  24961. */
  24962. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24963. /**
  24964. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24965. * @param name defines the name of the mesh to create
  24966. * @param diameter sets the diameter size (float) of the torus (default 1)
  24967. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24968. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24969. * @param scene defines the hosting scene
  24970. * @param updatable defines if the mesh must be flagged as updatable
  24971. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24972. * @returns a new Mesh
  24973. */
  24974. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24975. /**
  24976. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24977. * @param name defines the name of the mesh to create
  24978. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24979. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24980. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24981. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24982. * @param p the number of windings on X axis (positive integers, default 2)
  24983. * @param q the number of windings on Y axis (positive integers, default 3)
  24984. * @param scene defines the hosting scene
  24985. * @param updatable defines if the mesh must be flagged as updatable
  24986. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24987. * @returns a new Mesh
  24988. */
  24989. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24990. /**
  24991. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24992. * @param name defines the name of the mesh to create
  24993. * @param points is an array successive Vector3
  24994. * @param scene defines the hosting scene
  24995. * @param updatable defines if the mesh must be flagged as updatable
  24996. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  24997. * @returns a new Mesh
  24998. */
  24999. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25000. /**
  25001. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25002. * @param name defines the name of the mesh to create
  25003. * @param points is an array successive Vector3
  25004. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25005. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25006. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25007. * @param scene defines the hosting scene
  25008. * @param updatable defines if the mesh must be flagged as updatable
  25009. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25010. * @returns a new Mesh
  25011. */
  25012. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25013. /**
  25014. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25015. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25016. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25017. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25018. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25019. * Remember you can only change the shape positions, not their number when updating a polygon.
  25020. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25021. * @param name defines the name of the mesh to create
  25022. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25023. * @param scene defines the hosting scene
  25024. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25025. * @param updatable defines if the mesh must be flagged as updatable
  25026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25027. * @param earcutInjection can be used to inject your own earcut reference
  25028. * @returns a new Mesh
  25029. */
  25030. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25031. /**
  25032. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25033. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25034. * @param name defines the name of the mesh to create
  25035. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25036. * @param depth defines the height of extrusion
  25037. * @param scene defines the hosting scene
  25038. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25039. * @param updatable defines if the mesh must be flagged as updatable
  25040. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25041. * @param earcutInjection can be used to inject your own earcut reference
  25042. * @returns a new Mesh
  25043. */
  25044. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25045. /**
  25046. * Creates an extruded shape mesh.
  25047. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25048. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25049. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25050. * @param name defines the name of the mesh to create
  25051. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25052. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25053. * @param scale is the value to scale the shape
  25054. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25055. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25056. * @param scene defines the hosting scene
  25057. * @param updatable defines if the mesh must be flagged as updatable
  25058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25059. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25060. * @returns a new Mesh
  25061. */
  25062. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25063. /**
  25064. * Creates an custom extruded shape mesh.
  25065. * The custom extrusion is a parametric shape.
  25066. * It has no predefined shape. Its final shape will depend on the input parameters.
  25067. * Please consider using the same method from the MeshBuilder class instead
  25068. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25069. * @param name defines the name of the mesh to create
  25070. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25071. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25072. * @param scaleFunction is a custom Javascript function called on each path point
  25073. * @param rotationFunction is a custom Javascript function called on each path point
  25074. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25075. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25076. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25077. * @param scene defines the hosting scene
  25078. * @param updatable defines if the mesh must be flagged as updatable
  25079. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25080. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25081. * @returns a new Mesh
  25082. */
  25083. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25084. /**
  25085. * Creates lathe mesh.
  25086. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25087. * Please consider using the same method from the MeshBuilder class instead
  25088. * @param name defines the name of the mesh to create
  25089. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25090. * @param radius is the radius value of the lathe
  25091. * @param tessellation is the side number of the lathe.
  25092. * @param scene defines the hosting scene
  25093. * @param updatable defines if the mesh must be flagged as updatable
  25094. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25095. * @returns a new Mesh
  25096. */
  25097. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25098. /**
  25099. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25100. * @param name defines the name of the mesh to create
  25101. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25102. * @param scene defines the hosting scene
  25103. * @param updatable defines if the mesh must be flagged as updatable
  25104. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25105. * @returns a new Mesh
  25106. */
  25107. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25108. /**
  25109. * Creates a ground mesh.
  25110. * Please consider using the same method from the MeshBuilder class instead
  25111. * @param name defines the name of the mesh to create
  25112. * @param width set the width of the ground
  25113. * @param height set the height of the ground
  25114. * @param subdivisions sets the number of subdivisions per side
  25115. * @param scene defines the hosting scene
  25116. * @param updatable defines if the mesh must be flagged as updatable
  25117. * @returns a new Mesh
  25118. */
  25119. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25120. /**
  25121. * Creates a tiled ground mesh.
  25122. * Please consider using the same method from the MeshBuilder class instead
  25123. * @param name defines the name of the mesh to create
  25124. * @param xmin set the ground minimum X coordinate
  25125. * @param zmin set the ground minimum Y coordinate
  25126. * @param xmax set the ground maximum X coordinate
  25127. * @param zmax set the ground maximum Z coordinate
  25128. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25129. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25130. * @param scene defines the hosting scene
  25131. * @param updatable defines if the mesh must be flagged as updatable
  25132. * @returns a new Mesh
  25133. */
  25134. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25135. w: number;
  25136. h: number;
  25137. }, precision: {
  25138. w: number;
  25139. h: number;
  25140. }, scene: Scene, updatable?: boolean): Mesh;
  25141. /**
  25142. * Creates a ground mesh from a height map.
  25143. * Please consider using the same method from the MeshBuilder class instead
  25144. * @see http://doc.babylonjs.com/babylon101/height_map
  25145. * @param name defines the name of the mesh to create
  25146. * @param url sets the URL of the height map image resource
  25147. * @param width set the ground width size
  25148. * @param height set the ground height size
  25149. * @param subdivisions sets the number of subdivision per side
  25150. * @param minHeight is the minimum altitude on the ground
  25151. * @param maxHeight is the maximum altitude on the ground
  25152. * @param scene defines the hosting scene
  25153. * @param updatable defines if the mesh must be flagged as updatable
  25154. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25155. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25156. * @returns a new Mesh
  25157. */
  25158. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25159. /**
  25160. * Creates a tube mesh.
  25161. * The tube is a parametric shape.
  25162. * It has no predefined shape. Its final shape will depend on the input parameters.
  25163. * Please consider using the same method from the MeshBuilder class instead
  25164. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25165. * @param name defines the name of the mesh to create
  25166. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25167. * @param radius sets the tube radius size
  25168. * @param tessellation is the number of sides on the tubular surface
  25169. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25170. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25171. * @param scene defines the hosting scene
  25172. * @param updatable defines if the mesh must be flagged as updatable
  25173. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25174. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25175. * @returns a new Mesh
  25176. */
  25177. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25178. (i: number, distance: number): number;
  25179. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25180. /**
  25181. * Creates a polyhedron mesh.
  25182. * Please consider using the same method from the MeshBuilder class instead.
  25183. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  25184. * * The parameter `size` (positive float, default 1) sets the polygon size
  25185. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25186. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  25187. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  25188. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  25189. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  25190. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  25191. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25192. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25193. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25194. * @param name defines the name of the mesh to create
  25195. * @param options defines the options used to create the mesh
  25196. * @param scene defines the hosting scene
  25197. * @returns a new Mesh
  25198. */
  25199. static CreatePolyhedron(name: string, options: {
  25200. type?: number;
  25201. size?: number;
  25202. sizeX?: number;
  25203. sizeY?: number;
  25204. sizeZ?: number;
  25205. custom?: any;
  25206. faceUV?: Vector4[];
  25207. faceColors?: Color4[];
  25208. updatable?: boolean;
  25209. sideOrientation?: number;
  25210. }, scene: Scene): Mesh;
  25211. /**
  25212. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25213. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25214. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  25215. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25216. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  25217. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25218. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25220. * @param name defines the name of the mesh
  25221. * @param options defines the options used to create the mesh
  25222. * @param scene defines the hosting scene
  25223. * @returns a new Mesh
  25224. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25225. */
  25226. static CreateIcoSphere(name: string, options: {
  25227. radius?: number;
  25228. flat?: boolean;
  25229. subdivisions?: number;
  25230. sideOrientation?: number;
  25231. updatable?: boolean;
  25232. }, scene: Scene): Mesh;
  25233. /**
  25234. * Creates a decal mesh.
  25235. * Please consider using the same method from the MeshBuilder class instead.
  25236. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25237. * @param name defines the name of the mesh
  25238. * @param sourceMesh defines the mesh receiving the decal
  25239. * @param position sets the position of the decal in world coordinates
  25240. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25241. * @param size sets the decal scaling
  25242. * @param angle sets the angle to rotate the decal
  25243. * @returns a new Mesh
  25244. */
  25245. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25246. /**
  25247. * Prepare internal position array for software CPU skinning
  25248. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25249. */
  25250. setPositionsForCPUSkinning(): Float32Array;
  25251. /**
  25252. * Prepare internal normal array for software CPU skinning
  25253. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25254. */
  25255. setNormalsForCPUSkinning(): Float32Array;
  25256. /**
  25257. * Updates the vertex buffer by applying transformation from the bones
  25258. * @param skeleton defines the skeleton to apply to current mesh
  25259. * @returns the current mesh
  25260. */
  25261. applySkeleton(skeleton: Skeleton): Mesh;
  25262. /**
  25263. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  25264. * @param meshes defines the list of meshes to scan
  25265. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25266. */
  25267. static MinMax(meshes: AbstractMesh[]): {
  25268. min: Vector3;
  25269. max: Vector3;
  25270. };
  25271. /**
  25272. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25273. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25274. * @returns a vector3
  25275. */
  25276. static Center(meshesOrMinMaxVector: {
  25277. min: Vector3;
  25278. max: Vector3;
  25279. } | AbstractMesh[]): Vector3;
  25280. /**
  25281. * Merge the array of meshes into a single mesh for performance reasons.
  25282. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25283. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25284. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25285. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25286. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25287. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25288. * @returns a new mesh
  25289. */
  25290. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25291. /** @hidden */
  25292. addInstance(instance: InstancedMesh): void;
  25293. /** @hidden */
  25294. removeInstance(instance: InstancedMesh): void;
  25295. }
  25296. }
  25297. declare module "babylonjs/Cameras/camera" {
  25298. import { SmartArray } from "babylonjs/Misc/smartArray";
  25299. import { Observable } from "babylonjs/Misc/observable";
  25300. import { Nullable } from "babylonjs/types";
  25301. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25302. import { Scene } from "babylonjs/scene";
  25303. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25304. import { Node } from "babylonjs/node";
  25305. import { Mesh } from "babylonjs/Meshes/mesh";
  25306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25307. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25308. import { Viewport } from "babylonjs/Maths/math.viewport";
  25309. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25311. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25312. import { Ray } from "babylonjs/Culling/ray";
  25313. /**
  25314. * This is the base class of all the camera used in the application.
  25315. * @see http://doc.babylonjs.com/features/cameras
  25316. */
  25317. export class Camera extends Node {
  25318. /** @hidden */
  25319. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25320. /**
  25321. * This is the default projection mode used by the cameras.
  25322. * It helps recreating a feeling of perspective and better appreciate depth.
  25323. * This is the best way to simulate real life cameras.
  25324. */
  25325. static readonly PERSPECTIVE_CAMERA: number;
  25326. /**
  25327. * This helps creating camera with an orthographic mode.
  25328. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  25329. */
  25330. static readonly ORTHOGRAPHIC_CAMERA: number;
  25331. /**
  25332. * This is the default FOV mode for perspective cameras.
  25333. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25334. */
  25335. static readonly FOVMODE_VERTICAL_FIXED: number;
  25336. /**
  25337. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25338. */
  25339. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25340. /**
  25341. * This specifies ther is no need for a camera rig.
  25342. * Basically only one eye is rendered corresponding to the camera.
  25343. */
  25344. static readonly RIG_MODE_NONE: number;
  25345. /**
  25346. * Simulates a camera Rig with one blue eye and one red eye.
  25347. * This can be use with 3d blue and red glasses.
  25348. */
  25349. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25350. /**
  25351. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25352. */
  25353. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25354. /**
  25355. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25356. */
  25357. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25358. /**
  25359. * Defines that both eyes of the camera will be rendered over under each other.
  25360. */
  25361. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25362. /**
  25363. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25364. */
  25365. static readonly RIG_MODE_VR: number;
  25366. /**
  25367. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25368. */
  25369. static readonly RIG_MODE_WEBVR: number;
  25370. /**
  25371. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25372. */
  25373. static readonly RIG_MODE_CUSTOM: number;
  25374. /**
  25375. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25376. */
  25377. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25378. /**
  25379. * Define the input manager associated with the camera.
  25380. */
  25381. inputs: CameraInputsManager<Camera>;
  25382. /** @hidden */
  25383. _position: Vector3;
  25384. /**
  25385. * Define the current local position of the camera in the scene
  25386. */
  25387. position: Vector3;
  25388. /**
  25389. * The vector the camera should consider as up.
  25390. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25391. */
  25392. upVector: Vector3;
  25393. /**
  25394. * Define the current limit on the left side for an orthographic camera
  25395. * In scene unit
  25396. */
  25397. orthoLeft: Nullable<number>;
  25398. /**
  25399. * Define the current limit on the right side for an orthographic camera
  25400. * In scene unit
  25401. */
  25402. orthoRight: Nullable<number>;
  25403. /**
  25404. * Define the current limit on the bottom side for an orthographic camera
  25405. * In scene unit
  25406. */
  25407. orthoBottom: Nullable<number>;
  25408. /**
  25409. * Define the current limit on the top side for an orthographic camera
  25410. * In scene unit
  25411. */
  25412. orthoTop: Nullable<number>;
  25413. /**
  25414. * Field Of View is set in Radians. (default is 0.8)
  25415. */
  25416. fov: number;
  25417. /**
  25418. * Define the minimum distance the camera can see from.
  25419. * This is important to note that the depth buffer are not infinite and the closer it starts
  25420. * the more your scene might encounter depth fighting issue.
  25421. */
  25422. minZ: number;
  25423. /**
  25424. * Define the maximum distance the camera can see to.
  25425. * This is important to note that the depth buffer are not infinite and the further it end
  25426. * the more your scene might encounter depth fighting issue.
  25427. */
  25428. maxZ: number;
  25429. /**
  25430. * Define the default inertia of the camera.
  25431. * This helps giving a smooth feeling to the camera movement.
  25432. */
  25433. inertia: number;
  25434. /**
  25435. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25436. */
  25437. mode: number;
  25438. /**
  25439. * Define wether the camera is intermediate.
  25440. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25441. */
  25442. isIntermediate: boolean;
  25443. /**
  25444. * Define the viewport of the camera.
  25445. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25446. */
  25447. viewport: Viewport;
  25448. /**
  25449. * Restricts the camera to viewing objects with the same layerMask.
  25450. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25451. */
  25452. layerMask: number;
  25453. /**
  25454. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25455. */
  25456. fovMode: number;
  25457. /**
  25458. * Rig mode of the camera.
  25459. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25460. * This is normally controlled byt the camera themselves as internal use.
  25461. */
  25462. cameraRigMode: number;
  25463. /**
  25464. * Defines the distance between both "eyes" in case of a RIG
  25465. */
  25466. interaxialDistance: number;
  25467. /**
  25468. * Defines if stereoscopic rendering is done side by side or over under.
  25469. */
  25470. isStereoscopicSideBySide: boolean;
  25471. /**
  25472. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  25473. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25474. * else in the scene. (Eg. security camera)
  25475. *
  25476. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  25477. */
  25478. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25479. /**
  25480. * When set, the camera will render to this render target instead of the default canvas
  25481. *
  25482. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25483. */
  25484. outputRenderTarget: Nullable<RenderTargetTexture>;
  25485. /**
  25486. * Observable triggered when the camera view matrix has changed.
  25487. */
  25488. onViewMatrixChangedObservable: Observable<Camera>;
  25489. /**
  25490. * Observable triggered when the camera Projection matrix has changed.
  25491. */
  25492. onProjectionMatrixChangedObservable: Observable<Camera>;
  25493. /**
  25494. * Observable triggered when the inputs have been processed.
  25495. */
  25496. onAfterCheckInputsObservable: Observable<Camera>;
  25497. /**
  25498. * Observable triggered when reset has been called and applied to the camera.
  25499. */
  25500. onRestoreStateObservable: Observable<Camera>;
  25501. /** @hidden */
  25502. _cameraRigParams: any;
  25503. /** @hidden */
  25504. _rigCameras: Camera[];
  25505. /** @hidden */
  25506. _rigPostProcess: Nullable<PostProcess>;
  25507. protected _webvrViewMatrix: Matrix;
  25508. /** @hidden */
  25509. _skipRendering: boolean;
  25510. /** @hidden */
  25511. _projectionMatrix: Matrix;
  25512. /** @hidden */
  25513. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25514. /** @hidden */
  25515. _activeMeshes: SmartArray<AbstractMesh>;
  25516. protected _globalPosition: Vector3;
  25517. /** @hidden */
  25518. _computedViewMatrix: Matrix;
  25519. private _doNotComputeProjectionMatrix;
  25520. private _transformMatrix;
  25521. private _frustumPlanes;
  25522. private _refreshFrustumPlanes;
  25523. private _storedFov;
  25524. private _stateStored;
  25525. /**
  25526. * Instantiates a new camera object.
  25527. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25528. * @see http://doc.babylonjs.com/features/cameras
  25529. * @param name Defines the name of the camera in the scene
  25530. * @param position Defines the position of the camera
  25531. * @param scene Defines the scene the camera belongs too
  25532. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25533. */
  25534. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25535. /**
  25536. * Store current camera state (fov, position, etc..)
  25537. * @returns the camera
  25538. */
  25539. storeState(): Camera;
  25540. /**
  25541. * Restores the camera state values if it has been stored. You must call storeState() first
  25542. */
  25543. protected _restoreStateValues(): boolean;
  25544. /**
  25545. * Restored camera state. You must call storeState() first.
  25546. * @returns true if restored and false otherwise
  25547. */
  25548. restoreState(): boolean;
  25549. /**
  25550. * Gets the class name of the camera.
  25551. * @returns the class name
  25552. */
  25553. getClassName(): string;
  25554. /** @hidden */
  25555. readonly _isCamera: boolean;
  25556. /**
  25557. * Gets a string representation of the camera useful for debug purpose.
  25558. * @param fullDetails Defines that a more verboe level of logging is required
  25559. * @returns the string representation
  25560. */
  25561. toString(fullDetails?: boolean): string;
  25562. /**
  25563. * Gets the current world space position of the camera.
  25564. */
  25565. readonly globalPosition: Vector3;
  25566. /**
  25567. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25568. * @returns the active meshe list
  25569. */
  25570. getActiveMeshes(): SmartArray<AbstractMesh>;
  25571. /**
  25572. * Check wether a mesh is part of the current active mesh list of the camera
  25573. * @param mesh Defines the mesh to check
  25574. * @returns true if active, false otherwise
  25575. */
  25576. isActiveMesh(mesh: Mesh): boolean;
  25577. /**
  25578. * Is this camera ready to be used/rendered
  25579. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25580. * @return true if the camera is ready
  25581. */
  25582. isReady(completeCheck?: boolean): boolean;
  25583. /** @hidden */
  25584. _initCache(): void;
  25585. /** @hidden */
  25586. _updateCache(ignoreParentClass?: boolean): void;
  25587. /** @hidden */
  25588. _isSynchronized(): boolean;
  25589. /** @hidden */
  25590. _isSynchronizedViewMatrix(): boolean;
  25591. /** @hidden */
  25592. _isSynchronizedProjectionMatrix(): boolean;
  25593. /**
  25594. * Attach the input controls to a specific dom element to get the input from.
  25595. * @param element Defines the element the controls should be listened from
  25596. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25597. */
  25598. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25599. /**
  25600. * Detach the current controls from the specified dom element.
  25601. * @param element Defines the element to stop listening the inputs from
  25602. */
  25603. detachControl(element: HTMLElement): void;
  25604. /**
  25605. * Update the camera state according to the different inputs gathered during the frame.
  25606. */
  25607. update(): void;
  25608. /** @hidden */
  25609. _checkInputs(): void;
  25610. /** @hidden */
  25611. readonly rigCameras: Camera[];
  25612. /**
  25613. * Gets the post process used by the rig cameras
  25614. */
  25615. readonly rigPostProcess: Nullable<PostProcess>;
  25616. /**
  25617. * Internal, gets the first post proces.
  25618. * @returns the first post process to be run on this camera.
  25619. */
  25620. _getFirstPostProcess(): Nullable<PostProcess>;
  25621. private _cascadePostProcessesToRigCams;
  25622. /**
  25623. * Attach a post process to the camera.
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25625. * @param postProcess The post process to attach to the camera
  25626. * @param insertAt The position of the post process in case several of them are in use in the scene
  25627. * @returns the position the post process has been inserted at
  25628. */
  25629. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25630. /**
  25631. * Detach a post process to the camera.
  25632. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25633. * @param postProcess The post process to detach from the camera
  25634. */
  25635. detachPostProcess(postProcess: PostProcess): void;
  25636. /**
  25637. * Gets the current world matrix of the camera
  25638. */
  25639. getWorldMatrix(): Matrix;
  25640. /** @hidden */
  25641. _getViewMatrix(): Matrix;
  25642. /**
  25643. * Gets the current view matrix of the camera.
  25644. * @param force forces the camera to recompute the matrix without looking at the cached state
  25645. * @returns the view matrix
  25646. */
  25647. getViewMatrix(force?: boolean): Matrix;
  25648. /**
  25649. * Freeze the projection matrix.
  25650. * It will prevent the cache check of the camera projection compute and can speed up perf
  25651. * if no parameter of the camera are meant to change
  25652. * @param projection Defines manually a projection if necessary
  25653. */
  25654. freezeProjectionMatrix(projection?: Matrix): void;
  25655. /**
  25656. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25657. */
  25658. unfreezeProjectionMatrix(): void;
  25659. /**
  25660. * Gets the current projection matrix of the camera.
  25661. * @param force forces the camera to recompute the matrix without looking at the cached state
  25662. * @returns the projection matrix
  25663. */
  25664. getProjectionMatrix(force?: boolean): Matrix;
  25665. /**
  25666. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25667. * @returns a Matrix
  25668. */
  25669. getTransformationMatrix(): Matrix;
  25670. private _updateFrustumPlanes;
  25671. /**
  25672. * Checks if a cullable object (mesh...) is in the camera frustum
  25673. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25674. * @param target The object to check
  25675. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25676. * @returns true if the object is in frustum otherwise false
  25677. */
  25678. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25679. /**
  25680. * Checks if a cullable object (mesh...) is in the camera frustum
  25681. * Unlike isInFrustum this cheks the full bounding box
  25682. * @param target The object to check
  25683. * @returns true if the object is in frustum otherwise false
  25684. */
  25685. isCompletelyInFrustum(target: ICullable): boolean;
  25686. /**
  25687. * Gets a ray in the forward direction from the camera.
  25688. * @param length Defines the length of the ray to create
  25689. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25690. * @param origin Defines the start point of the ray which defaults to the camera position
  25691. * @returns the forward ray
  25692. */
  25693. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25694. /**
  25695. * Releases resources associated with this node.
  25696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25698. */
  25699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25700. /** @hidden */
  25701. _isLeftCamera: boolean;
  25702. /**
  25703. * Gets the left camera of a rig setup in case of Rigged Camera
  25704. */
  25705. readonly isLeftCamera: boolean;
  25706. /** @hidden */
  25707. _isRightCamera: boolean;
  25708. /**
  25709. * Gets the right camera of a rig setup in case of Rigged Camera
  25710. */
  25711. readonly isRightCamera: boolean;
  25712. /**
  25713. * Gets the left camera of a rig setup in case of Rigged Camera
  25714. */
  25715. readonly leftCamera: Nullable<FreeCamera>;
  25716. /**
  25717. * Gets the right camera of a rig setup in case of Rigged Camera
  25718. */
  25719. readonly rightCamera: Nullable<FreeCamera>;
  25720. /**
  25721. * Gets the left camera target of a rig setup in case of Rigged Camera
  25722. * @returns the target position
  25723. */
  25724. getLeftTarget(): Nullable<Vector3>;
  25725. /**
  25726. * Gets the right camera target of a rig setup in case of Rigged Camera
  25727. * @returns the target position
  25728. */
  25729. getRightTarget(): Nullable<Vector3>;
  25730. /**
  25731. * @hidden
  25732. */
  25733. setCameraRigMode(mode: number, rigParams: any): void;
  25734. /** @hidden */
  25735. static _setStereoscopicRigMode(camera: Camera): void;
  25736. /** @hidden */
  25737. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25738. /** @hidden */
  25739. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25740. /** @hidden */
  25741. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25742. /** @hidden */
  25743. _getVRProjectionMatrix(): Matrix;
  25744. protected _updateCameraRotationMatrix(): void;
  25745. protected _updateWebVRCameraRotationMatrix(): void;
  25746. /**
  25747. * This function MUST be overwritten by the different WebVR cameras available.
  25748. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25749. * @hidden
  25750. */
  25751. _getWebVRProjectionMatrix(): Matrix;
  25752. /**
  25753. * This function MUST be overwritten by the different WebVR cameras available.
  25754. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25755. * @hidden
  25756. */
  25757. _getWebVRViewMatrix(): Matrix;
  25758. /** @hidden */
  25759. setCameraRigParameter(name: string, value: any): void;
  25760. /**
  25761. * needs to be overridden by children so sub has required properties to be copied
  25762. * @hidden
  25763. */
  25764. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25765. /**
  25766. * May need to be overridden by children
  25767. * @hidden
  25768. */
  25769. _updateRigCameras(): void;
  25770. /** @hidden */
  25771. _setupInputs(): void;
  25772. /**
  25773. * Serialiaze the camera setup to a json represention
  25774. * @returns the JSON representation
  25775. */
  25776. serialize(): any;
  25777. /**
  25778. * Clones the current camera.
  25779. * @param name The cloned camera name
  25780. * @returns the cloned camera
  25781. */
  25782. clone(name: string): Camera;
  25783. /**
  25784. * Gets the direction of the camera relative to a given local axis.
  25785. * @param localAxis Defines the reference axis to provide a relative direction.
  25786. * @return the direction
  25787. */
  25788. getDirection(localAxis: Vector3): Vector3;
  25789. /**
  25790. * Returns the current camera absolute rotation
  25791. */
  25792. readonly absoluteRotation: Quaternion;
  25793. /**
  25794. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25795. * @param localAxis Defines the reference axis to provide a relative direction.
  25796. * @param result Defines the vector to store the result in
  25797. */
  25798. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25799. /**
  25800. * Gets a camera constructor for a given camera type
  25801. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25802. * @param name The name of the camera the result will be able to instantiate
  25803. * @param scene The scene the result will construct the camera in
  25804. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25805. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25806. * @returns a factory method to construc the camera
  25807. */
  25808. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25809. /**
  25810. * Compute the world matrix of the camera.
  25811. * @returns the camera workd matrix
  25812. */
  25813. computeWorldMatrix(): Matrix;
  25814. /**
  25815. * Parse a JSON and creates the camera from the parsed information
  25816. * @param parsedCamera The JSON to parse
  25817. * @param scene The scene to instantiate the camera in
  25818. * @returns the newly constructed camera
  25819. */
  25820. static Parse(parsedCamera: any, scene: Scene): Camera;
  25821. }
  25822. }
  25823. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25824. import { Nullable } from "babylonjs/types";
  25825. import { Scene } from "babylonjs/scene";
  25826. import { Vector4 } from "babylonjs/Maths/math.vector";
  25827. import { Mesh } from "babylonjs/Meshes/mesh";
  25828. /**
  25829. * Class containing static functions to help procedurally build meshes
  25830. */
  25831. export class DiscBuilder {
  25832. /**
  25833. * Creates a plane polygonal mesh. By default, this is a disc
  25834. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25835. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25836. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  25837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25838. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25839. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25840. * @param name defines the name of the mesh
  25841. * @param options defines the options used to create the mesh
  25842. * @param scene defines the hosting scene
  25843. * @returns the plane polygonal mesh
  25844. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25845. */
  25846. static CreateDisc(name: string, options: {
  25847. radius?: number;
  25848. tessellation?: number;
  25849. arc?: number;
  25850. updatable?: boolean;
  25851. sideOrientation?: number;
  25852. frontUVs?: Vector4;
  25853. backUVs?: Vector4;
  25854. }, scene?: Nullable<Scene>): Mesh;
  25855. }
  25856. }
  25857. declare module "babylonjs/Particles/solidParticleSystem" {
  25858. import { Vector3 } from "babylonjs/Maths/math.vector";
  25859. import { Mesh } from "babylonjs/Meshes/mesh";
  25860. import { Scene, IDisposable } from "babylonjs/scene";
  25861. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25862. /**
  25863. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25864. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  25865. * The SPS is also a particle system. It provides some methods to manage the particles.
  25866. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25867. *
  25868. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25869. */
  25870. export class SolidParticleSystem implements IDisposable {
  25871. /**
  25872. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25873. * Example : var p = SPS.particles[i];
  25874. */
  25875. particles: SolidParticle[];
  25876. /**
  25877. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25878. */
  25879. nbParticles: number;
  25880. /**
  25881. * If the particles must ever face the camera (default false). Useful for planar particles.
  25882. */
  25883. billboard: boolean;
  25884. /**
  25885. * Recompute normals when adding a shape
  25886. */
  25887. recomputeNormals: boolean;
  25888. /**
  25889. * This a counter ofr your own usage. It's not set by any SPS functions.
  25890. */
  25891. counter: number;
  25892. /**
  25893. * The SPS name. This name is also given to the underlying mesh.
  25894. */
  25895. name: string;
  25896. /**
  25897. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25898. */
  25899. mesh: Mesh;
  25900. /**
  25901. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25902. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25903. */
  25904. vars: any;
  25905. /**
  25906. * This array is populated when the SPS is set as 'pickable'.
  25907. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25908. * Each element of this array is an object `{idx: int, faceId: int}`.
  25909. * `idx` is the picked particle index in the `SPS.particles` array
  25910. * `faceId` is the picked face index counted within this particle.
  25911. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25912. */
  25913. pickedParticles: {
  25914. idx: number;
  25915. faceId: number;
  25916. }[];
  25917. /**
  25918. * This array is populated when `enableDepthSort` is set to true.
  25919. * Each element of this array is an instance of the class DepthSortedParticle.
  25920. */
  25921. depthSortedParticles: DepthSortedParticle[];
  25922. /**
  25923. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25924. * @hidden
  25925. */
  25926. _bSphereOnly: boolean;
  25927. /**
  25928. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25929. * @hidden
  25930. */
  25931. _bSphereRadiusFactor: number;
  25932. private _scene;
  25933. private _positions;
  25934. private _indices;
  25935. private _normals;
  25936. private _colors;
  25937. private _uvs;
  25938. private _indices32;
  25939. private _positions32;
  25940. private _normals32;
  25941. private _fixedNormal32;
  25942. private _colors32;
  25943. private _uvs32;
  25944. private _index;
  25945. private _updatable;
  25946. private _pickable;
  25947. private _isVisibilityBoxLocked;
  25948. private _alwaysVisible;
  25949. private _depthSort;
  25950. private _shapeCounter;
  25951. private _copy;
  25952. private _color;
  25953. private _computeParticleColor;
  25954. private _computeParticleTexture;
  25955. private _computeParticleRotation;
  25956. private _computeParticleVertex;
  25957. private _computeBoundingBox;
  25958. private _depthSortParticles;
  25959. private _camera;
  25960. private _mustUnrotateFixedNormals;
  25961. private _particlesIntersect;
  25962. private _needs32Bits;
  25963. /**
  25964. * Creates a SPS (Solid Particle System) object.
  25965. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25966. * @param scene (Scene) is the scene in which the SPS is added.
  25967. * @param options defines the options of the sps e.g.
  25968. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25969. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25970. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25971. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25972. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25973. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25974. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25975. */
  25976. constructor(name: string, scene: Scene, options?: {
  25977. updatable?: boolean;
  25978. isPickable?: boolean;
  25979. enableDepthSort?: boolean;
  25980. particleIntersection?: boolean;
  25981. boundingSphereOnly?: boolean;
  25982. bSphereRadiusFactor?: number;
  25983. });
  25984. /**
  25985. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25986. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25987. * @returns the created mesh
  25988. */
  25989. buildMesh(): Mesh;
  25990. /**
  25991. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  25992. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  25993. * Thus the particles generated from `digest()` have their property `position` set yet.
  25994. * @param mesh ( Mesh ) is the mesh to be digested
  25995. * @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
  25996. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  25997. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  25998. * @returns the current SPS
  25999. */
  26000. digest(mesh: Mesh, options?: {
  26001. facetNb?: number;
  26002. number?: number;
  26003. delta?: number;
  26004. }): SolidParticleSystem;
  26005. private _unrotateFixedNormals;
  26006. private _resetCopy;
  26007. private _meshBuilder;
  26008. private _posToShape;
  26009. private _uvsToShapeUV;
  26010. private _addParticle;
  26011. /**
  26012. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26013. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26014. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26015. * @param nb (positive integer) the number of particles to be created from this model
  26016. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26017. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26018. * @returns the number of shapes in the system
  26019. */
  26020. addShape(mesh: Mesh, nb: number, options?: {
  26021. positionFunction?: any;
  26022. vertexFunction?: any;
  26023. }): number;
  26024. private _rebuildParticle;
  26025. /**
  26026. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26027. * @returns the SPS.
  26028. */
  26029. rebuildMesh(): SolidParticleSystem;
  26030. /**
  26031. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26032. * This method calls `updateParticle()` for each particle of the SPS.
  26033. * For an animated SPS, it is usually called within the render loop.
  26034. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26035. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26036. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26037. * @returns the SPS.
  26038. */
  26039. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26040. /**
  26041. * Disposes the SPS.
  26042. */
  26043. dispose(): void;
  26044. /**
  26045. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26046. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26047. * @returns the SPS.
  26048. */
  26049. refreshVisibleSize(): SolidParticleSystem;
  26050. /**
  26051. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26052. * @param size the size (float) of the visibility box
  26053. * note : this doesn't lock the SPS mesh bounding box.
  26054. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26055. */
  26056. setVisibilityBox(size: number): void;
  26057. /**
  26058. * Gets whether the SPS as always visible or not
  26059. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26060. */
  26061. /**
  26062. * Sets the SPS as always visible or not
  26063. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26064. */
  26065. isAlwaysVisible: boolean;
  26066. /**
  26067. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26069. */
  26070. /**
  26071. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26072. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26073. */
  26074. isVisibilityBoxLocked: boolean;
  26075. /**
  26076. * Tells to `setParticles()` to compute the particle rotations or not.
  26077. * Default value : true. The SPS is faster when it's set to false.
  26078. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26079. */
  26080. /**
  26081. * Gets if `setParticles()` computes the particle rotations or not.
  26082. * Default value : true. The SPS is faster when it's set to false.
  26083. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26084. */
  26085. computeParticleRotation: boolean;
  26086. /**
  26087. * Tells to `setParticles()` to compute the particle colors or not.
  26088. * Default value : true. The SPS is faster when it's set to false.
  26089. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26090. */
  26091. /**
  26092. * Gets if `setParticles()` computes the particle colors or not.
  26093. * Default value : true. The SPS is faster when it's set to false.
  26094. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26095. */
  26096. computeParticleColor: boolean;
  26097. /**
  26098. * Gets if `setParticles()` computes the particle textures or not.
  26099. * Default value : true. The SPS is faster when it's set to false.
  26100. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26101. */
  26102. computeParticleTexture: boolean;
  26103. /**
  26104. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26105. * Default value : false. The SPS is faster when it's set to false.
  26106. * Note : the particle custom vertex positions aren't stored values.
  26107. */
  26108. /**
  26109. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26110. * Default value : false. The SPS is faster when it's set to false.
  26111. * Note : the particle custom vertex positions aren't stored values.
  26112. */
  26113. computeParticleVertex: boolean;
  26114. /**
  26115. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26116. */
  26117. /**
  26118. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26119. */
  26120. computeBoundingBox: boolean;
  26121. /**
  26122. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26123. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26124. * Default : `true`
  26125. */
  26126. /**
  26127. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26128. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26129. * Default : `true`
  26130. */
  26131. depthSortParticles: boolean;
  26132. /**
  26133. * This function does nothing. It may be overwritten to set all the particle first values.
  26134. * The SPS doesn't call this function, you may have to call it by your own.
  26135. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26136. */
  26137. initParticles(): void;
  26138. /**
  26139. * This function does nothing. It may be overwritten to recycle a particle.
  26140. * The SPS doesn't call this function, you may have to call it by your own.
  26141. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26142. * @param particle The particle to recycle
  26143. * @returns the recycled particle
  26144. */
  26145. recycleParticle(particle: SolidParticle): SolidParticle;
  26146. /**
  26147. * Updates a particle : this function should be overwritten by the user.
  26148. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26149. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26150. * @example : just set a particle position or velocity and recycle conditions
  26151. * @param particle The particle to update
  26152. * @returns the updated particle
  26153. */
  26154. updateParticle(particle: SolidParticle): SolidParticle;
  26155. /**
  26156. * Updates a vertex of a particle : it can be overwritten by the user.
  26157. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26158. * @param particle the current particle
  26159. * @param vertex the current index of the current particle
  26160. * @param pt the index of the current vertex in the particle shape
  26161. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26162. * @example : just set a vertex particle position
  26163. * @returns the updated vertex
  26164. */
  26165. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26166. /**
  26167. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26168. * This does nothing and may be overwritten by the user.
  26169. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26170. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26171. * @param update the boolean update value actually passed to setParticles()
  26172. */
  26173. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26174. /**
  26175. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26176. * This will be passed three parameters.
  26177. * This does nothing and may be overwritten by the user.
  26178. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26179. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26180. * @param update the boolean update value actually passed to setParticles()
  26181. */
  26182. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26183. }
  26184. }
  26185. declare module "babylonjs/Particles/solidParticle" {
  26186. import { Nullable } from "babylonjs/types";
  26187. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26188. import { Color4 } from "babylonjs/Maths/math.color";
  26189. import { Mesh } from "babylonjs/Meshes/mesh";
  26190. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26191. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26192. import { Plane } from "babylonjs/Maths/math.plane";
  26193. /**
  26194. * Represents one particle of a solid particle system.
  26195. */
  26196. export class SolidParticle {
  26197. /**
  26198. * particle global index
  26199. */
  26200. idx: number;
  26201. /**
  26202. * The color of the particle
  26203. */
  26204. color: Nullable<Color4>;
  26205. /**
  26206. * The world space position of the particle.
  26207. */
  26208. position: Vector3;
  26209. /**
  26210. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26211. */
  26212. rotation: Vector3;
  26213. /**
  26214. * The world space rotation quaternion of the particle.
  26215. */
  26216. rotationQuaternion: Nullable<Quaternion>;
  26217. /**
  26218. * The scaling of the particle.
  26219. */
  26220. scaling: Vector3;
  26221. /**
  26222. * The uvs of the particle.
  26223. */
  26224. uvs: Vector4;
  26225. /**
  26226. * The current speed of the particle.
  26227. */
  26228. velocity: Vector3;
  26229. /**
  26230. * The pivot point in the particle local space.
  26231. */
  26232. pivot: Vector3;
  26233. /**
  26234. * Must the particle be translated from its pivot point in its local space ?
  26235. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26236. * Default : false
  26237. */
  26238. translateFromPivot: boolean;
  26239. /**
  26240. * Is the particle active or not ?
  26241. */
  26242. alive: boolean;
  26243. /**
  26244. * Is the particle visible or not ?
  26245. */
  26246. isVisible: boolean;
  26247. /**
  26248. * Index of this particle in the global "positions" array (Internal use)
  26249. * @hidden
  26250. */
  26251. _pos: number;
  26252. /**
  26253. * @hidden Index of this particle in the global "indices" array (Internal use)
  26254. */
  26255. _ind: number;
  26256. /**
  26257. * @hidden ModelShape of this particle (Internal use)
  26258. */
  26259. _model: ModelShape;
  26260. /**
  26261. * ModelShape id of this particle
  26262. */
  26263. shapeId: number;
  26264. /**
  26265. * Index of the particle in its shape id
  26266. */
  26267. idxInShape: number;
  26268. /**
  26269. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26270. */
  26271. _modelBoundingInfo: BoundingInfo;
  26272. /**
  26273. * @hidden Particle BoundingInfo object (Internal use)
  26274. */
  26275. _boundingInfo: BoundingInfo;
  26276. /**
  26277. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26278. */
  26279. _sps: SolidParticleSystem;
  26280. /**
  26281. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26282. */
  26283. _stillInvisible: boolean;
  26284. /**
  26285. * @hidden Last computed particle rotation matrix
  26286. */
  26287. _rotationMatrix: number[];
  26288. /**
  26289. * Parent particle Id, if any.
  26290. * Default null.
  26291. */
  26292. parentId: Nullable<number>;
  26293. /**
  26294. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26295. * The possible values are :
  26296. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26297. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26298. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26299. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26300. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26301. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26302. * */
  26303. cullingStrategy: number;
  26304. /**
  26305. * @hidden Internal global position in the SPS.
  26306. */
  26307. _globalPosition: Vector3;
  26308. /**
  26309. * Creates a Solid Particle object.
  26310. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26311. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26312. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26313. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26314. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26315. * @param shapeId (integer) is the model shape identifier in the SPS.
  26316. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26317. * @param sps defines the sps it is associated to
  26318. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26319. */
  26320. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26321. /**
  26322. * Legacy support, changed scale to scaling
  26323. */
  26324. /**
  26325. * Legacy support, changed scale to scaling
  26326. */
  26327. scale: Vector3;
  26328. /**
  26329. * Legacy support, changed quaternion to rotationQuaternion
  26330. */
  26331. /**
  26332. * Legacy support, changed quaternion to rotationQuaternion
  26333. */
  26334. quaternion: Nullable<Quaternion>;
  26335. /**
  26336. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26337. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26338. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26339. * @returns true if it intersects
  26340. */
  26341. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26342. /**
  26343. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26344. * A particle is in the frustum if its bounding box intersects the frustum
  26345. * @param frustumPlanes defines the frustum to test
  26346. * @returns true if the particle is in the frustum planes
  26347. */
  26348. isInFrustum(frustumPlanes: Plane[]): boolean;
  26349. /**
  26350. * get the rotation matrix of the particle
  26351. * @hidden
  26352. */
  26353. getRotationMatrix(m: Matrix): void;
  26354. }
  26355. /**
  26356. * Represents the shape of the model used by one particle of a solid particle system.
  26357. * SPS internal tool, don't use it manually.
  26358. */
  26359. export class ModelShape {
  26360. /**
  26361. * The shape id
  26362. * @hidden
  26363. */
  26364. shapeID: number;
  26365. /**
  26366. * flat array of model positions (internal use)
  26367. * @hidden
  26368. */
  26369. _shape: Vector3[];
  26370. /**
  26371. * flat array of model UVs (internal use)
  26372. * @hidden
  26373. */
  26374. _shapeUV: number[];
  26375. /**
  26376. * length of the shape in the model indices array (internal use)
  26377. * @hidden
  26378. */
  26379. _indicesLength: number;
  26380. /**
  26381. * Custom position function (internal use)
  26382. * @hidden
  26383. */
  26384. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26385. /**
  26386. * Custom vertex function (internal use)
  26387. * @hidden
  26388. */
  26389. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26390. /**
  26391. * 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.
  26392. * SPS internal tool, don't use it manually.
  26393. * @hidden
  26394. */
  26395. 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>);
  26396. }
  26397. /**
  26398. * Represents a Depth Sorted Particle in the solid particle system.
  26399. */
  26400. export class DepthSortedParticle {
  26401. /**
  26402. * Index of the particle in the "indices" array
  26403. */
  26404. ind: number;
  26405. /**
  26406. * Length of the particle shape in the "indices" array
  26407. */
  26408. indicesLength: number;
  26409. /**
  26410. * Squared distance from the particle to the camera
  26411. */
  26412. sqDistance: number;
  26413. }
  26414. }
  26415. declare module "babylonjs/Collisions/meshCollisionData" {
  26416. import { Collider } from "babylonjs/Collisions/collider";
  26417. import { Vector3 } from "babylonjs/Maths/math.vector";
  26418. import { Nullable } from "babylonjs/types";
  26419. import { Observer } from "babylonjs/Misc/observable";
  26420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26421. /**
  26422. * @hidden
  26423. */
  26424. export class _MeshCollisionData {
  26425. _checkCollisions: boolean;
  26426. _collisionMask: number;
  26427. _collisionGroup: number;
  26428. _collider: Nullable<Collider>;
  26429. _oldPositionForCollisions: Vector3;
  26430. _diffPositionForCollisions: Vector3;
  26431. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26432. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26433. }
  26434. }
  26435. declare module "babylonjs/Meshes/abstractMesh" {
  26436. import { Observable } from "babylonjs/Misc/observable";
  26437. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26438. import { Camera } from "babylonjs/Cameras/camera";
  26439. import { Scene, IDisposable } from "babylonjs/scene";
  26440. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26441. import { Node } from "babylonjs/node";
  26442. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26443. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26444. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26445. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26446. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26447. import { Material } from "babylonjs/Materials/material";
  26448. import { Light } from "babylonjs/Lights/light";
  26449. import { Skeleton } from "babylonjs/Bones/skeleton";
  26450. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26451. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26452. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26453. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26454. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26455. import { Plane } from "babylonjs/Maths/math.plane";
  26456. import { Ray } from "babylonjs/Culling/ray";
  26457. import { Collider } from "babylonjs/Collisions/collider";
  26458. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26459. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26460. /** @hidden */
  26461. class _FacetDataStorage {
  26462. facetPositions: Vector3[];
  26463. facetNormals: Vector3[];
  26464. facetPartitioning: number[][];
  26465. facetNb: number;
  26466. partitioningSubdivisions: number;
  26467. partitioningBBoxRatio: number;
  26468. facetDataEnabled: boolean;
  26469. facetParameters: any;
  26470. bbSize: Vector3;
  26471. subDiv: {
  26472. max: number;
  26473. X: number;
  26474. Y: number;
  26475. Z: number;
  26476. };
  26477. facetDepthSort: boolean;
  26478. facetDepthSortEnabled: boolean;
  26479. depthSortedIndices: IndicesArray;
  26480. depthSortedFacets: {
  26481. ind: number;
  26482. sqDistance: number;
  26483. }[];
  26484. facetDepthSortFunction: (f1: {
  26485. ind: number;
  26486. sqDistance: number;
  26487. }, f2: {
  26488. ind: number;
  26489. sqDistance: number;
  26490. }) => number;
  26491. facetDepthSortFrom: Vector3;
  26492. facetDepthSortOrigin: Vector3;
  26493. invertedMatrix: Matrix;
  26494. }
  26495. /**
  26496. * @hidden
  26497. **/
  26498. class _InternalAbstractMeshDataInfo {
  26499. _hasVertexAlpha: boolean;
  26500. _useVertexColors: boolean;
  26501. _numBoneInfluencers: number;
  26502. _applyFog: boolean;
  26503. _receiveShadows: boolean;
  26504. _facetData: _FacetDataStorage;
  26505. _visibility: number;
  26506. _skeleton: Nullable<Skeleton>;
  26507. _layerMask: number;
  26508. _computeBonesUsingShaders: boolean;
  26509. _isActive: boolean;
  26510. _onlyForInstances: boolean;
  26511. _isActiveIntermediate: boolean;
  26512. _onlyForInstancesIntermediate: boolean;
  26513. }
  26514. /**
  26515. * Class used to store all common mesh properties
  26516. */
  26517. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26518. /** No occlusion */
  26519. static OCCLUSION_TYPE_NONE: number;
  26520. /** Occlusion set to optimisitic */
  26521. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26522. /** Occlusion set to strict */
  26523. static OCCLUSION_TYPE_STRICT: number;
  26524. /** Use an accurante occlusion algorithm */
  26525. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26526. /** Use a conservative occlusion algorithm */
  26527. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26528. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26529. * Test order :
  26530. * Is the bounding sphere outside the frustum ?
  26531. * If not, are the bounding box vertices outside the frustum ?
  26532. * It not, then the cullable object is in the frustum.
  26533. */
  26534. static readonly CULLINGSTRATEGY_STANDARD: number;
  26535. /** Culling strategy : Bounding Sphere Only.
  26536. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26537. * It's also less accurate than the standard because some not visible objects can still be selected.
  26538. * Test : is the bounding sphere outside the frustum ?
  26539. * If not, then the cullable object is in the frustum.
  26540. */
  26541. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26542. /** Culling strategy : Optimistic Inclusion.
  26543. * This in an inclusion test first, then the standard exclusion test.
  26544. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26545. * 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.
  26546. * Anyway, it's as accurate as the standard strategy.
  26547. * Test :
  26548. * Is the cullable object bounding sphere center in the frustum ?
  26549. * If not, apply the default culling strategy.
  26550. */
  26551. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26552. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26553. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26554. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26555. * 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.
  26556. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26557. * Test :
  26558. * Is the cullable object bounding sphere center in the frustum ?
  26559. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26560. */
  26561. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26562. /**
  26563. * No billboard
  26564. */
  26565. static readonly BILLBOARDMODE_NONE: number;
  26566. /** Billboard on X axis */
  26567. static readonly BILLBOARDMODE_X: number;
  26568. /** Billboard on Y axis */
  26569. static readonly BILLBOARDMODE_Y: number;
  26570. /** Billboard on Z axis */
  26571. static readonly BILLBOARDMODE_Z: number;
  26572. /** Billboard on all axes */
  26573. static readonly BILLBOARDMODE_ALL: number;
  26574. /** Billboard on using position instead of orientation */
  26575. static readonly BILLBOARDMODE_USE_POSITION: number;
  26576. /** @hidden */
  26577. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26578. /**
  26579. * The culling strategy to use to check whether the mesh must be rendered or not.
  26580. * This value can be changed at any time and will be used on the next render mesh selection.
  26581. * The possible values are :
  26582. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26583. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26584. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26585. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26586. * Please read each static variable documentation to get details about the culling process.
  26587. * */
  26588. cullingStrategy: number;
  26589. /**
  26590. * Gets the number of facets in the mesh
  26591. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26592. */
  26593. readonly facetNb: number;
  26594. /**
  26595. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26596. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26597. */
  26598. partitioningSubdivisions: number;
  26599. /**
  26600. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26601. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26602. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26603. */
  26604. partitioningBBoxRatio: number;
  26605. /**
  26606. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26607. * Works only for updatable meshes.
  26608. * Doesn't work with multi-materials
  26609. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26610. */
  26611. mustDepthSortFacets: boolean;
  26612. /**
  26613. * The location (Vector3) where the facet depth sort must be computed from.
  26614. * By default, the active camera position.
  26615. * Used only when facet depth sort is enabled
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26617. */
  26618. facetDepthSortFrom: Vector3;
  26619. /**
  26620. * gets a boolean indicating if facetData is enabled
  26621. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26622. */
  26623. readonly isFacetDataEnabled: boolean;
  26624. /** @hidden */
  26625. _updateNonUniformScalingState(value: boolean): boolean;
  26626. /**
  26627. * An event triggered when this mesh collides with another one
  26628. */
  26629. onCollideObservable: Observable<AbstractMesh>;
  26630. /** Set a function to call when this mesh collides with another one */
  26631. onCollide: () => void;
  26632. /**
  26633. * An event triggered when the collision's position changes
  26634. */
  26635. onCollisionPositionChangeObservable: Observable<Vector3>;
  26636. /** Set a function to call when the collision's position changes */
  26637. onCollisionPositionChange: () => void;
  26638. /**
  26639. * An event triggered when material is changed
  26640. */
  26641. onMaterialChangedObservable: Observable<AbstractMesh>;
  26642. /**
  26643. * Gets or sets the orientation for POV movement & rotation
  26644. */
  26645. definedFacingForward: boolean;
  26646. /** @hidden */
  26647. _occlusionQuery: Nullable<WebGLQuery>;
  26648. /** @hidden */
  26649. _renderingGroup: Nullable<RenderingGroup>;
  26650. /**
  26651. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26652. */
  26653. /**
  26654. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26655. */
  26656. visibility: number;
  26657. /** Gets or sets the alpha index used to sort transparent meshes
  26658. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26659. */
  26660. alphaIndex: number;
  26661. /**
  26662. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26663. */
  26664. isVisible: boolean;
  26665. /**
  26666. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26667. */
  26668. isPickable: boolean;
  26669. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26670. showSubMeshesBoundingBox: boolean;
  26671. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26672. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26673. */
  26674. isBlocker: boolean;
  26675. /**
  26676. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26677. */
  26678. enablePointerMoveEvents: boolean;
  26679. /**
  26680. * Specifies the rendering group id for this mesh (0 by default)
  26681. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26682. */
  26683. renderingGroupId: number;
  26684. private _material;
  26685. /** Gets or sets current material */
  26686. material: Nullable<Material>;
  26687. /**
  26688. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26689. * @see http://doc.babylonjs.com/babylon101/shadows
  26690. */
  26691. receiveShadows: boolean;
  26692. /** Defines color to use when rendering outline */
  26693. outlineColor: Color3;
  26694. /** Define width to use when rendering outline */
  26695. outlineWidth: number;
  26696. /** Defines color to use when rendering overlay */
  26697. overlayColor: Color3;
  26698. /** Defines alpha to use when rendering overlay */
  26699. overlayAlpha: number;
  26700. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26701. hasVertexAlpha: boolean;
  26702. /** 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) */
  26703. useVertexColors: boolean;
  26704. /**
  26705. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26706. */
  26707. computeBonesUsingShaders: boolean;
  26708. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26709. numBoneInfluencers: number;
  26710. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26711. applyFog: boolean;
  26712. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26713. useOctreeForRenderingSelection: boolean;
  26714. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26715. useOctreeForPicking: boolean;
  26716. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26717. useOctreeForCollisions: boolean;
  26718. /**
  26719. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26720. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26721. */
  26722. layerMask: number;
  26723. /**
  26724. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26725. */
  26726. alwaysSelectAsActiveMesh: boolean;
  26727. /**
  26728. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26729. */
  26730. doNotSyncBoundingInfo: boolean;
  26731. /**
  26732. * Gets or sets the current action manager
  26733. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26734. */
  26735. actionManager: Nullable<AbstractActionManager>;
  26736. private _meshCollisionData;
  26737. /**
  26738. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26739. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26740. */
  26741. ellipsoid: Vector3;
  26742. /**
  26743. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26744. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26745. */
  26746. ellipsoidOffset: Vector3;
  26747. /**
  26748. * Gets or sets a collision mask used to mask collisions (default is -1).
  26749. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26750. */
  26751. collisionMask: number;
  26752. /**
  26753. * Gets or sets the current collision group mask (-1 by default).
  26754. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26755. */
  26756. collisionGroup: number;
  26757. /**
  26758. * Defines edge width used when edgesRenderer is enabled
  26759. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26760. */
  26761. edgesWidth: number;
  26762. /**
  26763. * Defines edge color used when edgesRenderer is enabled
  26764. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26765. */
  26766. edgesColor: Color4;
  26767. /** @hidden */
  26768. _edgesRenderer: Nullable<IEdgesRenderer>;
  26769. /** @hidden */
  26770. _masterMesh: Nullable<AbstractMesh>;
  26771. /** @hidden */
  26772. _boundingInfo: Nullable<BoundingInfo>;
  26773. /** @hidden */
  26774. _renderId: number;
  26775. /**
  26776. * Gets or sets the list of subMeshes
  26777. * @see http://doc.babylonjs.com/how_to/multi_materials
  26778. */
  26779. subMeshes: SubMesh[];
  26780. /** @hidden */
  26781. _intersectionsInProgress: AbstractMesh[];
  26782. /** @hidden */
  26783. _unIndexed: boolean;
  26784. /** @hidden */
  26785. _lightSources: Light[];
  26786. /** Gets the list of lights affecting that mesh */
  26787. readonly lightSources: Light[];
  26788. /** @hidden */
  26789. readonly _positions: Nullable<Vector3[]>;
  26790. /** @hidden */
  26791. _waitingData: {
  26792. lods: Nullable<any>;
  26793. actions: Nullable<any>;
  26794. freezeWorldMatrix: Nullable<boolean>;
  26795. };
  26796. /** @hidden */
  26797. _bonesTransformMatrices: Nullable<Float32Array>;
  26798. /** @hidden */
  26799. _transformMatrixTexture: Nullable<RawTexture>;
  26800. /**
  26801. * Gets or sets a skeleton to apply skining transformations
  26802. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26803. */
  26804. skeleton: Nullable<Skeleton>;
  26805. /**
  26806. * An event triggered when the mesh is rebuilt.
  26807. */
  26808. onRebuildObservable: Observable<AbstractMesh>;
  26809. /**
  26810. * Creates a new AbstractMesh
  26811. * @param name defines the name of the mesh
  26812. * @param scene defines the hosting scene
  26813. */
  26814. constructor(name: string, scene?: Nullable<Scene>);
  26815. /**
  26816. * Returns the string "AbstractMesh"
  26817. * @returns "AbstractMesh"
  26818. */
  26819. getClassName(): string;
  26820. /**
  26821. * Gets a string representation of the current mesh
  26822. * @param fullDetails defines a boolean indicating if full details must be included
  26823. * @returns a string representation of the current mesh
  26824. */
  26825. toString(fullDetails?: boolean): string;
  26826. /**
  26827. * @hidden
  26828. */
  26829. protected _getEffectiveParent(): Nullable<Node>;
  26830. /** @hidden */
  26831. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26832. /** @hidden */
  26833. _rebuild(): void;
  26834. /** @hidden */
  26835. _resyncLightSources(): void;
  26836. /** @hidden */
  26837. _resyncLighSource(light: Light): void;
  26838. /** @hidden */
  26839. _unBindEffect(): void;
  26840. /** @hidden */
  26841. _removeLightSource(light: Light, dispose: boolean): void;
  26842. private _markSubMeshesAsDirty;
  26843. /** @hidden */
  26844. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26845. /** @hidden */
  26846. _markSubMeshesAsAttributesDirty(): void;
  26847. /** @hidden */
  26848. _markSubMeshesAsMiscDirty(): void;
  26849. /**
  26850. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26851. */
  26852. scaling: Vector3;
  26853. /**
  26854. * Returns true if the mesh is blocked. Implemented by child classes
  26855. */
  26856. readonly isBlocked: boolean;
  26857. /**
  26858. * Returns the mesh itself by default. Implemented by child classes
  26859. * @param camera defines the camera to use to pick the right LOD level
  26860. * @returns the currentAbstractMesh
  26861. */
  26862. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26863. /**
  26864. * Returns 0 by default. Implemented by child classes
  26865. * @returns an integer
  26866. */
  26867. getTotalVertices(): number;
  26868. /**
  26869. * Returns a positive integer : the total number of indices in this mesh geometry.
  26870. * @returns the numner of indices or zero if the mesh has no geometry.
  26871. */
  26872. getTotalIndices(): number;
  26873. /**
  26874. * Returns null by default. Implemented by child classes
  26875. * @returns null
  26876. */
  26877. getIndices(): Nullable<IndicesArray>;
  26878. /**
  26879. * Returns the array of the requested vertex data kind. Implemented by child classes
  26880. * @param kind defines the vertex data kind to use
  26881. * @returns null
  26882. */
  26883. getVerticesData(kind: string): Nullable<FloatArray>;
  26884. /**
  26885. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26886. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26887. * Note that a new underlying VertexBuffer object is created each call.
  26888. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26889. * @param kind defines vertex data kind:
  26890. * * VertexBuffer.PositionKind
  26891. * * VertexBuffer.UVKind
  26892. * * VertexBuffer.UV2Kind
  26893. * * VertexBuffer.UV3Kind
  26894. * * VertexBuffer.UV4Kind
  26895. * * VertexBuffer.UV5Kind
  26896. * * VertexBuffer.UV6Kind
  26897. * * VertexBuffer.ColorKind
  26898. * * VertexBuffer.MatricesIndicesKind
  26899. * * VertexBuffer.MatricesIndicesExtraKind
  26900. * * VertexBuffer.MatricesWeightsKind
  26901. * * VertexBuffer.MatricesWeightsExtraKind
  26902. * @param data defines the data source
  26903. * @param updatable defines if the data must be flagged as updatable (or static)
  26904. * @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
  26905. * @returns the current mesh
  26906. */
  26907. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26908. /**
  26909. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26910. * If the mesh has no geometry, it is simply returned as it is.
  26911. * @param kind defines vertex data kind:
  26912. * * VertexBuffer.PositionKind
  26913. * * VertexBuffer.UVKind
  26914. * * VertexBuffer.UV2Kind
  26915. * * VertexBuffer.UV3Kind
  26916. * * VertexBuffer.UV4Kind
  26917. * * VertexBuffer.UV5Kind
  26918. * * VertexBuffer.UV6Kind
  26919. * * VertexBuffer.ColorKind
  26920. * * VertexBuffer.MatricesIndicesKind
  26921. * * VertexBuffer.MatricesIndicesExtraKind
  26922. * * VertexBuffer.MatricesWeightsKind
  26923. * * VertexBuffer.MatricesWeightsExtraKind
  26924. * @param data defines the data source
  26925. * @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
  26926. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26927. * @returns the current mesh
  26928. */
  26929. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26930. /**
  26931. * Sets the mesh indices,
  26932. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26933. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26934. * @param totalVertices Defines the total number of vertices
  26935. * @returns the current mesh
  26936. */
  26937. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26938. /**
  26939. * Gets a boolean indicating if specific vertex data is present
  26940. * @param kind defines the vertex data kind to use
  26941. * @returns true is data kind is present
  26942. */
  26943. isVerticesDataPresent(kind: string): boolean;
  26944. /**
  26945. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26946. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26947. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26948. * @returns a BoundingInfo
  26949. */
  26950. getBoundingInfo(): BoundingInfo;
  26951. /**
  26952. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26953. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26954. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26955. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26956. * @returns the current mesh
  26957. */
  26958. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26959. /**
  26960. * Overwrite the current bounding info
  26961. * @param boundingInfo defines the new bounding info
  26962. * @returns the current mesh
  26963. */
  26964. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26965. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26966. readonly useBones: boolean;
  26967. /** @hidden */
  26968. _preActivate(): void;
  26969. /** @hidden */
  26970. _preActivateForIntermediateRendering(renderId: number): void;
  26971. /** @hidden */
  26972. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26973. /** @hidden */
  26974. _postActivate(): void;
  26975. /** @hidden */
  26976. _freeze(): void;
  26977. /** @hidden */
  26978. _unFreeze(): void;
  26979. /**
  26980. * Gets the current world matrix
  26981. * @returns a Matrix
  26982. */
  26983. getWorldMatrix(): Matrix;
  26984. /** @hidden */
  26985. _getWorldMatrixDeterminant(): number;
  26986. /**
  26987. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  26988. */
  26989. readonly isAnInstance: boolean;
  26990. /**
  26991. * Gets a boolean indicating if this mesh has instances
  26992. */
  26993. readonly hasInstances: boolean;
  26994. /**
  26995. * Perform relative position change from the point of view of behind the front of the mesh.
  26996. * This is performed taking into account the meshes current rotation, so you do not have to care.
  26997. * Supports definition of mesh facing forward or backward
  26998. * @param amountRight defines the distance on the right axis
  26999. * @param amountUp defines the distance on the up axis
  27000. * @param amountForward defines the distance on the forward axis
  27001. * @returns the current mesh
  27002. */
  27003. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27004. /**
  27005. * Calculate relative position change from the point of view of behind the front of the mesh.
  27006. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27007. * Supports definition of mesh facing forward or backward
  27008. * @param amountRight defines the distance on the right axis
  27009. * @param amountUp defines the distance on the up axis
  27010. * @param amountForward defines the distance on the forward axis
  27011. * @returns the new displacement vector
  27012. */
  27013. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27014. /**
  27015. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27016. * Supports definition of mesh facing forward or backward
  27017. * @param flipBack defines the flip
  27018. * @param twirlClockwise defines the twirl
  27019. * @param tiltRight defines the tilt
  27020. * @returns the current mesh
  27021. */
  27022. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27023. /**
  27024. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27025. * Supports definition of mesh facing forward or backward.
  27026. * @param flipBack defines the flip
  27027. * @param twirlClockwise defines the twirl
  27028. * @param tiltRight defines the tilt
  27029. * @returns the new rotation vector
  27030. */
  27031. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27032. /**
  27033. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27034. * This means the mesh underlying bounding box and sphere are recomputed.
  27035. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27036. * @returns the current mesh
  27037. */
  27038. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27039. /** @hidden */
  27040. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27041. /** @hidden */
  27042. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27043. /** @hidden */
  27044. _updateBoundingInfo(): AbstractMesh;
  27045. /** @hidden */
  27046. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27047. /** @hidden */
  27048. protected _afterComputeWorldMatrix(): void;
  27049. /** @hidden */
  27050. readonly _effectiveMesh: AbstractMesh;
  27051. /**
  27052. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27053. * A mesh is in the frustum if its bounding box intersects the frustum
  27054. * @param frustumPlanes defines the frustum to test
  27055. * @returns true if the mesh is in the frustum planes
  27056. */
  27057. isInFrustum(frustumPlanes: Plane[]): boolean;
  27058. /**
  27059. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27060. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27061. * @param frustumPlanes defines the frustum to test
  27062. * @returns true if the mesh is completely in the frustum planes
  27063. */
  27064. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27065. /**
  27066. * True if the mesh intersects another mesh or a SolidParticle object
  27067. * @param mesh defines a target mesh or SolidParticle to test
  27068. * @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)
  27069. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27070. * @returns true if there is an intersection
  27071. */
  27072. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27073. /**
  27074. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27075. * @param point defines the point to test
  27076. * @returns true if there is an intersection
  27077. */
  27078. intersectsPoint(point: Vector3): boolean;
  27079. /**
  27080. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27082. */
  27083. checkCollisions: boolean;
  27084. /**
  27085. * Gets Collider object used to compute collisions (not physics)
  27086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27087. */
  27088. readonly collider: Nullable<Collider>;
  27089. /**
  27090. * Move the mesh using collision engine
  27091. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27092. * @param displacement defines the requested displacement vector
  27093. * @returns the current mesh
  27094. */
  27095. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27096. private _onCollisionPositionChange;
  27097. /** @hidden */
  27098. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27099. /** @hidden */
  27100. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27101. /** @hidden */
  27102. _checkCollision(collider: Collider): AbstractMesh;
  27103. /** @hidden */
  27104. _generatePointsArray(): boolean;
  27105. /**
  27106. * Checks if the passed Ray intersects with the mesh
  27107. * @param ray defines the ray to use
  27108. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27109. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27110. * @returns the picking info
  27111. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27112. */
  27113. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27114. /**
  27115. * Clones the current mesh
  27116. * @param name defines the mesh name
  27117. * @param newParent defines the new mesh parent
  27118. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27119. * @returns the new mesh
  27120. */
  27121. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27122. /**
  27123. * Disposes all the submeshes of the current meshnp
  27124. * @returns the current mesh
  27125. */
  27126. releaseSubMeshes(): AbstractMesh;
  27127. /**
  27128. * Releases resources associated with this abstract mesh.
  27129. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27130. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27131. */
  27132. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27133. /**
  27134. * Adds the passed mesh as a child to the current mesh
  27135. * @param mesh defines the child mesh
  27136. * @returns the current mesh
  27137. */
  27138. addChild(mesh: AbstractMesh): AbstractMesh;
  27139. /**
  27140. * Removes the passed mesh from the current mesh children list
  27141. * @param mesh defines the child mesh
  27142. * @returns the current mesh
  27143. */
  27144. removeChild(mesh: AbstractMesh): AbstractMesh;
  27145. /** @hidden */
  27146. private _initFacetData;
  27147. /**
  27148. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27149. * This method can be called within the render loop.
  27150. * 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
  27151. * @returns the current mesh
  27152. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27153. */
  27154. updateFacetData(): AbstractMesh;
  27155. /**
  27156. * Returns the facetLocalNormals array.
  27157. * The normals are expressed in the mesh local spac
  27158. * @returns an array of Vector3
  27159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27160. */
  27161. getFacetLocalNormals(): Vector3[];
  27162. /**
  27163. * Returns the facetLocalPositions array.
  27164. * The facet positions are expressed in the mesh local space
  27165. * @returns an array of Vector3
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27167. */
  27168. getFacetLocalPositions(): Vector3[];
  27169. /**
  27170. * Returns the facetLocalPartioning array
  27171. * @returns an array of array of numbers
  27172. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27173. */
  27174. getFacetLocalPartitioning(): number[][];
  27175. /**
  27176. * Returns the i-th facet position in the world system.
  27177. * This method allocates a new Vector3 per call
  27178. * @param i defines the facet index
  27179. * @returns a new Vector3
  27180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27181. */
  27182. getFacetPosition(i: number): Vector3;
  27183. /**
  27184. * Sets the reference Vector3 with the i-th facet position in the world system
  27185. * @param i defines the facet index
  27186. * @param ref defines the target vector
  27187. * @returns the current mesh
  27188. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27189. */
  27190. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27191. /**
  27192. * Returns the i-th facet normal in the world system.
  27193. * This method allocates a new Vector3 per call
  27194. * @param i defines the facet index
  27195. * @returns a new Vector3
  27196. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27197. */
  27198. getFacetNormal(i: number): Vector3;
  27199. /**
  27200. * Sets the reference Vector3 with the i-th facet normal in the world system
  27201. * @param i defines the facet index
  27202. * @param ref defines the target vector
  27203. * @returns the current mesh
  27204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27205. */
  27206. getFacetNormalToRef(i: number, ref: Vector3): this;
  27207. /**
  27208. * 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)
  27209. * @param x defines x coordinate
  27210. * @param y defines y coordinate
  27211. * @param z defines z coordinate
  27212. * @returns the array of facet indexes
  27213. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27214. */
  27215. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27216. /**
  27217. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27218. * @param projected sets as the (x,y,z) world projection on the facet
  27219. * @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
  27220. * @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
  27221. * @param x defines x coordinate
  27222. * @param y defines y coordinate
  27223. * @param z defines z coordinate
  27224. * @returns the face index if found (or null instead)
  27225. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27226. */
  27227. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27228. /**
  27229. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27230. * @param projected sets as the (x,y,z) local projection on the facet
  27231. * @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
  27232. * @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
  27233. * @param x defines x coordinate
  27234. * @param y defines y coordinate
  27235. * @param z defines z coordinate
  27236. * @returns the face index if found (or null instead)
  27237. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27238. */
  27239. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27240. /**
  27241. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27242. * @returns the parameters
  27243. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27244. */
  27245. getFacetDataParameters(): any;
  27246. /**
  27247. * Disables the feature FacetData and frees the related memory
  27248. * @returns the current mesh
  27249. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27250. */
  27251. disableFacetData(): AbstractMesh;
  27252. /**
  27253. * Updates the AbstractMesh indices array
  27254. * @param indices defines the data source
  27255. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27256. * @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)
  27257. * @returns the current mesh
  27258. */
  27259. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27260. /**
  27261. * Creates new normals data for the mesh
  27262. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27263. * @returns the current mesh
  27264. */
  27265. createNormals(updatable: boolean): AbstractMesh;
  27266. /**
  27267. * Align the mesh with a normal
  27268. * @param normal defines the normal to use
  27269. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27270. * @returns the current mesh
  27271. */
  27272. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27273. /** @hidden */
  27274. _checkOcclusionQuery(): boolean;
  27275. /**
  27276. * Disables the mesh edge rendering mode
  27277. * @returns the currentAbstractMesh
  27278. */
  27279. disableEdgesRendering(): AbstractMesh;
  27280. /**
  27281. * Enables the edge rendering mode on the mesh.
  27282. * This mode makes the mesh edges visible
  27283. * @param epsilon defines the maximal distance between two angles to detect a face
  27284. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27285. * @returns the currentAbstractMesh
  27286. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27287. */
  27288. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27289. }
  27290. }
  27291. declare module "babylonjs/Actions/actionEvent" {
  27292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27293. import { Nullable } from "babylonjs/types";
  27294. import { Sprite } from "babylonjs/Sprites/sprite";
  27295. import { Scene } from "babylonjs/scene";
  27296. import { Vector2 } from "babylonjs/Maths/math.vector";
  27297. /**
  27298. * Interface used to define ActionEvent
  27299. */
  27300. export interface IActionEvent {
  27301. /** The mesh or sprite that triggered the action */
  27302. source: any;
  27303. /** The X mouse cursor position at the time of the event */
  27304. pointerX: number;
  27305. /** The Y mouse cursor position at the time of the event */
  27306. pointerY: number;
  27307. /** The mesh that is currently pointed at (can be null) */
  27308. meshUnderPointer: Nullable<AbstractMesh>;
  27309. /** the original (browser) event that triggered the ActionEvent */
  27310. sourceEvent?: any;
  27311. /** additional data for the event */
  27312. additionalData?: any;
  27313. }
  27314. /**
  27315. * ActionEvent is the event being sent when an action is triggered.
  27316. */
  27317. export class ActionEvent implements IActionEvent {
  27318. /** The mesh or sprite that triggered the action */
  27319. source: any;
  27320. /** The X mouse cursor position at the time of the event */
  27321. pointerX: number;
  27322. /** The Y mouse cursor position at the time of the event */
  27323. pointerY: number;
  27324. /** The mesh that is currently pointed at (can be null) */
  27325. meshUnderPointer: Nullable<AbstractMesh>;
  27326. /** the original (browser) event that triggered the ActionEvent */
  27327. sourceEvent?: any;
  27328. /** additional data for the event */
  27329. additionalData?: any;
  27330. /**
  27331. * Creates a new ActionEvent
  27332. * @param source The mesh or sprite that triggered the action
  27333. * @param pointerX The X mouse cursor position at the time of the event
  27334. * @param pointerY The Y mouse cursor position at the time of the event
  27335. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27336. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27337. * @param additionalData additional data for the event
  27338. */
  27339. constructor(
  27340. /** The mesh or sprite that triggered the action */
  27341. source: any,
  27342. /** The X mouse cursor position at the time of the event */
  27343. pointerX: number,
  27344. /** The Y mouse cursor position at the time of the event */
  27345. pointerY: number,
  27346. /** The mesh that is currently pointed at (can be null) */
  27347. meshUnderPointer: Nullable<AbstractMesh>,
  27348. /** the original (browser) event that triggered the ActionEvent */
  27349. sourceEvent?: any,
  27350. /** additional data for the event */
  27351. additionalData?: any);
  27352. /**
  27353. * Helper function to auto-create an ActionEvent from a source mesh.
  27354. * @param source The source mesh that triggered the event
  27355. * @param evt The original (browser) event
  27356. * @param additionalData additional data for the event
  27357. * @returns the new ActionEvent
  27358. */
  27359. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27360. /**
  27361. * Helper function to auto-create an ActionEvent from a source sprite
  27362. * @param source The source sprite that triggered the event
  27363. * @param scene Scene associated with the sprite
  27364. * @param evt The original (browser) event
  27365. * @param additionalData additional data for the event
  27366. * @returns the new ActionEvent
  27367. */
  27368. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27369. /**
  27370. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27371. * @param scene the scene where the event occurred
  27372. * @param evt The original (browser) event
  27373. * @returns the new ActionEvent
  27374. */
  27375. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27376. /**
  27377. * Helper function to auto-create an ActionEvent from a primitive
  27378. * @param prim defines the target primitive
  27379. * @param pointerPos defines the pointer position
  27380. * @param evt The original (browser) event
  27381. * @param additionalData additional data for the event
  27382. * @returns the new ActionEvent
  27383. */
  27384. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27385. }
  27386. }
  27387. declare module "babylonjs/Actions/abstractActionManager" {
  27388. import { IDisposable } from "babylonjs/scene";
  27389. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27390. import { IAction } from "babylonjs/Actions/action";
  27391. import { Nullable } from "babylonjs/types";
  27392. /**
  27393. * Abstract class used to decouple action Manager from scene and meshes.
  27394. * Do not instantiate.
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27396. */
  27397. export abstract class AbstractActionManager implements IDisposable {
  27398. /** Gets the list of active triggers */
  27399. static Triggers: {
  27400. [key: string]: number;
  27401. };
  27402. /** Gets the cursor to use when hovering items */
  27403. hoverCursor: string;
  27404. /** Gets the list of actions */
  27405. actions: IAction[];
  27406. /**
  27407. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27408. */
  27409. isRecursive: boolean;
  27410. /**
  27411. * Releases all associated resources
  27412. */
  27413. abstract dispose(): void;
  27414. /**
  27415. * Does this action manager has pointer triggers
  27416. */
  27417. abstract readonly hasPointerTriggers: boolean;
  27418. /**
  27419. * Does this action manager has pick triggers
  27420. */
  27421. abstract readonly hasPickTriggers: boolean;
  27422. /**
  27423. * Process a specific trigger
  27424. * @param trigger defines the trigger to process
  27425. * @param evt defines the event details to be processed
  27426. */
  27427. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27428. /**
  27429. * Does this action manager handles actions of any of the given triggers
  27430. * @param triggers defines the triggers to be tested
  27431. * @return a boolean indicating whether one (or more) of the triggers is handled
  27432. */
  27433. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27434. /**
  27435. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27436. * speed.
  27437. * @param triggerA defines the trigger to be tested
  27438. * @param triggerB defines the trigger to be tested
  27439. * @return a boolean indicating whether one (or more) of the triggers is handled
  27440. */
  27441. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27442. /**
  27443. * Does this action manager handles actions of a given trigger
  27444. * @param trigger defines the trigger to be tested
  27445. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27446. * @return whether the trigger is handled
  27447. */
  27448. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27449. /**
  27450. * Serialize this manager to a JSON object
  27451. * @param name defines the property name to store this manager
  27452. * @returns a JSON representation of this manager
  27453. */
  27454. abstract serialize(name: string): any;
  27455. /**
  27456. * Registers an action to this action manager
  27457. * @param action defines the action to be registered
  27458. * @return the action amended (prepared) after registration
  27459. */
  27460. abstract registerAction(action: IAction): Nullable<IAction>;
  27461. /**
  27462. * Unregisters an action to this action manager
  27463. * @param action defines the action to be unregistered
  27464. * @return a boolean indicating whether the action has been unregistered
  27465. */
  27466. abstract unregisterAction(action: IAction): Boolean;
  27467. /**
  27468. * Does exist one action manager with at least one trigger
  27469. **/
  27470. static readonly HasTriggers: boolean;
  27471. /**
  27472. * Does exist one action manager with at least one pick trigger
  27473. **/
  27474. static readonly HasPickTriggers: boolean;
  27475. /**
  27476. * Does exist one action manager that handles actions of a given trigger
  27477. * @param trigger defines the trigger to be tested
  27478. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27479. **/
  27480. static HasSpecificTrigger(trigger: number): boolean;
  27481. }
  27482. }
  27483. declare module "babylonjs/node" {
  27484. import { Scene } from "babylonjs/scene";
  27485. import { Nullable } from "babylonjs/types";
  27486. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27487. import { Engine } from "babylonjs/Engines/engine";
  27488. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27489. import { Observable } from "babylonjs/Misc/observable";
  27490. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27491. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27492. import { Animatable } from "babylonjs/Animations/animatable";
  27493. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27494. import { Animation } from "babylonjs/Animations/animation";
  27495. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27497. /**
  27498. * Defines how a node can be built from a string name.
  27499. */
  27500. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27501. /**
  27502. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27503. */
  27504. export class Node implements IBehaviorAware<Node> {
  27505. /** @hidden */
  27506. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27507. private static _NodeConstructors;
  27508. /**
  27509. * Add a new node constructor
  27510. * @param type defines the type name of the node to construct
  27511. * @param constructorFunc defines the constructor function
  27512. */
  27513. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27514. /**
  27515. * Returns a node constructor based on type name
  27516. * @param type defines the type name
  27517. * @param name defines the new node name
  27518. * @param scene defines the hosting scene
  27519. * @param options defines optional options to transmit to constructors
  27520. * @returns the new constructor or null
  27521. */
  27522. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27523. /**
  27524. * Gets or sets the name of the node
  27525. */
  27526. name: string;
  27527. /**
  27528. * Gets or sets the id of the node
  27529. */
  27530. id: string;
  27531. /**
  27532. * Gets or sets the unique id of the node
  27533. */
  27534. uniqueId: number;
  27535. /**
  27536. * Gets or sets a string used to store user defined state for the node
  27537. */
  27538. state: string;
  27539. /**
  27540. * Gets or sets an object used to store user defined information for the node
  27541. */
  27542. metadata: any;
  27543. /**
  27544. * For internal use only. Please do not use.
  27545. */
  27546. reservedDataStore: any;
  27547. /**
  27548. * List of inspectable custom properties (used by the Inspector)
  27549. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27550. */
  27551. inspectableCustomProperties: IInspectable[];
  27552. private _doNotSerialize;
  27553. /**
  27554. * Gets or sets a boolean used to define if the node must be serialized
  27555. */
  27556. doNotSerialize: boolean;
  27557. /** @hidden */
  27558. _isDisposed: boolean;
  27559. /**
  27560. * Gets a list of Animations associated with the node
  27561. */
  27562. animations: import("babylonjs/Animations/animation").Animation[];
  27563. protected _ranges: {
  27564. [name: string]: Nullable<AnimationRange>;
  27565. };
  27566. /**
  27567. * Callback raised when the node is ready to be used
  27568. */
  27569. onReady: Nullable<(node: Node) => void>;
  27570. private _isEnabled;
  27571. private _isParentEnabled;
  27572. private _isReady;
  27573. /** @hidden */
  27574. _currentRenderId: number;
  27575. private _parentUpdateId;
  27576. /** @hidden */
  27577. _childUpdateId: number;
  27578. /** @hidden */
  27579. _waitingParentId: Nullable<string>;
  27580. /** @hidden */
  27581. _scene: Scene;
  27582. /** @hidden */
  27583. _cache: any;
  27584. private _parentNode;
  27585. private _children;
  27586. /** @hidden */
  27587. _worldMatrix: Matrix;
  27588. /** @hidden */
  27589. _worldMatrixDeterminant: number;
  27590. /** @hidden */
  27591. _worldMatrixDeterminantIsDirty: boolean;
  27592. /** @hidden */
  27593. private _sceneRootNodesIndex;
  27594. /**
  27595. * Gets a boolean indicating if the node has been disposed
  27596. * @returns true if the node was disposed
  27597. */
  27598. isDisposed(): boolean;
  27599. /**
  27600. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27601. * @see https://doc.babylonjs.com/how_to/parenting
  27602. */
  27603. parent: Nullable<Node>;
  27604. private addToSceneRootNodes;
  27605. private removeFromSceneRootNodes;
  27606. private _animationPropertiesOverride;
  27607. /**
  27608. * Gets or sets the animation properties override
  27609. */
  27610. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27611. /**
  27612. * Gets a string idenfifying the name of the class
  27613. * @returns "Node" string
  27614. */
  27615. getClassName(): string;
  27616. /** @hidden */
  27617. readonly _isNode: boolean;
  27618. /**
  27619. * An event triggered when the mesh is disposed
  27620. */
  27621. onDisposeObservable: Observable<Node>;
  27622. private _onDisposeObserver;
  27623. /**
  27624. * Sets a callback that will be raised when the node will be disposed
  27625. */
  27626. onDispose: () => void;
  27627. /**
  27628. * Creates a new Node
  27629. * @param name the name and id to be given to this node
  27630. * @param scene the scene this node will be added to
  27631. * @param addToRootNodes the node will be added to scene.rootNodes
  27632. */
  27633. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27634. /**
  27635. * Gets the scene of the node
  27636. * @returns a scene
  27637. */
  27638. getScene(): Scene;
  27639. /**
  27640. * Gets the engine of the node
  27641. * @returns a Engine
  27642. */
  27643. getEngine(): Engine;
  27644. private _behaviors;
  27645. /**
  27646. * Attach a behavior to the node
  27647. * @see http://doc.babylonjs.com/features/behaviour
  27648. * @param behavior defines the behavior to attach
  27649. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27650. * @returns the current Node
  27651. */
  27652. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27653. /**
  27654. * Remove an attached behavior
  27655. * @see http://doc.babylonjs.com/features/behaviour
  27656. * @param behavior defines the behavior to attach
  27657. * @returns the current Node
  27658. */
  27659. removeBehavior(behavior: Behavior<Node>): Node;
  27660. /**
  27661. * Gets the list of attached behaviors
  27662. * @see http://doc.babylonjs.com/features/behaviour
  27663. */
  27664. readonly behaviors: Behavior<Node>[];
  27665. /**
  27666. * Gets an attached behavior by name
  27667. * @param name defines the name of the behavior to look for
  27668. * @see http://doc.babylonjs.com/features/behaviour
  27669. * @returns null if behavior was not found else the requested behavior
  27670. */
  27671. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27672. /**
  27673. * Returns the latest update of the World matrix
  27674. * @returns a Matrix
  27675. */
  27676. getWorldMatrix(): Matrix;
  27677. /** @hidden */
  27678. _getWorldMatrixDeterminant(): number;
  27679. /**
  27680. * Returns directly the latest state of the mesh World matrix.
  27681. * A Matrix is returned.
  27682. */
  27683. readonly worldMatrixFromCache: Matrix;
  27684. /** @hidden */
  27685. _initCache(): void;
  27686. /** @hidden */
  27687. updateCache(force?: boolean): void;
  27688. /** @hidden */
  27689. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27690. /** @hidden */
  27691. _updateCache(ignoreParentClass?: boolean): void;
  27692. /** @hidden */
  27693. _isSynchronized(): boolean;
  27694. /** @hidden */
  27695. _markSyncedWithParent(): void;
  27696. /** @hidden */
  27697. isSynchronizedWithParent(): boolean;
  27698. /** @hidden */
  27699. isSynchronized(): boolean;
  27700. /**
  27701. * Is this node ready to be used/rendered
  27702. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27703. * @return true if the node is ready
  27704. */
  27705. isReady(completeCheck?: boolean): boolean;
  27706. /**
  27707. * Is this node enabled?
  27708. * 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
  27709. * @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
  27710. * @return whether this node (and its parent) is enabled
  27711. */
  27712. isEnabled(checkAncestors?: boolean): boolean;
  27713. /** @hidden */
  27714. protected _syncParentEnabledState(): void;
  27715. /**
  27716. * Set the enabled state of this node
  27717. * @param value defines the new enabled state
  27718. */
  27719. setEnabled(value: boolean): void;
  27720. /**
  27721. * Is this node a descendant of the given node?
  27722. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27723. * @param ancestor defines the parent node to inspect
  27724. * @returns a boolean indicating if this node is a descendant of the given node
  27725. */
  27726. isDescendantOf(ancestor: Node): boolean;
  27727. /** @hidden */
  27728. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27729. /**
  27730. * Will return all nodes that have this node as ascendant
  27731. * @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
  27732. * @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
  27733. * @return all children nodes of all types
  27734. */
  27735. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27736. /**
  27737. * Get all child-meshes of this node
  27738. * @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)
  27739. * @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
  27740. * @returns an array of AbstractMesh
  27741. */
  27742. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27743. /**
  27744. * Get all direct children of this node
  27745. * @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
  27746. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  27747. * @returns an array of Node
  27748. */
  27749. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27750. /** @hidden */
  27751. _setReady(state: boolean): void;
  27752. /**
  27753. * Get an animation by name
  27754. * @param name defines the name of the animation to look for
  27755. * @returns null if not found else the requested animation
  27756. */
  27757. getAnimationByName(name: string): Nullable<Animation>;
  27758. /**
  27759. * Creates an animation range for this node
  27760. * @param name defines the name of the range
  27761. * @param from defines the starting key
  27762. * @param to defines the end key
  27763. */
  27764. createAnimationRange(name: string, from: number, to: number): void;
  27765. /**
  27766. * Delete a specific animation range
  27767. * @param name defines the name of the range to delete
  27768. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27769. */
  27770. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27771. /**
  27772. * Get an animation range by name
  27773. * @param name defines the name of the animation range to look for
  27774. * @returns null if not found else the requested animation range
  27775. */
  27776. getAnimationRange(name: string): Nullable<AnimationRange>;
  27777. /**
  27778. * Gets the list of all animation ranges defined on this node
  27779. * @returns an array
  27780. */
  27781. getAnimationRanges(): Nullable<AnimationRange>[];
  27782. /**
  27783. * Will start the animation sequence
  27784. * @param name defines the range frames for animation sequence
  27785. * @param loop defines if the animation should loop (false by default)
  27786. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27787. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27788. * @returns the object created for this animation. If range does not exist, it will return null
  27789. */
  27790. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27791. /**
  27792. * Serialize animation ranges into a JSON compatible object
  27793. * @returns serialization object
  27794. */
  27795. serializeAnimationRanges(): any;
  27796. /**
  27797. * Computes the world matrix of the node
  27798. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27799. * @returns the world matrix
  27800. */
  27801. computeWorldMatrix(force?: boolean): Matrix;
  27802. /**
  27803. * Releases resources associated with this node.
  27804. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27805. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27806. */
  27807. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27808. /**
  27809. * Parse animation range data from a serialization object and store them into a given node
  27810. * @param node defines where to store the animation ranges
  27811. * @param parsedNode defines the serialization object to read data from
  27812. * @param scene defines the hosting scene
  27813. */
  27814. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27815. /**
  27816. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27817. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27818. * @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
  27819. * @returns the new bounding vectors
  27820. */
  27821. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27822. min: Vector3;
  27823. max: Vector3;
  27824. };
  27825. }
  27826. }
  27827. declare module "babylonjs/Animations/animation" {
  27828. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27829. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27830. import { Color3 } from "babylonjs/Maths/math.color";
  27831. import { Nullable } from "babylonjs/types";
  27832. import { Scene } from "babylonjs/scene";
  27833. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27834. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27835. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27836. import { Node } from "babylonjs/node";
  27837. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27838. import { Size } from "babylonjs/Maths/math.size";
  27839. import { Animatable } from "babylonjs/Animations/animatable";
  27840. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27841. /**
  27842. * @hidden
  27843. */
  27844. export class _IAnimationState {
  27845. key: number;
  27846. repeatCount: number;
  27847. workValue?: any;
  27848. loopMode?: number;
  27849. offsetValue?: any;
  27850. highLimitValue?: any;
  27851. }
  27852. /**
  27853. * Class used to store any kind of animation
  27854. */
  27855. export class Animation {
  27856. /**Name of the animation */
  27857. name: string;
  27858. /**Property to animate */
  27859. targetProperty: string;
  27860. /**The frames per second of the animation */
  27861. framePerSecond: number;
  27862. /**The data type of the animation */
  27863. dataType: number;
  27864. /**The loop mode of the animation */
  27865. loopMode?: number | undefined;
  27866. /**Specifies if blending should be enabled */
  27867. enableBlending?: boolean | undefined;
  27868. /**
  27869. * Use matrix interpolation instead of using direct key value when animating matrices
  27870. */
  27871. static AllowMatricesInterpolation: boolean;
  27872. /**
  27873. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27874. */
  27875. static AllowMatrixDecomposeForInterpolation: boolean;
  27876. /**
  27877. * Stores the key frames of the animation
  27878. */
  27879. private _keys;
  27880. /**
  27881. * Stores the easing function of the animation
  27882. */
  27883. private _easingFunction;
  27884. /**
  27885. * @hidden Internal use only
  27886. */
  27887. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27888. /**
  27889. * The set of event that will be linked to this animation
  27890. */
  27891. private _events;
  27892. /**
  27893. * Stores an array of target property paths
  27894. */
  27895. targetPropertyPath: string[];
  27896. /**
  27897. * Stores the blending speed of the animation
  27898. */
  27899. blendingSpeed: number;
  27900. /**
  27901. * Stores the animation ranges for the animation
  27902. */
  27903. private _ranges;
  27904. /**
  27905. * @hidden Internal use
  27906. */
  27907. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27908. /**
  27909. * Sets up an animation
  27910. * @param property The property to animate
  27911. * @param animationType The animation type to apply
  27912. * @param framePerSecond The frames per second of the animation
  27913. * @param easingFunction The easing function used in the animation
  27914. * @returns The created animation
  27915. */
  27916. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27917. /**
  27918. * Create and start an animation on a node
  27919. * @param name defines the name of the global animation that will be run on all nodes
  27920. * @param node defines the root node where the animation will take place
  27921. * @param targetProperty defines property to animate
  27922. * @param framePerSecond defines the number of frame per second yo use
  27923. * @param totalFrame defines the number of frames in total
  27924. * @param from defines the initial value
  27925. * @param to defines the final value
  27926. * @param loopMode defines which loop mode you want to use (off by default)
  27927. * @param easingFunction defines the easing function to use (linear by default)
  27928. * @param onAnimationEnd defines the callback to call when animation end
  27929. * @returns the animatable created for this animation
  27930. */
  27931. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27932. /**
  27933. * Create and start an animation on a node and its descendants
  27934. * @param name defines the name of the global animation that will be run on all nodes
  27935. * @param node defines the root node where the animation will take place
  27936. * @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
  27937. * @param targetProperty defines property to animate
  27938. * @param framePerSecond defines the number of frame per second to use
  27939. * @param totalFrame defines the number of frames in total
  27940. * @param from defines the initial value
  27941. * @param to defines the final value
  27942. * @param loopMode defines which loop mode you want to use (off by default)
  27943. * @param easingFunction defines the easing function to use (linear by default)
  27944. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27945. * @returns the list of animatables created for all nodes
  27946. * @example https://www.babylonjs-playground.com/#MH0VLI
  27947. */
  27948. 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[]>;
  27949. /**
  27950. * Creates a new animation, merges it with the existing animations and starts it
  27951. * @param name Name of the animation
  27952. * @param node Node which contains the scene that begins the animations
  27953. * @param targetProperty Specifies which property to animate
  27954. * @param framePerSecond The frames per second of the animation
  27955. * @param totalFrame The total number of frames
  27956. * @param from The frame at the beginning of the animation
  27957. * @param to The frame at the end of the animation
  27958. * @param loopMode Specifies the loop mode of the animation
  27959. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27960. * @param onAnimationEnd Callback to run once the animation is complete
  27961. * @returns Nullable animation
  27962. */
  27963. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27964. /**
  27965. * Transition property of an host to the target Value
  27966. * @param property The property to transition
  27967. * @param targetValue The target Value of the property
  27968. * @param host The object where the property to animate belongs
  27969. * @param scene Scene used to run the animation
  27970. * @param frameRate Framerate (in frame/s) to use
  27971. * @param transition The transition type we want to use
  27972. * @param duration The duration of the animation, in milliseconds
  27973. * @param onAnimationEnd Callback trigger at the end of the animation
  27974. * @returns Nullable animation
  27975. */
  27976. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27977. /**
  27978. * Return the array of runtime animations currently using this animation
  27979. */
  27980. readonly runtimeAnimations: RuntimeAnimation[];
  27981. /**
  27982. * Specifies if any of the runtime animations are currently running
  27983. */
  27984. readonly hasRunningRuntimeAnimations: boolean;
  27985. /**
  27986. * Initializes the animation
  27987. * @param name Name of the animation
  27988. * @param targetProperty Property to animate
  27989. * @param framePerSecond The frames per second of the animation
  27990. * @param dataType The data type of the animation
  27991. * @param loopMode The loop mode of the animation
  27992. * @param enableBlending Specifies if blending should be enabled
  27993. */
  27994. constructor(
  27995. /**Name of the animation */
  27996. name: string,
  27997. /**Property to animate */
  27998. targetProperty: string,
  27999. /**The frames per second of the animation */
  28000. framePerSecond: number,
  28001. /**The data type of the animation */
  28002. dataType: number,
  28003. /**The loop mode of the animation */
  28004. loopMode?: number | undefined,
  28005. /**Specifies if blending should be enabled */
  28006. enableBlending?: boolean | undefined);
  28007. /**
  28008. * Converts the animation to a string
  28009. * @param fullDetails support for multiple levels of logging within scene loading
  28010. * @returns String form of the animation
  28011. */
  28012. toString(fullDetails?: boolean): string;
  28013. /**
  28014. * Add an event to this animation
  28015. * @param event Event to add
  28016. */
  28017. addEvent(event: AnimationEvent): void;
  28018. /**
  28019. * Remove all events found at the given frame
  28020. * @param frame The frame to remove events from
  28021. */
  28022. removeEvents(frame: number): void;
  28023. /**
  28024. * Retrieves all the events from the animation
  28025. * @returns Events from the animation
  28026. */
  28027. getEvents(): AnimationEvent[];
  28028. /**
  28029. * Creates an animation range
  28030. * @param name Name of the animation range
  28031. * @param from Starting frame of the animation range
  28032. * @param to Ending frame of the animation
  28033. */
  28034. createRange(name: string, from: number, to: number): void;
  28035. /**
  28036. * Deletes an animation range by name
  28037. * @param name Name of the animation range to delete
  28038. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28039. */
  28040. deleteRange(name: string, deleteFrames?: boolean): void;
  28041. /**
  28042. * Gets the animation range by name, or null if not defined
  28043. * @param name Name of the animation range
  28044. * @returns Nullable animation range
  28045. */
  28046. getRange(name: string): Nullable<AnimationRange>;
  28047. /**
  28048. * Gets the key frames from the animation
  28049. * @returns The key frames of the animation
  28050. */
  28051. getKeys(): Array<IAnimationKey>;
  28052. /**
  28053. * Gets the highest frame rate of the animation
  28054. * @returns Highest frame rate of the animation
  28055. */
  28056. getHighestFrame(): number;
  28057. /**
  28058. * Gets the easing function of the animation
  28059. * @returns Easing function of the animation
  28060. */
  28061. getEasingFunction(): IEasingFunction;
  28062. /**
  28063. * Sets the easing function of the animation
  28064. * @param easingFunction A custom mathematical formula for animation
  28065. */
  28066. setEasingFunction(easingFunction: EasingFunction): void;
  28067. /**
  28068. * Interpolates a scalar linearly
  28069. * @param startValue Start value of the animation curve
  28070. * @param endValue End value of the animation curve
  28071. * @param gradient Scalar amount to interpolate
  28072. * @returns Interpolated scalar value
  28073. */
  28074. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28075. /**
  28076. * Interpolates a scalar cubically
  28077. * @param startValue Start value of the animation curve
  28078. * @param outTangent End tangent of the animation
  28079. * @param endValue End value of the animation curve
  28080. * @param inTangent Start tangent of the animation curve
  28081. * @param gradient Scalar amount to interpolate
  28082. * @returns Interpolated scalar value
  28083. */
  28084. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28085. /**
  28086. * Interpolates a quaternion using a spherical linear interpolation
  28087. * @param startValue Start value of the animation curve
  28088. * @param endValue End value of the animation curve
  28089. * @param gradient Scalar amount to interpolate
  28090. * @returns Interpolated quaternion value
  28091. */
  28092. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28093. /**
  28094. * Interpolates a quaternion cubically
  28095. * @param startValue Start value of the animation curve
  28096. * @param outTangent End tangent of the animation curve
  28097. * @param endValue End value of the animation curve
  28098. * @param inTangent Start tangent of the animation curve
  28099. * @param gradient Scalar amount to interpolate
  28100. * @returns Interpolated quaternion value
  28101. */
  28102. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28103. /**
  28104. * Interpolates a Vector3 linearl
  28105. * @param startValue Start value of the animation curve
  28106. * @param endValue End value of the animation curve
  28107. * @param gradient Scalar amount to interpolate
  28108. * @returns Interpolated scalar value
  28109. */
  28110. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28111. /**
  28112. * Interpolates a Vector3 cubically
  28113. * @param startValue Start value of the animation curve
  28114. * @param outTangent End tangent of the animation
  28115. * @param endValue End value of the animation curve
  28116. * @param inTangent Start tangent of the animation curve
  28117. * @param gradient Scalar amount to interpolate
  28118. * @returns InterpolatedVector3 value
  28119. */
  28120. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28121. /**
  28122. * Interpolates a Vector2 linearly
  28123. * @param startValue Start value of the animation curve
  28124. * @param endValue End value of the animation curve
  28125. * @param gradient Scalar amount to interpolate
  28126. * @returns Interpolated Vector2 value
  28127. */
  28128. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28129. /**
  28130. * Interpolates a Vector2 cubically
  28131. * @param startValue Start value of the animation curve
  28132. * @param outTangent End tangent of the animation
  28133. * @param endValue End value of the animation curve
  28134. * @param inTangent Start tangent of the animation curve
  28135. * @param gradient Scalar amount to interpolate
  28136. * @returns Interpolated Vector2 value
  28137. */
  28138. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28139. /**
  28140. * Interpolates a size linearly
  28141. * @param startValue Start value of the animation curve
  28142. * @param endValue End value of the animation curve
  28143. * @param gradient Scalar amount to interpolate
  28144. * @returns Interpolated Size value
  28145. */
  28146. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28147. /**
  28148. * Interpolates a Color3 linearly
  28149. * @param startValue Start value of the animation curve
  28150. * @param endValue End value of the animation curve
  28151. * @param gradient Scalar amount to interpolate
  28152. * @returns Interpolated Color3 value
  28153. */
  28154. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28155. /**
  28156. * @hidden Internal use only
  28157. */
  28158. _getKeyValue(value: any): any;
  28159. /**
  28160. * @hidden Internal use only
  28161. */
  28162. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28163. /**
  28164. * Defines the function to use to interpolate matrices
  28165. * @param startValue defines the start matrix
  28166. * @param endValue defines the end matrix
  28167. * @param gradient defines the gradient between both matrices
  28168. * @param result defines an optional target matrix where to store the interpolation
  28169. * @returns the interpolated matrix
  28170. */
  28171. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28172. /**
  28173. * Makes a copy of the animation
  28174. * @returns Cloned animation
  28175. */
  28176. clone(): Animation;
  28177. /**
  28178. * Sets the key frames of the animation
  28179. * @param values The animation key frames to set
  28180. */
  28181. setKeys(values: Array<IAnimationKey>): void;
  28182. /**
  28183. * Serializes the animation to an object
  28184. * @returns Serialized object
  28185. */
  28186. serialize(): any;
  28187. /**
  28188. * Float animation type
  28189. */
  28190. private static _ANIMATIONTYPE_FLOAT;
  28191. /**
  28192. * Vector3 animation type
  28193. */
  28194. private static _ANIMATIONTYPE_VECTOR3;
  28195. /**
  28196. * Quaternion animation type
  28197. */
  28198. private static _ANIMATIONTYPE_QUATERNION;
  28199. /**
  28200. * Matrix animation type
  28201. */
  28202. private static _ANIMATIONTYPE_MATRIX;
  28203. /**
  28204. * Color3 animation type
  28205. */
  28206. private static _ANIMATIONTYPE_COLOR3;
  28207. /**
  28208. * Vector2 animation type
  28209. */
  28210. private static _ANIMATIONTYPE_VECTOR2;
  28211. /**
  28212. * Size animation type
  28213. */
  28214. private static _ANIMATIONTYPE_SIZE;
  28215. /**
  28216. * Relative Loop Mode
  28217. */
  28218. private static _ANIMATIONLOOPMODE_RELATIVE;
  28219. /**
  28220. * Cycle Loop Mode
  28221. */
  28222. private static _ANIMATIONLOOPMODE_CYCLE;
  28223. /**
  28224. * Constant Loop Mode
  28225. */
  28226. private static _ANIMATIONLOOPMODE_CONSTANT;
  28227. /**
  28228. * Get the float animation type
  28229. */
  28230. static readonly ANIMATIONTYPE_FLOAT: number;
  28231. /**
  28232. * Get the Vector3 animation type
  28233. */
  28234. static readonly ANIMATIONTYPE_VECTOR3: number;
  28235. /**
  28236. * Get the Vector2 animation type
  28237. */
  28238. static readonly ANIMATIONTYPE_VECTOR2: number;
  28239. /**
  28240. * Get the Size animation type
  28241. */
  28242. static readonly ANIMATIONTYPE_SIZE: number;
  28243. /**
  28244. * Get the Quaternion animation type
  28245. */
  28246. static readonly ANIMATIONTYPE_QUATERNION: number;
  28247. /**
  28248. * Get the Matrix animation type
  28249. */
  28250. static readonly ANIMATIONTYPE_MATRIX: number;
  28251. /**
  28252. * Get the Color3 animation type
  28253. */
  28254. static readonly ANIMATIONTYPE_COLOR3: number;
  28255. /**
  28256. * Get the Relative Loop Mode
  28257. */
  28258. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28259. /**
  28260. * Get the Cycle Loop Mode
  28261. */
  28262. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28263. /**
  28264. * Get the Constant Loop Mode
  28265. */
  28266. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28267. /** @hidden */
  28268. static _UniversalLerp(left: any, right: any, amount: number): any;
  28269. /**
  28270. * Parses an animation object and creates an animation
  28271. * @param parsedAnimation Parsed animation object
  28272. * @returns Animation object
  28273. */
  28274. static Parse(parsedAnimation: any): Animation;
  28275. /**
  28276. * Appends the serialized animations from the source animations
  28277. * @param source Source containing the animations
  28278. * @param destination Target to store the animations
  28279. */
  28280. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28281. }
  28282. }
  28283. declare module "babylonjs/Animations/animatable.interface" {
  28284. import { Nullable } from "babylonjs/types";
  28285. import { Animation } from "babylonjs/Animations/animation";
  28286. /**
  28287. * Interface containing an array of animations
  28288. */
  28289. export interface IAnimatable {
  28290. /**
  28291. * Array of animations
  28292. */
  28293. animations: Nullable<Array<Animation>>;
  28294. }
  28295. }
  28296. declare module "babylonjs/Materials/fresnelParameters" {
  28297. import { Color3 } from "babylonjs/Maths/math.color";
  28298. /**
  28299. * This represents all the required information to add a fresnel effect on a material:
  28300. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28301. */
  28302. export class FresnelParameters {
  28303. private _isEnabled;
  28304. /**
  28305. * Define if the fresnel effect is enable or not.
  28306. */
  28307. isEnabled: boolean;
  28308. /**
  28309. * Define the color used on edges (grazing angle)
  28310. */
  28311. leftColor: Color3;
  28312. /**
  28313. * Define the color used on center
  28314. */
  28315. rightColor: Color3;
  28316. /**
  28317. * Define bias applied to computed fresnel term
  28318. */
  28319. bias: number;
  28320. /**
  28321. * Defined the power exponent applied to fresnel term
  28322. */
  28323. power: number;
  28324. /**
  28325. * Clones the current fresnel and its valuues
  28326. * @returns a clone fresnel configuration
  28327. */
  28328. clone(): FresnelParameters;
  28329. /**
  28330. * Serializes the current fresnel parameters to a JSON representation.
  28331. * @return the JSON serialization
  28332. */
  28333. serialize(): any;
  28334. /**
  28335. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28336. * @param parsedFresnelParameters Define the JSON representation
  28337. * @returns the parsed parameters
  28338. */
  28339. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28340. }
  28341. }
  28342. declare module "babylonjs/Misc/decorators" {
  28343. import { Nullable } from "babylonjs/types";
  28344. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28345. import { Scene } from "babylonjs/scene";
  28346. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28347. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28348. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28349. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28350. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28351. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28352. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28353. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28354. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28355. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28356. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28357. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28358. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28359. /**
  28360. * Decorator used to define property that can be serialized as reference to a camera
  28361. * @param sourceName defines the name of the property to decorate
  28362. */
  28363. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. /**
  28365. * Class used to help serialization objects
  28366. */
  28367. export class SerializationHelper {
  28368. /** @hidden */
  28369. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28370. /** @hidden */
  28371. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28372. /** @hidden */
  28373. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28374. /** @hidden */
  28375. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28376. /**
  28377. * Appends the serialized animations from the source animations
  28378. * @param source Source containing the animations
  28379. * @param destination Target to store the animations
  28380. */
  28381. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28382. /**
  28383. * Static function used to serialized a specific entity
  28384. * @param entity defines the entity to serialize
  28385. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28386. * @returns a JSON compatible object representing the serialization of the entity
  28387. */
  28388. static Serialize<T>(entity: T, serializationObject?: any): any;
  28389. /**
  28390. * Creates a new entity from a serialization data object
  28391. * @param creationFunction defines a function used to instanciated the new entity
  28392. * @param source defines the source serialization data
  28393. * @param scene defines the hosting scene
  28394. * @param rootUrl defines the root url for resources
  28395. * @returns a new entity
  28396. */
  28397. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28398. /**
  28399. * Clones an object
  28400. * @param creationFunction defines the function used to instanciate the new object
  28401. * @param source defines the source object
  28402. * @returns the cloned object
  28403. */
  28404. static Clone<T>(creationFunction: () => T, source: T): T;
  28405. /**
  28406. * Instanciates a new object based on a source one (some data will be shared between both object)
  28407. * @param creationFunction defines the function used to instanciate the new object
  28408. * @param source defines the source object
  28409. * @returns the new object
  28410. */
  28411. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28412. }
  28413. }
  28414. declare module "babylonjs/Misc/guid" {
  28415. /**
  28416. * Class used to manipulate GUIDs
  28417. */
  28418. export class GUID {
  28419. /**
  28420. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28421. * Be aware Math.random() could cause collisions, but:
  28422. * "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"
  28423. * @returns a pseudo random id
  28424. */
  28425. static RandomId(): string;
  28426. }
  28427. }
  28428. declare module "babylonjs/Materials/Textures/baseTexture" {
  28429. import { Observable } from "babylonjs/Misc/observable";
  28430. import { Nullable } from "babylonjs/types";
  28431. import { Scene } from "babylonjs/scene";
  28432. import { Matrix } from "babylonjs/Maths/math.vector";
  28433. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28434. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28435. import { ISize } from "babylonjs/Maths/math.size";
  28436. /**
  28437. * Base class of all the textures in babylon.
  28438. * It groups all the common properties the materials, post process, lights... might need
  28439. * in order to make a correct use of the texture.
  28440. */
  28441. export class BaseTexture implements IAnimatable {
  28442. /**
  28443. * Default anisotropic filtering level for the application.
  28444. * It is set to 4 as a good tradeoff between perf and quality.
  28445. */
  28446. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28447. /**
  28448. * Gets or sets the unique id of the texture
  28449. */
  28450. uniqueId: number;
  28451. /**
  28452. * Define the name of the texture.
  28453. */
  28454. name: string;
  28455. /**
  28456. * Gets or sets an object used to store user defined information.
  28457. */
  28458. metadata: any;
  28459. /**
  28460. * For internal use only. Please do not use.
  28461. */
  28462. reservedDataStore: any;
  28463. private _hasAlpha;
  28464. /**
  28465. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28466. */
  28467. hasAlpha: boolean;
  28468. /**
  28469. * Defines if the alpha value should be determined via the rgb values.
  28470. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28471. */
  28472. getAlphaFromRGB: boolean;
  28473. /**
  28474. * Intensity or strength of the texture.
  28475. * It is commonly used by materials to fine tune the intensity of the texture
  28476. */
  28477. level: number;
  28478. /**
  28479. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28480. * This is part of the texture as textures usually maps to one uv set.
  28481. */
  28482. coordinatesIndex: number;
  28483. private _coordinatesMode;
  28484. /**
  28485. * How a texture is mapped.
  28486. *
  28487. * | Value | Type | Description |
  28488. * | ----- | ----------------------------------- | ----------- |
  28489. * | 0 | EXPLICIT_MODE | |
  28490. * | 1 | SPHERICAL_MODE | |
  28491. * | 2 | PLANAR_MODE | |
  28492. * | 3 | CUBIC_MODE | |
  28493. * | 4 | PROJECTION_MODE | |
  28494. * | 5 | SKYBOX_MODE | |
  28495. * | 6 | INVCUBIC_MODE | |
  28496. * | 7 | EQUIRECTANGULAR_MODE | |
  28497. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28498. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28499. */
  28500. coordinatesMode: number;
  28501. /**
  28502. * | Value | Type | Description |
  28503. * | ----- | ------------------ | ----------- |
  28504. * | 0 | CLAMP_ADDRESSMODE | |
  28505. * | 1 | WRAP_ADDRESSMODE | |
  28506. * | 2 | MIRROR_ADDRESSMODE | |
  28507. */
  28508. wrapU: number;
  28509. /**
  28510. * | Value | Type | Description |
  28511. * | ----- | ------------------ | ----------- |
  28512. * | 0 | CLAMP_ADDRESSMODE | |
  28513. * | 1 | WRAP_ADDRESSMODE | |
  28514. * | 2 | MIRROR_ADDRESSMODE | |
  28515. */
  28516. wrapV: number;
  28517. /**
  28518. * | Value | Type | Description |
  28519. * | ----- | ------------------ | ----------- |
  28520. * | 0 | CLAMP_ADDRESSMODE | |
  28521. * | 1 | WRAP_ADDRESSMODE | |
  28522. * | 2 | MIRROR_ADDRESSMODE | |
  28523. */
  28524. wrapR: number;
  28525. /**
  28526. * With compliant hardware and browser (supporting anisotropic filtering)
  28527. * this defines the level of anisotropic filtering in the texture.
  28528. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28529. */
  28530. anisotropicFilteringLevel: number;
  28531. /**
  28532. * Define if the texture is a cube texture or if false a 2d texture.
  28533. */
  28534. isCube: boolean;
  28535. /**
  28536. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28537. */
  28538. is3D: boolean;
  28539. /**
  28540. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28541. * HDR texture are usually stored in linear space.
  28542. * This only impacts the PBR and Background materials
  28543. */
  28544. gammaSpace: boolean;
  28545. /**
  28546. * Gets or sets whether or not the texture contains RGBD data.
  28547. */
  28548. isRGBD: boolean;
  28549. /**
  28550. * Is Z inverted in the texture (useful in a cube texture).
  28551. */
  28552. invertZ: boolean;
  28553. /**
  28554. * Are mip maps generated for this texture or not.
  28555. */
  28556. readonly noMipmap: boolean;
  28557. /**
  28558. * @hidden
  28559. */
  28560. lodLevelInAlpha: boolean;
  28561. /**
  28562. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28563. */
  28564. lodGenerationOffset: number;
  28565. /**
  28566. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28567. */
  28568. lodGenerationScale: number;
  28569. /**
  28570. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28571. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28572. * average roughness values.
  28573. */
  28574. linearSpecularLOD: boolean;
  28575. /**
  28576. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28577. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28578. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28579. */
  28580. irradianceTexture: Nullable<BaseTexture>;
  28581. /**
  28582. * Define if the texture is a render target.
  28583. */
  28584. isRenderTarget: boolean;
  28585. /**
  28586. * Define the unique id of the texture in the scene.
  28587. */
  28588. readonly uid: string;
  28589. /**
  28590. * Return a string representation of the texture.
  28591. * @returns the texture as a string
  28592. */
  28593. toString(): string;
  28594. /**
  28595. * Get the class name of the texture.
  28596. * @returns "BaseTexture"
  28597. */
  28598. getClassName(): string;
  28599. /**
  28600. * Define the list of animation attached to the texture.
  28601. */
  28602. animations: import("babylonjs/Animations/animation").Animation[];
  28603. /**
  28604. * An event triggered when the texture is disposed.
  28605. */
  28606. onDisposeObservable: Observable<BaseTexture>;
  28607. private _onDisposeObserver;
  28608. /**
  28609. * Callback triggered when the texture has been disposed.
  28610. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28611. */
  28612. onDispose: () => void;
  28613. /**
  28614. * Define the current state of the loading sequence when in delayed load mode.
  28615. */
  28616. delayLoadState: number;
  28617. private _scene;
  28618. /** @hidden */
  28619. _texture: Nullable<InternalTexture>;
  28620. private _uid;
  28621. /**
  28622. * Define if the texture is preventinga material to render or not.
  28623. * If not and the texture is not ready, the engine will use a default black texture instead.
  28624. */
  28625. readonly isBlocking: boolean;
  28626. /**
  28627. * Instantiates a new BaseTexture.
  28628. * Base class of all the textures in babylon.
  28629. * It groups all the common properties the materials, post process, lights... might need
  28630. * in order to make a correct use of the texture.
  28631. * @param scene Define the scene the texture blongs to
  28632. */
  28633. constructor(scene: Nullable<Scene>);
  28634. /**
  28635. * Get the scene the texture belongs to.
  28636. * @returns the scene or null if undefined
  28637. */
  28638. getScene(): Nullable<Scene>;
  28639. /**
  28640. * Get the texture transform matrix used to offset tile the texture for istance.
  28641. * @returns the transformation matrix
  28642. */
  28643. getTextureMatrix(): Matrix;
  28644. /**
  28645. * Get the texture reflection matrix used to rotate/transform the reflection.
  28646. * @returns the reflection matrix
  28647. */
  28648. getReflectionTextureMatrix(): Matrix;
  28649. /**
  28650. * Get the underlying lower level texture from Babylon.
  28651. * @returns the insternal texture
  28652. */
  28653. getInternalTexture(): Nullable<InternalTexture>;
  28654. /**
  28655. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28656. * @returns true if ready or not blocking
  28657. */
  28658. isReadyOrNotBlocking(): boolean;
  28659. /**
  28660. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28661. * @returns true if fully ready
  28662. */
  28663. isReady(): boolean;
  28664. private _cachedSize;
  28665. /**
  28666. * Get the size of the texture.
  28667. * @returns the texture size.
  28668. */
  28669. getSize(): ISize;
  28670. /**
  28671. * Get the base size of the texture.
  28672. * It can be different from the size if the texture has been resized for POT for instance
  28673. * @returns the base size
  28674. */
  28675. getBaseSize(): ISize;
  28676. /**
  28677. * Update the sampling mode of the texture.
  28678. * Default is Trilinear mode.
  28679. *
  28680. * | Value | Type | Description |
  28681. * | ----- | ------------------ | ----------- |
  28682. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28683. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28684. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28685. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28686. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28687. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28688. * | 7 | NEAREST_LINEAR | |
  28689. * | 8 | NEAREST_NEAREST | |
  28690. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28691. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28692. * | 11 | LINEAR_LINEAR | |
  28693. * | 12 | LINEAR_NEAREST | |
  28694. *
  28695. * > _mag_: magnification filter (close to the viewer)
  28696. * > _min_: minification filter (far from the viewer)
  28697. * > _mip_: filter used between mip map levels
  28698. *@param samplingMode Define the new sampling mode of the texture
  28699. */
  28700. updateSamplingMode(samplingMode: number): void;
  28701. /**
  28702. * Scales the texture if is `canRescale()`
  28703. * @param ratio the resize factor we want to use to rescale
  28704. */
  28705. scale(ratio: number): void;
  28706. /**
  28707. * Get if the texture can rescale.
  28708. */
  28709. readonly canRescale: boolean;
  28710. /** @hidden */
  28711. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28712. /** @hidden */
  28713. _rebuild(): void;
  28714. /**
  28715. * Triggers the load sequence in delayed load mode.
  28716. */
  28717. delayLoad(): void;
  28718. /**
  28719. * Clones the texture.
  28720. * @returns the cloned texture
  28721. */
  28722. clone(): Nullable<BaseTexture>;
  28723. /**
  28724. * Get the texture underlying type (INT, FLOAT...)
  28725. */
  28726. readonly textureType: number;
  28727. /**
  28728. * Get the texture underlying format (RGB, RGBA...)
  28729. */
  28730. readonly textureFormat: number;
  28731. /**
  28732. * Indicates that textures need to be re-calculated for all materials
  28733. */
  28734. protected _markAllSubMeshesAsTexturesDirty(): void;
  28735. /**
  28736. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28737. * This will returns an RGBA array buffer containing either in values (0-255) or
  28738. * float values (0-1) depending of the underlying buffer type.
  28739. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28740. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28741. * @param buffer defines a user defined buffer to fill with data (can be null)
  28742. * @returns The Array buffer containing the pixels data.
  28743. */
  28744. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28745. /**
  28746. * Release and destroy the underlying lower level texture aka internalTexture.
  28747. */
  28748. releaseInternalTexture(): void;
  28749. /** @hidden */
  28750. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28751. /** @hidden */
  28752. readonly _lodTextureMid: Nullable<BaseTexture>;
  28753. /** @hidden */
  28754. readonly _lodTextureLow: Nullable<BaseTexture>;
  28755. /**
  28756. * Dispose the texture and release its associated resources.
  28757. */
  28758. dispose(): void;
  28759. /**
  28760. * Serialize the texture into a JSON representation that can be parsed later on.
  28761. * @returns the JSON representation of the texture
  28762. */
  28763. serialize(): any;
  28764. /**
  28765. * Helper function to be called back once a list of texture contains only ready textures.
  28766. * @param textures Define the list of textures to wait for
  28767. * @param callback Define the callback triggered once the entire list will be ready
  28768. */
  28769. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28770. }
  28771. }
  28772. declare module "babylonjs/Materials/effect" {
  28773. import { Observable } from "babylonjs/Misc/observable";
  28774. import { Nullable } from "babylonjs/types";
  28775. import { IDisposable } from "babylonjs/scene";
  28776. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28777. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28778. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28779. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28780. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28781. import { Engine } from "babylonjs/Engines/engine";
  28782. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28783. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28784. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28785. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28786. /**
  28787. * Options to be used when creating an effect.
  28788. */
  28789. export interface IEffectCreationOptions {
  28790. /**
  28791. * Atrributes that will be used in the shader.
  28792. */
  28793. attributes: string[];
  28794. /**
  28795. * Uniform varible names that will be set in the shader.
  28796. */
  28797. uniformsNames: string[];
  28798. /**
  28799. * Uniform buffer varible names that will be set in the shader.
  28800. */
  28801. uniformBuffersNames: string[];
  28802. /**
  28803. * Sampler texture variable names that will be set in the shader.
  28804. */
  28805. samplers: string[];
  28806. /**
  28807. * Define statements that will be set in the shader.
  28808. */
  28809. defines: any;
  28810. /**
  28811. * Possible fallbacks for this effect to improve performance when needed.
  28812. */
  28813. fallbacks: Nullable<IEffectFallbacks>;
  28814. /**
  28815. * Callback that will be called when the shader is compiled.
  28816. */
  28817. onCompiled: Nullable<(effect: Effect) => void>;
  28818. /**
  28819. * Callback that will be called if an error occurs during shader compilation.
  28820. */
  28821. onError: Nullable<(effect: Effect, errors: string) => void>;
  28822. /**
  28823. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28824. */
  28825. indexParameters?: any;
  28826. /**
  28827. * Max number of lights that can be used in the shader.
  28828. */
  28829. maxSimultaneousLights?: number;
  28830. /**
  28831. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28832. */
  28833. transformFeedbackVaryings?: Nullable<string[]>;
  28834. }
  28835. /**
  28836. * Effect containing vertex and fragment shader that can be executed on an object.
  28837. */
  28838. export class Effect implements IDisposable {
  28839. /**
  28840. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28841. */
  28842. static ShadersRepository: string;
  28843. /**
  28844. * Name of the effect.
  28845. */
  28846. name: any;
  28847. /**
  28848. * String container all the define statements that should be set on the shader.
  28849. */
  28850. defines: string;
  28851. /**
  28852. * Callback that will be called when the shader is compiled.
  28853. */
  28854. onCompiled: Nullable<(effect: Effect) => void>;
  28855. /**
  28856. * Callback that will be called if an error occurs during shader compilation.
  28857. */
  28858. onError: Nullable<(effect: Effect, errors: string) => void>;
  28859. /**
  28860. * Callback that will be called when effect is bound.
  28861. */
  28862. onBind: Nullable<(effect: Effect) => void>;
  28863. /**
  28864. * Unique ID of the effect.
  28865. */
  28866. uniqueId: number;
  28867. /**
  28868. * Observable that will be called when the shader is compiled.
  28869. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28870. */
  28871. onCompileObservable: Observable<Effect>;
  28872. /**
  28873. * Observable that will be called if an error occurs during shader compilation.
  28874. */
  28875. onErrorObservable: Observable<Effect>;
  28876. /** @hidden */
  28877. _onBindObservable: Nullable<Observable<Effect>>;
  28878. /**
  28879. * Observable that will be called when effect is bound.
  28880. */
  28881. readonly onBindObservable: Observable<Effect>;
  28882. /** @hidden */
  28883. _bonesComputationForcedToCPU: boolean;
  28884. private static _uniqueIdSeed;
  28885. private _engine;
  28886. private _uniformBuffersNames;
  28887. private _uniformsNames;
  28888. private _samplerList;
  28889. private _samplers;
  28890. private _isReady;
  28891. private _compilationError;
  28892. private _allFallbacksProcessed;
  28893. private _attributesNames;
  28894. private _attributes;
  28895. private _uniforms;
  28896. /**
  28897. * Key for the effect.
  28898. * @hidden
  28899. */
  28900. _key: string;
  28901. private _indexParameters;
  28902. private _fallbacks;
  28903. private _vertexSourceCode;
  28904. private _fragmentSourceCode;
  28905. private _vertexSourceCodeOverride;
  28906. private _fragmentSourceCodeOverride;
  28907. private _transformFeedbackVaryings;
  28908. /**
  28909. * Compiled shader to webGL program.
  28910. * @hidden
  28911. */
  28912. _pipelineContext: Nullable<IPipelineContext>;
  28913. private _valueCache;
  28914. private static _baseCache;
  28915. /**
  28916. * Instantiates an effect.
  28917. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28918. * @param baseName Name of the effect.
  28919. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28920. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28921. * @param samplers List of sampler variables that will be passed to the shader.
  28922. * @param engine Engine to be used to render the effect
  28923. * @param defines Define statements to be added to the shader.
  28924. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28925. * @param onCompiled Callback that will be called when the shader is compiled.
  28926. * @param onError Callback that will be called if an error occurs during shader compilation.
  28927. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28928. */
  28929. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28930. private _useFinalCode;
  28931. /**
  28932. * Unique key for this effect
  28933. */
  28934. readonly key: string;
  28935. /**
  28936. * If the effect has been compiled and prepared.
  28937. * @returns if the effect is compiled and prepared.
  28938. */
  28939. isReady(): boolean;
  28940. private _isReadyInternal;
  28941. /**
  28942. * The engine the effect was initialized with.
  28943. * @returns the engine.
  28944. */
  28945. getEngine(): Engine;
  28946. /**
  28947. * The pipeline context for this effect
  28948. * @returns the associated pipeline context
  28949. */
  28950. getPipelineContext(): Nullable<IPipelineContext>;
  28951. /**
  28952. * The set of names of attribute variables for the shader.
  28953. * @returns An array of attribute names.
  28954. */
  28955. getAttributesNames(): string[];
  28956. /**
  28957. * Returns the attribute at the given index.
  28958. * @param index The index of the attribute.
  28959. * @returns The location of the attribute.
  28960. */
  28961. getAttributeLocation(index: number): number;
  28962. /**
  28963. * Returns the attribute based on the name of the variable.
  28964. * @param name of the attribute to look up.
  28965. * @returns the attribute location.
  28966. */
  28967. getAttributeLocationByName(name: string): number;
  28968. /**
  28969. * The number of attributes.
  28970. * @returns the numnber of attributes.
  28971. */
  28972. getAttributesCount(): number;
  28973. /**
  28974. * Gets the index of a uniform variable.
  28975. * @param uniformName of the uniform to look up.
  28976. * @returns the index.
  28977. */
  28978. getUniformIndex(uniformName: string): number;
  28979. /**
  28980. * Returns the attribute based on the name of the variable.
  28981. * @param uniformName of the uniform to look up.
  28982. * @returns the location of the uniform.
  28983. */
  28984. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28985. /**
  28986. * Returns an array of sampler variable names
  28987. * @returns The array of sampler variable neames.
  28988. */
  28989. getSamplers(): string[];
  28990. /**
  28991. * The error from the last compilation.
  28992. * @returns the error string.
  28993. */
  28994. getCompilationError(): string;
  28995. /**
  28996. * Gets a boolean indicating that all fallbacks were used during compilation
  28997. * @returns true if all fallbacks were used
  28998. */
  28999. allFallbacksProcessed(): boolean;
  29000. /**
  29001. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29002. * @param func The callback to be used.
  29003. */
  29004. executeWhenCompiled(func: (effect: Effect) => void): void;
  29005. private _checkIsReady;
  29006. private _loadShader;
  29007. /**
  29008. * Recompiles the webGL program
  29009. * @param vertexSourceCode The source code for the vertex shader.
  29010. * @param fragmentSourceCode The source code for the fragment shader.
  29011. * @param onCompiled Callback called when completed.
  29012. * @param onError Callback called on error.
  29013. * @hidden
  29014. */
  29015. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29016. /**
  29017. * Prepares the effect
  29018. * @hidden
  29019. */
  29020. _prepareEffect(): void;
  29021. private _processCompilationErrors;
  29022. /**
  29023. * Checks if the effect is supported. (Must be called after compilation)
  29024. */
  29025. readonly isSupported: boolean;
  29026. /**
  29027. * Binds a texture to the engine to be used as output of the shader.
  29028. * @param channel Name of the output variable.
  29029. * @param texture Texture to bind.
  29030. * @hidden
  29031. */
  29032. _bindTexture(channel: string, texture: InternalTexture): void;
  29033. /**
  29034. * Sets a texture on the engine to be used in the shader.
  29035. * @param channel Name of the sampler variable.
  29036. * @param texture Texture to set.
  29037. */
  29038. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29039. /**
  29040. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29041. * @param channel Name of the sampler variable.
  29042. * @param texture Texture to set.
  29043. */
  29044. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29045. /**
  29046. * Sets an array of textures on the engine to be used in the shader.
  29047. * @param channel Name of the variable.
  29048. * @param textures Textures to set.
  29049. */
  29050. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29051. /**
  29052. * 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)
  29053. * @param channel Name of the sampler variable.
  29054. * @param postProcess Post process to get the input texture from.
  29055. */
  29056. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29057. /**
  29058. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29059. * 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)
  29060. * @param channel Name of the sampler variable.
  29061. * @param postProcess Post process to get the output texture from.
  29062. */
  29063. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29064. /** @hidden */
  29065. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29066. /** @hidden */
  29067. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29068. /** @hidden */
  29069. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29070. /** @hidden */
  29071. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29072. /**
  29073. * Binds a buffer to a uniform.
  29074. * @param buffer Buffer to bind.
  29075. * @param name Name of the uniform variable to bind to.
  29076. */
  29077. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29078. /**
  29079. * Binds block to a uniform.
  29080. * @param blockName Name of the block to bind.
  29081. * @param index Index to bind.
  29082. */
  29083. bindUniformBlock(blockName: string, index: number): void;
  29084. /**
  29085. * Sets an interger value on a uniform variable.
  29086. * @param uniformName Name of the variable.
  29087. * @param value Value to be set.
  29088. * @returns this effect.
  29089. */
  29090. setInt(uniformName: string, value: number): Effect;
  29091. /**
  29092. * Sets an int array on a uniform variable.
  29093. * @param uniformName Name of the variable.
  29094. * @param array array to be set.
  29095. * @returns this effect.
  29096. */
  29097. setIntArray(uniformName: string, array: Int32Array): Effect;
  29098. /**
  29099. * 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)
  29100. * @param uniformName Name of the variable.
  29101. * @param array array to be set.
  29102. * @returns this effect.
  29103. */
  29104. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29105. /**
  29106. * 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)
  29107. * @param uniformName Name of the variable.
  29108. * @param array array to be set.
  29109. * @returns this effect.
  29110. */
  29111. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29112. /**
  29113. * 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)
  29114. * @param uniformName Name of the variable.
  29115. * @param array array to be set.
  29116. * @returns this effect.
  29117. */
  29118. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29119. /**
  29120. * Sets an float array on a uniform variable.
  29121. * @param uniformName Name of the variable.
  29122. * @param array array to be set.
  29123. * @returns this effect.
  29124. */
  29125. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29126. /**
  29127. * 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)
  29128. * @param uniformName Name of the variable.
  29129. * @param array array to be set.
  29130. * @returns this effect.
  29131. */
  29132. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29133. /**
  29134. * 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)
  29135. * @param uniformName Name of the variable.
  29136. * @param array array to be set.
  29137. * @returns this effect.
  29138. */
  29139. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29140. /**
  29141. * 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)
  29142. * @param uniformName Name of the variable.
  29143. * @param array array to be set.
  29144. * @returns this effect.
  29145. */
  29146. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29147. /**
  29148. * Sets an array on a uniform variable.
  29149. * @param uniformName Name of the variable.
  29150. * @param array array to be set.
  29151. * @returns this effect.
  29152. */
  29153. setArray(uniformName: string, array: number[]): Effect;
  29154. /**
  29155. * 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)
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setArray2(uniformName: string, array: number[]): Effect;
  29161. /**
  29162. * 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)
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setArray3(uniformName: string, array: number[]): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setArray4(uniformName: string, array: number[]): Effect;
  29175. /**
  29176. * Sets matrices on a uniform variable.
  29177. * @param uniformName Name of the variable.
  29178. * @param matrices matrices to be set.
  29179. * @returns this effect.
  29180. */
  29181. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29182. /**
  29183. * Sets matrix on a uniform variable.
  29184. * @param uniformName Name of the variable.
  29185. * @param matrix matrix to be set.
  29186. * @returns this effect.
  29187. */
  29188. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29189. /**
  29190. * 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)
  29191. * @param uniformName Name of the variable.
  29192. * @param matrix matrix to be set.
  29193. * @returns this effect.
  29194. */
  29195. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29196. /**
  29197. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29198. * @param uniformName Name of the variable.
  29199. * @param matrix matrix to be set.
  29200. * @returns this effect.
  29201. */
  29202. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29203. /**
  29204. * Sets a float on a uniform variable.
  29205. * @param uniformName Name of the variable.
  29206. * @param value value to be set.
  29207. * @returns this effect.
  29208. */
  29209. setFloat(uniformName: string, value: number): Effect;
  29210. /**
  29211. * Sets a boolean on a uniform variable.
  29212. * @param uniformName Name of the variable.
  29213. * @param bool value to be set.
  29214. * @returns this effect.
  29215. */
  29216. setBool(uniformName: string, bool: boolean): Effect;
  29217. /**
  29218. * Sets a Vector2 on a uniform variable.
  29219. * @param uniformName Name of the variable.
  29220. * @param vector2 vector2 to be set.
  29221. * @returns this effect.
  29222. */
  29223. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29224. /**
  29225. * Sets a float2 on a uniform variable.
  29226. * @param uniformName Name of the variable.
  29227. * @param x First float in float2.
  29228. * @param y Second float in float2.
  29229. * @returns this effect.
  29230. */
  29231. setFloat2(uniformName: string, x: number, y: number): Effect;
  29232. /**
  29233. * Sets a Vector3 on a uniform variable.
  29234. * @param uniformName Name of the variable.
  29235. * @param vector3 Value to be set.
  29236. * @returns this effect.
  29237. */
  29238. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29239. /**
  29240. * Sets a float3 on a uniform variable.
  29241. * @param uniformName Name of the variable.
  29242. * @param x First float in float3.
  29243. * @param y Second float in float3.
  29244. * @param z Third float in float3.
  29245. * @returns this effect.
  29246. */
  29247. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29248. /**
  29249. * Sets a Vector4 on a uniform variable.
  29250. * @param uniformName Name of the variable.
  29251. * @param vector4 Value to be set.
  29252. * @returns this effect.
  29253. */
  29254. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29255. /**
  29256. * Sets a float4 on a uniform variable.
  29257. * @param uniformName Name of the variable.
  29258. * @param x First float in float4.
  29259. * @param y Second float in float4.
  29260. * @param z Third float in float4.
  29261. * @param w Fourth float in float4.
  29262. * @returns this effect.
  29263. */
  29264. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29265. /**
  29266. * Sets a Color3 on a uniform variable.
  29267. * @param uniformName Name of the variable.
  29268. * @param color3 Value to be set.
  29269. * @returns this effect.
  29270. */
  29271. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29272. /**
  29273. * Sets a Color4 on a uniform variable.
  29274. * @param uniformName Name of the variable.
  29275. * @param color3 Value to be set.
  29276. * @param alpha Alpha value to be set.
  29277. * @returns this effect.
  29278. */
  29279. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29280. /**
  29281. * Sets a Color4 on a uniform variable
  29282. * @param uniformName defines the name of the variable
  29283. * @param color4 defines the value to be set
  29284. * @returns this effect.
  29285. */
  29286. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29287. /** Release all associated resources */
  29288. dispose(): void;
  29289. /**
  29290. * This function will add a new shader to the shader store
  29291. * @param name the name of the shader
  29292. * @param pixelShader optional pixel shader content
  29293. * @param vertexShader optional vertex shader content
  29294. */
  29295. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29296. /**
  29297. * Store of each shader (The can be looked up using effect.key)
  29298. */
  29299. static ShadersStore: {
  29300. [key: string]: string;
  29301. };
  29302. /**
  29303. * Store of each included file for a shader (The can be looked up using effect.key)
  29304. */
  29305. static IncludesShadersStore: {
  29306. [key: string]: string;
  29307. };
  29308. /**
  29309. * Resets the cache of effects.
  29310. */
  29311. static ResetCache(): void;
  29312. }
  29313. }
  29314. declare module "babylonjs/Engines/engineCapabilities" {
  29315. import { Nullable } from "babylonjs/types";
  29316. /**
  29317. * Class used to describe the capabilities of the engine relatively to the current browser
  29318. */
  29319. export class EngineCapabilities {
  29320. /** Maximum textures units per fragment shader */
  29321. maxTexturesImageUnits: number;
  29322. /** Maximum texture units per vertex shader */
  29323. maxVertexTextureImageUnits: number;
  29324. /** Maximum textures units in the entire pipeline */
  29325. maxCombinedTexturesImageUnits: number;
  29326. /** Maximum texture size */
  29327. maxTextureSize: number;
  29328. /** Maximum cube texture size */
  29329. maxCubemapTextureSize: number;
  29330. /** Maximum render texture size */
  29331. maxRenderTextureSize: number;
  29332. /** Maximum number of vertex attributes */
  29333. maxVertexAttribs: number;
  29334. /** Maximum number of varyings */
  29335. maxVaryingVectors: number;
  29336. /** Maximum number of uniforms per vertex shader */
  29337. maxVertexUniformVectors: number;
  29338. /** Maximum number of uniforms per fragment shader */
  29339. maxFragmentUniformVectors: number;
  29340. /** Defines if standard derivates (dx/dy) are supported */
  29341. standardDerivatives: boolean;
  29342. /** Defines if s3tc texture compression is supported */
  29343. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29344. /** Defines if pvrtc texture compression is supported */
  29345. pvrtc: any;
  29346. /** Defines if etc1 texture compression is supported */
  29347. etc1: any;
  29348. /** Defines if etc2 texture compression is supported */
  29349. etc2: any;
  29350. /** Defines if astc texture compression is supported */
  29351. astc: any;
  29352. /** Defines if float textures are supported */
  29353. textureFloat: boolean;
  29354. /** Defines if vertex array objects are supported */
  29355. vertexArrayObject: boolean;
  29356. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29357. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29358. /** Gets the maximum level of anisotropy supported */
  29359. maxAnisotropy: number;
  29360. /** Defines if instancing is supported */
  29361. instancedArrays: boolean;
  29362. /** Defines if 32 bits indices are supported */
  29363. uintIndices: boolean;
  29364. /** Defines if high precision shaders are supported */
  29365. highPrecisionShaderSupported: boolean;
  29366. /** Defines if depth reading in the fragment shader is supported */
  29367. fragmentDepthSupported: boolean;
  29368. /** Defines if float texture linear filtering is supported*/
  29369. textureFloatLinearFiltering: boolean;
  29370. /** Defines if rendering to float textures is supported */
  29371. textureFloatRender: boolean;
  29372. /** Defines if half float textures are supported*/
  29373. textureHalfFloat: boolean;
  29374. /** Defines if half float texture linear filtering is supported*/
  29375. textureHalfFloatLinearFiltering: boolean;
  29376. /** Defines if rendering to half float textures is supported */
  29377. textureHalfFloatRender: boolean;
  29378. /** Defines if textureLOD shader command is supported */
  29379. textureLOD: boolean;
  29380. /** Defines if draw buffers extension is supported */
  29381. drawBuffersExtension: boolean;
  29382. /** Defines if depth textures are supported */
  29383. depthTextureExtension: boolean;
  29384. /** Defines if float color buffer are supported */
  29385. colorBufferFloat: boolean;
  29386. /** Gets disjoint timer query extension (null if not supported) */
  29387. timerQuery: EXT_disjoint_timer_query;
  29388. /** Defines if timestamp can be used with timer query */
  29389. canUseTimestampForTimerQuery: boolean;
  29390. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29391. multiview: any;
  29392. /** Function used to let the system compiles shaders in background */
  29393. parallelShaderCompile: {
  29394. COMPLETION_STATUS_KHR: number;
  29395. };
  29396. /** Max number of texture samples for MSAA */
  29397. maxMSAASamples: number;
  29398. /** Defines if the blend min max extension is supported */
  29399. blendMinMax: boolean;
  29400. }
  29401. }
  29402. declare module "babylonjs/States/depthCullingState" {
  29403. import { Nullable } from "babylonjs/types";
  29404. /**
  29405. * @hidden
  29406. **/
  29407. export class DepthCullingState {
  29408. private _isDepthTestDirty;
  29409. private _isDepthMaskDirty;
  29410. private _isDepthFuncDirty;
  29411. private _isCullFaceDirty;
  29412. private _isCullDirty;
  29413. private _isZOffsetDirty;
  29414. private _isFrontFaceDirty;
  29415. private _depthTest;
  29416. private _depthMask;
  29417. private _depthFunc;
  29418. private _cull;
  29419. private _cullFace;
  29420. private _zOffset;
  29421. private _frontFace;
  29422. /**
  29423. * Initializes the state.
  29424. */
  29425. constructor();
  29426. readonly isDirty: boolean;
  29427. zOffset: number;
  29428. cullFace: Nullable<number>;
  29429. cull: Nullable<boolean>;
  29430. depthFunc: Nullable<number>;
  29431. depthMask: boolean;
  29432. depthTest: boolean;
  29433. frontFace: Nullable<number>;
  29434. reset(): void;
  29435. apply(gl: WebGLRenderingContext): void;
  29436. }
  29437. }
  29438. declare module "babylonjs/States/stencilState" {
  29439. /**
  29440. * @hidden
  29441. **/
  29442. export class StencilState {
  29443. /** 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 */
  29444. static readonly ALWAYS: number;
  29445. /** Passed to stencilOperation to specify that stencil value must be kept */
  29446. static readonly KEEP: number;
  29447. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29448. static readonly REPLACE: number;
  29449. private _isStencilTestDirty;
  29450. private _isStencilMaskDirty;
  29451. private _isStencilFuncDirty;
  29452. private _isStencilOpDirty;
  29453. private _stencilTest;
  29454. private _stencilMask;
  29455. private _stencilFunc;
  29456. private _stencilFuncRef;
  29457. private _stencilFuncMask;
  29458. private _stencilOpStencilFail;
  29459. private _stencilOpDepthFail;
  29460. private _stencilOpStencilDepthPass;
  29461. readonly isDirty: boolean;
  29462. stencilFunc: number;
  29463. stencilFuncRef: number;
  29464. stencilFuncMask: number;
  29465. stencilOpStencilFail: number;
  29466. stencilOpDepthFail: number;
  29467. stencilOpStencilDepthPass: number;
  29468. stencilMask: number;
  29469. stencilTest: boolean;
  29470. constructor();
  29471. reset(): void;
  29472. apply(gl: WebGLRenderingContext): void;
  29473. }
  29474. }
  29475. declare module "babylonjs/States/alphaCullingState" {
  29476. /**
  29477. * @hidden
  29478. **/
  29479. export class AlphaState {
  29480. private _isAlphaBlendDirty;
  29481. private _isBlendFunctionParametersDirty;
  29482. private _isBlendEquationParametersDirty;
  29483. private _isBlendConstantsDirty;
  29484. private _alphaBlend;
  29485. private _blendFunctionParameters;
  29486. private _blendEquationParameters;
  29487. private _blendConstants;
  29488. /**
  29489. * Initializes the state.
  29490. */
  29491. constructor();
  29492. readonly isDirty: boolean;
  29493. alphaBlend: boolean;
  29494. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29495. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29496. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29497. reset(): void;
  29498. apply(gl: WebGLRenderingContext): void;
  29499. }
  29500. }
  29501. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29502. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29503. /** @hidden */
  29504. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29505. attributeProcessor(attribute: string): string;
  29506. varyingProcessor(varying: string, isFragment: boolean): string;
  29507. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29508. }
  29509. }
  29510. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29511. /**
  29512. * Interface for attribute information associated with buffer instanciation
  29513. */
  29514. export class InstancingAttributeInfo {
  29515. /**
  29516. * Index/offset of the attribute in the vertex shader
  29517. */
  29518. index: number;
  29519. /**
  29520. * size of the attribute, 1, 2, 3 or 4
  29521. */
  29522. attributeSize: number;
  29523. /**
  29524. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29525. * default is FLOAT
  29526. */
  29527. attribyteType: number;
  29528. /**
  29529. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29530. */
  29531. normalized: boolean;
  29532. /**
  29533. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29534. */
  29535. offset: number;
  29536. /**
  29537. * Name of the GLSL attribute, for debugging purpose only
  29538. */
  29539. attributeName: string;
  29540. }
  29541. }
  29542. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29544. import { Nullable } from "babylonjs/types";
  29545. module "babylonjs/Engines/thinEngine" {
  29546. interface ThinEngine {
  29547. /**
  29548. * Update a video texture
  29549. * @param texture defines the texture to update
  29550. * @param video defines the video element to use
  29551. * @param invertY defines if data must be stored with Y axis inverted
  29552. */
  29553. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29554. }
  29555. }
  29556. }
  29557. declare module "babylonjs/Materials/Textures/videoTexture" {
  29558. import { Observable } from "babylonjs/Misc/observable";
  29559. import { Nullable } from "babylonjs/types";
  29560. import { Scene } from "babylonjs/scene";
  29561. import { Texture } from "babylonjs/Materials/Textures/texture";
  29562. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29563. /**
  29564. * Settings for finer control over video usage
  29565. */
  29566. export interface VideoTextureSettings {
  29567. /**
  29568. * Applies `autoplay` to video, if specified
  29569. */
  29570. autoPlay?: boolean;
  29571. /**
  29572. * Applies `loop` to video, if specified
  29573. */
  29574. loop?: boolean;
  29575. /**
  29576. * Automatically updates internal texture from video at every frame in the render loop
  29577. */
  29578. autoUpdateTexture: boolean;
  29579. /**
  29580. * Image src displayed during the video loading or until the user interacts with the video.
  29581. */
  29582. poster?: string;
  29583. }
  29584. /**
  29585. * If you want to display a video in your scene, this is the special texture for that.
  29586. * This special texture works similar to other textures, with the exception of a few parameters.
  29587. * @see https://doc.babylonjs.com/how_to/video_texture
  29588. */
  29589. export class VideoTexture extends Texture {
  29590. /**
  29591. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29592. */
  29593. readonly autoUpdateTexture: boolean;
  29594. /**
  29595. * The video instance used by the texture internally
  29596. */
  29597. readonly video: HTMLVideoElement;
  29598. private _onUserActionRequestedObservable;
  29599. /**
  29600. * Event triggerd when a dom action is required by the user to play the video.
  29601. * This happens due to recent changes in browser policies preventing video to auto start.
  29602. */
  29603. readonly onUserActionRequestedObservable: Observable<Texture>;
  29604. private _generateMipMaps;
  29605. private _engine;
  29606. private _stillImageCaptured;
  29607. private _displayingPosterTexture;
  29608. private _settings;
  29609. private _createInternalTextureOnEvent;
  29610. private _frameId;
  29611. /**
  29612. * Creates a video texture.
  29613. * If you want to display a video in your scene, this is the special texture for that.
  29614. * This special texture works similar to other textures, with the exception of a few parameters.
  29615. * @see https://doc.babylonjs.com/how_to/video_texture
  29616. * @param name optional name, will detect from video source, if not defined
  29617. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29618. * @param scene is obviously the current scene.
  29619. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29620. * @param invertY is false by default but can be used to invert video on Y axis
  29621. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29622. * @param settings allows finer control over video usage
  29623. */
  29624. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29625. private _getName;
  29626. private _getVideo;
  29627. private _createInternalTexture;
  29628. private reset;
  29629. /**
  29630. * @hidden Internal method to initiate `update`.
  29631. */
  29632. _rebuild(): void;
  29633. /**
  29634. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29635. */
  29636. update(): void;
  29637. /**
  29638. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29639. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29640. */
  29641. updateTexture(isVisible: boolean): void;
  29642. protected _updateInternalTexture: () => void;
  29643. /**
  29644. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29645. * @param url New url.
  29646. */
  29647. updateURL(url: string): void;
  29648. /**
  29649. * Dispose the texture and release its associated resources.
  29650. */
  29651. dispose(): void;
  29652. /**
  29653. * Creates a video texture straight from a stream.
  29654. * @param scene Define the scene the texture should be created in
  29655. * @param stream Define the stream the texture should be created from
  29656. * @returns The created video texture as a promise
  29657. */
  29658. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29659. /**
  29660. * Creates a video texture straight from your WebCam video feed.
  29661. * @param scene Define the scene the texture should be created in
  29662. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29663. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29664. * @returns The created video texture as a promise
  29665. */
  29666. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29667. minWidth: number;
  29668. maxWidth: number;
  29669. minHeight: number;
  29670. maxHeight: number;
  29671. deviceId: string;
  29672. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29673. /**
  29674. * Creates a video texture straight from your WebCam video feed.
  29675. * @param scene Define the scene the texture should be created in
  29676. * @param onReady Define a callback to triggered once the texture will be ready
  29677. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29678. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29679. */
  29680. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29681. minWidth: number;
  29682. maxWidth: number;
  29683. minHeight: number;
  29684. maxHeight: number;
  29685. deviceId: string;
  29686. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29687. }
  29688. }
  29689. declare module "babylonjs/Engines/thinEngine" {
  29690. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29691. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29692. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29693. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29694. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29695. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29696. import { Observable } from "babylonjs/Misc/observable";
  29697. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29698. import { StencilState } from "babylonjs/States/stencilState";
  29699. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29700. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29701. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29702. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29703. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29704. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29705. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29706. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29707. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29708. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29709. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29710. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29711. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29712. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29713. /**
  29714. * Defines the interface used by objects working like Scene
  29715. * @hidden
  29716. */
  29717. interface ISceneLike {
  29718. _addPendingData(data: any): void;
  29719. _removePendingData(data: any): void;
  29720. offlineProvider: IOfflineProvider;
  29721. }
  29722. /** Interface defining initialization parameters for Engine class */
  29723. export interface EngineOptions extends WebGLContextAttributes {
  29724. /**
  29725. * Defines if the engine should no exceed a specified device ratio
  29726. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29727. */
  29728. limitDeviceRatio?: number;
  29729. /**
  29730. * Defines if webvr should be enabled automatically
  29731. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29732. */
  29733. autoEnableWebVR?: boolean;
  29734. /**
  29735. * Defines if webgl2 should be turned off even if supported
  29736. * @see http://doc.babylonjs.com/features/webgl2
  29737. */
  29738. disableWebGL2Support?: boolean;
  29739. /**
  29740. * Defines if webaudio should be initialized as well
  29741. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29742. */
  29743. audioEngine?: boolean;
  29744. /**
  29745. * Defines if animations should run using a deterministic lock step
  29746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29747. */
  29748. deterministicLockstep?: boolean;
  29749. /** Defines the maximum steps to use with deterministic lock step mode */
  29750. lockstepMaxSteps?: number;
  29751. /**
  29752. * Defines that engine should ignore context lost events
  29753. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29754. */
  29755. doNotHandleContextLost?: boolean;
  29756. /**
  29757. * Defines that engine should ignore modifying touch action attribute and style
  29758. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29759. */
  29760. doNotHandleTouchAction?: boolean;
  29761. /**
  29762. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29763. */
  29764. useHighPrecisionFloats?: boolean;
  29765. }
  29766. /**
  29767. * The base engine class (root of all engines)
  29768. */
  29769. export class ThinEngine {
  29770. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29771. static ExceptionList: ({
  29772. key: string;
  29773. capture: string;
  29774. captureConstraint: number;
  29775. targets: string[];
  29776. } | {
  29777. key: string;
  29778. capture: null;
  29779. captureConstraint: null;
  29780. targets: string[];
  29781. })[];
  29782. /** @hidden */
  29783. static _TextureLoaders: IInternalTextureLoader[];
  29784. /**
  29785. * Returns the current npm package of the sdk
  29786. */
  29787. static readonly NpmPackage: string;
  29788. /**
  29789. * Returns the current version of the framework
  29790. */
  29791. static readonly Version: string;
  29792. /**
  29793. * Returns a string describing the current engine
  29794. */
  29795. readonly description: string;
  29796. /**
  29797. * Gets or sets the epsilon value used by collision engine
  29798. */
  29799. static CollisionsEpsilon: number;
  29800. /**
  29801. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29802. */
  29803. static ShadersRepository: string;
  29804. /** @hidden */
  29805. _shaderProcessor: IShaderProcessor;
  29806. /**
  29807. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29808. */
  29809. forcePOTTextures: boolean;
  29810. /**
  29811. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29812. */
  29813. isFullscreen: boolean;
  29814. /**
  29815. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29816. */
  29817. cullBackFaces: boolean;
  29818. /**
  29819. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29820. */
  29821. renderEvenInBackground: boolean;
  29822. /**
  29823. * Gets or sets a boolean indicating that cache can be kept between frames
  29824. */
  29825. preventCacheWipeBetweenFrames: boolean;
  29826. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29827. validateShaderPrograms: boolean;
  29828. /**
  29829. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29830. */
  29831. disableUniformBuffers: boolean;
  29832. /** @hidden */
  29833. _uniformBuffers: UniformBuffer[];
  29834. /**
  29835. * Gets a boolean indicating that the engine supports uniform buffers
  29836. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29837. */
  29838. readonly supportsUniformBuffers: boolean;
  29839. /** @hidden */
  29840. _gl: WebGLRenderingContext;
  29841. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29842. protected _windowIsBackground: boolean;
  29843. protected _webGLVersion: number;
  29844. protected _highPrecisionShadersAllowed: boolean;
  29845. /** @hidden */
  29846. readonly _shouldUseHighPrecisionShader: boolean;
  29847. /**
  29848. * Gets a boolean indicating that only power of 2 textures are supported
  29849. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29850. */
  29851. readonly needPOTTextures: boolean;
  29852. /** @hidden */
  29853. _badOS: boolean;
  29854. /** @hidden */
  29855. _badDesktopOS: boolean;
  29856. private _hardwareScalingLevel;
  29857. /** @hidden */
  29858. _caps: EngineCapabilities;
  29859. private _isStencilEnable;
  29860. protected _colorWrite: boolean;
  29861. private _glVersion;
  29862. private _glRenderer;
  29863. private _glVendor;
  29864. /** @hidden */
  29865. _videoTextureSupported: boolean;
  29866. protected _renderingQueueLaunched: boolean;
  29867. protected _activeRenderLoops: (() => void)[];
  29868. /**
  29869. * Observable signaled when a context lost event is raised
  29870. */
  29871. onContextLostObservable: Observable<ThinEngine>;
  29872. /**
  29873. * Observable signaled when a context restored event is raised
  29874. */
  29875. onContextRestoredObservable: Observable<ThinEngine>;
  29876. private _onContextLost;
  29877. private _onContextRestored;
  29878. protected _contextWasLost: boolean;
  29879. /** @hidden */
  29880. _doNotHandleContextLost: boolean;
  29881. /**
  29882. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29884. */
  29885. doNotHandleContextLost: boolean;
  29886. /**
  29887. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29888. */
  29889. disableVertexArrayObjects: boolean;
  29890. /** @hidden */
  29891. protected _depthCullingState: DepthCullingState;
  29892. /** @hidden */
  29893. protected _stencilState: StencilState;
  29894. /** @hidden */
  29895. protected _alphaState: AlphaState;
  29896. /** @hidden */
  29897. _internalTexturesCache: InternalTexture[];
  29898. /** @hidden */
  29899. protected _activeChannel: number;
  29900. private _currentTextureChannel;
  29901. /** @hidden */
  29902. protected _boundTexturesCache: {
  29903. [key: string]: Nullable<InternalTexture>;
  29904. };
  29905. /** @hidden */
  29906. protected _currentEffect: Nullable<Effect>;
  29907. /** @hidden */
  29908. protected _currentProgram: Nullable<WebGLProgram>;
  29909. private _compiledEffects;
  29910. private _vertexAttribArraysEnabled;
  29911. /** @hidden */
  29912. protected _cachedViewport: Nullable<IViewportLike>;
  29913. private _cachedVertexArrayObject;
  29914. /** @hidden */
  29915. protected _cachedVertexBuffers: any;
  29916. /** @hidden */
  29917. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29918. /** @hidden */
  29919. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29920. /** @hidden */
  29921. _currentRenderTarget: Nullable<InternalTexture>;
  29922. private _uintIndicesCurrentlySet;
  29923. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29924. /** @hidden */
  29925. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29926. private _currentBufferPointers;
  29927. private _currentInstanceLocations;
  29928. private _currentInstanceBuffers;
  29929. private _textureUnits;
  29930. /** @hidden */
  29931. _workingCanvas: Nullable<HTMLCanvasElement>;
  29932. /** @hidden */
  29933. _workingContext: Nullable<CanvasRenderingContext2D>;
  29934. /** @hidden */
  29935. _bindedRenderFunction: any;
  29936. private _vaoRecordInProgress;
  29937. private _mustWipeVertexAttributes;
  29938. private _emptyTexture;
  29939. private _emptyCubeTexture;
  29940. private _emptyTexture3D;
  29941. /** @hidden */
  29942. _frameHandler: number;
  29943. private _nextFreeTextureSlots;
  29944. private _maxSimultaneousTextures;
  29945. private _activeRequests;
  29946. protected _texturesSupported: string[];
  29947. /** @hidden */
  29948. _textureFormatInUse: Nullable<string>;
  29949. protected readonly _supportsHardwareTextureRescaling: boolean;
  29950. /**
  29951. * Gets the list of texture formats supported
  29952. */
  29953. readonly texturesSupported: Array<string>;
  29954. /**
  29955. * Gets the list of texture formats in use
  29956. */
  29957. readonly textureFormatInUse: Nullable<string>;
  29958. /**
  29959. * Gets the current viewport
  29960. */
  29961. readonly currentViewport: Nullable<IViewportLike>;
  29962. /**
  29963. * Gets the default empty texture
  29964. */
  29965. readonly emptyTexture: InternalTexture;
  29966. /**
  29967. * Gets the default empty 3D texture
  29968. */
  29969. readonly emptyTexture3D: InternalTexture;
  29970. /**
  29971. * Gets the default empty cube texture
  29972. */
  29973. readonly emptyCubeTexture: InternalTexture;
  29974. /**
  29975. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29976. */
  29977. readonly premultipliedAlpha: boolean;
  29978. /**
  29979. * Observable event triggered before each texture is initialized
  29980. */
  29981. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29982. /**
  29983. * Creates a new engine
  29984. * @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
  29985. * @param antialias defines enable antialiasing (default: false)
  29986. * @param options defines further options to be sent to the getContext() function
  29987. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29988. */
  29989. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29990. private _rebuildInternalTextures;
  29991. private _rebuildEffects;
  29992. /**
  29993. * Gets a boolean indicating if all created effects are ready
  29994. * @returns true if all effects are ready
  29995. */
  29996. areAllEffectsReady(): boolean;
  29997. protected _rebuildBuffers(): void;
  29998. private _initGLContext;
  29999. /**
  30000. * Gets version of the current webGL context
  30001. */
  30002. readonly webGLVersion: number;
  30003. /**
  30004. * Gets a string idenfifying the name of the class
  30005. * @returns "Engine" string
  30006. */
  30007. getClassName(): string;
  30008. /**
  30009. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30010. */
  30011. readonly isStencilEnable: boolean;
  30012. /** @hidden */
  30013. _prepareWorkingCanvas(): void;
  30014. /**
  30015. * Reset the texture cache to empty state
  30016. */
  30017. resetTextureCache(): void;
  30018. /**
  30019. * Gets an object containing information about the current webGL context
  30020. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30021. */
  30022. getGlInfo(): {
  30023. vendor: string;
  30024. renderer: string;
  30025. version: string;
  30026. };
  30027. /**
  30028. * Defines the hardware scaling level.
  30029. * By default the hardware scaling level is computed from the window device ratio.
  30030. * 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.
  30031. * @param level defines the level to use
  30032. */
  30033. setHardwareScalingLevel(level: number): void;
  30034. /**
  30035. * Gets the current hardware scaling level.
  30036. * By default the hardware scaling level is computed from the window device ratio.
  30037. * 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.
  30038. * @returns a number indicating the current hardware scaling level
  30039. */
  30040. getHardwareScalingLevel(): number;
  30041. /**
  30042. * Gets the list of loaded textures
  30043. * @returns an array containing all loaded textures
  30044. */
  30045. getLoadedTexturesCache(): InternalTexture[];
  30046. /**
  30047. * Gets the object containing all engine capabilities
  30048. * @returns the EngineCapabilities object
  30049. */
  30050. getCaps(): EngineCapabilities;
  30051. /**
  30052. * stop executing a render loop function and remove it from the execution array
  30053. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30054. */
  30055. stopRenderLoop(renderFunction?: () => void): void;
  30056. /** @hidden */
  30057. _renderLoop(): void;
  30058. /**
  30059. * Gets the HTML canvas attached with the current webGL context
  30060. * @returns a HTML canvas
  30061. */
  30062. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30063. /**
  30064. * Gets host window
  30065. * @returns the host window object
  30066. */
  30067. getHostWindow(): Window;
  30068. /**
  30069. * Gets the current render width
  30070. * @param useScreen defines if screen size must be used (or the current render target if any)
  30071. * @returns a number defining the current render width
  30072. */
  30073. getRenderWidth(useScreen?: boolean): number;
  30074. /**
  30075. * Gets the current render height
  30076. * @param useScreen defines if screen size must be used (or the current render target if any)
  30077. * @returns a number defining the current render height
  30078. */
  30079. getRenderHeight(useScreen?: boolean): number;
  30080. /**
  30081. * Can be used to override the current requestAnimationFrame requester.
  30082. * @hidden
  30083. */
  30084. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30085. /**
  30086. * Register and execute a render loop. The engine can have more than one render function
  30087. * @param renderFunction defines the function to continuously execute
  30088. */
  30089. runRenderLoop(renderFunction: () => void): void;
  30090. /**
  30091. * Clear the current render buffer or the current render target (if any is set up)
  30092. * @param color defines the color to use
  30093. * @param backBuffer defines if the back buffer must be cleared
  30094. * @param depth defines if the depth buffer must be cleared
  30095. * @param stencil defines if the stencil buffer must be cleared
  30096. */
  30097. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30098. private _viewportCached;
  30099. /** @hidden */
  30100. _viewport(x: number, y: number, width: number, height: number): void;
  30101. /**
  30102. * Set the WebGL's viewport
  30103. * @param viewport defines the viewport element to be used
  30104. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30105. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30106. */
  30107. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30108. /**
  30109. * Begin a new frame
  30110. */
  30111. beginFrame(): void;
  30112. /**
  30113. * Enf the current frame
  30114. */
  30115. endFrame(): void;
  30116. /**
  30117. * Resize the view according to the canvas' size
  30118. */
  30119. resize(): void;
  30120. /**
  30121. * Force a specific size of the canvas
  30122. * @param width defines the new canvas' width
  30123. * @param height defines the new canvas' height
  30124. */
  30125. setSize(width: number, height: number): void;
  30126. /**
  30127. * Binds the frame buffer to the specified texture.
  30128. * @param texture The texture to render to or null for the default canvas
  30129. * @param faceIndex The face of the texture to render to in case of cube texture
  30130. * @param requiredWidth The width of the target to render to
  30131. * @param requiredHeight The height of the target to render to
  30132. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30133. * @param depthStencilTexture The depth stencil texture to use to render
  30134. * @param lodLevel defines le lod level to bind to the frame buffer
  30135. */
  30136. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30137. /** @hidden */
  30138. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30139. /**
  30140. * Unbind the current render target texture from the webGL context
  30141. * @param texture defines the render target texture to unbind
  30142. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30143. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30144. */
  30145. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30146. /**
  30147. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30148. */
  30149. flushFramebuffer(): void;
  30150. /**
  30151. * Unbind the current render target and bind the default framebuffer
  30152. */
  30153. restoreDefaultFramebuffer(): void;
  30154. private _resetVertexBufferBinding;
  30155. /**
  30156. * Creates a vertex buffer
  30157. * @param data the data for the vertex buffer
  30158. * @returns the new WebGL static buffer
  30159. */
  30160. createVertexBuffer(data: DataArray): DataBuffer;
  30161. private _createVertexBuffer;
  30162. /**
  30163. * Creates a dynamic vertex buffer
  30164. * @param data the data for the dynamic vertex buffer
  30165. * @returns the new WebGL dynamic buffer
  30166. */
  30167. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30168. /**
  30169. * Updates a dynamic vertex buffer.
  30170. * @param vertexBuffer the vertex buffer to update
  30171. * @param data the data used to update the vertex buffer
  30172. * @param byteOffset the byte offset of the data
  30173. * @param byteLength the byte length of the data
  30174. */
  30175. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30176. protected _resetIndexBufferBinding(): void;
  30177. /**
  30178. * Creates a new index buffer
  30179. * @param indices defines the content of the index buffer
  30180. * @param updatable defines if the index buffer must be updatable
  30181. * @returns a new webGL buffer
  30182. */
  30183. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30184. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30185. /**
  30186. * Bind a webGL buffer to the webGL context
  30187. * @param buffer defines the buffer to bind
  30188. */
  30189. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30190. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30191. private bindBuffer;
  30192. /**
  30193. * update the bound buffer with the given data
  30194. * @param data defines the data to update
  30195. */
  30196. updateArrayBuffer(data: Float32Array): void;
  30197. private _vertexAttribPointer;
  30198. private _bindIndexBufferWithCache;
  30199. private _bindVertexBuffersAttributes;
  30200. /**
  30201. * Records a vertex array object
  30202. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30203. * @param vertexBuffers defines the list of vertex buffers to store
  30204. * @param indexBuffer defines the index buffer to store
  30205. * @param effect defines the effect to store
  30206. * @returns the new vertex array object
  30207. */
  30208. recordVertexArrayObject(vertexBuffers: {
  30209. [key: string]: VertexBuffer;
  30210. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30211. /**
  30212. * Bind a specific vertex array object
  30213. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30214. * @param vertexArrayObject defines the vertex array object to bind
  30215. * @param indexBuffer defines the index buffer to bind
  30216. */
  30217. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30218. /**
  30219. * Bind webGl buffers directly to the webGL context
  30220. * @param vertexBuffer defines the vertex buffer to bind
  30221. * @param indexBuffer defines the index buffer to bind
  30222. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30223. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30224. * @param effect defines the effect associated with the vertex buffer
  30225. */
  30226. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30227. private _unbindVertexArrayObject;
  30228. /**
  30229. * Bind a list of vertex buffers to the webGL context
  30230. * @param vertexBuffers defines the list of vertex buffers to bind
  30231. * @param indexBuffer defines the index buffer to bind
  30232. * @param effect defines the effect associated with the vertex buffers
  30233. */
  30234. bindBuffers(vertexBuffers: {
  30235. [key: string]: Nullable<VertexBuffer>;
  30236. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30237. /**
  30238. * Unbind all instance attributes
  30239. */
  30240. unbindInstanceAttributes(): void;
  30241. /**
  30242. * Release and free the memory of a vertex array object
  30243. * @param vao defines the vertex array object to delete
  30244. */
  30245. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30246. /** @hidden */
  30247. _releaseBuffer(buffer: DataBuffer): boolean;
  30248. protected _deleteBuffer(buffer: DataBuffer): void;
  30249. /**
  30250. * Creates a webGL buffer to use with instanciation
  30251. * @param capacity defines the size of the buffer
  30252. * @returns the webGL buffer
  30253. */
  30254. createInstancesBuffer(capacity: number): DataBuffer;
  30255. /**
  30256. * Delete a webGL buffer used with instanciation
  30257. * @param buffer defines the webGL buffer to delete
  30258. */
  30259. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30260. /**
  30261. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30262. * @param instancesBuffer defines the webGL buffer to update and bind
  30263. * @param data defines the data to store in the buffer
  30264. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30265. */
  30266. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30267. /**
  30268. * Apply all cached states (depth, culling, stencil and alpha)
  30269. */
  30270. applyStates(): void;
  30271. /**
  30272. * Send a draw order
  30273. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30274. * @param indexStart defines the starting index
  30275. * @param indexCount defines the number of index to draw
  30276. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30277. */
  30278. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30279. /**
  30280. * Draw a list of points
  30281. * @param verticesStart defines the index of first vertex to draw
  30282. * @param verticesCount defines the count of vertices to draw
  30283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30284. */
  30285. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30286. /**
  30287. * Draw a list of unindexed primitives
  30288. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30289. * @param verticesStart defines the index of first vertex to draw
  30290. * @param verticesCount defines the count of vertices to draw
  30291. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30292. */
  30293. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30294. /**
  30295. * Draw a list of indexed primitives
  30296. * @param fillMode defines the primitive to use
  30297. * @param indexStart defines the starting index
  30298. * @param indexCount defines the number of index to draw
  30299. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30300. */
  30301. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30302. /**
  30303. * Draw a list of unindexed primitives
  30304. * @param fillMode defines the primitive to use
  30305. * @param verticesStart defines the index of first vertex to draw
  30306. * @param verticesCount defines the count of vertices to draw
  30307. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30308. */
  30309. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30310. private _drawMode;
  30311. /** @hidden */
  30312. protected _reportDrawCall(): void;
  30313. /** @hidden */
  30314. _releaseEffect(effect: Effect): void;
  30315. /** @hidden */
  30316. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30317. /**
  30318. * Create a new effect (used to store vertex/fragment shaders)
  30319. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30320. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30321. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30322. * @param samplers defines an array of string used to represent textures
  30323. * @param defines defines the string containing the defines to use to compile the shaders
  30324. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30325. * @param onCompiled defines a function to call when the effect creation is successful
  30326. * @param onError defines a function to call when the effect creation has failed
  30327. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30328. * @returns the new Effect
  30329. */
  30330. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30331. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30332. private _compileShader;
  30333. private _compileRawShader;
  30334. /**
  30335. * Directly creates a webGL program
  30336. * @param pipelineContext defines the pipeline context to attach to
  30337. * @param vertexCode defines the vertex shader code to use
  30338. * @param fragmentCode defines the fragment shader code to use
  30339. * @param context defines the webGL context to use (if not set, the current one will be used)
  30340. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30341. * @returns the new webGL program
  30342. */
  30343. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30344. /**
  30345. * Creates a webGL program
  30346. * @param pipelineContext defines the pipeline context to attach to
  30347. * @param vertexCode defines the vertex shader code to use
  30348. * @param fragmentCode defines the fragment shader code to use
  30349. * @param defines defines the string containing the defines to use to compile the shaders
  30350. * @param context defines the webGL context to use (if not set, the current one will be used)
  30351. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30352. * @returns the new webGL program
  30353. */
  30354. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30355. /**
  30356. * Creates a new pipeline context
  30357. * @returns the new pipeline
  30358. */
  30359. createPipelineContext(): IPipelineContext;
  30360. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30361. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30362. /** @hidden */
  30363. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30364. /** @hidden */
  30365. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30366. /** @hidden */
  30367. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30368. /**
  30369. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30370. * @param pipelineContext defines the pipeline context to use
  30371. * @param uniformsNames defines the list of uniform names
  30372. * @returns an array of webGL uniform locations
  30373. */
  30374. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30375. /**
  30376. * Gets the lsit of active attributes for a given webGL program
  30377. * @param pipelineContext defines the pipeline context to use
  30378. * @param attributesNames defines the list of attribute names to get
  30379. * @returns an array of indices indicating the offset of each attribute
  30380. */
  30381. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30382. /**
  30383. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30384. * @param effect defines the effect to activate
  30385. */
  30386. enableEffect(effect: Nullable<Effect>): void;
  30387. /**
  30388. * Set the value of an uniform to an array of int32
  30389. * @param uniform defines the webGL uniform location where to store the value
  30390. * @param array defines the array of int32 to store
  30391. */
  30392. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30393. /**
  30394. * Set the value of an uniform to an array of int32 (stored as vec2)
  30395. * @param uniform defines the webGL uniform location where to store the value
  30396. * @param array defines the array of int32 to store
  30397. */
  30398. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30399. /**
  30400. * Set the value of an uniform to an array of int32 (stored as vec3)
  30401. * @param uniform defines the webGL uniform location where to store the value
  30402. * @param array defines the array of int32 to store
  30403. */
  30404. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30405. /**
  30406. * Set the value of an uniform to an array of int32 (stored as vec4)
  30407. * @param uniform defines the webGL uniform location where to store the value
  30408. * @param array defines the array of int32 to store
  30409. */
  30410. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30411. /**
  30412. * Set the value of an uniform to an array of float32
  30413. * @param uniform defines the webGL uniform location where to store the value
  30414. * @param array defines the array of float32 to store
  30415. */
  30416. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30417. /**
  30418. * Set the value of an uniform to an array of float32 (stored as vec2)
  30419. * @param uniform defines the webGL uniform location where to store the value
  30420. * @param array defines the array of float32 to store
  30421. */
  30422. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30423. /**
  30424. * Set the value of an uniform to an array of float32 (stored as vec3)
  30425. * @param uniform defines the webGL uniform location where to store the value
  30426. * @param array defines the array of float32 to store
  30427. */
  30428. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30429. /**
  30430. * Set the value of an uniform to an array of float32 (stored as vec4)
  30431. * @param uniform defines the webGL uniform location where to store the value
  30432. * @param array defines the array of float32 to store
  30433. */
  30434. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30435. /**
  30436. * Set the value of an uniform to an array of number
  30437. * @param uniform defines the webGL uniform location where to store the value
  30438. * @param array defines the array of number to store
  30439. */
  30440. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30441. /**
  30442. * Set the value of an uniform to an array of number (stored as vec2)
  30443. * @param uniform defines the webGL uniform location where to store the value
  30444. * @param array defines the array of number to store
  30445. */
  30446. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30447. /**
  30448. * Set the value of an uniform to an array of number (stored as vec3)
  30449. * @param uniform defines the webGL uniform location where to store the value
  30450. * @param array defines the array of number to store
  30451. */
  30452. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30453. /**
  30454. * Set the value of an uniform to an array of number (stored as vec4)
  30455. * @param uniform defines the webGL uniform location where to store the value
  30456. * @param array defines the array of number to store
  30457. */
  30458. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30459. /**
  30460. * Set the value of an uniform to an array of float32 (stored as matrices)
  30461. * @param uniform defines the webGL uniform location where to store the value
  30462. * @param matrices defines the array of float32 to store
  30463. */
  30464. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30465. /**
  30466. * Set the value of an uniform to a matrix (3x3)
  30467. * @param uniform defines the webGL uniform location where to store the value
  30468. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30469. */
  30470. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30471. /**
  30472. * Set the value of an uniform to a matrix (2x2)
  30473. * @param uniform defines the webGL uniform location where to store the value
  30474. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30475. */
  30476. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30477. /**
  30478. * Set the value of an uniform to a number (int)
  30479. * @param uniform defines the webGL uniform location where to store the value
  30480. * @param value defines the int number to store
  30481. */
  30482. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30483. /**
  30484. * Set the value of an uniform to a number (float)
  30485. * @param uniform defines the webGL uniform location where to store the value
  30486. * @param value defines the float number to store
  30487. */
  30488. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30489. /**
  30490. * Set the value of an uniform to a vec2
  30491. * @param uniform defines the webGL uniform location where to store the value
  30492. * @param x defines the 1st component of the value
  30493. * @param y defines the 2nd component of the value
  30494. */
  30495. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30496. /**
  30497. * Set the value of an uniform to a vec3
  30498. * @param uniform defines the webGL uniform location where to store the value
  30499. * @param x defines the 1st component of the value
  30500. * @param y defines the 2nd component of the value
  30501. * @param z defines the 3rd component of the value
  30502. */
  30503. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30504. /**
  30505. * Set the value of an uniform to a boolean
  30506. * @param uniform defines the webGL uniform location where to store the value
  30507. * @param bool defines the boolean to store
  30508. */
  30509. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30510. /**
  30511. * Set the value of an uniform to a vec4
  30512. * @param uniform defines the webGL uniform location where to store the value
  30513. * @param x defines the 1st component of the value
  30514. * @param y defines the 2nd component of the value
  30515. * @param z defines the 3rd component of the value
  30516. * @param w defines the 4th component of the value
  30517. */
  30518. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30519. /**
  30520. * Sets a Color4 on a uniform variable
  30521. * @param uniform defines the uniform location
  30522. * @param color4 defines the value to be set
  30523. */
  30524. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30525. /**
  30526. * Gets the depth culling state manager
  30527. */
  30528. readonly depthCullingState: DepthCullingState;
  30529. /**
  30530. * Gets the alpha state manager
  30531. */
  30532. readonly alphaState: AlphaState;
  30533. /**
  30534. * Gets the stencil state manager
  30535. */
  30536. readonly stencilState: StencilState;
  30537. /**
  30538. * Clears the list of texture accessible through engine.
  30539. * This can help preventing texture load conflict due to name collision.
  30540. */
  30541. clearInternalTexturesCache(): void;
  30542. /**
  30543. * Force the entire cache to be cleared
  30544. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30545. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30546. */
  30547. wipeCaches(bruteForce?: boolean): void;
  30548. /** @hidden */
  30549. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30550. min: number;
  30551. mag: number;
  30552. };
  30553. /** @hidden */
  30554. _createTexture(): WebGLTexture;
  30555. /**
  30556. * Usually called from Texture.ts.
  30557. * Passed information to create a WebGLTexture
  30558. * @param urlArg defines a value which contains one of the following:
  30559. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30560. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30561. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30562. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30563. * @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)
  30564. * @param scene needed for loading to the correct scene
  30565. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30566. * @param onLoad optional callback to be called upon successful completion
  30567. * @param onError optional callback to be called upon failure
  30568. * @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
  30569. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30570. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30571. * @param forcedExtension defines the extension to use to pick the right loader
  30572. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30573. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30574. */
  30575. 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;
  30576. /**
  30577. * @hidden
  30578. */
  30579. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30580. /**
  30581. * Creates a raw texture
  30582. * @param data defines the data to store in the texture
  30583. * @param width defines the width of the texture
  30584. * @param height defines the height of the texture
  30585. * @param format defines the format of the data
  30586. * @param generateMipMaps defines if the engine should generate the mip levels
  30587. * @param invertY defines if data must be stored with Y axis inverted
  30588. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30589. * @param compression defines the compression used (null by default)
  30590. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30591. * @returns the raw texture inside an InternalTexture
  30592. */
  30593. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30594. /**
  30595. * Creates a new raw cube texture
  30596. * @param data defines the array of data to use to create each face
  30597. * @param size defines the size of the textures
  30598. * @param format defines the format of the data
  30599. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30600. * @param generateMipMaps defines if the engine should generate the mip levels
  30601. * @param invertY defines if data must be stored with Y axis inverted
  30602. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30603. * @param compression defines the compression used (null by default)
  30604. * @returns the cube texture as an InternalTexture
  30605. */
  30606. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30607. /**
  30608. * Creates a new raw 3D texture
  30609. * @param data defines the data used to create the texture
  30610. * @param width defines the width of the texture
  30611. * @param height defines the height of the texture
  30612. * @param depth defines the depth of the texture
  30613. * @param format defines the format of the texture
  30614. * @param generateMipMaps defines if the engine must generate mip levels
  30615. * @param invertY defines if data must be stored with Y axis inverted
  30616. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30617. * @param compression defines the compressed used (can be null)
  30618. * @param textureType defines the compressed used (can be null)
  30619. * @returns a new raw 3D texture (stored in an InternalTexture)
  30620. */
  30621. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30622. private _unpackFlipYCached;
  30623. /**
  30624. * In case you are sharing the context with other applications, it might
  30625. * be interested to not cache the unpack flip y state to ensure a consistent
  30626. * value would be set.
  30627. */
  30628. enableUnpackFlipYCached: boolean;
  30629. /** @hidden */
  30630. _unpackFlipY(value: boolean): void;
  30631. /** @hidden */
  30632. _getUnpackAlignement(): number;
  30633. /**
  30634. * Update the sampling mode of a given texture
  30635. * @param samplingMode defines the required sampling mode
  30636. * @param texture defines the texture to update
  30637. */
  30638. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30639. /**
  30640. * Updates a depth texture Comparison Mode and Function.
  30641. * If the comparison Function is equal to 0, the mode will be set to none.
  30642. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30643. * @param texture The texture to set the comparison function for
  30644. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30645. */
  30646. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30647. /** @hidden */
  30648. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30649. width: number;
  30650. height: number;
  30651. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30652. /**
  30653. * Creates a depth stencil texture.
  30654. * This is only available in WebGL 2 or with the depth texture extension available.
  30655. * @param size The size of face edge in the texture.
  30656. * @param options The options defining the texture.
  30657. * @returns The texture
  30658. */
  30659. createDepthStencilTexture(size: number | {
  30660. width: number;
  30661. height: number;
  30662. }, options: DepthTextureCreationOptions): InternalTexture;
  30663. /**
  30664. * Creates a depth stencil texture.
  30665. * This is only available in WebGL 2 or with the depth texture extension available.
  30666. * @param size The size of face edge in the texture.
  30667. * @param options The options defining the texture.
  30668. * @returns The texture
  30669. */
  30670. private _createDepthStencilTexture;
  30671. /** @hidden */
  30672. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30673. /** @hidden */
  30674. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30675. /** @hidden */
  30676. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30677. /** @hidden */
  30678. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30679. /**
  30680. * @hidden
  30681. */
  30682. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30683. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30684. private _prepareWebGLTexture;
  30685. /** @hidden */
  30686. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30687. /** @hidden */
  30688. _releaseFramebufferObjects(texture: InternalTexture): void;
  30689. /** @hidden */
  30690. _releaseTexture(texture: InternalTexture): void;
  30691. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30692. protected _setProgram(program: WebGLProgram): void;
  30693. protected _boundUniforms: {
  30694. [key: number]: WebGLUniformLocation;
  30695. };
  30696. /**
  30697. * Binds an effect to the webGL context
  30698. * @param effect defines the effect to bind
  30699. */
  30700. bindSamplers(effect: Effect): void;
  30701. private _activateCurrentTexture;
  30702. /** @hidden */
  30703. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30704. /** @hidden */
  30705. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30706. /**
  30707. * Unbind all textures from the webGL context
  30708. */
  30709. unbindAllTextures(): void;
  30710. /**
  30711. * Sets a texture to the according uniform.
  30712. * @param channel The texture channel
  30713. * @param uniform The uniform to set
  30714. * @param texture The texture to apply
  30715. */
  30716. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30717. private _bindSamplerUniformToChannel;
  30718. private _getTextureWrapMode;
  30719. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30720. /**
  30721. * Sets an array of texture to the webGL context
  30722. * @param channel defines the channel where the texture array must be set
  30723. * @param uniform defines the associated uniform location
  30724. * @param textures defines the array of textures to bind
  30725. */
  30726. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30727. /** @hidden */
  30728. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30729. private _setTextureParameterFloat;
  30730. private _setTextureParameterInteger;
  30731. /**
  30732. * Unbind all vertex attributes from the webGL context
  30733. */
  30734. unbindAllAttributes(): void;
  30735. /**
  30736. * 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
  30737. */
  30738. releaseEffects(): void;
  30739. /**
  30740. * Dispose and release all associated resources
  30741. */
  30742. dispose(): void;
  30743. /**
  30744. * Attach a new callback raised when context lost event is fired
  30745. * @param callback defines the callback to call
  30746. */
  30747. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30748. /**
  30749. * Attach a new callback raised when context restored event is fired
  30750. * @param callback defines the callback to call
  30751. */
  30752. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30753. /**
  30754. * Get the current error code of the webGL context
  30755. * @returns the error code
  30756. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30757. */
  30758. getError(): number;
  30759. private _canRenderToFloatFramebuffer;
  30760. private _canRenderToHalfFloatFramebuffer;
  30761. private _canRenderToFramebuffer;
  30762. /** @hidden */
  30763. _getWebGLTextureType(type: number): number;
  30764. /** @hidden */
  30765. _getInternalFormat(format: number): number;
  30766. /** @hidden */
  30767. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30768. /** @hidden */
  30769. _getRGBAMultiSampleBufferFormat(type: number): number;
  30770. /** @hidden */
  30771. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30772. /**
  30773. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30774. * @returns true if the engine can be created
  30775. * @ignorenaming
  30776. */
  30777. static isSupported(): boolean;
  30778. /**
  30779. * Find the next highest power of two.
  30780. * @param x Number to start search from.
  30781. * @return Next highest power of two.
  30782. */
  30783. static CeilingPOT(x: number): number;
  30784. /**
  30785. * Find the next lowest power of two.
  30786. * @param x Number to start search from.
  30787. * @return Next lowest power of two.
  30788. */
  30789. static FloorPOT(x: number): number;
  30790. /**
  30791. * Find the nearest power of two.
  30792. * @param x Number to start search from.
  30793. * @return Next nearest power of two.
  30794. */
  30795. static NearestPOT(x: number): number;
  30796. /**
  30797. * Get the closest exponent of two
  30798. * @param value defines the value to approximate
  30799. * @param max defines the maximum value to return
  30800. * @param mode defines how to define the closest value
  30801. * @returns closest exponent of two of the given value
  30802. */
  30803. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30804. /**
  30805. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30806. * @param func - the function to be called
  30807. * @param requester - the object that will request the next frame. Falls back to window.
  30808. * @returns frame number
  30809. */
  30810. static QueueNewFrame(func: () => void, requester?: any): number;
  30811. }
  30812. }
  30813. declare module "babylonjs/Maths/sphericalPolynomial" {
  30814. import { Vector3 } from "babylonjs/Maths/math.vector";
  30815. import { Color3 } from "babylonjs/Maths/math.color";
  30816. /**
  30817. * Class representing spherical harmonics coefficients to the 3rd degree
  30818. */
  30819. export class SphericalHarmonics {
  30820. /**
  30821. * Defines whether or not the harmonics have been prescaled for rendering.
  30822. */
  30823. preScaled: boolean;
  30824. /**
  30825. * The l0,0 coefficients of the spherical harmonics
  30826. */
  30827. l00: Vector3;
  30828. /**
  30829. * The l1,-1 coefficients of the spherical harmonics
  30830. */
  30831. l1_1: Vector3;
  30832. /**
  30833. * The l1,0 coefficients of the spherical harmonics
  30834. */
  30835. l10: Vector3;
  30836. /**
  30837. * The l1,1 coefficients of the spherical harmonics
  30838. */
  30839. l11: Vector3;
  30840. /**
  30841. * The l2,-2 coefficients of the spherical harmonics
  30842. */
  30843. l2_2: Vector3;
  30844. /**
  30845. * The l2,-1 coefficients of the spherical harmonics
  30846. */
  30847. l2_1: Vector3;
  30848. /**
  30849. * The l2,0 coefficients of the spherical harmonics
  30850. */
  30851. l20: Vector3;
  30852. /**
  30853. * The l2,1 coefficients of the spherical harmonics
  30854. */
  30855. l21: Vector3;
  30856. /**
  30857. * The l2,2 coefficients of the spherical harmonics
  30858. */
  30859. l22: Vector3;
  30860. /**
  30861. * Adds a light to the spherical harmonics
  30862. * @param direction the direction of the light
  30863. * @param color the color of the light
  30864. * @param deltaSolidAngle the delta solid angle of the light
  30865. */
  30866. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30867. /**
  30868. * Scales the spherical harmonics by the given amount
  30869. * @param scale the amount to scale
  30870. */
  30871. scaleInPlace(scale: number): void;
  30872. /**
  30873. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30874. *
  30875. * ```
  30876. * E_lm = A_l * L_lm
  30877. * ```
  30878. *
  30879. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30880. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30881. * the scaling factors are given in equation 9.
  30882. */
  30883. convertIncidentRadianceToIrradiance(): void;
  30884. /**
  30885. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30886. *
  30887. * ```
  30888. * L = (1/pi) * E * rho
  30889. * ```
  30890. *
  30891. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30892. */
  30893. convertIrradianceToLambertianRadiance(): void;
  30894. /**
  30895. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30896. * required operations at run time.
  30897. *
  30898. * This is simply done by scaling back the SH with Ylm constants parameter.
  30899. * The trigonometric part being applied by the shader at run time.
  30900. */
  30901. preScaleForRendering(): void;
  30902. /**
  30903. * Constructs a spherical harmonics from an array.
  30904. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30905. * @returns the spherical harmonics
  30906. */
  30907. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30908. /**
  30909. * Gets the spherical harmonics from polynomial
  30910. * @param polynomial the spherical polynomial
  30911. * @returns the spherical harmonics
  30912. */
  30913. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30914. }
  30915. /**
  30916. * Class representing spherical polynomial coefficients to the 3rd degree
  30917. */
  30918. export class SphericalPolynomial {
  30919. private _harmonics;
  30920. /**
  30921. * The spherical harmonics used to create the polynomials.
  30922. */
  30923. readonly preScaledHarmonics: SphericalHarmonics;
  30924. /**
  30925. * The x coefficients of the spherical polynomial
  30926. */
  30927. x: Vector3;
  30928. /**
  30929. * The y coefficients of the spherical polynomial
  30930. */
  30931. y: Vector3;
  30932. /**
  30933. * The z coefficients of the spherical polynomial
  30934. */
  30935. z: Vector3;
  30936. /**
  30937. * The xx coefficients of the spherical polynomial
  30938. */
  30939. xx: Vector3;
  30940. /**
  30941. * The yy coefficients of the spherical polynomial
  30942. */
  30943. yy: Vector3;
  30944. /**
  30945. * The zz coefficients of the spherical polynomial
  30946. */
  30947. zz: Vector3;
  30948. /**
  30949. * The xy coefficients of the spherical polynomial
  30950. */
  30951. xy: Vector3;
  30952. /**
  30953. * The yz coefficients of the spherical polynomial
  30954. */
  30955. yz: Vector3;
  30956. /**
  30957. * The zx coefficients of the spherical polynomial
  30958. */
  30959. zx: Vector3;
  30960. /**
  30961. * Adds an ambient color to the spherical polynomial
  30962. * @param color the color to add
  30963. */
  30964. addAmbient(color: Color3): void;
  30965. /**
  30966. * Scales the spherical polynomial by the given amount
  30967. * @param scale the amount to scale
  30968. */
  30969. scaleInPlace(scale: number): void;
  30970. /**
  30971. * Gets the spherical polynomial from harmonics
  30972. * @param harmonics the spherical harmonics
  30973. * @returns the spherical polynomial
  30974. */
  30975. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30976. /**
  30977. * Constructs a spherical polynomial from an array.
  30978. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30979. * @returns the spherical polynomial
  30980. */
  30981. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30982. }
  30983. }
  30984. declare module "babylonjs/Materials/Textures/internalTexture" {
  30985. import { Observable } from "babylonjs/Misc/observable";
  30986. import { Nullable, int } from "babylonjs/types";
  30987. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30989. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  30990. /**
  30991. * Defines the source of the internal texture
  30992. */
  30993. export enum InternalTextureSource {
  30994. /**
  30995. * The source of the texture data is unknown
  30996. */
  30997. Unknown = 0,
  30998. /**
  30999. * Texture data comes from an URL
  31000. */
  31001. Url = 1,
  31002. /**
  31003. * Texture data is only used for temporary storage
  31004. */
  31005. Temp = 2,
  31006. /**
  31007. * Texture data comes from raw data (ArrayBuffer)
  31008. */
  31009. Raw = 3,
  31010. /**
  31011. * Texture content is dynamic (video or dynamic texture)
  31012. */
  31013. Dynamic = 4,
  31014. /**
  31015. * Texture content is generated by rendering to it
  31016. */
  31017. RenderTarget = 5,
  31018. /**
  31019. * Texture content is part of a multi render target process
  31020. */
  31021. MultiRenderTarget = 6,
  31022. /**
  31023. * Texture data comes from a cube data file
  31024. */
  31025. Cube = 7,
  31026. /**
  31027. * Texture data comes from a raw cube data
  31028. */
  31029. CubeRaw = 8,
  31030. /**
  31031. * Texture data come from a prefiltered cube data file
  31032. */
  31033. CubePrefiltered = 9,
  31034. /**
  31035. * Texture content is raw 3D data
  31036. */
  31037. Raw3D = 10,
  31038. /**
  31039. * Texture content is a depth texture
  31040. */
  31041. Depth = 11,
  31042. /**
  31043. * Texture data comes from a raw cube data encoded with RGBD
  31044. */
  31045. CubeRawRGBD = 12
  31046. }
  31047. /**
  31048. * Class used to store data associated with WebGL texture data for the engine
  31049. * This class should not be used directly
  31050. */
  31051. export class InternalTexture {
  31052. /** @hidden */
  31053. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31054. /**
  31055. * Defines if the texture is ready
  31056. */
  31057. isReady: boolean;
  31058. /**
  31059. * Defines if the texture is a cube texture
  31060. */
  31061. isCube: boolean;
  31062. /**
  31063. * Defines if the texture contains 3D data
  31064. */
  31065. is3D: boolean;
  31066. /**
  31067. * Defines if the texture contains multiview data
  31068. */
  31069. isMultiview: boolean;
  31070. /**
  31071. * Gets the URL used to load this texture
  31072. */
  31073. url: string;
  31074. /**
  31075. * Gets the sampling mode of the texture
  31076. */
  31077. samplingMode: number;
  31078. /**
  31079. * Gets a boolean indicating if the texture needs mipmaps generation
  31080. */
  31081. generateMipMaps: boolean;
  31082. /**
  31083. * Gets the number of samples used by the texture (WebGL2+ only)
  31084. */
  31085. samples: number;
  31086. /**
  31087. * Gets the type of the texture (int, float...)
  31088. */
  31089. type: number;
  31090. /**
  31091. * Gets the format of the texture (RGB, RGBA...)
  31092. */
  31093. format: number;
  31094. /**
  31095. * Observable called when the texture is loaded
  31096. */
  31097. onLoadedObservable: Observable<InternalTexture>;
  31098. /**
  31099. * Gets the width of the texture
  31100. */
  31101. width: number;
  31102. /**
  31103. * Gets the height of the texture
  31104. */
  31105. height: number;
  31106. /**
  31107. * Gets the depth of the texture
  31108. */
  31109. depth: number;
  31110. /**
  31111. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31112. */
  31113. baseWidth: number;
  31114. /**
  31115. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31116. */
  31117. baseHeight: number;
  31118. /**
  31119. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31120. */
  31121. baseDepth: number;
  31122. /**
  31123. * Gets a boolean indicating if the texture is inverted on Y axis
  31124. */
  31125. invertY: boolean;
  31126. /** @hidden */
  31127. _invertVScale: boolean;
  31128. /** @hidden */
  31129. _associatedChannel: number;
  31130. /** @hidden */
  31131. _source: InternalTextureSource;
  31132. /** @hidden */
  31133. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31134. /** @hidden */
  31135. _bufferView: Nullable<ArrayBufferView>;
  31136. /** @hidden */
  31137. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31138. /** @hidden */
  31139. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31140. /** @hidden */
  31141. _size: number;
  31142. /** @hidden */
  31143. _extension: string;
  31144. /** @hidden */
  31145. _files: Nullable<string[]>;
  31146. /** @hidden */
  31147. _workingCanvas: Nullable<HTMLCanvasElement>;
  31148. /** @hidden */
  31149. _workingContext: Nullable<CanvasRenderingContext2D>;
  31150. /** @hidden */
  31151. _framebuffer: Nullable<WebGLFramebuffer>;
  31152. /** @hidden */
  31153. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31154. /** @hidden */
  31155. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31156. /** @hidden */
  31157. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31158. /** @hidden */
  31159. _attachments: Nullable<number[]>;
  31160. /** @hidden */
  31161. _cachedCoordinatesMode: Nullable<number>;
  31162. /** @hidden */
  31163. _cachedWrapU: Nullable<number>;
  31164. /** @hidden */
  31165. _cachedWrapV: Nullable<number>;
  31166. /** @hidden */
  31167. _cachedWrapR: Nullable<number>;
  31168. /** @hidden */
  31169. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31170. /** @hidden */
  31171. _isDisabled: boolean;
  31172. /** @hidden */
  31173. _compression: Nullable<string>;
  31174. /** @hidden */
  31175. _generateStencilBuffer: boolean;
  31176. /** @hidden */
  31177. _generateDepthBuffer: boolean;
  31178. /** @hidden */
  31179. _comparisonFunction: number;
  31180. /** @hidden */
  31181. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31182. /** @hidden */
  31183. _lodGenerationScale: number;
  31184. /** @hidden */
  31185. _lodGenerationOffset: number;
  31186. /** @hidden */
  31187. _colorTextureArray: Nullable<WebGLTexture>;
  31188. /** @hidden */
  31189. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31190. /** @hidden */
  31191. _lodTextureHigh: Nullable<BaseTexture>;
  31192. /** @hidden */
  31193. _lodTextureMid: Nullable<BaseTexture>;
  31194. /** @hidden */
  31195. _lodTextureLow: Nullable<BaseTexture>;
  31196. /** @hidden */
  31197. _isRGBD: boolean;
  31198. /** @hidden */
  31199. _linearSpecularLOD: boolean;
  31200. /** @hidden */
  31201. _irradianceTexture: Nullable<BaseTexture>;
  31202. /** @hidden */
  31203. _webGLTexture: Nullable<WebGLTexture>;
  31204. /** @hidden */
  31205. _references: number;
  31206. private _engine;
  31207. /**
  31208. * Gets the Engine the texture belongs to.
  31209. * @returns The babylon engine
  31210. */
  31211. getEngine(): ThinEngine;
  31212. /**
  31213. * Gets the data source type of the texture
  31214. */
  31215. readonly source: InternalTextureSource;
  31216. /**
  31217. * Creates a new InternalTexture
  31218. * @param engine defines the engine to use
  31219. * @param source defines the type of data that will be used
  31220. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31221. */
  31222. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31223. /**
  31224. * Increments the number of references (ie. the number of Texture that point to it)
  31225. */
  31226. incrementReferences(): void;
  31227. /**
  31228. * Change the size of the texture (not the size of the content)
  31229. * @param width defines the new width
  31230. * @param height defines the new height
  31231. * @param depth defines the new depth (1 by default)
  31232. */
  31233. updateSize(width: int, height: int, depth?: int): void;
  31234. /** @hidden */
  31235. _rebuild(): void;
  31236. /** @hidden */
  31237. _swapAndDie(target: InternalTexture): void;
  31238. /**
  31239. * Dispose the current allocated resources
  31240. */
  31241. dispose(): void;
  31242. }
  31243. }
  31244. declare module "babylonjs/Audio/analyser" {
  31245. import { Scene } from "babylonjs/scene";
  31246. /**
  31247. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31248. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31249. */
  31250. export class Analyser {
  31251. /**
  31252. * Gets or sets the smoothing
  31253. * @ignorenaming
  31254. */
  31255. SMOOTHING: number;
  31256. /**
  31257. * Gets or sets the FFT table size
  31258. * @ignorenaming
  31259. */
  31260. FFT_SIZE: number;
  31261. /**
  31262. * Gets or sets the bar graph amplitude
  31263. * @ignorenaming
  31264. */
  31265. BARGRAPHAMPLITUDE: number;
  31266. /**
  31267. * Gets or sets the position of the debug canvas
  31268. * @ignorenaming
  31269. */
  31270. DEBUGCANVASPOS: {
  31271. x: number;
  31272. y: number;
  31273. };
  31274. /**
  31275. * Gets or sets the debug canvas size
  31276. * @ignorenaming
  31277. */
  31278. DEBUGCANVASSIZE: {
  31279. width: number;
  31280. height: number;
  31281. };
  31282. private _byteFreqs;
  31283. private _byteTime;
  31284. private _floatFreqs;
  31285. private _webAudioAnalyser;
  31286. private _debugCanvas;
  31287. private _debugCanvasContext;
  31288. private _scene;
  31289. private _registerFunc;
  31290. private _audioEngine;
  31291. /**
  31292. * Creates a new analyser
  31293. * @param scene defines hosting scene
  31294. */
  31295. constructor(scene: Scene);
  31296. /**
  31297. * Get the number of data values you will have to play with for the visualization
  31298. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31299. * @returns a number
  31300. */
  31301. getFrequencyBinCount(): number;
  31302. /**
  31303. * Gets the current frequency data as a byte array
  31304. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31305. * @returns a Uint8Array
  31306. */
  31307. getByteFrequencyData(): Uint8Array;
  31308. /**
  31309. * Gets the current waveform as a byte array
  31310. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31311. * @returns a Uint8Array
  31312. */
  31313. getByteTimeDomainData(): Uint8Array;
  31314. /**
  31315. * Gets the current frequency data as a float array
  31316. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31317. * @returns a Float32Array
  31318. */
  31319. getFloatFrequencyData(): Float32Array;
  31320. /**
  31321. * Renders the debug canvas
  31322. */
  31323. drawDebugCanvas(): void;
  31324. /**
  31325. * Stops rendering the debug canvas and removes it
  31326. */
  31327. stopDebugCanvas(): void;
  31328. /**
  31329. * Connects two audio nodes
  31330. * @param inputAudioNode defines first node to connect
  31331. * @param outputAudioNode defines second node to connect
  31332. */
  31333. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31334. /**
  31335. * Releases all associated resources
  31336. */
  31337. dispose(): void;
  31338. }
  31339. }
  31340. declare module "babylonjs/Audio/audioEngine" {
  31341. import { IDisposable } from "babylonjs/scene";
  31342. import { Analyser } from "babylonjs/Audio/analyser";
  31343. import { Nullable } from "babylonjs/types";
  31344. import { Observable } from "babylonjs/Misc/observable";
  31345. /**
  31346. * This represents an audio engine and it is responsible
  31347. * to play, synchronize and analyse sounds throughout the application.
  31348. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31349. */
  31350. export interface IAudioEngine extends IDisposable {
  31351. /**
  31352. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31353. */
  31354. readonly canUseWebAudio: boolean;
  31355. /**
  31356. * Gets the current AudioContext if available.
  31357. */
  31358. readonly audioContext: Nullable<AudioContext>;
  31359. /**
  31360. * The master gain node defines the global audio volume of your audio engine.
  31361. */
  31362. readonly masterGain: GainNode;
  31363. /**
  31364. * Gets whether or not mp3 are supported by your browser.
  31365. */
  31366. readonly isMP3supported: boolean;
  31367. /**
  31368. * Gets whether or not ogg are supported by your browser.
  31369. */
  31370. readonly isOGGsupported: boolean;
  31371. /**
  31372. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31373. * @ignoreNaming
  31374. */
  31375. WarnedWebAudioUnsupported: boolean;
  31376. /**
  31377. * Defines if the audio engine relies on a custom unlocked button.
  31378. * In this case, the embedded button will not be displayed.
  31379. */
  31380. useCustomUnlockedButton: boolean;
  31381. /**
  31382. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31383. */
  31384. readonly unlocked: boolean;
  31385. /**
  31386. * Event raised when audio has been unlocked on the browser.
  31387. */
  31388. onAudioUnlockedObservable: Observable<AudioEngine>;
  31389. /**
  31390. * Event raised when audio has been locked on the browser.
  31391. */
  31392. onAudioLockedObservable: Observable<AudioEngine>;
  31393. /**
  31394. * Flags the audio engine in Locked state.
  31395. * This happens due to new browser policies preventing audio to autoplay.
  31396. */
  31397. lock(): void;
  31398. /**
  31399. * Unlocks the audio engine once a user action has been done on the dom.
  31400. * This is helpful to resume play once browser policies have been satisfied.
  31401. */
  31402. unlock(): void;
  31403. }
  31404. /**
  31405. * This represents the default audio engine used in babylon.
  31406. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31408. */
  31409. export class AudioEngine implements IAudioEngine {
  31410. private _audioContext;
  31411. private _audioContextInitialized;
  31412. private _muteButton;
  31413. private _hostElement;
  31414. /**
  31415. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31416. */
  31417. canUseWebAudio: boolean;
  31418. /**
  31419. * The master gain node defines the global audio volume of your audio engine.
  31420. */
  31421. masterGain: GainNode;
  31422. /**
  31423. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31424. * @ignoreNaming
  31425. */
  31426. WarnedWebAudioUnsupported: boolean;
  31427. /**
  31428. * Gets whether or not mp3 are supported by your browser.
  31429. */
  31430. isMP3supported: boolean;
  31431. /**
  31432. * Gets whether or not ogg are supported by your browser.
  31433. */
  31434. isOGGsupported: boolean;
  31435. /**
  31436. * Gets whether audio has been unlocked on the device.
  31437. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31438. * a user interaction has happened.
  31439. */
  31440. unlocked: boolean;
  31441. /**
  31442. * Defines if the audio engine relies on a custom unlocked button.
  31443. * In this case, the embedded button will not be displayed.
  31444. */
  31445. useCustomUnlockedButton: boolean;
  31446. /**
  31447. * Event raised when audio has been unlocked on the browser.
  31448. */
  31449. onAudioUnlockedObservable: Observable<AudioEngine>;
  31450. /**
  31451. * Event raised when audio has been locked on the browser.
  31452. */
  31453. onAudioLockedObservable: Observable<AudioEngine>;
  31454. /**
  31455. * Gets the current AudioContext if available.
  31456. */
  31457. readonly audioContext: Nullable<AudioContext>;
  31458. private _connectedAnalyser;
  31459. /**
  31460. * Instantiates a new audio engine.
  31461. *
  31462. * There should be only one per page as some browsers restrict the number
  31463. * of audio contexts you can create.
  31464. * @param hostElement defines the host element where to display the mute icon if necessary
  31465. */
  31466. constructor(hostElement?: Nullable<HTMLElement>);
  31467. /**
  31468. * Flags the audio engine in Locked state.
  31469. * This happens due to new browser policies preventing audio to autoplay.
  31470. */
  31471. lock(): void;
  31472. /**
  31473. * Unlocks the audio engine once a user action has been done on the dom.
  31474. * This is helpful to resume play once browser policies have been satisfied.
  31475. */
  31476. unlock(): void;
  31477. private _resumeAudioContext;
  31478. private _initializeAudioContext;
  31479. private _tryToRun;
  31480. private _triggerRunningState;
  31481. private _triggerSuspendedState;
  31482. private _displayMuteButton;
  31483. private _moveButtonToTopLeft;
  31484. private _onResize;
  31485. private _hideMuteButton;
  31486. /**
  31487. * Destroy and release the resources associated with the audio ccontext.
  31488. */
  31489. dispose(): void;
  31490. /**
  31491. * Gets the global volume sets on the master gain.
  31492. * @returns the global volume if set or -1 otherwise
  31493. */
  31494. getGlobalVolume(): number;
  31495. /**
  31496. * Sets the global volume of your experience (sets on the master gain).
  31497. * @param newVolume Defines the new global volume of the application
  31498. */
  31499. setGlobalVolume(newVolume: number): void;
  31500. /**
  31501. * Connect the audio engine to an audio analyser allowing some amazing
  31502. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31504. * @param analyser The analyser to connect to the engine
  31505. */
  31506. connectToAnalyser(analyser: Analyser): void;
  31507. }
  31508. }
  31509. declare module "babylonjs/Loading/loadingScreen" {
  31510. /**
  31511. * Interface used to present a loading screen while loading a scene
  31512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31513. */
  31514. export interface ILoadingScreen {
  31515. /**
  31516. * Function called to display the loading screen
  31517. */
  31518. displayLoadingUI: () => void;
  31519. /**
  31520. * Function called to hide the loading screen
  31521. */
  31522. hideLoadingUI: () => void;
  31523. /**
  31524. * Gets or sets the color to use for the background
  31525. */
  31526. loadingUIBackgroundColor: string;
  31527. /**
  31528. * Gets or sets the text to display while loading
  31529. */
  31530. loadingUIText: string;
  31531. }
  31532. /**
  31533. * Class used for the default loading screen
  31534. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31535. */
  31536. export class DefaultLoadingScreen implements ILoadingScreen {
  31537. private _renderingCanvas;
  31538. private _loadingText;
  31539. private _loadingDivBackgroundColor;
  31540. private _loadingDiv;
  31541. private _loadingTextDiv;
  31542. /** Gets or sets the logo url to use for the default loading screen */
  31543. static DefaultLogoUrl: string;
  31544. /** Gets or sets the spinner url to use for the default loading screen */
  31545. static DefaultSpinnerUrl: string;
  31546. /**
  31547. * Creates a new default loading screen
  31548. * @param _renderingCanvas defines the canvas used to render the scene
  31549. * @param _loadingText defines the default text to display
  31550. * @param _loadingDivBackgroundColor defines the default background color
  31551. */
  31552. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31553. /**
  31554. * Function called to display the loading screen
  31555. */
  31556. displayLoadingUI(): void;
  31557. /**
  31558. * Function called to hide the loading screen
  31559. */
  31560. hideLoadingUI(): void;
  31561. /**
  31562. * Gets or sets the text to display while loading
  31563. */
  31564. loadingUIText: string;
  31565. /**
  31566. * Gets or sets the color to use for the background
  31567. */
  31568. loadingUIBackgroundColor: string;
  31569. private _resizeLoadingUI;
  31570. }
  31571. }
  31572. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31573. /**
  31574. * Interface for any object that can request an animation frame
  31575. */
  31576. export interface ICustomAnimationFrameRequester {
  31577. /**
  31578. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31579. */
  31580. renderFunction?: Function;
  31581. /**
  31582. * Called to request the next frame to render to
  31583. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31584. */
  31585. requestAnimationFrame: Function;
  31586. /**
  31587. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31588. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31589. */
  31590. requestID?: number;
  31591. }
  31592. }
  31593. declare module "babylonjs/Misc/performanceMonitor" {
  31594. /**
  31595. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31596. */
  31597. export class PerformanceMonitor {
  31598. private _enabled;
  31599. private _rollingFrameTime;
  31600. private _lastFrameTimeMs;
  31601. /**
  31602. * constructor
  31603. * @param frameSampleSize The number of samples required to saturate the sliding window
  31604. */
  31605. constructor(frameSampleSize?: number);
  31606. /**
  31607. * Samples current frame
  31608. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31609. */
  31610. sampleFrame(timeMs?: number): void;
  31611. /**
  31612. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31613. */
  31614. readonly averageFrameTime: number;
  31615. /**
  31616. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31617. */
  31618. readonly averageFrameTimeVariance: number;
  31619. /**
  31620. * Returns the frame time of the most recent frame
  31621. */
  31622. readonly instantaneousFrameTime: number;
  31623. /**
  31624. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31625. */
  31626. readonly averageFPS: number;
  31627. /**
  31628. * Returns the average framerate in frames per second using the most recent frame time
  31629. */
  31630. readonly instantaneousFPS: number;
  31631. /**
  31632. * Returns true if enough samples have been taken to completely fill the sliding window
  31633. */
  31634. readonly isSaturated: boolean;
  31635. /**
  31636. * Enables contributions to the sliding window sample set
  31637. */
  31638. enable(): void;
  31639. /**
  31640. * Disables contributions to the sliding window sample set
  31641. * Samples will not be interpolated over the disabled period
  31642. */
  31643. disable(): void;
  31644. /**
  31645. * Returns true if sampling is enabled
  31646. */
  31647. readonly isEnabled: boolean;
  31648. /**
  31649. * Resets performance monitor
  31650. */
  31651. reset(): void;
  31652. }
  31653. /**
  31654. * RollingAverage
  31655. *
  31656. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31657. */
  31658. export class RollingAverage {
  31659. /**
  31660. * Current average
  31661. */
  31662. average: number;
  31663. /**
  31664. * Current variance
  31665. */
  31666. variance: number;
  31667. protected _samples: Array<number>;
  31668. protected _sampleCount: number;
  31669. protected _pos: number;
  31670. protected _m2: number;
  31671. /**
  31672. * constructor
  31673. * @param length The number of samples required to saturate the sliding window
  31674. */
  31675. constructor(length: number);
  31676. /**
  31677. * Adds a sample to the sample set
  31678. * @param v The sample value
  31679. */
  31680. add(v: number): void;
  31681. /**
  31682. * Returns previously added values or null if outside of history or outside the sliding window domain
  31683. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31684. * @return Value previously recorded with add() or null if outside of range
  31685. */
  31686. history(i: number): number;
  31687. /**
  31688. * Returns true if enough samples have been taken to completely fill the sliding window
  31689. * @return true if sample-set saturated
  31690. */
  31691. isSaturated(): boolean;
  31692. /**
  31693. * Resets the rolling average (equivalent to 0 samples taken so far)
  31694. */
  31695. reset(): void;
  31696. /**
  31697. * Wraps a value around the sample range boundaries
  31698. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31699. * @return Wrapped position in sample range
  31700. */
  31701. protected _wrapPosition(i: number): number;
  31702. }
  31703. }
  31704. declare module "babylonjs/Misc/perfCounter" {
  31705. /**
  31706. * This class is used to track a performance counter which is number based.
  31707. * The user has access to many properties which give statistics of different nature.
  31708. *
  31709. * The implementer can track two kinds of Performance Counter: time and count.
  31710. * 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.
  31711. * 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.
  31712. */
  31713. export class PerfCounter {
  31714. /**
  31715. * Gets or sets a global boolean to turn on and off all the counters
  31716. */
  31717. static Enabled: boolean;
  31718. /**
  31719. * Returns the smallest value ever
  31720. */
  31721. readonly min: number;
  31722. /**
  31723. * Returns the biggest value ever
  31724. */
  31725. readonly max: number;
  31726. /**
  31727. * Returns the average value since the performance counter is running
  31728. */
  31729. readonly average: number;
  31730. /**
  31731. * Returns the average value of the last second the counter was monitored
  31732. */
  31733. readonly lastSecAverage: number;
  31734. /**
  31735. * Returns the current value
  31736. */
  31737. readonly current: number;
  31738. /**
  31739. * Gets the accumulated total
  31740. */
  31741. readonly total: number;
  31742. /**
  31743. * Gets the total value count
  31744. */
  31745. readonly count: number;
  31746. /**
  31747. * Creates a new counter
  31748. */
  31749. constructor();
  31750. /**
  31751. * Call this method to start monitoring a new frame.
  31752. * 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.
  31753. */
  31754. fetchNewFrame(): void;
  31755. /**
  31756. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31757. * @param newCount the count value to add to the monitored count
  31758. * @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.
  31759. */
  31760. addCount(newCount: number, fetchResult: boolean): void;
  31761. /**
  31762. * Start monitoring this performance counter
  31763. */
  31764. beginMonitoring(): void;
  31765. /**
  31766. * Compute the time lapsed since the previous beginMonitoring() call.
  31767. * @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
  31768. */
  31769. endMonitoring(newFrame?: boolean): void;
  31770. private _fetchResult;
  31771. private _startMonitoringTime;
  31772. private _min;
  31773. private _max;
  31774. private _average;
  31775. private _current;
  31776. private _totalValueCount;
  31777. private _totalAccumulated;
  31778. private _lastSecAverage;
  31779. private _lastSecAccumulated;
  31780. private _lastSecTime;
  31781. private _lastSecValueCount;
  31782. }
  31783. }
  31784. declare module "babylonjs/Engines/engine" {
  31785. import { Observable } from "babylonjs/Misc/observable";
  31786. import { Nullable, IndicesArray } from "babylonjs/types";
  31787. import { Scene } from "babylonjs/scene";
  31788. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31789. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31790. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31791. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31792. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31793. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31794. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31795. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31796. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31797. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31798. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31799. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31800. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31801. import { Material } from "babylonjs/Materials/material";
  31802. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31803. /**
  31804. * Defines the interface used by display changed events
  31805. */
  31806. export interface IDisplayChangedEventArgs {
  31807. /** Gets the vrDisplay object (if any) */
  31808. vrDisplay: Nullable<any>;
  31809. /** Gets a boolean indicating if webVR is supported */
  31810. vrSupported: boolean;
  31811. }
  31812. /**
  31813. * Defines the interface used by objects containing a viewport (like a camera)
  31814. */
  31815. interface IViewportOwnerLike {
  31816. /**
  31817. * Gets or sets the viewport
  31818. */
  31819. viewport: IViewportLike;
  31820. }
  31821. /**
  31822. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31823. */
  31824. export class Engine extends ThinEngine {
  31825. /** Defines that alpha blending is disabled */
  31826. static readonly ALPHA_DISABLE: number;
  31827. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31828. static readonly ALPHA_ADD: number;
  31829. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31830. static readonly ALPHA_COMBINE: number;
  31831. /** Defines that alpha blending to DEST - SRC * DEST */
  31832. static readonly ALPHA_SUBTRACT: number;
  31833. /** Defines that alpha blending to SRC * DEST */
  31834. static readonly ALPHA_MULTIPLY: number;
  31835. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31836. static readonly ALPHA_MAXIMIZED: number;
  31837. /** Defines that alpha blending to SRC + DEST */
  31838. static readonly ALPHA_ONEONE: number;
  31839. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31840. static readonly ALPHA_PREMULTIPLIED: number;
  31841. /**
  31842. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31843. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31844. */
  31845. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31846. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31847. static readonly ALPHA_INTERPOLATE: number;
  31848. /**
  31849. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31850. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31851. */
  31852. static readonly ALPHA_SCREENMODE: number;
  31853. /** Defines that the ressource is not delayed*/
  31854. static readonly DELAYLOADSTATE_NONE: number;
  31855. /** Defines that the ressource was successfully delay loaded */
  31856. static readonly DELAYLOADSTATE_LOADED: number;
  31857. /** Defines that the ressource is currently delay loading */
  31858. static readonly DELAYLOADSTATE_LOADING: number;
  31859. /** Defines that the ressource is delayed and has not started loading */
  31860. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31861. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31862. static readonly NEVER: number;
  31863. /** 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 */
  31864. static readonly ALWAYS: number;
  31865. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31866. static readonly LESS: number;
  31867. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31868. static readonly EQUAL: number;
  31869. /** 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 */
  31870. static readonly LEQUAL: number;
  31871. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31872. static readonly GREATER: number;
  31873. /** 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 */
  31874. static readonly GEQUAL: number;
  31875. /** 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 */
  31876. static readonly NOTEQUAL: number;
  31877. /** Passed to stencilOperation to specify that stencil value must be kept */
  31878. static readonly KEEP: number;
  31879. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31880. static readonly REPLACE: number;
  31881. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31882. static readonly INCR: number;
  31883. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31884. static readonly DECR: number;
  31885. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31886. static readonly INVERT: number;
  31887. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31888. static readonly INCR_WRAP: number;
  31889. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31890. static readonly DECR_WRAP: number;
  31891. /** Texture is not repeating outside of 0..1 UVs */
  31892. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31893. /** Texture is repeating outside of 0..1 UVs */
  31894. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31895. /** Texture is repeating and mirrored */
  31896. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31897. /** ALPHA */
  31898. static readonly TEXTUREFORMAT_ALPHA: number;
  31899. /** LUMINANCE */
  31900. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31901. /** LUMINANCE_ALPHA */
  31902. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31903. /** RGB */
  31904. static readonly TEXTUREFORMAT_RGB: number;
  31905. /** RGBA */
  31906. static readonly TEXTUREFORMAT_RGBA: number;
  31907. /** RED */
  31908. static readonly TEXTUREFORMAT_RED: number;
  31909. /** RED (2nd reference) */
  31910. static readonly TEXTUREFORMAT_R: number;
  31911. /** RG */
  31912. static readonly TEXTUREFORMAT_RG: number;
  31913. /** RED_INTEGER */
  31914. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31915. /** RED_INTEGER (2nd reference) */
  31916. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31917. /** RG_INTEGER */
  31918. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31919. /** RGB_INTEGER */
  31920. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31921. /** RGBA_INTEGER */
  31922. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31923. /** UNSIGNED_BYTE */
  31924. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31925. /** UNSIGNED_BYTE (2nd reference) */
  31926. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31927. /** FLOAT */
  31928. static readonly TEXTURETYPE_FLOAT: number;
  31929. /** HALF_FLOAT */
  31930. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31931. /** BYTE */
  31932. static readonly TEXTURETYPE_BYTE: number;
  31933. /** SHORT */
  31934. static readonly TEXTURETYPE_SHORT: number;
  31935. /** UNSIGNED_SHORT */
  31936. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31937. /** INT */
  31938. static readonly TEXTURETYPE_INT: number;
  31939. /** UNSIGNED_INT */
  31940. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31941. /** UNSIGNED_SHORT_4_4_4_4 */
  31942. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31943. /** UNSIGNED_SHORT_5_5_5_1 */
  31944. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31945. /** UNSIGNED_SHORT_5_6_5 */
  31946. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31947. /** UNSIGNED_INT_2_10_10_10_REV */
  31948. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31949. /** UNSIGNED_INT_24_8 */
  31950. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31951. /** UNSIGNED_INT_10F_11F_11F_REV */
  31952. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31953. /** UNSIGNED_INT_5_9_9_9_REV */
  31954. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31955. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31956. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31957. /** nearest is mag = nearest and min = nearest and mip = linear */
  31958. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31959. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31960. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31961. /** Trilinear is mag = linear and min = linear and mip = linear */
  31962. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31963. /** nearest is mag = nearest and min = nearest and mip = linear */
  31964. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31965. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31966. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31967. /** Trilinear is mag = linear and min = linear and mip = linear */
  31968. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31969. /** mag = nearest and min = nearest and mip = nearest */
  31970. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31971. /** mag = nearest and min = linear and mip = nearest */
  31972. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31973. /** mag = nearest and min = linear and mip = linear */
  31974. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31975. /** mag = nearest and min = linear and mip = none */
  31976. static readonly TEXTURE_NEAREST_LINEAR: number;
  31977. /** mag = nearest and min = nearest and mip = none */
  31978. static readonly TEXTURE_NEAREST_NEAREST: number;
  31979. /** mag = linear and min = nearest and mip = nearest */
  31980. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31981. /** mag = linear and min = nearest and mip = linear */
  31982. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31983. /** mag = linear and min = linear and mip = none */
  31984. static readonly TEXTURE_LINEAR_LINEAR: number;
  31985. /** mag = linear and min = nearest and mip = none */
  31986. static readonly TEXTURE_LINEAR_NEAREST: number;
  31987. /** Explicit coordinates mode */
  31988. static readonly TEXTURE_EXPLICIT_MODE: number;
  31989. /** Spherical coordinates mode */
  31990. static readonly TEXTURE_SPHERICAL_MODE: number;
  31991. /** Planar coordinates mode */
  31992. static readonly TEXTURE_PLANAR_MODE: number;
  31993. /** Cubic coordinates mode */
  31994. static readonly TEXTURE_CUBIC_MODE: number;
  31995. /** Projection coordinates mode */
  31996. static readonly TEXTURE_PROJECTION_MODE: number;
  31997. /** Skybox coordinates mode */
  31998. static readonly TEXTURE_SKYBOX_MODE: number;
  31999. /** Inverse Cubic coordinates mode */
  32000. static readonly TEXTURE_INVCUBIC_MODE: number;
  32001. /** Equirectangular coordinates mode */
  32002. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32003. /** Equirectangular Fixed coordinates mode */
  32004. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32005. /** Equirectangular Fixed Mirrored coordinates mode */
  32006. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32007. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32008. static readonly SCALEMODE_FLOOR: number;
  32009. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32010. static readonly SCALEMODE_NEAREST: number;
  32011. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32012. static readonly SCALEMODE_CEILING: number;
  32013. /**
  32014. * Returns the current npm package of the sdk
  32015. */
  32016. static readonly NpmPackage: string;
  32017. /**
  32018. * Returns the current version of the framework
  32019. */
  32020. static readonly Version: string;
  32021. /** Gets the list of created engines */
  32022. static readonly Instances: Engine[];
  32023. /**
  32024. * Gets the latest created engine
  32025. */
  32026. static readonly LastCreatedEngine: Nullable<Engine>;
  32027. /**
  32028. * Gets the latest created scene
  32029. */
  32030. static readonly LastCreatedScene: Nullable<Scene>;
  32031. /**
  32032. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32033. * @param flag defines which part of the materials must be marked as dirty
  32034. * @param predicate defines a predicate used to filter which materials should be affected
  32035. */
  32036. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32037. /**
  32038. * Method called to create the default loading screen.
  32039. * This can be overriden in your own app.
  32040. * @param canvas The rendering canvas element
  32041. * @returns The loading screen
  32042. */
  32043. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32044. /**
  32045. * Method called to create the default rescale post process on each engine.
  32046. */
  32047. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32048. /**
  32049. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32050. **/
  32051. enableOfflineSupport: boolean;
  32052. /**
  32053. * 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)
  32054. **/
  32055. disableManifestCheck: boolean;
  32056. /**
  32057. * Gets the list of created scenes
  32058. */
  32059. scenes: Scene[];
  32060. /**
  32061. * Event raised when a new scene is created
  32062. */
  32063. onNewSceneAddedObservable: Observable<Scene>;
  32064. /**
  32065. * Gets the list of created postprocesses
  32066. */
  32067. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32068. /**
  32069. * Gets a boolean indicating if the pointer is currently locked
  32070. */
  32071. isPointerLock: boolean;
  32072. /**
  32073. * Observable event triggered each time the rendering canvas is resized
  32074. */
  32075. onResizeObservable: Observable<Engine>;
  32076. /**
  32077. * Observable event triggered each time the canvas loses focus
  32078. */
  32079. onCanvasBlurObservable: Observable<Engine>;
  32080. /**
  32081. * Observable event triggered each time the canvas gains focus
  32082. */
  32083. onCanvasFocusObservable: Observable<Engine>;
  32084. /**
  32085. * Observable event triggered each time the canvas receives pointerout event
  32086. */
  32087. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32088. /**
  32089. * Observable raised when the engine begins a new frame
  32090. */
  32091. onBeginFrameObservable: Observable<Engine>;
  32092. /**
  32093. * If set, will be used to request the next animation frame for the render loop
  32094. */
  32095. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32096. /**
  32097. * Observable raised when the engine ends the current frame
  32098. */
  32099. onEndFrameObservable: Observable<Engine>;
  32100. /**
  32101. * Observable raised when the engine is about to compile a shader
  32102. */
  32103. onBeforeShaderCompilationObservable: Observable<Engine>;
  32104. /**
  32105. * Observable raised when the engine has jsut compiled a shader
  32106. */
  32107. onAfterShaderCompilationObservable: Observable<Engine>;
  32108. /**
  32109. * Gets the audio engine
  32110. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32111. * @ignorenaming
  32112. */
  32113. static audioEngine: IAudioEngine;
  32114. /**
  32115. * Default AudioEngine factory responsible of creating the Audio Engine.
  32116. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32117. */
  32118. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32119. /**
  32120. * Default offline support factory responsible of creating a tool used to store data locally.
  32121. * By default, this will create a Database object if the workload has been embedded.
  32122. */
  32123. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32124. private _loadingScreen;
  32125. private _pointerLockRequested;
  32126. private _dummyFramebuffer;
  32127. private _rescalePostProcess;
  32128. /** @hidden */
  32129. protected _alphaMode: number;
  32130. /** @hidden */
  32131. protected _alphaEquation: number;
  32132. private _deterministicLockstep;
  32133. private _lockstepMaxSteps;
  32134. protected readonly _supportsHardwareTextureRescaling: boolean;
  32135. private _fps;
  32136. private _deltaTime;
  32137. /** @hidden */
  32138. _drawCalls: PerfCounter;
  32139. /**
  32140. * Turn this value on if you want to pause FPS computation when in background
  32141. */
  32142. disablePerformanceMonitorInBackground: boolean;
  32143. private _performanceMonitor;
  32144. /**
  32145. * Gets the performance monitor attached to this engine
  32146. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32147. */
  32148. readonly performanceMonitor: PerformanceMonitor;
  32149. private _onFocus;
  32150. private _onBlur;
  32151. private _onCanvasPointerOut;
  32152. private _onCanvasBlur;
  32153. private _onCanvasFocus;
  32154. private _onFullscreenChange;
  32155. private _onPointerLockChange;
  32156. /**
  32157. * Creates a new engine
  32158. * @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
  32159. * @param antialias defines enable antialiasing (default: false)
  32160. * @param options defines further options to be sent to the getContext() function
  32161. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32162. */
  32163. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32164. /**
  32165. * Gets current aspect ratio
  32166. * @param viewportOwner defines the camera to use to get the aspect ratio
  32167. * @param useScreen defines if screen size must be used (or the current render target if any)
  32168. * @returns a number defining the aspect ratio
  32169. */
  32170. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32171. /**
  32172. * Gets current screen aspect ratio
  32173. * @returns a number defining the aspect ratio
  32174. */
  32175. getScreenAspectRatio(): number;
  32176. /**
  32177. * Gets host document
  32178. * @returns the host document object
  32179. */
  32180. getHostDocument(): Document;
  32181. /**
  32182. * Gets the client rect of the HTML canvas attached with the current webGL context
  32183. * @returns a client rectanglee
  32184. */
  32185. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32186. /**
  32187. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32188. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32189. * @returns true if engine is in deterministic lock step mode
  32190. */
  32191. isDeterministicLockStep(): boolean;
  32192. /**
  32193. * Gets the max steps when engine is running in deterministic lock step
  32194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32195. * @returns the max steps
  32196. */
  32197. getLockstepMaxSteps(): number;
  32198. /**
  32199. * Force the mipmap generation for the given render target texture
  32200. * @param texture defines the render target texture to use
  32201. */
  32202. generateMipMapsForCubemap(texture: InternalTexture): void;
  32203. /** States */
  32204. /**
  32205. * Set various states to the webGL context
  32206. * @param culling defines backface culling state
  32207. * @param zOffset defines the value to apply to zOffset (0 by default)
  32208. * @param force defines if states must be applied even if cache is up to date
  32209. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32210. */
  32211. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32212. /**
  32213. * Set the z offset to apply to current rendering
  32214. * @param value defines the offset to apply
  32215. */
  32216. setZOffset(value: number): void;
  32217. /**
  32218. * Gets the current value of the zOffset
  32219. * @returns the current zOffset state
  32220. */
  32221. getZOffset(): number;
  32222. /**
  32223. * Enable or disable depth buffering
  32224. * @param enable defines the state to set
  32225. */
  32226. setDepthBuffer(enable: boolean): void;
  32227. /**
  32228. * Gets a boolean indicating if depth writing is enabled
  32229. * @returns the current depth writing state
  32230. */
  32231. getDepthWrite(): boolean;
  32232. /**
  32233. * Enable or disable depth writing
  32234. * @param enable defines the state to set
  32235. */
  32236. setDepthWrite(enable: boolean): void;
  32237. /**
  32238. * Enable or disable color writing
  32239. * @param enable defines the state to set
  32240. */
  32241. setColorWrite(enable: boolean): void;
  32242. /**
  32243. * Gets a boolean indicating if color writing is enabled
  32244. * @returns the current color writing state
  32245. */
  32246. getColorWrite(): boolean;
  32247. /**
  32248. * Sets alpha constants used by some alpha blending modes
  32249. * @param r defines the red component
  32250. * @param g defines the green component
  32251. * @param b defines the blue component
  32252. * @param a defines the alpha component
  32253. */
  32254. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32255. /**
  32256. * Sets the current alpha mode
  32257. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32258. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32260. */
  32261. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32262. /**
  32263. * Gets the current alpha mode
  32264. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32265. * @returns the current alpha mode
  32266. */
  32267. getAlphaMode(): number;
  32268. /**
  32269. * Sets the current alpha equation
  32270. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32271. */
  32272. setAlphaEquation(equation: number): void;
  32273. /**
  32274. * Gets the current alpha equation.
  32275. * @returns the current alpha equation
  32276. */
  32277. getAlphaEquation(): number;
  32278. /**
  32279. * Gets a boolean indicating if stencil buffer is enabled
  32280. * @returns the current stencil buffer state
  32281. */
  32282. getStencilBuffer(): boolean;
  32283. /**
  32284. * Enable or disable the stencil buffer
  32285. * @param enable defines if the stencil buffer must be enabled or disabled
  32286. */
  32287. setStencilBuffer(enable: boolean): void;
  32288. /**
  32289. * Gets the current stencil mask
  32290. * @returns a number defining the new stencil mask to use
  32291. */
  32292. getStencilMask(): number;
  32293. /**
  32294. * Sets the current stencil mask
  32295. * @param mask defines the new stencil mask to use
  32296. */
  32297. setStencilMask(mask: number): void;
  32298. /**
  32299. * Gets the current stencil function
  32300. * @returns a number defining the stencil function to use
  32301. */
  32302. getStencilFunction(): number;
  32303. /**
  32304. * Gets the current stencil reference value
  32305. * @returns a number defining the stencil reference value to use
  32306. */
  32307. getStencilFunctionReference(): number;
  32308. /**
  32309. * Gets the current stencil mask
  32310. * @returns a number defining the stencil mask to use
  32311. */
  32312. getStencilFunctionMask(): number;
  32313. /**
  32314. * Sets the current stencil function
  32315. * @param stencilFunc defines the new stencil function to use
  32316. */
  32317. setStencilFunction(stencilFunc: number): void;
  32318. /**
  32319. * Sets the current stencil reference
  32320. * @param reference defines the new stencil reference to use
  32321. */
  32322. setStencilFunctionReference(reference: number): void;
  32323. /**
  32324. * Sets the current stencil mask
  32325. * @param mask defines the new stencil mask to use
  32326. */
  32327. setStencilFunctionMask(mask: number): void;
  32328. /**
  32329. * Gets the current stencil operation when stencil fails
  32330. * @returns a number defining stencil operation to use when stencil fails
  32331. */
  32332. getStencilOperationFail(): number;
  32333. /**
  32334. * Gets the current stencil operation when depth fails
  32335. * @returns a number defining stencil operation to use when depth fails
  32336. */
  32337. getStencilOperationDepthFail(): number;
  32338. /**
  32339. * Gets the current stencil operation when stencil passes
  32340. * @returns a number defining stencil operation to use when stencil passes
  32341. */
  32342. getStencilOperationPass(): number;
  32343. /**
  32344. * Sets the stencil operation to use when stencil fails
  32345. * @param operation defines the stencil operation to use when stencil fails
  32346. */
  32347. setStencilOperationFail(operation: number): void;
  32348. /**
  32349. * Sets the stencil operation to use when depth fails
  32350. * @param operation defines the stencil operation to use when depth fails
  32351. */
  32352. setStencilOperationDepthFail(operation: number): void;
  32353. /**
  32354. * Sets the stencil operation to use when stencil passes
  32355. * @param operation defines the stencil operation to use when stencil passes
  32356. */
  32357. setStencilOperationPass(operation: number): void;
  32358. /**
  32359. * Sets a boolean indicating if the dithering state is enabled or disabled
  32360. * @param value defines the dithering state
  32361. */
  32362. setDitheringState(value: boolean): void;
  32363. /**
  32364. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32365. * @param value defines the rasterizer state
  32366. */
  32367. setRasterizerState(value: boolean): void;
  32368. /**
  32369. * Gets the current depth function
  32370. * @returns a number defining the depth function
  32371. */
  32372. getDepthFunction(): Nullable<number>;
  32373. /**
  32374. * Sets the current depth function
  32375. * @param depthFunc defines the function to use
  32376. */
  32377. setDepthFunction(depthFunc: number): void;
  32378. /**
  32379. * Sets the current depth function to GREATER
  32380. */
  32381. setDepthFunctionToGreater(): void;
  32382. /**
  32383. * Sets the current depth function to GEQUAL
  32384. */
  32385. setDepthFunctionToGreaterOrEqual(): void;
  32386. /**
  32387. * Sets the current depth function to LESS
  32388. */
  32389. setDepthFunctionToLess(): void;
  32390. /**
  32391. * Sets the current depth function to LEQUAL
  32392. */
  32393. setDepthFunctionToLessOrEqual(): void;
  32394. private _cachedStencilBuffer;
  32395. private _cachedStencilFunction;
  32396. private _cachedStencilMask;
  32397. private _cachedStencilOperationPass;
  32398. private _cachedStencilOperationFail;
  32399. private _cachedStencilOperationDepthFail;
  32400. private _cachedStencilReference;
  32401. /**
  32402. * Caches the the state of the stencil buffer
  32403. */
  32404. cacheStencilState(): void;
  32405. /**
  32406. * Restores the state of the stencil buffer
  32407. */
  32408. restoreStencilState(): void;
  32409. /**
  32410. * Directly set the WebGL Viewport
  32411. * @param x defines the x coordinate of the viewport (in screen space)
  32412. * @param y defines the y coordinate of the viewport (in screen space)
  32413. * @param width defines the width of the viewport (in screen space)
  32414. * @param height defines the height of the viewport (in screen space)
  32415. * @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
  32416. */
  32417. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32418. /**
  32419. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32420. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32421. * @param y defines the y-coordinate of the corner of the clear rectangle
  32422. * @param width defines the width of the clear rectangle
  32423. * @param height defines the height of the clear rectangle
  32424. * @param clearColor defines the clear color
  32425. */
  32426. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32427. /**
  32428. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32429. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32430. * @param y defines the y-coordinate of the corner of the clear rectangle
  32431. * @param width defines the width of the clear rectangle
  32432. * @param height defines the height of the clear rectangle
  32433. */
  32434. enableScissor(x: number, y: number, width: number, height: number): void;
  32435. /**
  32436. * Disable previously set scissor test rectangle
  32437. */
  32438. disableScissor(): void;
  32439. protected _reportDrawCall(): void;
  32440. /**
  32441. * Initializes a webVR display and starts listening to display change events
  32442. * The onVRDisplayChangedObservable will be notified upon these changes
  32443. * @returns The onVRDisplayChangedObservable
  32444. */
  32445. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32446. /** @hidden */
  32447. _prepareVRComponent(): void;
  32448. /** @hidden */
  32449. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32450. /** @hidden */
  32451. _submitVRFrame(): void;
  32452. /**
  32453. * Call this function to leave webVR mode
  32454. * Will do nothing if webVR is not supported or if there is no webVR device
  32455. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32456. */
  32457. disableVR(): void;
  32458. /**
  32459. * Gets a boolean indicating that the system is in VR mode and is presenting
  32460. * @returns true if VR mode is engaged
  32461. */
  32462. isVRPresenting(): boolean;
  32463. /** @hidden */
  32464. _requestVRFrame(): void;
  32465. /** @hidden */
  32466. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32467. /**
  32468. * Gets the source code of the vertex shader associated with a specific webGL program
  32469. * @param program defines the program to use
  32470. * @returns a string containing the source code of the vertex shader associated with the program
  32471. */
  32472. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32473. /**
  32474. * Gets the source code of the fragment shader associated with a specific webGL program
  32475. * @param program defines the program to use
  32476. * @returns a string containing the source code of the fragment shader associated with the program
  32477. */
  32478. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32479. /**
  32480. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32481. * @param x defines the x coordinate of the rectangle where pixels must be read
  32482. * @param y defines the y coordinate of the rectangle where pixels must be read
  32483. * @param width defines the width of the rectangle where pixels must be read
  32484. * @param height defines the height of the rectangle where pixels must be read
  32485. * @returns a Uint8Array containing RGBA colors
  32486. */
  32487. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32488. /**
  32489. * Sets a depth stencil texture from a render target to the according uniform.
  32490. * @param channel The texture channel
  32491. * @param uniform The uniform to set
  32492. * @param texture The render target texture containing the depth stencil texture to apply
  32493. */
  32494. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32495. /**
  32496. * Sets a texture to the webGL context from a postprocess
  32497. * @param channel defines the channel to use
  32498. * @param postProcess defines the source postprocess
  32499. */
  32500. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32501. /**
  32502. * Binds the output of the passed in post process to the texture channel specified
  32503. * @param channel The channel the texture should be bound to
  32504. * @param postProcess The post process which's output should be bound
  32505. */
  32506. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32507. /** @hidden */
  32508. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32509. protected _rebuildBuffers(): void;
  32510. _renderLoop(): void;
  32511. /**
  32512. * Toggle full screen mode
  32513. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32514. */
  32515. switchFullscreen(requestPointerLock: boolean): void;
  32516. /**
  32517. * Enters full screen mode
  32518. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32519. */
  32520. enterFullscreen(requestPointerLock: boolean): void;
  32521. /**
  32522. * Exits full screen mode
  32523. */
  32524. exitFullscreen(): void;
  32525. /**
  32526. * Enters Pointerlock mode
  32527. */
  32528. enterPointerlock(): void;
  32529. /**
  32530. * Exits Pointerlock mode
  32531. */
  32532. exitPointerlock(): void;
  32533. /**
  32534. * Begin a new frame
  32535. */
  32536. beginFrame(): void;
  32537. /**
  32538. * Enf the current frame
  32539. */
  32540. endFrame(): void;
  32541. resize(): void;
  32542. /**
  32543. * Set the compressed texture format to use, based on the formats you have, and the formats
  32544. * supported by the hardware / browser.
  32545. *
  32546. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32547. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32548. * to API arguments needed to compressed textures. This puts the burden on the container
  32549. * generator to house the arcane code for determining these for current & future formats.
  32550. *
  32551. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32552. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32553. *
  32554. * Note: The result of this call is not taken into account when a texture is base64.
  32555. *
  32556. * @param formatsAvailable defines the list of those format families you have created
  32557. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32558. *
  32559. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32560. * @returns The extension selected.
  32561. */
  32562. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32563. /**
  32564. * Force a specific size of the canvas
  32565. * @param width defines the new canvas' width
  32566. * @param height defines the new canvas' height
  32567. */
  32568. setSize(width: number, height: number): void;
  32569. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32570. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32571. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32572. _releaseTexture(texture: InternalTexture): void;
  32573. /**
  32574. * @hidden
  32575. * Rescales a texture
  32576. * @param source input texutre
  32577. * @param destination destination texture
  32578. * @param scene scene to use to render the resize
  32579. * @param internalFormat format to use when resizing
  32580. * @param onComplete callback to be called when resize has completed
  32581. */
  32582. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32583. /**
  32584. * Gets the current framerate
  32585. * @returns a number representing the framerate
  32586. */
  32587. getFps(): number;
  32588. /**
  32589. * Gets the time spent between current and previous frame
  32590. * @returns a number representing the delta time in ms
  32591. */
  32592. getDeltaTime(): number;
  32593. private _measureFps;
  32594. /**
  32595. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32596. * @param renderTarget The render target to set the frame buffer for
  32597. */
  32598. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32599. /**
  32600. * Update a dynamic index buffer
  32601. * @param indexBuffer defines the target index buffer
  32602. * @param indices defines the data to update
  32603. * @param offset defines the offset in the target index buffer where update should start
  32604. */
  32605. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32606. /**
  32607. * Updates the sample count of a render target texture
  32608. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32609. * @param texture defines the texture to update
  32610. * @param samples defines the sample count to set
  32611. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32612. */
  32613. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32614. /** @hidden */
  32615. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32616. dispose(): void;
  32617. private _disableTouchAction;
  32618. /**
  32619. * Display the loading screen
  32620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32621. */
  32622. displayLoadingUI(): void;
  32623. /**
  32624. * Hide the loading screen
  32625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32626. */
  32627. hideLoadingUI(): void;
  32628. /**
  32629. * Gets the current loading screen object
  32630. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32631. */
  32632. /**
  32633. * Sets the current loading screen object
  32634. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32635. */
  32636. loadingScreen: ILoadingScreen;
  32637. /**
  32638. * Sets the current loading screen text
  32639. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32640. */
  32641. loadingUIText: string;
  32642. /**
  32643. * Sets the current loading screen background color
  32644. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32645. */
  32646. loadingUIBackgroundColor: string;
  32647. /** Pointerlock and fullscreen */
  32648. /**
  32649. * Ask the browser to promote the current element to pointerlock mode
  32650. * @param element defines the DOM element to promote
  32651. */
  32652. static _RequestPointerlock(element: HTMLElement): void;
  32653. /**
  32654. * Asks the browser to exit pointerlock mode
  32655. */
  32656. static _ExitPointerlock(): void;
  32657. /**
  32658. * Ask the browser to promote the current element to fullscreen rendering mode
  32659. * @param element defines the DOM element to promote
  32660. */
  32661. static _RequestFullscreen(element: HTMLElement): void;
  32662. /**
  32663. * Asks the browser to exit fullscreen mode
  32664. */
  32665. static _ExitFullscreen(): void;
  32666. }
  32667. }
  32668. declare module "babylonjs/Engines/engineStore" {
  32669. import { Nullable } from "babylonjs/types";
  32670. import { Engine } from "babylonjs/Engines/engine";
  32671. import { Scene } from "babylonjs/scene";
  32672. /**
  32673. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32674. * during the life time of the application.
  32675. */
  32676. export class EngineStore {
  32677. /** Gets the list of created engines */
  32678. static Instances: import("babylonjs/Engines/engine").Engine[];
  32679. /** @hidden */
  32680. static _LastCreatedScene: Nullable<Scene>;
  32681. /**
  32682. * Gets the latest created engine
  32683. */
  32684. static readonly LastCreatedEngine: Nullable<Engine>;
  32685. /**
  32686. * Gets the latest created scene
  32687. */
  32688. static readonly LastCreatedScene: Nullable<Scene>;
  32689. /**
  32690. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32691. * @ignorenaming
  32692. */
  32693. static UseFallbackTexture: boolean;
  32694. /**
  32695. * Texture content used if a texture cannot loaded
  32696. * @ignorenaming
  32697. */
  32698. static FallbackTexture: string;
  32699. }
  32700. }
  32701. declare module "babylonjs/Misc/promise" {
  32702. /**
  32703. * Helper class that provides a small promise polyfill
  32704. */
  32705. export class PromisePolyfill {
  32706. /**
  32707. * Static function used to check if the polyfill is required
  32708. * If this is the case then the function will inject the polyfill to window.Promise
  32709. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32710. */
  32711. static Apply(force?: boolean): void;
  32712. }
  32713. }
  32714. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32715. /**
  32716. * Interface for screenshot methods with describe argument called `size` as object with options
  32717. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32718. */
  32719. export interface IScreenshotSize {
  32720. /**
  32721. * number in pixels for canvas height
  32722. */
  32723. height?: number;
  32724. /**
  32725. * multiplier allowing render at a higher or lower resolution
  32726. * If value is defined then height and width will be ignored and taken from camera
  32727. */
  32728. precision?: number;
  32729. /**
  32730. * number in pixels for canvas width
  32731. */
  32732. width?: number;
  32733. }
  32734. }
  32735. declare module "babylonjs/Misc/tools" {
  32736. import { Nullable, float } from "babylonjs/types";
  32737. import { DomManagement } from "babylonjs/Misc/domManagement";
  32738. import { WebRequest } from "babylonjs/Misc/webRequest";
  32739. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32740. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32741. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32742. import { Camera } from "babylonjs/Cameras/camera";
  32743. import { Engine } from "babylonjs/Engines/engine";
  32744. interface IColor4Like {
  32745. r: float;
  32746. g: float;
  32747. b: float;
  32748. a: float;
  32749. }
  32750. /**
  32751. * Class containing a set of static utilities functions
  32752. */
  32753. export class Tools {
  32754. /**
  32755. * Gets or sets the base URL to use to load assets
  32756. */
  32757. static BaseUrl: string;
  32758. /**
  32759. * Enable/Disable Custom HTTP Request Headers globally.
  32760. * default = false
  32761. * @see CustomRequestHeaders
  32762. */
  32763. static UseCustomRequestHeaders: boolean;
  32764. /**
  32765. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32766. * i.e. when loading files, where the server/service expects an Authorization header
  32767. */
  32768. static CustomRequestHeaders: {
  32769. [key: string]: string;
  32770. };
  32771. /**
  32772. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32773. */
  32774. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32775. /**
  32776. * Default behaviour for cors in the application.
  32777. * It can be a string if the expected behavior is identical in the entire app.
  32778. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32779. */
  32780. static CorsBehavior: string | ((url: string | string[]) => string);
  32781. /**
  32782. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32783. * @ignorenaming
  32784. */
  32785. static UseFallbackTexture: boolean;
  32786. /**
  32787. * Use this object to register external classes like custom textures or material
  32788. * to allow the laoders to instantiate them
  32789. */
  32790. static RegisteredExternalClasses: {
  32791. [key: string]: Object;
  32792. };
  32793. /**
  32794. * Texture content used if a texture cannot loaded
  32795. * @ignorenaming
  32796. */
  32797. static fallbackTexture: string;
  32798. /**
  32799. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32800. * @param u defines the coordinate on X axis
  32801. * @param v defines the coordinate on Y axis
  32802. * @param width defines the width of the source data
  32803. * @param height defines the height of the source data
  32804. * @param pixels defines the source byte array
  32805. * @param color defines the output color
  32806. */
  32807. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32808. /**
  32809. * Interpolates between a and b via alpha
  32810. * @param a The lower value (returned when alpha = 0)
  32811. * @param b The upper value (returned when alpha = 1)
  32812. * @param alpha The interpolation-factor
  32813. * @return The mixed value
  32814. */
  32815. static Mix(a: number, b: number, alpha: number): number;
  32816. /**
  32817. * Tries to instantiate a new object from a given class name
  32818. * @param className defines the class name to instantiate
  32819. * @returns the new object or null if the system was not able to do the instantiation
  32820. */
  32821. static Instantiate(className: string): any;
  32822. /**
  32823. * Provides a slice function that will work even on IE
  32824. * @param data defines the array to slice
  32825. * @param start defines the start of the data (optional)
  32826. * @param end defines the end of the data (optional)
  32827. * @returns the new sliced array
  32828. */
  32829. static Slice<T>(data: T, start?: number, end?: number): T;
  32830. /**
  32831. * Polyfill for setImmediate
  32832. * @param action defines the action to execute after the current execution block
  32833. */
  32834. static SetImmediate(action: () => void): void;
  32835. /**
  32836. * Function indicating if a number is an exponent of 2
  32837. * @param value defines the value to test
  32838. * @returns true if the value is an exponent of 2
  32839. */
  32840. static IsExponentOfTwo(value: number): boolean;
  32841. private static _tmpFloatArray;
  32842. /**
  32843. * Returns the nearest 32-bit single precision float representation of a Number
  32844. * @param value A Number. If the parameter is of a different type, it will get converted
  32845. * to a number or to NaN if it cannot be converted
  32846. * @returns number
  32847. */
  32848. static FloatRound(value: number): number;
  32849. /**
  32850. * Extracts the filename from a path
  32851. * @param path defines the path to use
  32852. * @returns the filename
  32853. */
  32854. static GetFilename(path: string): string;
  32855. /**
  32856. * Extracts the "folder" part of a path (everything before the filename).
  32857. * @param uri The URI to extract the info from
  32858. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32859. * @returns The "folder" part of the path
  32860. */
  32861. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32862. /**
  32863. * Extracts text content from a DOM element hierarchy
  32864. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32865. */
  32866. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32867. /**
  32868. * Convert an angle in radians to degrees
  32869. * @param angle defines the angle to convert
  32870. * @returns the angle in degrees
  32871. */
  32872. static ToDegrees(angle: number): number;
  32873. /**
  32874. * Convert an angle in degrees to radians
  32875. * @param angle defines the angle to convert
  32876. * @returns the angle in radians
  32877. */
  32878. static ToRadians(angle: number): number;
  32879. /**
  32880. * Encode a buffer to a base64 string
  32881. * @param buffer defines the buffer to encode
  32882. * @returns the encoded string
  32883. */
  32884. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32885. /**
  32886. * Returns an array if obj is not an array
  32887. * @param obj defines the object to evaluate as an array
  32888. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32889. * @returns either obj directly if obj is an array or a new array containing obj
  32890. */
  32891. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32892. /**
  32893. * Gets the pointer prefix to use
  32894. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32895. */
  32896. static GetPointerPrefix(): string;
  32897. /**
  32898. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32899. * @param url define the url we are trying
  32900. * @param element define the dom element where to configure the cors policy
  32901. */
  32902. static SetCorsBehavior(url: string | string[], element: {
  32903. crossOrigin: string | null;
  32904. }): void;
  32905. /**
  32906. * Removes unwanted characters from an url
  32907. * @param url defines the url to clean
  32908. * @returns the cleaned url
  32909. */
  32910. static CleanUrl(url: string): string;
  32911. /**
  32912. * Gets or sets a function used to pre-process url before using them to load assets
  32913. */
  32914. static PreprocessUrl: (url: string) => string;
  32915. /**
  32916. * Loads an image as an HTMLImageElement.
  32917. * @param input url string, ArrayBuffer, or Blob to load
  32918. * @param onLoad callback called when the image successfully loads
  32919. * @param onError callback called when the image fails to load
  32920. * @param offlineProvider offline provider for caching
  32921. * @returns the HTMLImageElement of the loaded image
  32922. */
  32923. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  32924. /**
  32925. * Loads a file
  32926. * @param url url string, ArrayBuffer, or Blob to load
  32927. * @param onSuccess callback called when the file successfully loads
  32928. * @param onProgress callback called while file is loading (if the server supports this mode)
  32929. * @param offlineProvider defines the offline provider for caching
  32930. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32931. * @param onError callback called when the file fails to load
  32932. * @returns a file request object
  32933. */
  32934. 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;
  32935. /**
  32936. * Loads a file from a url
  32937. * @param url the file url to load
  32938. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32939. */
  32940. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32941. /**
  32942. * Load a script (identified by an url). When the url returns, the
  32943. * content of this file is added into a new script element, attached to the DOM (body element)
  32944. * @param scriptUrl defines the url of the script to laod
  32945. * @param onSuccess defines the callback called when the script is loaded
  32946. * @param onError defines the callback to call if an error occurs
  32947. * @param scriptId defines the id of the script element
  32948. */
  32949. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32950. /**
  32951. * Load an asynchronous script (identified by an url). When the url returns, the
  32952. * content of this file is added into a new script element, attached to the DOM (body element)
  32953. * @param scriptUrl defines the url of the script to laod
  32954. * @param scriptId defines the id of the script element
  32955. * @returns a promise request object
  32956. */
  32957. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32958. /**
  32959. * Loads a file from a blob
  32960. * @param fileToLoad defines the blob to use
  32961. * @param callback defines the callback to call when data is loaded
  32962. * @param progressCallback defines the callback to call during loading process
  32963. * @returns a file request object
  32964. */
  32965. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32966. /**
  32967. * Loads a file
  32968. * @param fileToLoad defines the file to load
  32969. * @param callback defines the callback to call when data is loaded
  32970. * @param progressCallBack defines the callback to call during loading process
  32971. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32972. * @returns a file request object
  32973. */
  32974. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32975. /**
  32976. * Creates a data url from a given string content
  32977. * @param content defines the content to convert
  32978. * @returns the new data url link
  32979. */
  32980. static FileAsURL(content: string): string;
  32981. /**
  32982. * Format the given number to a specific decimal format
  32983. * @param value defines the number to format
  32984. * @param decimals defines the number of decimals to use
  32985. * @returns the formatted string
  32986. */
  32987. static Format(value: number, decimals?: number): string;
  32988. /**
  32989. * Tries to copy an object by duplicating every property
  32990. * @param source defines the source object
  32991. * @param destination defines the target object
  32992. * @param doNotCopyList defines a list of properties to avoid
  32993. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  32994. */
  32995. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  32996. /**
  32997. * Gets a boolean indicating if the given object has no own property
  32998. * @param obj defines the object to test
  32999. * @returns true if object has no own property
  33000. */
  33001. static IsEmpty(obj: any): boolean;
  33002. /**
  33003. * Function used to register events at window level
  33004. * @param windowElement defines the Window object to use
  33005. * @param events defines the events to register
  33006. */
  33007. static RegisterTopRootEvents(windowElement: Window, events: {
  33008. name: string;
  33009. handler: Nullable<(e: FocusEvent) => any>;
  33010. }[]): void;
  33011. /**
  33012. * Function used to unregister events from window level
  33013. * @param windowElement defines the Window object to use
  33014. * @param events defines the events to unregister
  33015. */
  33016. static UnregisterTopRootEvents(windowElement: Window, events: {
  33017. name: string;
  33018. handler: Nullable<(e: FocusEvent) => any>;
  33019. }[]): void;
  33020. /**
  33021. * @ignore
  33022. */
  33023. static _ScreenshotCanvas: HTMLCanvasElement;
  33024. /**
  33025. * Dumps the current bound framebuffer
  33026. * @param width defines the rendering width
  33027. * @param height defines the rendering height
  33028. * @param engine defines the hosting engine
  33029. * @param successCallback defines the callback triggered once the data are available
  33030. * @param mimeType defines the mime type of the result
  33031. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33032. */
  33033. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33034. /**
  33035. * Converts the canvas data to blob.
  33036. * This acts as a polyfill for browsers not supporting the to blob function.
  33037. * @param canvas Defines the canvas to extract the data from
  33038. * @param successCallback Defines the callback triggered once the data are available
  33039. * @param mimeType Defines the mime type of the result
  33040. */
  33041. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33042. /**
  33043. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33044. * @param successCallback defines the callback triggered once the data are available
  33045. * @param mimeType defines the mime type of the result
  33046. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33047. */
  33048. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33049. /**
  33050. * Downloads a blob in the browser
  33051. * @param blob defines the blob to download
  33052. * @param fileName defines the name of the downloaded file
  33053. */
  33054. static Download(blob: Blob, fileName: string): void;
  33055. /**
  33056. * Captures a screenshot of the current rendering
  33057. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33058. * @param engine defines the rendering engine
  33059. * @param camera defines the source camera
  33060. * @param size This parameter can be set to a single number or to an object with the
  33061. * following (optional) properties: precision, width, height. If a single number is passed,
  33062. * it will be used for both width and height. If an object is passed, the screenshot size
  33063. * will be derived from the parameters. The precision property is a multiplier allowing
  33064. * rendering at a higher or lower resolution
  33065. * @param successCallback defines the callback receives a single parameter which contains the
  33066. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33067. * src parameter of an <img> to display it
  33068. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33069. * Check your browser for supported MIME types
  33070. */
  33071. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33072. /**
  33073. * Captures a screenshot of the current rendering
  33074. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33075. * @param engine defines the rendering engine
  33076. * @param camera defines the source camera
  33077. * @param size This parameter can be set to a single number or to an object with the
  33078. * following (optional) properties: precision, width, height. If a single number is passed,
  33079. * it will be used for both width and height. If an object is passed, the screenshot size
  33080. * will be derived from the parameters. The precision property is a multiplier allowing
  33081. * rendering at a higher or lower resolution
  33082. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33083. * Check your browser for supported MIME types
  33084. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33085. * to the src parameter of an <img> to display it
  33086. */
  33087. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33088. /**
  33089. * Generates an image screenshot from the specified camera.
  33090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33091. * @param engine The engine to use for rendering
  33092. * @param camera The camera to use for rendering
  33093. * @param size This parameter can be set to a single number or to an object with the
  33094. * following (optional) properties: precision, width, height. If a single number is passed,
  33095. * it will be used for both width and height. If an object is passed, the screenshot size
  33096. * will be derived from the parameters. The precision property is a multiplier allowing
  33097. * rendering at a higher or lower resolution
  33098. * @param successCallback The callback receives a single parameter which contains the
  33099. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33100. * src parameter of an <img> to display it
  33101. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33102. * Check your browser for supported MIME types
  33103. * @param samples Texture samples (default: 1)
  33104. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33105. * @param fileName A name for for the downloaded file.
  33106. */
  33107. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33108. /**
  33109. * Generates an image screenshot from the specified camera.
  33110. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33111. * @param engine The engine to use for rendering
  33112. * @param camera The camera to use for rendering
  33113. * @param size This parameter can be set to a single number or to an object with the
  33114. * following (optional) properties: precision, width, height. If a single number is passed,
  33115. * it will be used for both width and height. If an object is passed, the screenshot size
  33116. * will be derived from the parameters. The precision property is a multiplier allowing
  33117. * rendering at a higher or lower resolution
  33118. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33119. * Check your browser for supported MIME types
  33120. * @param samples Texture samples (default: 1)
  33121. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33122. * @param fileName A name for for the downloaded file.
  33123. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33124. * to the src parameter of an <img> to display it
  33125. */
  33126. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33127. /**
  33128. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33129. * Be aware Math.random() could cause collisions, but:
  33130. * "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"
  33131. * @returns a pseudo random id
  33132. */
  33133. static RandomId(): string;
  33134. /**
  33135. * Test if the given uri is a base64 string
  33136. * @param uri The uri to test
  33137. * @return True if the uri is a base64 string or false otherwise
  33138. */
  33139. static IsBase64(uri: string): boolean;
  33140. /**
  33141. * Decode the given base64 uri.
  33142. * @param uri The uri to decode
  33143. * @return The decoded base64 data.
  33144. */
  33145. static DecodeBase64(uri: string): ArrayBuffer;
  33146. /**
  33147. * Gets the absolute url.
  33148. * @param url the input url
  33149. * @return the absolute url
  33150. */
  33151. static GetAbsoluteUrl(url: string): string;
  33152. /**
  33153. * No log
  33154. */
  33155. static readonly NoneLogLevel: number;
  33156. /**
  33157. * Only message logs
  33158. */
  33159. static readonly MessageLogLevel: number;
  33160. /**
  33161. * Only warning logs
  33162. */
  33163. static readonly WarningLogLevel: number;
  33164. /**
  33165. * Only error logs
  33166. */
  33167. static readonly ErrorLogLevel: number;
  33168. /**
  33169. * All logs
  33170. */
  33171. static readonly AllLogLevel: number;
  33172. /**
  33173. * Gets a value indicating the number of loading errors
  33174. * @ignorenaming
  33175. */
  33176. static readonly errorsCount: number;
  33177. /**
  33178. * Callback called when a new log is added
  33179. */
  33180. static OnNewCacheEntry: (entry: string) => void;
  33181. /**
  33182. * Log a message to the console
  33183. * @param message defines the message to log
  33184. */
  33185. static Log(message: string): void;
  33186. /**
  33187. * Write a warning message to the console
  33188. * @param message defines the message to log
  33189. */
  33190. static Warn(message: string): void;
  33191. /**
  33192. * Write an error message to the console
  33193. * @param message defines the message to log
  33194. */
  33195. static Error(message: string): void;
  33196. /**
  33197. * Gets current log cache (list of logs)
  33198. */
  33199. static readonly LogCache: string;
  33200. /**
  33201. * Clears the log cache
  33202. */
  33203. static ClearLogCache(): void;
  33204. /**
  33205. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33206. */
  33207. static LogLevels: number;
  33208. /**
  33209. * Checks if the window object exists
  33210. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33211. */
  33212. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33213. /**
  33214. * No performance log
  33215. */
  33216. static readonly PerformanceNoneLogLevel: number;
  33217. /**
  33218. * Use user marks to log performance
  33219. */
  33220. static readonly PerformanceUserMarkLogLevel: number;
  33221. /**
  33222. * Log performance to the console
  33223. */
  33224. static readonly PerformanceConsoleLogLevel: number;
  33225. private static _performance;
  33226. /**
  33227. * Sets the current performance log level
  33228. */
  33229. static PerformanceLogLevel: number;
  33230. private static _StartPerformanceCounterDisabled;
  33231. private static _EndPerformanceCounterDisabled;
  33232. private static _StartUserMark;
  33233. private static _EndUserMark;
  33234. private static _StartPerformanceConsole;
  33235. private static _EndPerformanceConsole;
  33236. /**
  33237. * Starts a performance counter
  33238. */
  33239. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33240. /**
  33241. * Ends a specific performance coutner
  33242. */
  33243. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33244. /**
  33245. * Gets either window.performance.now() if supported or Date.now() else
  33246. */
  33247. static readonly Now: number;
  33248. /**
  33249. * This method will return the name of the class used to create the instance of the given object.
  33250. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33251. * @param object the object to get the class name from
  33252. * @param isType defines if the object is actually a type
  33253. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33254. */
  33255. static GetClassName(object: any, isType?: boolean): string;
  33256. /**
  33257. * Gets the first element of an array satisfying a given predicate
  33258. * @param array defines the array to browse
  33259. * @param predicate defines the predicate to use
  33260. * @returns null if not found or the element
  33261. */
  33262. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33263. /**
  33264. * This method will return the name of the full name of the class, including its owning module (if any).
  33265. * 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).
  33266. * @param object the object to get the class name from
  33267. * @param isType defines if the object is actually a type
  33268. * @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.
  33269. * @ignorenaming
  33270. */
  33271. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33272. /**
  33273. * Returns a promise that resolves after the given amount of time.
  33274. * @param delay Number of milliseconds to delay
  33275. * @returns Promise that resolves after the given amount of time
  33276. */
  33277. static DelayAsync(delay: number): Promise<void>;
  33278. }
  33279. /**
  33280. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33281. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33282. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33283. * @param name The name of the class, case should be preserved
  33284. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33285. */
  33286. export function className(name: string, module?: string): (target: Object) => void;
  33287. /**
  33288. * An implementation of a loop for asynchronous functions.
  33289. */
  33290. export class AsyncLoop {
  33291. /**
  33292. * Defines the number of iterations for the loop
  33293. */
  33294. iterations: number;
  33295. /**
  33296. * Defines the current index of the loop.
  33297. */
  33298. index: number;
  33299. private _done;
  33300. private _fn;
  33301. private _successCallback;
  33302. /**
  33303. * Constructor.
  33304. * @param iterations the number of iterations.
  33305. * @param func the function to run each iteration
  33306. * @param successCallback the callback that will be called upon succesful execution
  33307. * @param offset starting offset.
  33308. */
  33309. constructor(
  33310. /**
  33311. * Defines the number of iterations for the loop
  33312. */
  33313. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33314. /**
  33315. * Execute the next iteration. Must be called after the last iteration was finished.
  33316. */
  33317. executeNext(): void;
  33318. /**
  33319. * Break the loop and run the success callback.
  33320. */
  33321. breakLoop(): void;
  33322. /**
  33323. * Create and run an async loop.
  33324. * @param iterations the number of iterations.
  33325. * @param fn the function to run each iteration
  33326. * @param successCallback the callback that will be called upon succesful execution
  33327. * @param offset starting offset.
  33328. * @returns the created async loop object
  33329. */
  33330. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33331. /**
  33332. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33333. * @param iterations total number of iterations
  33334. * @param syncedIterations number of synchronous iterations in each async iteration.
  33335. * @param fn the function to call each iteration.
  33336. * @param callback a success call back that will be called when iterating stops.
  33337. * @param breakFunction a break condition (optional)
  33338. * @param timeout timeout settings for the setTimeout function. default - 0.
  33339. * @returns the created async loop object
  33340. */
  33341. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33342. }
  33343. }
  33344. declare module "babylonjs/Misc/stringDictionary" {
  33345. import { Nullable } from "babylonjs/types";
  33346. /**
  33347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33348. * The underlying implementation relies on an associative array to ensure the best performances.
  33349. * The value can be anything including 'null' but except 'undefined'
  33350. */
  33351. export class StringDictionary<T> {
  33352. /**
  33353. * This will clear this dictionary and copy the content from the 'source' one.
  33354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33355. * @param source the dictionary to take the content from and copy to this dictionary
  33356. */
  33357. copyFrom(source: StringDictionary<T>): void;
  33358. /**
  33359. * Get a value based from its key
  33360. * @param key the given key to get the matching value from
  33361. * @return the value if found, otherwise undefined is returned
  33362. */
  33363. get(key: string): T | undefined;
  33364. /**
  33365. * Get a value from its key or add it if it doesn't exist.
  33366. * This method will ensure you that a given key/data will be present in the dictionary.
  33367. * @param key the given key to get the matching value from
  33368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33369. * The factory will only be invoked if there's no data for the given key.
  33370. * @return the value corresponding to the key.
  33371. */
  33372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33373. /**
  33374. * Get a value from its key if present in the dictionary otherwise add it
  33375. * @param key the key to get the value from
  33376. * @param val if there's no such key/value pair in the dictionary add it with this value
  33377. * @return the value corresponding to the key
  33378. */
  33379. getOrAdd(key: string, val: T): T;
  33380. /**
  33381. * Check if there's a given key in the dictionary
  33382. * @param key the key to check for
  33383. * @return true if the key is present, false otherwise
  33384. */
  33385. contains(key: string): boolean;
  33386. /**
  33387. * Add a new key and its corresponding value
  33388. * @param key the key to add
  33389. * @param value the value corresponding to the key
  33390. * @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
  33391. */
  33392. add(key: string, value: T): boolean;
  33393. /**
  33394. * Update a specific value associated to a key
  33395. * @param key defines the key to use
  33396. * @param value defines the value to store
  33397. * @returns true if the value was updated (or false if the key was not found)
  33398. */
  33399. set(key: string, value: T): boolean;
  33400. /**
  33401. * Get the element of the given key and remove it from the dictionary
  33402. * @param key defines the key to search
  33403. * @returns the value associated with the key or null if not found
  33404. */
  33405. getAndRemove(key: string): Nullable<T>;
  33406. /**
  33407. * Remove a key/value from the dictionary.
  33408. * @param key the key to remove
  33409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33410. */
  33411. remove(key: string): boolean;
  33412. /**
  33413. * Clear the whole content of the dictionary
  33414. */
  33415. clear(): void;
  33416. /**
  33417. * Gets the current count
  33418. */
  33419. readonly count: number;
  33420. /**
  33421. * Execute a callback on each key/val of the dictionary.
  33422. * Note that you can remove any element in this dictionary in the callback implementation
  33423. * @param callback the callback to execute on a given key/value pair
  33424. */
  33425. forEach(callback: (key: string, val: T) => void): void;
  33426. /**
  33427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33429. * Note that you can remove any element in this dictionary in the callback implementation
  33430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33431. * @returns the first item
  33432. */
  33433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33434. private _count;
  33435. private _data;
  33436. }
  33437. }
  33438. declare module "babylonjs/Collisions/collisionCoordinator" {
  33439. import { Nullable } from "babylonjs/types";
  33440. import { Scene } from "babylonjs/scene";
  33441. import { Vector3 } from "babylonjs/Maths/math.vector";
  33442. import { Collider } from "babylonjs/Collisions/collider";
  33443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33444. /** @hidden */
  33445. export interface ICollisionCoordinator {
  33446. createCollider(): Collider;
  33447. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33448. init(scene: Scene): void;
  33449. }
  33450. /** @hidden */
  33451. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33452. private _scene;
  33453. private _scaledPosition;
  33454. private _scaledVelocity;
  33455. private _finalPosition;
  33456. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33457. createCollider(): Collider;
  33458. init(scene: Scene): void;
  33459. private _collideWithWorld;
  33460. }
  33461. }
  33462. declare module "babylonjs/Inputs/scene.inputManager" {
  33463. import { Nullable } from "babylonjs/types";
  33464. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33465. import { Vector2 } from "babylonjs/Maths/math.vector";
  33466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33467. import { Scene } from "babylonjs/scene";
  33468. /**
  33469. * Class used to manage all inputs for the scene.
  33470. */
  33471. export class InputManager {
  33472. /** The distance in pixel that you have to move to prevent some events */
  33473. static DragMovementThreshold: number;
  33474. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33475. static LongPressDelay: number;
  33476. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33477. static DoubleClickDelay: number;
  33478. /** If you need to check double click without raising a single click at first click, enable this flag */
  33479. static ExclusiveDoubleClickMode: boolean;
  33480. private _wheelEventName;
  33481. private _onPointerMove;
  33482. private _onPointerDown;
  33483. private _onPointerUp;
  33484. private _initClickEvent;
  33485. private _initActionManager;
  33486. private _delayedSimpleClick;
  33487. private _delayedSimpleClickTimeout;
  33488. private _previousDelayedSimpleClickTimeout;
  33489. private _meshPickProceed;
  33490. private _previousButtonPressed;
  33491. private _currentPickResult;
  33492. private _previousPickResult;
  33493. private _totalPointersPressed;
  33494. private _doubleClickOccured;
  33495. private _pointerOverMesh;
  33496. private _pickedDownMesh;
  33497. private _pickedUpMesh;
  33498. private _pointerX;
  33499. private _pointerY;
  33500. private _unTranslatedPointerX;
  33501. private _unTranslatedPointerY;
  33502. private _startingPointerPosition;
  33503. private _previousStartingPointerPosition;
  33504. private _startingPointerTime;
  33505. private _previousStartingPointerTime;
  33506. private _pointerCaptures;
  33507. private _onKeyDown;
  33508. private _onKeyUp;
  33509. private _onCanvasFocusObserver;
  33510. private _onCanvasBlurObserver;
  33511. private _scene;
  33512. /**
  33513. * Creates a new InputManager
  33514. * @param scene defines the hosting scene
  33515. */
  33516. constructor(scene: Scene);
  33517. /**
  33518. * Gets the mesh that is currently under the pointer
  33519. */
  33520. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33521. /**
  33522. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33523. */
  33524. readonly unTranslatedPointer: Vector2;
  33525. /**
  33526. * Gets or sets the current on-screen X position of the pointer
  33527. */
  33528. pointerX: number;
  33529. /**
  33530. * Gets or sets the current on-screen Y position of the pointer
  33531. */
  33532. pointerY: number;
  33533. private _updatePointerPosition;
  33534. private _processPointerMove;
  33535. private _setRayOnPointerInfo;
  33536. private _checkPrePointerObservable;
  33537. /**
  33538. * Use this method to simulate a pointer move on a mesh
  33539. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33540. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33541. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33542. */
  33543. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33544. /**
  33545. * Use this method to simulate a pointer down on a mesh
  33546. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33547. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33548. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33549. */
  33550. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33551. private _processPointerDown;
  33552. /** @hidden */
  33553. _isPointerSwiping(): boolean;
  33554. /**
  33555. * Use this method to simulate a pointer up on a mesh
  33556. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33557. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33558. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33559. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33560. */
  33561. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33562. private _processPointerUp;
  33563. /**
  33564. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33565. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33566. * @returns true if the pointer was captured
  33567. */
  33568. isPointerCaptured(pointerId?: number): boolean;
  33569. /**
  33570. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33571. * @param attachUp defines if you want to attach events to pointerup
  33572. * @param attachDown defines if you want to attach events to pointerdown
  33573. * @param attachMove defines if you want to attach events to pointermove
  33574. */
  33575. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33576. /**
  33577. * Detaches all event handlers
  33578. */
  33579. detachControl(): void;
  33580. /**
  33581. * Force the value of meshUnderPointer
  33582. * @param mesh defines the mesh to use
  33583. */
  33584. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33585. /**
  33586. * Gets the mesh under the pointer
  33587. * @returns a Mesh or null if no mesh is under the pointer
  33588. */
  33589. getPointerOverMesh(): Nullable<AbstractMesh>;
  33590. }
  33591. }
  33592. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33593. /**
  33594. * Helper class used to generate session unique ID
  33595. */
  33596. export class UniqueIdGenerator {
  33597. private static _UniqueIdCounter;
  33598. /**
  33599. * Gets an unique (relatively to the current scene) Id
  33600. */
  33601. static readonly UniqueId: number;
  33602. }
  33603. }
  33604. declare module "babylonjs/Animations/animationGroup" {
  33605. import { Animatable } from "babylonjs/Animations/animatable";
  33606. import { Animation } from "babylonjs/Animations/animation";
  33607. import { Scene, IDisposable } from "babylonjs/scene";
  33608. import { Observable } from "babylonjs/Misc/observable";
  33609. import { Nullable } from "babylonjs/types";
  33610. import "babylonjs/Animations/animatable";
  33611. /**
  33612. * This class defines the direct association between an animation and a target
  33613. */
  33614. export class TargetedAnimation {
  33615. /**
  33616. * Animation to perform
  33617. */
  33618. animation: Animation;
  33619. /**
  33620. * Target to animate
  33621. */
  33622. target: any;
  33623. /**
  33624. * Serialize the object
  33625. * @returns the JSON object representing the current entity
  33626. */
  33627. serialize(): any;
  33628. }
  33629. /**
  33630. * Use this class to create coordinated animations on multiple targets
  33631. */
  33632. export class AnimationGroup implements IDisposable {
  33633. /** The name of the animation group */
  33634. name: string;
  33635. private _scene;
  33636. private _targetedAnimations;
  33637. private _animatables;
  33638. private _from;
  33639. private _to;
  33640. private _isStarted;
  33641. private _isPaused;
  33642. private _speedRatio;
  33643. private _loopAnimation;
  33644. /**
  33645. * Gets or sets the unique id of the node
  33646. */
  33647. uniqueId: number;
  33648. /**
  33649. * This observable will notify when one animation have ended
  33650. */
  33651. onAnimationEndObservable: Observable<TargetedAnimation>;
  33652. /**
  33653. * Observer raised when one animation loops
  33654. */
  33655. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33656. /**
  33657. * This observable will notify when all animations have ended.
  33658. */
  33659. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33660. /**
  33661. * This observable will notify when all animations have paused.
  33662. */
  33663. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33664. /**
  33665. * This observable will notify when all animations are playing.
  33666. */
  33667. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33668. /**
  33669. * Gets the first frame
  33670. */
  33671. readonly from: number;
  33672. /**
  33673. * Gets the last frame
  33674. */
  33675. readonly to: number;
  33676. /**
  33677. * Define if the animations are started
  33678. */
  33679. readonly isStarted: boolean;
  33680. /**
  33681. * Gets a value indicating that the current group is playing
  33682. */
  33683. readonly isPlaying: boolean;
  33684. /**
  33685. * Gets or sets the speed ratio to use for all animations
  33686. */
  33687. /**
  33688. * Gets or sets the speed ratio to use for all animations
  33689. */
  33690. speedRatio: number;
  33691. /**
  33692. * Gets or sets if all animations should loop or not
  33693. */
  33694. loopAnimation: boolean;
  33695. /**
  33696. * Gets the targeted animations for this animation group
  33697. */
  33698. readonly targetedAnimations: Array<TargetedAnimation>;
  33699. /**
  33700. * returning the list of animatables controlled by this animation group.
  33701. */
  33702. readonly animatables: Array<Animatable>;
  33703. /**
  33704. * Instantiates a new Animation Group.
  33705. * This helps managing several animations at once.
  33706. * @see http://doc.babylonjs.com/how_to/group
  33707. * @param name Defines the name of the group
  33708. * @param scene Defines the scene the group belongs to
  33709. */
  33710. constructor(
  33711. /** The name of the animation group */
  33712. name: string, scene?: Nullable<Scene>);
  33713. /**
  33714. * Add an animation (with its target) in the group
  33715. * @param animation defines the animation we want to add
  33716. * @param target defines the target of the animation
  33717. * @returns the TargetedAnimation object
  33718. */
  33719. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33720. /**
  33721. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33722. * It can add constant keys at begin or end
  33723. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33724. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33725. * @returns the animation group
  33726. */
  33727. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33728. /**
  33729. * Start all animations on given targets
  33730. * @param loop defines if animations must loop
  33731. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33732. * @param from defines the from key (optional)
  33733. * @param to defines the to key (optional)
  33734. * @returns the current animation group
  33735. */
  33736. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33737. /**
  33738. * Pause all animations
  33739. * @returns the animation group
  33740. */
  33741. pause(): AnimationGroup;
  33742. /**
  33743. * Play all animations to initial state
  33744. * This function will start() the animations if they were not started or will restart() them if they were paused
  33745. * @param loop defines if animations must loop
  33746. * @returns the animation group
  33747. */
  33748. play(loop?: boolean): AnimationGroup;
  33749. /**
  33750. * Reset all animations to initial state
  33751. * @returns the animation group
  33752. */
  33753. reset(): AnimationGroup;
  33754. /**
  33755. * Restart animations from key 0
  33756. * @returns the animation group
  33757. */
  33758. restart(): AnimationGroup;
  33759. /**
  33760. * Stop all animations
  33761. * @returns the animation group
  33762. */
  33763. stop(): AnimationGroup;
  33764. /**
  33765. * Set animation weight for all animatables
  33766. * @param weight defines the weight to use
  33767. * @return the animationGroup
  33768. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33769. */
  33770. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33771. /**
  33772. * Synchronize and normalize all animatables with a source animatable
  33773. * @param root defines the root animatable to synchronize with
  33774. * @return the animationGroup
  33775. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33776. */
  33777. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33778. /**
  33779. * Goes to a specific frame in this animation group
  33780. * @param frame the frame number to go to
  33781. * @return the animationGroup
  33782. */
  33783. goToFrame(frame: number): AnimationGroup;
  33784. /**
  33785. * Dispose all associated resources
  33786. */
  33787. dispose(): void;
  33788. private _checkAnimationGroupEnded;
  33789. /**
  33790. * Clone the current animation group and returns a copy
  33791. * @param newName defines the name of the new group
  33792. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33793. * @returns the new aniamtion group
  33794. */
  33795. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33796. /**
  33797. * Serializes the animationGroup to an object
  33798. * @returns Serialized object
  33799. */
  33800. serialize(): any;
  33801. /**
  33802. * Returns a new AnimationGroup object parsed from the source provided.
  33803. * @param parsedAnimationGroup defines the source
  33804. * @param scene defines the scene that will receive the animationGroup
  33805. * @returns a new AnimationGroup
  33806. */
  33807. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33808. /**
  33809. * Returns the string "AnimationGroup"
  33810. * @returns "AnimationGroup"
  33811. */
  33812. getClassName(): string;
  33813. /**
  33814. * Creates a detailled string about the object
  33815. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33816. * @returns a string representing the object
  33817. */
  33818. toString(fullDetails?: boolean): string;
  33819. }
  33820. }
  33821. declare module "babylonjs/scene" {
  33822. import { Nullable } from "babylonjs/types";
  33823. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33824. import { Observable } from "babylonjs/Misc/observable";
  33825. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33826. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33827. import { Geometry } from "babylonjs/Meshes/geometry";
  33828. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33831. import { Mesh } from "babylonjs/Meshes/mesh";
  33832. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33833. import { Bone } from "babylonjs/Bones/bone";
  33834. import { Skeleton } from "babylonjs/Bones/skeleton";
  33835. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33836. import { Camera } from "babylonjs/Cameras/camera";
  33837. import { AbstractScene } from "babylonjs/abstractScene";
  33838. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33839. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33840. import { Material } from "babylonjs/Materials/material";
  33841. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33842. import { Effect } from "babylonjs/Materials/effect";
  33843. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33844. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33845. import { Light } from "babylonjs/Lights/light";
  33846. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33847. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33848. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33849. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33850. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33851. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33852. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33853. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33854. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33855. import { Engine } from "babylonjs/Engines/engine";
  33856. import { Node } from "babylonjs/node";
  33857. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33858. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33859. import { WebRequest } from "babylonjs/Misc/webRequest";
  33860. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33861. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33862. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33863. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33864. import { Plane } from "babylonjs/Maths/math.plane";
  33865. import { Ray } from "babylonjs/Culling/ray";
  33866. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33867. import { Animation } from "babylonjs/Animations/animation";
  33868. import { Animatable } from "babylonjs/Animations/animatable";
  33869. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33870. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33871. import { Collider } from "babylonjs/Collisions/collider";
  33872. /**
  33873. * Define an interface for all classes that will hold resources
  33874. */
  33875. export interface IDisposable {
  33876. /**
  33877. * Releases all held resources
  33878. */
  33879. dispose(): void;
  33880. }
  33881. /** Interface defining initialization parameters for Scene class */
  33882. export interface SceneOptions {
  33883. /**
  33884. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33885. * It will improve performance when the number of geometries becomes important.
  33886. */
  33887. useGeometryUniqueIdsMap?: boolean;
  33888. /**
  33889. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33890. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33891. */
  33892. useMaterialMeshMap?: boolean;
  33893. /**
  33894. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33895. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33896. */
  33897. useClonedMeshhMap?: boolean;
  33898. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33899. virtual?: boolean;
  33900. }
  33901. /**
  33902. * Represents a scene to be rendered by the engine.
  33903. * @see http://doc.babylonjs.com/features/scene
  33904. */
  33905. export class Scene extends AbstractScene implements IAnimatable {
  33906. /** The fog is deactivated */
  33907. static readonly FOGMODE_NONE: number;
  33908. /** The fog density is following an exponential function */
  33909. static readonly FOGMODE_EXP: number;
  33910. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33911. static readonly FOGMODE_EXP2: number;
  33912. /** The fog density is following a linear function. */
  33913. static readonly FOGMODE_LINEAR: number;
  33914. /**
  33915. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33917. */
  33918. static MinDeltaTime: number;
  33919. /**
  33920. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33921. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33922. */
  33923. static MaxDeltaTime: number;
  33924. /**
  33925. * Factory used to create the default material.
  33926. * @param name The name of the material to create
  33927. * @param scene The scene to create the material for
  33928. * @returns The default material
  33929. */
  33930. static DefaultMaterialFactory(scene: Scene): Material;
  33931. /**
  33932. * Factory used to create the a collision coordinator.
  33933. * @returns The collision coordinator
  33934. */
  33935. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33936. /** @hidden */
  33937. _inputManager: InputManager;
  33938. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33939. cameraToUseForPointers: Nullable<Camera>;
  33940. /** @hidden */
  33941. readonly _isScene: boolean;
  33942. /**
  33943. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33944. */
  33945. autoClear: boolean;
  33946. /**
  33947. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33948. */
  33949. autoClearDepthAndStencil: boolean;
  33950. /**
  33951. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33952. */
  33953. clearColor: Color4;
  33954. /**
  33955. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33956. */
  33957. ambientColor: Color3;
  33958. /**
  33959. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33960. * It should only be one of the following (if not the default embedded one):
  33961. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33962. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33963. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33964. * The material properties need to be setup according to the type of texture in use.
  33965. */
  33966. environmentBRDFTexture: BaseTexture;
  33967. /** @hidden */
  33968. protected _environmentTexture: Nullable<BaseTexture>;
  33969. /**
  33970. * Texture used in all pbr material as the reflection texture.
  33971. * As in the majority of the scene they are the same (exception for multi room and so on),
  33972. * this is easier to reference from here than from all the materials.
  33973. */
  33974. /**
  33975. * Texture used in all pbr material as the reflection texture.
  33976. * As in the majority of the scene they are the same (exception for multi room and so on),
  33977. * this is easier to set here than in all the materials.
  33978. */
  33979. environmentTexture: Nullable<BaseTexture>;
  33980. /** @hidden */
  33981. protected _environmentIntensity: number;
  33982. /**
  33983. * Intensity of the environment in all pbr material.
  33984. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33985. * As in the majority of the scene they are the same (exception for multi room and so on),
  33986. * this is easier to reference from here than from all the materials.
  33987. */
  33988. /**
  33989. * Intensity of the environment in all pbr material.
  33990. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  33991. * As in the majority of the scene they are the same (exception for multi room and so on),
  33992. * this is easier to set here than in all the materials.
  33993. */
  33994. environmentIntensity: number;
  33995. /** @hidden */
  33996. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  33997. /**
  33998. * Default image processing configuration used either in the rendering
  33999. * Forward main pass or through the imageProcessingPostProcess if present.
  34000. * As in the majority of the scene they are the same (exception for multi camera),
  34001. * this is easier to reference from here than from all the materials and post process.
  34002. *
  34003. * No setter as we it is a shared configuration, you can set the values instead.
  34004. */
  34005. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34006. private _forceWireframe;
  34007. /**
  34008. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34009. */
  34010. forceWireframe: boolean;
  34011. private _forcePointsCloud;
  34012. /**
  34013. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34014. */
  34015. forcePointsCloud: boolean;
  34016. /**
  34017. * Gets or sets the active clipplane 1
  34018. */
  34019. clipPlane: Nullable<Plane>;
  34020. /**
  34021. * Gets or sets the active clipplane 2
  34022. */
  34023. clipPlane2: Nullable<Plane>;
  34024. /**
  34025. * Gets or sets the active clipplane 3
  34026. */
  34027. clipPlane3: Nullable<Plane>;
  34028. /**
  34029. * Gets or sets the active clipplane 4
  34030. */
  34031. clipPlane4: Nullable<Plane>;
  34032. /**
  34033. * Gets or sets a boolean indicating if animations are enabled
  34034. */
  34035. animationsEnabled: boolean;
  34036. private _animationPropertiesOverride;
  34037. /**
  34038. * Gets or sets the animation properties override
  34039. */
  34040. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34041. /**
  34042. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34043. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34044. */
  34045. useConstantAnimationDeltaTime: boolean;
  34046. /**
  34047. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34048. * Please note that it requires to run a ray cast through the scene on every frame
  34049. */
  34050. constantlyUpdateMeshUnderPointer: boolean;
  34051. /**
  34052. * Defines the HTML cursor to use when hovering over interactive elements
  34053. */
  34054. hoverCursor: string;
  34055. /**
  34056. * Defines the HTML default cursor to use (empty by default)
  34057. */
  34058. defaultCursor: string;
  34059. /**
  34060. * This is used to call preventDefault() on pointer down
  34061. * in order to block unwanted artifacts like system double clicks
  34062. */
  34063. preventDefaultOnPointerDown: boolean;
  34064. /**
  34065. * This is used to call preventDefault() on pointer up
  34066. * in order to block unwanted artifacts like system double clicks
  34067. */
  34068. preventDefaultOnPointerUp: boolean;
  34069. /**
  34070. * Gets or sets user defined metadata
  34071. */
  34072. metadata: any;
  34073. /**
  34074. * For internal use only. Please do not use.
  34075. */
  34076. reservedDataStore: any;
  34077. /**
  34078. * Gets the name of the plugin used to load this scene (null by default)
  34079. */
  34080. loadingPluginName: string;
  34081. /**
  34082. * Use this array to add regular expressions used to disable offline support for specific urls
  34083. */
  34084. disableOfflineSupportExceptionRules: RegExp[];
  34085. /**
  34086. * An event triggered when the scene is disposed.
  34087. */
  34088. onDisposeObservable: Observable<Scene>;
  34089. private _onDisposeObserver;
  34090. /** Sets a function to be executed when this scene is disposed. */
  34091. onDispose: () => void;
  34092. /**
  34093. * An event triggered before rendering the scene (right after animations and physics)
  34094. */
  34095. onBeforeRenderObservable: Observable<Scene>;
  34096. private _onBeforeRenderObserver;
  34097. /** Sets a function to be executed before rendering this scene */
  34098. beforeRender: Nullable<() => void>;
  34099. /**
  34100. * An event triggered after rendering the scene
  34101. */
  34102. onAfterRenderObservable: Observable<Scene>;
  34103. /**
  34104. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34105. */
  34106. onAfterRenderCameraObservable: Observable<Camera>;
  34107. private _onAfterRenderObserver;
  34108. /** Sets a function to be executed after rendering this scene */
  34109. afterRender: Nullable<() => void>;
  34110. /**
  34111. * An event triggered before animating the scene
  34112. */
  34113. onBeforeAnimationsObservable: Observable<Scene>;
  34114. /**
  34115. * An event triggered after animations processing
  34116. */
  34117. onAfterAnimationsObservable: Observable<Scene>;
  34118. /**
  34119. * An event triggered before draw calls are ready to be sent
  34120. */
  34121. onBeforeDrawPhaseObservable: Observable<Scene>;
  34122. /**
  34123. * An event triggered after draw calls have been sent
  34124. */
  34125. onAfterDrawPhaseObservable: Observable<Scene>;
  34126. /**
  34127. * An event triggered when the scene is ready
  34128. */
  34129. onReadyObservable: Observable<Scene>;
  34130. /**
  34131. * An event triggered before rendering a camera
  34132. */
  34133. onBeforeCameraRenderObservable: Observable<Camera>;
  34134. private _onBeforeCameraRenderObserver;
  34135. /** Sets a function to be executed before rendering a camera*/
  34136. beforeCameraRender: () => void;
  34137. /**
  34138. * An event triggered after rendering a camera
  34139. */
  34140. onAfterCameraRenderObservable: Observable<Camera>;
  34141. private _onAfterCameraRenderObserver;
  34142. /** Sets a function to be executed after rendering a camera*/
  34143. afterCameraRender: () => void;
  34144. /**
  34145. * An event triggered when active meshes evaluation is about to start
  34146. */
  34147. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34148. /**
  34149. * An event triggered when active meshes evaluation is done
  34150. */
  34151. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34152. /**
  34153. * An event triggered when particles rendering is about to start
  34154. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34155. */
  34156. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34157. /**
  34158. * An event triggered when particles rendering is done
  34159. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34160. */
  34161. onAfterParticlesRenderingObservable: Observable<Scene>;
  34162. /**
  34163. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34164. */
  34165. onDataLoadedObservable: Observable<Scene>;
  34166. /**
  34167. * An event triggered when a camera is created
  34168. */
  34169. onNewCameraAddedObservable: Observable<Camera>;
  34170. /**
  34171. * An event triggered when a camera is removed
  34172. */
  34173. onCameraRemovedObservable: Observable<Camera>;
  34174. /**
  34175. * An event triggered when a light is created
  34176. */
  34177. onNewLightAddedObservable: Observable<Light>;
  34178. /**
  34179. * An event triggered when a light is removed
  34180. */
  34181. onLightRemovedObservable: Observable<Light>;
  34182. /**
  34183. * An event triggered when a geometry is created
  34184. */
  34185. onNewGeometryAddedObservable: Observable<Geometry>;
  34186. /**
  34187. * An event triggered when a geometry is removed
  34188. */
  34189. onGeometryRemovedObservable: Observable<Geometry>;
  34190. /**
  34191. * An event triggered when a transform node is created
  34192. */
  34193. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34194. /**
  34195. * An event triggered when a transform node is removed
  34196. */
  34197. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34198. /**
  34199. * An event triggered when a mesh is created
  34200. */
  34201. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34202. /**
  34203. * An event triggered when a mesh is removed
  34204. */
  34205. onMeshRemovedObservable: Observable<AbstractMesh>;
  34206. /**
  34207. * An event triggered when a skeleton is created
  34208. */
  34209. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34210. /**
  34211. * An event triggered when a skeleton is removed
  34212. */
  34213. onSkeletonRemovedObservable: Observable<Skeleton>;
  34214. /**
  34215. * An event triggered when a material is created
  34216. */
  34217. onNewMaterialAddedObservable: Observable<Material>;
  34218. /**
  34219. * An event triggered when a material is removed
  34220. */
  34221. onMaterialRemovedObservable: Observable<Material>;
  34222. /**
  34223. * An event triggered when a texture is created
  34224. */
  34225. onNewTextureAddedObservable: Observable<BaseTexture>;
  34226. /**
  34227. * An event triggered when a texture is removed
  34228. */
  34229. onTextureRemovedObservable: Observable<BaseTexture>;
  34230. /**
  34231. * An event triggered when render targets are about to be rendered
  34232. * Can happen multiple times per frame.
  34233. */
  34234. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34235. /**
  34236. * An event triggered when render targets were rendered.
  34237. * Can happen multiple times per frame.
  34238. */
  34239. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34240. /**
  34241. * An event triggered before calculating deterministic simulation step
  34242. */
  34243. onBeforeStepObservable: Observable<Scene>;
  34244. /**
  34245. * An event triggered after calculating deterministic simulation step
  34246. */
  34247. onAfterStepObservable: Observable<Scene>;
  34248. /**
  34249. * An event triggered when the activeCamera property is updated
  34250. */
  34251. onActiveCameraChanged: Observable<Scene>;
  34252. /**
  34253. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34254. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34255. * 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)
  34256. */
  34257. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34258. /**
  34259. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34260. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34261. * 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)
  34262. */
  34263. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34264. /**
  34265. * This Observable will when a mesh has been imported into the scene.
  34266. */
  34267. onMeshImportedObservable: Observable<AbstractMesh>;
  34268. /**
  34269. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34270. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34271. */
  34272. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34273. /** @hidden */
  34274. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34275. /**
  34276. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34277. */
  34278. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34279. /**
  34280. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34281. */
  34282. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34283. /**
  34284. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34285. */
  34286. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34287. /** Callback called when a pointer move is detected */
  34288. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34289. /** Callback called when a pointer down is detected */
  34290. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34291. /** Callback called when a pointer up is detected */
  34292. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34293. /** Callback called when a pointer pick is detected */
  34294. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34295. /**
  34296. * 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).
  34297. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34298. */
  34299. onPrePointerObservable: Observable<PointerInfoPre>;
  34300. /**
  34301. * Observable event triggered each time an input event is received from the rendering canvas
  34302. */
  34303. onPointerObservable: Observable<PointerInfo>;
  34304. /**
  34305. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34306. */
  34307. readonly unTranslatedPointer: Vector2;
  34308. /**
  34309. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34310. */
  34311. static DragMovementThreshold: number;
  34312. /**
  34313. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34314. */
  34315. static LongPressDelay: number;
  34316. /**
  34317. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34318. */
  34319. static DoubleClickDelay: number;
  34320. /** If you need to check double click without raising a single click at first click, enable this flag */
  34321. static ExclusiveDoubleClickMode: boolean;
  34322. /** @hidden */
  34323. _mirroredCameraPosition: Nullable<Vector3>;
  34324. /**
  34325. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34326. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34327. */
  34328. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34329. /**
  34330. * Observable event triggered each time an keyboard event is received from the hosting window
  34331. */
  34332. onKeyboardObservable: Observable<KeyboardInfo>;
  34333. private _useRightHandedSystem;
  34334. /**
  34335. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34336. */
  34337. useRightHandedSystem: boolean;
  34338. private _timeAccumulator;
  34339. private _currentStepId;
  34340. private _currentInternalStep;
  34341. /**
  34342. * Sets the step Id used by deterministic lock step
  34343. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34344. * @param newStepId defines the step Id
  34345. */
  34346. setStepId(newStepId: number): void;
  34347. /**
  34348. * Gets the step Id used by deterministic lock step
  34349. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34350. * @returns the step Id
  34351. */
  34352. getStepId(): number;
  34353. /**
  34354. * Gets the internal step used by deterministic lock step
  34355. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34356. * @returns the internal step
  34357. */
  34358. getInternalStep(): number;
  34359. private _fogEnabled;
  34360. /**
  34361. * Gets or sets a boolean indicating if fog is enabled on this scene
  34362. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34363. * (Default is true)
  34364. */
  34365. fogEnabled: boolean;
  34366. private _fogMode;
  34367. /**
  34368. * Gets or sets the fog mode to use
  34369. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34370. * | mode | value |
  34371. * | --- | --- |
  34372. * | FOGMODE_NONE | 0 |
  34373. * | FOGMODE_EXP | 1 |
  34374. * | FOGMODE_EXP2 | 2 |
  34375. * | FOGMODE_LINEAR | 3 |
  34376. */
  34377. fogMode: number;
  34378. /**
  34379. * Gets or sets the fog color to use
  34380. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34381. * (Default is Color3(0.2, 0.2, 0.3))
  34382. */
  34383. fogColor: Color3;
  34384. /**
  34385. * Gets or sets the fog density to use
  34386. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34387. * (Default is 0.1)
  34388. */
  34389. fogDensity: number;
  34390. /**
  34391. * Gets or sets the fog start distance to use
  34392. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34393. * (Default is 0)
  34394. */
  34395. fogStart: number;
  34396. /**
  34397. * Gets or sets the fog end distance to use
  34398. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34399. * (Default is 1000)
  34400. */
  34401. fogEnd: number;
  34402. private _shadowsEnabled;
  34403. /**
  34404. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34405. */
  34406. shadowsEnabled: boolean;
  34407. private _lightsEnabled;
  34408. /**
  34409. * Gets or sets a boolean indicating if lights are enabled on this scene
  34410. */
  34411. lightsEnabled: boolean;
  34412. /** All of the active cameras added to this scene. */
  34413. activeCameras: Camera[];
  34414. /** @hidden */
  34415. _activeCamera: Nullable<Camera>;
  34416. /** Gets or sets the current active camera */
  34417. activeCamera: Nullable<Camera>;
  34418. private _defaultMaterial;
  34419. /** The default material used on meshes when no material is affected */
  34420. /** The default material used on meshes when no material is affected */
  34421. defaultMaterial: Material;
  34422. private _texturesEnabled;
  34423. /**
  34424. * Gets or sets a boolean indicating if textures are enabled on this scene
  34425. */
  34426. texturesEnabled: boolean;
  34427. /**
  34428. * Gets or sets a boolean indicating if particles are enabled on this scene
  34429. */
  34430. particlesEnabled: boolean;
  34431. /**
  34432. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34433. */
  34434. spritesEnabled: boolean;
  34435. private _skeletonsEnabled;
  34436. /**
  34437. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34438. */
  34439. skeletonsEnabled: boolean;
  34440. /**
  34441. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34442. */
  34443. lensFlaresEnabled: boolean;
  34444. /**
  34445. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34446. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34447. */
  34448. collisionsEnabled: boolean;
  34449. private _collisionCoordinator;
  34450. /** @hidden */
  34451. readonly collisionCoordinator: ICollisionCoordinator;
  34452. /**
  34453. * Defines the gravity applied to this scene (used only for collisions)
  34454. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34455. */
  34456. gravity: Vector3;
  34457. /**
  34458. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34459. */
  34460. postProcessesEnabled: boolean;
  34461. /**
  34462. * The list of postprocesses added to the scene
  34463. */
  34464. postProcesses: PostProcess[];
  34465. /**
  34466. * Gets the current postprocess manager
  34467. */
  34468. postProcessManager: PostProcessManager;
  34469. /**
  34470. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34471. */
  34472. renderTargetsEnabled: boolean;
  34473. /**
  34474. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34475. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34476. */
  34477. dumpNextRenderTargets: boolean;
  34478. /**
  34479. * The list of user defined render targets added to the scene
  34480. */
  34481. customRenderTargets: RenderTargetTexture[];
  34482. /**
  34483. * Defines if texture loading must be delayed
  34484. * If true, textures will only be loaded when they need to be rendered
  34485. */
  34486. useDelayedTextureLoading: boolean;
  34487. /**
  34488. * Gets the list of meshes imported to the scene through SceneLoader
  34489. */
  34490. importedMeshesFiles: String[];
  34491. /**
  34492. * Gets or sets a boolean indicating if probes are enabled on this scene
  34493. */
  34494. probesEnabled: boolean;
  34495. /**
  34496. * Gets or sets the current offline provider to use to store scene data
  34497. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34498. */
  34499. offlineProvider: IOfflineProvider;
  34500. /**
  34501. * Gets or sets the action manager associated with the scene
  34502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34503. */
  34504. actionManager: AbstractActionManager;
  34505. private _meshesForIntersections;
  34506. /**
  34507. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34508. */
  34509. proceduralTexturesEnabled: boolean;
  34510. private _engine;
  34511. private _totalVertices;
  34512. /** @hidden */
  34513. _activeIndices: PerfCounter;
  34514. /** @hidden */
  34515. _activeParticles: PerfCounter;
  34516. /** @hidden */
  34517. _activeBones: PerfCounter;
  34518. private _animationRatio;
  34519. /** @hidden */
  34520. _animationTimeLast: number;
  34521. /** @hidden */
  34522. _animationTime: number;
  34523. /**
  34524. * Gets or sets a general scale for animation speed
  34525. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34526. */
  34527. animationTimeScale: number;
  34528. /** @hidden */
  34529. _cachedMaterial: Nullable<Material>;
  34530. /** @hidden */
  34531. _cachedEffect: Nullable<Effect>;
  34532. /** @hidden */
  34533. _cachedVisibility: Nullable<number>;
  34534. private _renderId;
  34535. private _frameId;
  34536. private _executeWhenReadyTimeoutId;
  34537. private _intermediateRendering;
  34538. private _viewUpdateFlag;
  34539. private _projectionUpdateFlag;
  34540. /** @hidden */
  34541. _toBeDisposed: Nullable<IDisposable>[];
  34542. private _activeRequests;
  34543. /** @hidden */
  34544. _pendingData: any[];
  34545. private _isDisposed;
  34546. /**
  34547. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34548. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34549. */
  34550. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34551. private _activeMeshes;
  34552. private _processedMaterials;
  34553. private _renderTargets;
  34554. /** @hidden */
  34555. _activeParticleSystems: SmartArray<IParticleSystem>;
  34556. private _activeSkeletons;
  34557. private _softwareSkinnedMeshes;
  34558. private _renderingManager;
  34559. /** @hidden */
  34560. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34561. private _transformMatrix;
  34562. private _sceneUbo;
  34563. /** @hidden */
  34564. _viewMatrix: Matrix;
  34565. private _projectionMatrix;
  34566. /** @hidden */
  34567. _forcedViewPosition: Nullable<Vector3>;
  34568. /** @hidden */
  34569. _frustumPlanes: Plane[];
  34570. /**
  34571. * Gets the list of frustum planes (built from the active camera)
  34572. */
  34573. readonly frustumPlanes: Plane[];
  34574. /**
  34575. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34576. * This is useful if there are more lights that the maximum simulteanous authorized
  34577. */
  34578. requireLightSorting: boolean;
  34579. /** @hidden */
  34580. readonly useMaterialMeshMap: boolean;
  34581. /** @hidden */
  34582. readonly useClonedMeshhMap: boolean;
  34583. private _externalData;
  34584. private _uid;
  34585. /**
  34586. * @hidden
  34587. * Backing store of defined scene components.
  34588. */
  34589. _components: ISceneComponent[];
  34590. /**
  34591. * @hidden
  34592. * Backing store of defined scene components.
  34593. */
  34594. _serializableComponents: ISceneSerializableComponent[];
  34595. /**
  34596. * List of components to register on the next registration step.
  34597. */
  34598. private _transientComponents;
  34599. /**
  34600. * Registers the transient components if needed.
  34601. */
  34602. private _registerTransientComponents;
  34603. /**
  34604. * @hidden
  34605. * Add a component to the scene.
  34606. * Note that the ccomponent could be registered on th next frame if this is called after
  34607. * the register component stage.
  34608. * @param component Defines the component to add to the scene
  34609. */
  34610. _addComponent(component: ISceneComponent): void;
  34611. /**
  34612. * @hidden
  34613. * Gets a component from the scene.
  34614. * @param name defines the name of the component to retrieve
  34615. * @returns the component or null if not present
  34616. */
  34617. _getComponent(name: string): Nullable<ISceneComponent>;
  34618. /**
  34619. * @hidden
  34620. * Defines the actions happening before camera updates.
  34621. */
  34622. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34623. /**
  34624. * @hidden
  34625. * Defines the actions happening before clear the canvas.
  34626. */
  34627. _beforeClearStage: Stage<SimpleStageAction>;
  34628. /**
  34629. * @hidden
  34630. * Defines the actions when collecting render targets for the frame.
  34631. */
  34632. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34633. /**
  34634. * @hidden
  34635. * Defines the actions happening for one camera in the frame.
  34636. */
  34637. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34638. /**
  34639. * @hidden
  34640. * Defines the actions happening during the per mesh ready checks.
  34641. */
  34642. _isReadyForMeshStage: Stage<MeshStageAction>;
  34643. /**
  34644. * @hidden
  34645. * Defines the actions happening before evaluate active mesh checks.
  34646. */
  34647. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34648. /**
  34649. * @hidden
  34650. * Defines the actions happening during the evaluate sub mesh checks.
  34651. */
  34652. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34653. /**
  34654. * @hidden
  34655. * Defines the actions happening during the active mesh stage.
  34656. */
  34657. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34658. /**
  34659. * @hidden
  34660. * Defines the actions happening during the per camera render target step.
  34661. */
  34662. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34663. /**
  34664. * @hidden
  34665. * Defines the actions happening just before the active camera is drawing.
  34666. */
  34667. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34668. /**
  34669. * @hidden
  34670. * Defines the actions happening just before a render target is drawing.
  34671. */
  34672. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34673. /**
  34674. * @hidden
  34675. * Defines the actions happening just before a rendering group is drawing.
  34676. */
  34677. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34678. /**
  34679. * @hidden
  34680. * Defines the actions happening just before a mesh is drawing.
  34681. */
  34682. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34683. /**
  34684. * @hidden
  34685. * Defines the actions happening just after a mesh has been drawn.
  34686. */
  34687. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34688. /**
  34689. * @hidden
  34690. * Defines the actions happening just after a rendering group has been drawn.
  34691. */
  34692. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34693. /**
  34694. * @hidden
  34695. * Defines the actions happening just after the active camera has been drawn.
  34696. */
  34697. _afterCameraDrawStage: Stage<CameraStageAction>;
  34698. /**
  34699. * @hidden
  34700. * Defines the actions happening just after a render target has been drawn.
  34701. */
  34702. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34703. /**
  34704. * @hidden
  34705. * Defines the actions happening just after rendering all cameras and computing intersections.
  34706. */
  34707. _afterRenderStage: Stage<SimpleStageAction>;
  34708. /**
  34709. * @hidden
  34710. * Defines the actions happening when a pointer move event happens.
  34711. */
  34712. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34713. /**
  34714. * @hidden
  34715. * Defines the actions happening when a pointer down event happens.
  34716. */
  34717. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34718. /**
  34719. * @hidden
  34720. * Defines the actions happening when a pointer up event happens.
  34721. */
  34722. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34723. /**
  34724. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34725. */
  34726. private geometriesByUniqueId;
  34727. /**
  34728. * Creates a new Scene
  34729. * @param engine defines the engine to use to render this scene
  34730. * @param options defines the scene options
  34731. */
  34732. constructor(engine: Engine, options?: SceneOptions);
  34733. /**
  34734. * Gets a string idenfifying the name of the class
  34735. * @returns "Scene" string
  34736. */
  34737. getClassName(): string;
  34738. private _defaultMeshCandidates;
  34739. /**
  34740. * @hidden
  34741. */
  34742. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34743. private _defaultSubMeshCandidates;
  34744. /**
  34745. * @hidden
  34746. */
  34747. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34748. /**
  34749. * Sets the default candidate providers for the scene.
  34750. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34751. * and getCollidingSubMeshCandidates to their default function
  34752. */
  34753. setDefaultCandidateProviders(): void;
  34754. /**
  34755. * Gets the mesh that is currently under the pointer
  34756. */
  34757. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34758. /**
  34759. * Gets or sets the current on-screen X position of the pointer
  34760. */
  34761. pointerX: number;
  34762. /**
  34763. * Gets or sets the current on-screen Y position of the pointer
  34764. */
  34765. pointerY: number;
  34766. /**
  34767. * Gets the cached material (ie. the latest rendered one)
  34768. * @returns the cached material
  34769. */
  34770. getCachedMaterial(): Nullable<Material>;
  34771. /**
  34772. * Gets the cached effect (ie. the latest rendered one)
  34773. * @returns the cached effect
  34774. */
  34775. getCachedEffect(): Nullable<Effect>;
  34776. /**
  34777. * Gets the cached visibility state (ie. the latest rendered one)
  34778. * @returns the cached visibility state
  34779. */
  34780. getCachedVisibility(): Nullable<number>;
  34781. /**
  34782. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34783. * @param material defines the current material
  34784. * @param effect defines the current effect
  34785. * @param visibility defines the current visibility state
  34786. * @returns true if one parameter is not cached
  34787. */
  34788. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34789. /**
  34790. * Gets the engine associated with the scene
  34791. * @returns an Engine
  34792. */
  34793. getEngine(): Engine;
  34794. /**
  34795. * Gets the total number of vertices rendered per frame
  34796. * @returns the total number of vertices rendered per frame
  34797. */
  34798. getTotalVertices(): number;
  34799. /**
  34800. * Gets the performance counter for total vertices
  34801. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34802. */
  34803. readonly totalVerticesPerfCounter: PerfCounter;
  34804. /**
  34805. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34806. * @returns the total number of active indices rendered per frame
  34807. */
  34808. getActiveIndices(): number;
  34809. /**
  34810. * Gets the performance counter for active indices
  34811. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34812. */
  34813. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34814. /**
  34815. * Gets the total number of active particles rendered per frame
  34816. * @returns the total number of active particles rendered per frame
  34817. */
  34818. getActiveParticles(): number;
  34819. /**
  34820. * Gets the performance counter for active particles
  34821. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34822. */
  34823. readonly activeParticlesPerfCounter: PerfCounter;
  34824. /**
  34825. * Gets the total number of active bones rendered per frame
  34826. * @returns the total number of active bones rendered per frame
  34827. */
  34828. getActiveBones(): number;
  34829. /**
  34830. * Gets the performance counter for active bones
  34831. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34832. */
  34833. readonly activeBonesPerfCounter: PerfCounter;
  34834. /**
  34835. * Gets the array of active meshes
  34836. * @returns an array of AbstractMesh
  34837. */
  34838. getActiveMeshes(): SmartArray<AbstractMesh>;
  34839. /**
  34840. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34841. * @returns a number
  34842. */
  34843. getAnimationRatio(): number;
  34844. /**
  34845. * Gets an unique Id for the current render phase
  34846. * @returns a number
  34847. */
  34848. getRenderId(): number;
  34849. /**
  34850. * Gets an unique Id for the current frame
  34851. * @returns a number
  34852. */
  34853. getFrameId(): number;
  34854. /** Call this function if you want to manually increment the render Id*/
  34855. incrementRenderId(): void;
  34856. private _createUbo;
  34857. /**
  34858. * Use this method to simulate a pointer move on a mesh
  34859. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34860. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34861. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34862. * @returns the current scene
  34863. */
  34864. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34865. /**
  34866. * Use this method to simulate a pointer down on a mesh
  34867. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34868. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34869. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34870. * @returns the current scene
  34871. */
  34872. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34873. /**
  34874. * Use this method to simulate a pointer up on a mesh
  34875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34878. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34879. * @returns the current scene
  34880. */
  34881. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34882. /**
  34883. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34884. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34885. * @returns true if the pointer was captured
  34886. */
  34887. isPointerCaptured(pointerId?: number): boolean;
  34888. /**
  34889. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34890. * @param attachUp defines if you want to attach events to pointerup
  34891. * @param attachDown defines if you want to attach events to pointerdown
  34892. * @param attachMove defines if you want to attach events to pointermove
  34893. */
  34894. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34895. /** Detaches all event handlers*/
  34896. detachControl(): void;
  34897. /**
  34898. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34899. * Delay loaded resources are not taking in account
  34900. * @return true if all required resources are ready
  34901. */
  34902. isReady(): boolean;
  34903. /** Resets all cached information relative to material (including effect and visibility) */
  34904. resetCachedMaterial(): void;
  34905. /**
  34906. * Registers a function to be called before every frame render
  34907. * @param func defines the function to register
  34908. */
  34909. registerBeforeRender(func: () => void): void;
  34910. /**
  34911. * Unregisters a function called before every frame render
  34912. * @param func defines the function to unregister
  34913. */
  34914. unregisterBeforeRender(func: () => void): void;
  34915. /**
  34916. * Registers a function to be called after every frame render
  34917. * @param func defines the function to register
  34918. */
  34919. registerAfterRender(func: () => void): void;
  34920. /**
  34921. * Unregisters a function called after every frame render
  34922. * @param func defines the function to unregister
  34923. */
  34924. unregisterAfterRender(func: () => void): void;
  34925. private _executeOnceBeforeRender;
  34926. /**
  34927. * The provided function will run before render once and will be disposed afterwards.
  34928. * A timeout delay can be provided so that the function will be executed in N ms.
  34929. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34930. * @param func The function to be executed.
  34931. * @param timeout optional delay in ms
  34932. */
  34933. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34934. /** @hidden */
  34935. _addPendingData(data: any): void;
  34936. /** @hidden */
  34937. _removePendingData(data: any): void;
  34938. /**
  34939. * Returns the number of items waiting to be loaded
  34940. * @returns the number of items waiting to be loaded
  34941. */
  34942. getWaitingItemsCount(): number;
  34943. /**
  34944. * Returns a boolean indicating if the scene is still loading data
  34945. */
  34946. readonly isLoading: boolean;
  34947. /**
  34948. * Registers a function to be executed when the scene is ready
  34949. * @param {Function} func - the function to be executed
  34950. */
  34951. executeWhenReady(func: () => void): void;
  34952. /**
  34953. * Returns a promise that resolves when the scene is ready
  34954. * @returns A promise that resolves when the scene is ready
  34955. */
  34956. whenReadyAsync(): Promise<void>;
  34957. /** @hidden */
  34958. _checkIsReady(): void;
  34959. /**
  34960. * Gets all animatable attached to the scene
  34961. */
  34962. readonly animatables: Animatable[];
  34963. /**
  34964. * Resets the last animation time frame.
  34965. * Useful to override when animations start running when loading a scene for the first time.
  34966. */
  34967. resetLastAnimationTimeFrame(): void;
  34968. /**
  34969. * Gets the current view matrix
  34970. * @returns a Matrix
  34971. */
  34972. getViewMatrix(): Matrix;
  34973. /**
  34974. * Gets the current projection matrix
  34975. * @returns a Matrix
  34976. */
  34977. getProjectionMatrix(): Matrix;
  34978. /**
  34979. * Gets the current transform matrix
  34980. * @returns a Matrix made of View * Projection
  34981. */
  34982. getTransformMatrix(): Matrix;
  34983. /**
  34984. * Sets the current transform matrix
  34985. * @param viewL defines the View matrix to use
  34986. * @param projectionL defines the Projection matrix to use
  34987. * @param viewR defines the right View matrix to use (if provided)
  34988. * @param projectionR defines the right Projection matrix to use (if provided)
  34989. */
  34990. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  34991. /**
  34992. * Gets the uniform buffer used to store scene data
  34993. * @returns a UniformBuffer
  34994. */
  34995. getSceneUniformBuffer(): UniformBuffer;
  34996. /**
  34997. * Gets an unique (relatively to the current scene) Id
  34998. * @returns an unique number for the scene
  34999. */
  35000. getUniqueId(): number;
  35001. /**
  35002. * Add a mesh to the list of scene's meshes
  35003. * @param newMesh defines the mesh to add
  35004. * @param recursive if all child meshes should also be added to the scene
  35005. */
  35006. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35007. /**
  35008. * Remove a mesh for the list of scene's meshes
  35009. * @param toRemove defines the mesh to remove
  35010. * @param recursive if all child meshes should also be removed from the scene
  35011. * @returns the index where the mesh was in the mesh list
  35012. */
  35013. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35014. /**
  35015. * Add a transform node to the list of scene's transform nodes
  35016. * @param newTransformNode defines the transform node to add
  35017. */
  35018. addTransformNode(newTransformNode: TransformNode): void;
  35019. /**
  35020. * Remove a transform node for the list of scene's transform nodes
  35021. * @param toRemove defines the transform node to remove
  35022. * @returns the index where the transform node was in the transform node list
  35023. */
  35024. removeTransformNode(toRemove: TransformNode): number;
  35025. /**
  35026. * Remove a skeleton for the list of scene's skeletons
  35027. * @param toRemove defines the skeleton to remove
  35028. * @returns the index where the skeleton was in the skeleton list
  35029. */
  35030. removeSkeleton(toRemove: Skeleton): number;
  35031. /**
  35032. * Remove a morph target for the list of scene's morph targets
  35033. * @param toRemove defines the morph target to remove
  35034. * @returns the index where the morph target was in the morph target list
  35035. */
  35036. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35037. /**
  35038. * Remove a light for the list of scene's lights
  35039. * @param toRemove defines the light to remove
  35040. * @returns the index where the light was in the light list
  35041. */
  35042. removeLight(toRemove: Light): number;
  35043. /**
  35044. * Remove a camera for the list of scene's cameras
  35045. * @param toRemove defines the camera to remove
  35046. * @returns the index where the camera was in the camera list
  35047. */
  35048. removeCamera(toRemove: Camera): number;
  35049. /**
  35050. * Remove a particle system for the list of scene's particle systems
  35051. * @param toRemove defines the particle system to remove
  35052. * @returns the index where the particle system was in the particle system list
  35053. */
  35054. removeParticleSystem(toRemove: IParticleSystem): number;
  35055. /**
  35056. * Remove a animation for the list of scene's animations
  35057. * @param toRemove defines the animation to remove
  35058. * @returns the index where the animation was in the animation list
  35059. */
  35060. removeAnimation(toRemove: Animation): number;
  35061. /**
  35062. * Will stop the animation of the given target
  35063. * @param target - the target
  35064. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35065. * @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)
  35066. */
  35067. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35068. /**
  35069. * Removes the given animation group from this scene.
  35070. * @param toRemove The animation group to remove
  35071. * @returns The index of the removed animation group
  35072. */
  35073. removeAnimationGroup(toRemove: AnimationGroup): number;
  35074. /**
  35075. * Removes the given multi-material from this scene.
  35076. * @param toRemove The multi-material to remove
  35077. * @returns The index of the removed multi-material
  35078. */
  35079. removeMultiMaterial(toRemove: MultiMaterial): number;
  35080. /**
  35081. * Removes the given material from this scene.
  35082. * @param toRemove The material to remove
  35083. * @returns The index of the removed material
  35084. */
  35085. removeMaterial(toRemove: Material): number;
  35086. /**
  35087. * Removes the given action manager from this scene.
  35088. * @param toRemove The action manager to remove
  35089. * @returns The index of the removed action manager
  35090. */
  35091. removeActionManager(toRemove: AbstractActionManager): number;
  35092. /**
  35093. * Removes the given texture from this scene.
  35094. * @param toRemove The texture to remove
  35095. * @returns The index of the removed texture
  35096. */
  35097. removeTexture(toRemove: BaseTexture): number;
  35098. /**
  35099. * Adds the given light to this scene
  35100. * @param newLight The light to add
  35101. */
  35102. addLight(newLight: Light): void;
  35103. /**
  35104. * Sorts the list list based on light priorities
  35105. */
  35106. sortLightsByPriority(): void;
  35107. /**
  35108. * Adds the given camera to this scene
  35109. * @param newCamera The camera to add
  35110. */
  35111. addCamera(newCamera: Camera): void;
  35112. /**
  35113. * Adds the given skeleton to this scene
  35114. * @param newSkeleton The skeleton to add
  35115. */
  35116. addSkeleton(newSkeleton: Skeleton): void;
  35117. /**
  35118. * Adds the given particle system to this scene
  35119. * @param newParticleSystem The particle system to add
  35120. */
  35121. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35122. /**
  35123. * Adds the given animation to this scene
  35124. * @param newAnimation The animation to add
  35125. */
  35126. addAnimation(newAnimation: Animation): void;
  35127. /**
  35128. * Adds the given animation group to this scene.
  35129. * @param newAnimationGroup The animation group to add
  35130. */
  35131. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35132. /**
  35133. * Adds the given multi-material to this scene
  35134. * @param newMultiMaterial The multi-material to add
  35135. */
  35136. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35137. /**
  35138. * Adds the given material to this scene
  35139. * @param newMaterial The material to add
  35140. */
  35141. addMaterial(newMaterial: Material): void;
  35142. /**
  35143. * Adds the given morph target to this scene
  35144. * @param newMorphTargetManager The morph target to add
  35145. */
  35146. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35147. /**
  35148. * Adds the given geometry to this scene
  35149. * @param newGeometry The geometry to add
  35150. */
  35151. addGeometry(newGeometry: Geometry): void;
  35152. /**
  35153. * Adds the given action manager to this scene
  35154. * @param newActionManager The action manager to add
  35155. */
  35156. addActionManager(newActionManager: AbstractActionManager): void;
  35157. /**
  35158. * Adds the given texture to this scene.
  35159. * @param newTexture The texture to add
  35160. */
  35161. addTexture(newTexture: BaseTexture): void;
  35162. /**
  35163. * Switch active camera
  35164. * @param newCamera defines the new active camera
  35165. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35166. */
  35167. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35168. /**
  35169. * sets the active camera of the scene using its ID
  35170. * @param id defines the camera's ID
  35171. * @return the new active camera or null if none found.
  35172. */
  35173. setActiveCameraByID(id: string): Nullable<Camera>;
  35174. /**
  35175. * sets the active camera of the scene using its name
  35176. * @param name defines the camera's name
  35177. * @returns the new active camera or null if none found.
  35178. */
  35179. setActiveCameraByName(name: string): Nullable<Camera>;
  35180. /**
  35181. * get an animation group using its name
  35182. * @param name defines the material's name
  35183. * @return the animation group or null if none found.
  35184. */
  35185. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35186. /**
  35187. * Get a material using its unique id
  35188. * @param uniqueId defines the material's unique id
  35189. * @return the material or null if none found.
  35190. */
  35191. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35192. /**
  35193. * get a material using its id
  35194. * @param id defines the material's ID
  35195. * @return the material or null if none found.
  35196. */
  35197. getMaterialByID(id: string): Nullable<Material>;
  35198. /**
  35199. * Gets a the last added material using a given id
  35200. * @param id defines the material's ID
  35201. * @return the last material with the given id or null if none found.
  35202. */
  35203. getLastMaterialByID(id: string): Nullable<Material>;
  35204. /**
  35205. * Gets a material using its name
  35206. * @param name defines the material's name
  35207. * @return the material or null if none found.
  35208. */
  35209. getMaterialByName(name: string): Nullable<Material>;
  35210. /**
  35211. * Get a texture using its unique id
  35212. * @param uniqueId defines the texture's unique id
  35213. * @return the texture or null if none found.
  35214. */
  35215. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35216. /**
  35217. * Gets a camera using its id
  35218. * @param id defines the id to look for
  35219. * @returns the camera or null if not found
  35220. */
  35221. getCameraByID(id: string): Nullable<Camera>;
  35222. /**
  35223. * Gets a camera using its unique id
  35224. * @param uniqueId defines the unique id to look for
  35225. * @returns the camera or null if not found
  35226. */
  35227. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35228. /**
  35229. * Gets a camera using its name
  35230. * @param name defines the camera's name
  35231. * @return the camera or null if none found.
  35232. */
  35233. getCameraByName(name: string): Nullable<Camera>;
  35234. /**
  35235. * Gets a bone using its id
  35236. * @param id defines the bone's id
  35237. * @return the bone or null if not found
  35238. */
  35239. getBoneByID(id: string): Nullable<Bone>;
  35240. /**
  35241. * Gets a bone using its id
  35242. * @param name defines the bone's name
  35243. * @return the bone or null if not found
  35244. */
  35245. getBoneByName(name: string): Nullable<Bone>;
  35246. /**
  35247. * Gets a light node using its name
  35248. * @param name defines the the light's name
  35249. * @return the light or null if none found.
  35250. */
  35251. getLightByName(name: string): Nullable<Light>;
  35252. /**
  35253. * Gets a light node using its id
  35254. * @param id defines the light's id
  35255. * @return the light or null if none found.
  35256. */
  35257. getLightByID(id: string): Nullable<Light>;
  35258. /**
  35259. * Gets a light node using its scene-generated unique ID
  35260. * @param uniqueId defines the light's unique id
  35261. * @return the light or null if none found.
  35262. */
  35263. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35264. /**
  35265. * Gets a particle system by id
  35266. * @param id defines the particle system id
  35267. * @return the corresponding system or null if none found
  35268. */
  35269. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35270. /**
  35271. * Gets a geometry using its ID
  35272. * @param id defines the geometry's id
  35273. * @return the geometry or null if none found.
  35274. */
  35275. getGeometryByID(id: string): Nullable<Geometry>;
  35276. private _getGeometryByUniqueID;
  35277. /**
  35278. * Add a new geometry to this scene
  35279. * @param geometry defines the geometry to be added to the scene.
  35280. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35281. * @return a boolean defining if the geometry was added or not
  35282. */
  35283. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35284. /**
  35285. * Removes an existing geometry
  35286. * @param geometry defines the geometry to be removed from the scene
  35287. * @return a boolean defining if the geometry was removed or not
  35288. */
  35289. removeGeometry(geometry: Geometry): boolean;
  35290. /**
  35291. * Gets the list of geometries attached to the scene
  35292. * @returns an array of Geometry
  35293. */
  35294. getGeometries(): Geometry[];
  35295. /**
  35296. * Gets the first added mesh found of a given ID
  35297. * @param id defines the id to search for
  35298. * @return the mesh found or null if not found at all
  35299. */
  35300. getMeshByID(id: string): Nullable<AbstractMesh>;
  35301. /**
  35302. * Gets a list of meshes using their id
  35303. * @param id defines the id to search for
  35304. * @returns a list of meshes
  35305. */
  35306. getMeshesByID(id: string): Array<AbstractMesh>;
  35307. /**
  35308. * Gets the first added transform node found of a given ID
  35309. * @param id defines the id to search for
  35310. * @return the found transform node or null if not found at all.
  35311. */
  35312. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35313. /**
  35314. * Gets a transform node with its auto-generated unique id
  35315. * @param uniqueId efines the unique id to search for
  35316. * @return the found transform node or null if not found at all.
  35317. */
  35318. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35319. /**
  35320. * Gets a list of transform nodes using their id
  35321. * @param id defines the id to search for
  35322. * @returns a list of transform nodes
  35323. */
  35324. getTransformNodesByID(id: string): Array<TransformNode>;
  35325. /**
  35326. * Gets a mesh with its auto-generated unique id
  35327. * @param uniqueId defines the unique id to search for
  35328. * @return the found mesh or null if not found at all.
  35329. */
  35330. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35331. /**
  35332. * Gets a the last added mesh using a given id
  35333. * @param id defines the id to search for
  35334. * @return the found mesh or null if not found at all.
  35335. */
  35336. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35337. /**
  35338. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35339. * @param id defines the id to search for
  35340. * @return the found node or null if not found at all
  35341. */
  35342. getLastEntryByID(id: string): Nullable<Node>;
  35343. /**
  35344. * Gets a node (Mesh, Camera, Light) using a given id
  35345. * @param id defines the id to search for
  35346. * @return the found node or null if not found at all
  35347. */
  35348. getNodeByID(id: string): Nullable<Node>;
  35349. /**
  35350. * Gets a node (Mesh, Camera, Light) using a given name
  35351. * @param name defines the name to search for
  35352. * @return the found node or null if not found at all.
  35353. */
  35354. getNodeByName(name: string): Nullable<Node>;
  35355. /**
  35356. * Gets a mesh using a given name
  35357. * @param name defines the name to search for
  35358. * @return the found mesh or null if not found at all.
  35359. */
  35360. getMeshByName(name: string): Nullable<AbstractMesh>;
  35361. /**
  35362. * Gets a transform node using a given name
  35363. * @param name defines the name to search for
  35364. * @return the found transform node or null if not found at all.
  35365. */
  35366. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35367. /**
  35368. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35369. * @param id defines the id to search for
  35370. * @return the found skeleton or null if not found at all.
  35371. */
  35372. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35373. /**
  35374. * Gets a skeleton using a given auto generated unique id
  35375. * @param uniqueId defines the unique id to search for
  35376. * @return the found skeleton or null if not found at all.
  35377. */
  35378. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35379. /**
  35380. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35381. * @param id defines the id to search for
  35382. * @return the found skeleton or null if not found at all.
  35383. */
  35384. getSkeletonById(id: string): Nullable<Skeleton>;
  35385. /**
  35386. * Gets a skeleton using a given name
  35387. * @param name defines the name to search for
  35388. * @return the found skeleton or null if not found at all.
  35389. */
  35390. getSkeletonByName(name: string): Nullable<Skeleton>;
  35391. /**
  35392. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35393. * @param id defines the id to search for
  35394. * @return the found morph target manager or null if not found at all.
  35395. */
  35396. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35397. /**
  35398. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35399. * @param id defines the id to search for
  35400. * @return the found morph target or null if not found at all.
  35401. */
  35402. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35403. /**
  35404. * Gets a boolean indicating if the given mesh is active
  35405. * @param mesh defines the mesh to look for
  35406. * @returns true if the mesh is in the active list
  35407. */
  35408. isActiveMesh(mesh: AbstractMesh): boolean;
  35409. /**
  35410. * Return a unique id as a string which can serve as an identifier for the scene
  35411. */
  35412. readonly uid: string;
  35413. /**
  35414. * Add an externaly attached data from its key.
  35415. * This method call will fail and return false, if such key already exists.
  35416. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35417. * @param key the unique key that identifies the data
  35418. * @param data the data object to associate to the key for this Engine instance
  35419. * @return true if no such key were already present and the data was added successfully, false otherwise
  35420. */
  35421. addExternalData<T>(key: string, data: T): boolean;
  35422. /**
  35423. * Get an externaly attached data from its key
  35424. * @param key the unique key that identifies the data
  35425. * @return the associated data, if present (can be null), or undefined if not present
  35426. */
  35427. getExternalData<T>(key: string): Nullable<T>;
  35428. /**
  35429. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35430. * @param key the unique key that identifies the data
  35431. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35432. * @return the associated data, can be null if the factory returned null.
  35433. */
  35434. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35435. /**
  35436. * Remove an externaly attached data from the Engine instance
  35437. * @param key the unique key that identifies the data
  35438. * @return true if the data was successfully removed, false if it doesn't exist
  35439. */
  35440. removeExternalData(key: string): boolean;
  35441. private _evaluateSubMesh;
  35442. /**
  35443. * Clear the processed materials smart array preventing retention point in material dispose.
  35444. */
  35445. freeProcessedMaterials(): void;
  35446. private _preventFreeActiveMeshesAndRenderingGroups;
  35447. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35448. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35449. * when disposing several meshes in a row or a hierarchy of meshes.
  35450. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35451. */
  35452. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35453. /**
  35454. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35455. */
  35456. freeActiveMeshes(): void;
  35457. /**
  35458. * Clear the info related to rendering groups preventing retention points during dispose.
  35459. */
  35460. freeRenderingGroups(): void;
  35461. /** @hidden */
  35462. _isInIntermediateRendering(): boolean;
  35463. /**
  35464. * Lambda returning the list of potentially active meshes.
  35465. */
  35466. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35467. /**
  35468. * Lambda returning the list of potentially active sub meshes.
  35469. */
  35470. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35471. /**
  35472. * Lambda returning the list of potentially intersecting sub meshes.
  35473. */
  35474. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35475. /**
  35476. * Lambda returning the list of potentially colliding sub meshes.
  35477. */
  35478. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35479. private _activeMeshesFrozen;
  35480. /**
  35481. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35482. * @returns the current scene
  35483. */
  35484. freezeActiveMeshes(): Scene;
  35485. /**
  35486. * Use this function to restart evaluating active meshes on every frame
  35487. * @returns the current scene
  35488. */
  35489. unfreezeActiveMeshes(): Scene;
  35490. private _evaluateActiveMeshes;
  35491. private _activeMesh;
  35492. /**
  35493. * Update the transform matrix to update from the current active camera
  35494. * @param force defines a boolean used to force the update even if cache is up to date
  35495. */
  35496. updateTransformMatrix(force?: boolean): void;
  35497. private _bindFrameBuffer;
  35498. /** @hidden */
  35499. _allowPostProcessClearColor: boolean;
  35500. /** @hidden */
  35501. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35502. private _processSubCameras;
  35503. private _checkIntersections;
  35504. /** @hidden */
  35505. _advancePhysicsEngineStep(step: number): void;
  35506. /**
  35507. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35508. */
  35509. getDeterministicFrameTime: () => number;
  35510. /** @hidden */
  35511. _animate(): void;
  35512. /** Execute all animations (for a frame) */
  35513. animate(): void;
  35514. /**
  35515. * Render the scene
  35516. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35517. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35518. */
  35519. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35520. /**
  35521. * Freeze all materials
  35522. * A frozen material will not be updatable but should be faster to render
  35523. */
  35524. freezeMaterials(): void;
  35525. /**
  35526. * Unfreeze all materials
  35527. * A frozen material will not be updatable but should be faster to render
  35528. */
  35529. unfreezeMaterials(): void;
  35530. /**
  35531. * Releases all held ressources
  35532. */
  35533. dispose(): void;
  35534. /**
  35535. * Gets if the scene is already disposed
  35536. */
  35537. readonly isDisposed: boolean;
  35538. /**
  35539. * Call this function to reduce memory footprint of the scene.
  35540. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35541. */
  35542. clearCachedVertexData(): void;
  35543. /**
  35544. * This function will remove the local cached buffer data from texture.
  35545. * It will save memory but will prevent the texture from being rebuilt
  35546. */
  35547. cleanCachedTextureBuffer(): void;
  35548. /**
  35549. * Get the world extend vectors with an optional filter
  35550. *
  35551. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35552. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35553. */
  35554. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35555. min: Vector3;
  35556. max: Vector3;
  35557. };
  35558. /**
  35559. * Creates a ray that can be used to pick in the scene
  35560. * @param x defines the x coordinate of the origin (on-screen)
  35561. * @param y defines the y coordinate of the origin (on-screen)
  35562. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35563. * @param camera defines the camera to use for the picking
  35564. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35565. * @returns a Ray
  35566. */
  35567. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35568. /**
  35569. * Creates a ray that can be used to pick in the scene
  35570. * @param x defines the x coordinate of the origin (on-screen)
  35571. * @param y defines the y coordinate of the origin (on-screen)
  35572. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35573. * @param result defines the ray where to store the picking ray
  35574. * @param camera defines the camera to use for the picking
  35575. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35576. * @returns the current scene
  35577. */
  35578. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35579. /**
  35580. * Creates a ray that can be used to pick in the scene
  35581. * @param x defines the x coordinate of the origin (on-screen)
  35582. * @param y defines the y coordinate of the origin (on-screen)
  35583. * @param camera defines the camera to use for the picking
  35584. * @returns a Ray
  35585. */
  35586. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35587. /**
  35588. * Creates a ray that can be used to pick in the scene
  35589. * @param x defines the x coordinate of the origin (on-screen)
  35590. * @param y defines the y coordinate of the origin (on-screen)
  35591. * @param result defines the ray where to store the picking ray
  35592. * @param camera defines the camera to use for the picking
  35593. * @returns the current scene
  35594. */
  35595. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35596. /** Launch a ray to try to pick a mesh in the scene
  35597. * @param x position on screen
  35598. * @param y position on screen
  35599. * @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
  35600. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35601. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35602. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35603. * @returns a PickingInfo
  35604. */
  35605. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35606. /** Use the given ray to pick a mesh in the scene
  35607. * @param ray The ray to use to pick meshes
  35608. * @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
  35609. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35610. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35611. * @returns a PickingInfo
  35612. */
  35613. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35614. /**
  35615. * Launch a ray to try to pick a mesh in the scene
  35616. * @param x X position on screen
  35617. * @param y Y position on screen
  35618. * @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
  35619. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35620. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35621. * @returns an array of PickingInfo
  35622. */
  35623. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35624. /**
  35625. * Launch a ray to try to pick a mesh in the scene
  35626. * @param ray Ray to use
  35627. * @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
  35628. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35629. * @returns an array of PickingInfo
  35630. */
  35631. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35632. /**
  35633. * Force the value of meshUnderPointer
  35634. * @param mesh defines the mesh to use
  35635. */
  35636. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35637. /**
  35638. * Gets the mesh under the pointer
  35639. * @returns a Mesh or null if no mesh is under the pointer
  35640. */
  35641. getPointerOverMesh(): Nullable<AbstractMesh>;
  35642. /** @hidden */
  35643. _rebuildGeometries(): void;
  35644. /** @hidden */
  35645. _rebuildTextures(): void;
  35646. private _getByTags;
  35647. /**
  35648. * Get a list of meshes by tags
  35649. * @param tagsQuery defines the tags query to use
  35650. * @param forEach defines a predicate used to filter results
  35651. * @returns an array of Mesh
  35652. */
  35653. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35654. /**
  35655. * Get a list of cameras by tags
  35656. * @param tagsQuery defines the tags query to use
  35657. * @param forEach defines a predicate used to filter results
  35658. * @returns an array of Camera
  35659. */
  35660. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35661. /**
  35662. * Get a list of lights by tags
  35663. * @param tagsQuery defines the tags query to use
  35664. * @param forEach defines a predicate used to filter results
  35665. * @returns an array of Light
  35666. */
  35667. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35668. /**
  35669. * Get a list of materials by tags
  35670. * @param tagsQuery defines the tags query to use
  35671. * @param forEach defines a predicate used to filter results
  35672. * @returns an array of Material
  35673. */
  35674. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35675. /**
  35676. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35677. * This allowed control for front to back rendering or reversly depending of the special needs.
  35678. *
  35679. * @param renderingGroupId The rendering group id corresponding to its index
  35680. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35681. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35682. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35683. */
  35684. 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;
  35685. /**
  35686. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35687. *
  35688. * @param renderingGroupId The rendering group id corresponding to its index
  35689. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35690. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35691. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35692. */
  35693. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35694. /**
  35695. * Gets the current auto clear configuration for one rendering group of the rendering
  35696. * manager.
  35697. * @param index the rendering group index to get the information for
  35698. * @returns The auto clear setup for the requested rendering group
  35699. */
  35700. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35701. private _blockMaterialDirtyMechanism;
  35702. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35703. blockMaterialDirtyMechanism: boolean;
  35704. /**
  35705. * Will flag all materials as dirty to trigger new shader compilation
  35706. * @param flag defines the flag used to specify which material part must be marked as dirty
  35707. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35708. */
  35709. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35710. /** @hidden */
  35711. _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;
  35712. /** @hidden */
  35713. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35714. }
  35715. }
  35716. declare module "babylonjs/assetContainer" {
  35717. import { AbstractScene } from "babylonjs/abstractScene";
  35718. import { Scene } from "babylonjs/scene";
  35719. import { Mesh } from "babylonjs/Meshes/mesh";
  35720. /**
  35721. * Set of assets to keep when moving a scene into an asset container.
  35722. */
  35723. export class KeepAssets extends AbstractScene {
  35724. }
  35725. /**
  35726. * Container with a set of assets that can be added or removed from a scene.
  35727. */
  35728. export class AssetContainer extends AbstractScene {
  35729. /**
  35730. * The scene the AssetContainer belongs to.
  35731. */
  35732. scene: Scene;
  35733. /**
  35734. * Instantiates an AssetContainer.
  35735. * @param scene The scene the AssetContainer belongs to.
  35736. */
  35737. constructor(scene: Scene);
  35738. /**
  35739. * Adds all the assets from the container to the scene.
  35740. */
  35741. addAllToScene(): void;
  35742. /**
  35743. * Removes all the assets in the container from the scene
  35744. */
  35745. removeAllFromScene(): void;
  35746. /**
  35747. * Disposes all the assets in the container
  35748. */
  35749. dispose(): void;
  35750. private _moveAssets;
  35751. /**
  35752. * Removes all the assets contained in the scene and adds them to the container.
  35753. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35754. */
  35755. moveAllFromScene(keepAssets?: KeepAssets): void;
  35756. /**
  35757. * 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.
  35758. * @returns the root mesh
  35759. */
  35760. createRootMesh(): Mesh;
  35761. }
  35762. }
  35763. declare module "babylonjs/abstractScene" {
  35764. import { Scene } from "babylonjs/scene";
  35765. import { Nullable } from "babylonjs/types";
  35766. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35767. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35768. import { Geometry } from "babylonjs/Meshes/geometry";
  35769. import { Skeleton } from "babylonjs/Bones/skeleton";
  35770. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35771. import { AssetContainer } from "babylonjs/assetContainer";
  35772. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35773. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35774. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35775. import { Material } from "babylonjs/Materials/material";
  35776. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35777. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35778. import { Camera } from "babylonjs/Cameras/camera";
  35779. import { Light } from "babylonjs/Lights/light";
  35780. import { Node } from "babylonjs/node";
  35781. import { Animation } from "babylonjs/Animations/animation";
  35782. /**
  35783. * Defines how the parser contract is defined.
  35784. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35785. */
  35786. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35787. /**
  35788. * Defines how the individual parser contract is defined.
  35789. * These parser can parse an individual asset
  35790. */
  35791. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35792. /**
  35793. * Base class of the scene acting as a container for the different elements composing a scene.
  35794. * This class is dynamically extended by the different components of the scene increasing
  35795. * flexibility and reducing coupling
  35796. */
  35797. export abstract class AbstractScene {
  35798. /**
  35799. * Stores the list of available parsers in the application.
  35800. */
  35801. private static _BabylonFileParsers;
  35802. /**
  35803. * Stores the list of available individual parsers in the application.
  35804. */
  35805. private static _IndividualBabylonFileParsers;
  35806. /**
  35807. * Adds a parser in the list of available ones
  35808. * @param name Defines the name of the parser
  35809. * @param parser Defines the parser to add
  35810. */
  35811. static AddParser(name: string, parser: BabylonFileParser): void;
  35812. /**
  35813. * Gets a general parser from the list of avaialble ones
  35814. * @param name Defines the name of the parser
  35815. * @returns the requested parser or null
  35816. */
  35817. static GetParser(name: string): Nullable<BabylonFileParser>;
  35818. /**
  35819. * Adds n individual parser in the list of available ones
  35820. * @param name Defines the name of the parser
  35821. * @param parser Defines the parser to add
  35822. */
  35823. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35824. /**
  35825. * Gets an individual parser from the list of avaialble ones
  35826. * @param name Defines the name of the parser
  35827. * @returns the requested parser or null
  35828. */
  35829. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35830. /**
  35831. * Parser json data and populate both a scene and its associated container object
  35832. * @param jsonData Defines the data to parse
  35833. * @param scene Defines the scene to parse the data for
  35834. * @param container Defines the container attached to the parsing sequence
  35835. * @param rootUrl Defines the root url of the data
  35836. */
  35837. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35838. /**
  35839. * Gets the list of root nodes (ie. nodes with no parent)
  35840. */
  35841. rootNodes: Node[];
  35842. /** All of the cameras added to this scene
  35843. * @see http://doc.babylonjs.com/babylon101/cameras
  35844. */
  35845. cameras: Camera[];
  35846. /**
  35847. * All of the lights added to this scene
  35848. * @see http://doc.babylonjs.com/babylon101/lights
  35849. */
  35850. lights: Light[];
  35851. /**
  35852. * All of the (abstract) meshes added to this scene
  35853. */
  35854. meshes: AbstractMesh[];
  35855. /**
  35856. * The list of skeletons added to the scene
  35857. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35858. */
  35859. skeletons: Skeleton[];
  35860. /**
  35861. * All of the particle systems added to this scene
  35862. * @see http://doc.babylonjs.com/babylon101/particles
  35863. */
  35864. particleSystems: IParticleSystem[];
  35865. /**
  35866. * Gets a list of Animations associated with the scene
  35867. */
  35868. animations: Animation[];
  35869. /**
  35870. * All of the animation groups added to this scene
  35871. * @see http://doc.babylonjs.com/how_to/group
  35872. */
  35873. animationGroups: AnimationGroup[];
  35874. /**
  35875. * All of the multi-materials added to this scene
  35876. * @see http://doc.babylonjs.com/how_to/multi_materials
  35877. */
  35878. multiMaterials: MultiMaterial[];
  35879. /**
  35880. * All of the materials added to this scene
  35881. * In the context of a Scene, it is not supposed to be modified manually.
  35882. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35883. * Note also that the order of the Material wihin the array is not significant and might change.
  35884. * @see http://doc.babylonjs.com/babylon101/materials
  35885. */
  35886. materials: Material[];
  35887. /**
  35888. * The list of morph target managers added to the scene
  35889. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35890. */
  35891. morphTargetManagers: MorphTargetManager[];
  35892. /**
  35893. * The list of geometries used in the scene.
  35894. */
  35895. geometries: Geometry[];
  35896. /**
  35897. * All of the tranform nodes added to this scene
  35898. * In the context of a Scene, it is not supposed to be modified manually.
  35899. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35900. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35901. * @see http://doc.babylonjs.com/how_to/transformnode
  35902. */
  35903. transformNodes: TransformNode[];
  35904. /**
  35905. * ActionManagers available on the scene.
  35906. */
  35907. actionManagers: AbstractActionManager[];
  35908. /**
  35909. * Textures to keep.
  35910. */
  35911. textures: BaseTexture[];
  35912. /**
  35913. * Environment texture for the scene
  35914. */
  35915. environmentTexture: Nullable<BaseTexture>;
  35916. }
  35917. }
  35918. declare module "babylonjs/Audio/sound" {
  35919. import { Observable } from "babylonjs/Misc/observable";
  35920. import { Vector3 } from "babylonjs/Maths/math.vector";
  35921. import { Nullable } from "babylonjs/types";
  35922. import { Scene } from "babylonjs/scene";
  35923. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35924. /**
  35925. * Interface used to define options for Sound class
  35926. */
  35927. export interface ISoundOptions {
  35928. /**
  35929. * Does the sound autoplay once loaded.
  35930. */
  35931. autoplay?: boolean;
  35932. /**
  35933. * Does the sound loop after it finishes playing once.
  35934. */
  35935. loop?: boolean;
  35936. /**
  35937. * Sound's volume
  35938. */
  35939. volume?: number;
  35940. /**
  35941. * Is it a spatial sound?
  35942. */
  35943. spatialSound?: boolean;
  35944. /**
  35945. * Maximum distance to hear that sound
  35946. */
  35947. maxDistance?: number;
  35948. /**
  35949. * Uses user defined attenuation function
  35950. */
  35951. useCustomAttenuation?: boolean;
  35952. /**
  35953. * Define the roll off factor of spatial sounds.
  35954. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35955. */
  35956. rolloffFactor?: number;
  35957. /**
  35958. * Define the reference distance the sound should be heard perfectly.
  35959. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35960. */
  35961. refDistance?: number;
  35962. /**
  35963. * Define the distance attenuation model the sound will follow.
  35964. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35965. */
  35966. distanceModel?: string;
  35967. /**
  35968. * Defines the playback speed (1 by default)
  35969. */
  35970. playbackRate?: number;
  35971. /**
  35972. * Defines if the sound is from a streaming source
  35973. */
  35974. streaming?: boolean;
  35975. /**
  35976. * Defines an optional length (in seconds) inside the sound file
  35977. */
  35978. length?: number;
  35979. /**
  35980. * Defines an optional offset (in seconds) inside the sound file
  35981. */
  35982. offset?: number;
  35983. /**
  35984. * If true, URLs will not be required to state the audio file codec to use.
  35985. */
  35986. skipCodecCheck?: boolean;
  35987. }
  35988. /**
  35989. * Defines a sound that can be played in the application.
  35990. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  35991. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35992. */
  35993. export class Sound {
  35994. /**
  35995. * The name of the sound in the scene.
  35996. */
  35997. name: string;
  35998. /**
  35999. * Does the sound autoplay once loaded.
  36000. */
  36001. autoplay: boolean;
  36002. /**
  36003. * Does the sound loop after it finishes playing once.
  36004. */
  36005. loop: boolean;
  36006. /**
  36007. * Does the sound use a custom attenuation curve to simulate the falloff
  36008. * happening when the source gets further away from the camera.
  36009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36010. */
  36011. useCustomAttenuation: boolean;
  36012. /**
  36013. * The sound track id this sound belongs to.
  36014. */
  36015. soundTrackId: number;
  36016. /**
  36017. * Is this sound currently played.
  36018. */
  36019. isPlaying: boolean;
  36020. /**
  36021. * Is this sound currently paused.
  36022. */
  36023. isPaused: boolean;
  36024. /**
  36025. * Does this sound enables spatial sound.
  36026. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36027. */
  36028. spatialSound: boolean;
  36029. /**
  36030. * Define the reference distance the sound should be heard perfectly.
  36031. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36032. */
  36033. refDistance: number;
  36034. /**
  36035. * Define the roll off factor of spatial sounds.
  36036. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36037. */
  36038. rolloffFactor: number;
  36039. /**
  36040. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36042. */
  36043. maxDistance: number;
  36044. /**
  36045. * Define the distance attenuation model the sound will follow.
  36046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36047. */
  36048. distanceModel: string;
  36049. /**
  36050. * @hidden
  36051. * Back Compat
  36052. **/
  36053. onended: () => any;
  36054. /**
  36055. * Observable event when the current playing sound finishes.
  36056. */
  36057. onEndedObservable: Observable<Sound>;
  36058. private _panningModel;
  36059. private _playbackRate;
  36060. private _streaming;
  36061. private _startTime;
  36062. private _startOffset;
  36063. private _position;
  36064. /** @hidden */
  36065. _positionInEmitterSpace: boolean;
  36066. private _localDirection;
  36067. private _volume;
  36068. private _isReadyToPlay;
  36069. private _isDirectional;
  36070. private _readyToPlayCallback;
  36071. private _audioBuffer;
  36072. private _soundSource;
  36073. private _streamingSource;
  36074. private _soundPanner;
  36075. private _soundGain;
  36076. private _inputAudioNode;
  36077. private _outputAudioNode;
  36078. private _coneInnerAngle;
  36079. private _coneOuterAngle;
  36080. private _coneOuterGain;
  36081. private _scene;
  36082. private _connectedTransformNode;
  36083. private _customAttenuationFunction;
  36084. private _registerFunc;
  36085. private _isOutputConnected;
  36086. private _htmlAudioElement;
  36087. private _urlType;
  36088. private _length?;
  36089. private _offset?;
  36090. /** @hidden */
  36091. static _SceneComponentInitialization: (scene: Scene) => void;
  36092. /**
  36093. * Create a sound and attach it to a scene
  36094. * @param name Name of your sound
  36095. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36096. * @param scene defines the scene the sound belongs to
  36097. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36098. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36099. */
  36100. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36101. /**
  36102. * Release the sound and its associated resources
  36103. */
  36104. dispose(): void;
  36105. /**
  36106. * Gets if the sounds is ready to be played or not.
  36107. * @returns true if ready, otherwise false
  36108. */
  36109. isReady(): boolean;
  36110. private _soundLoaded;
  36111. /**
  36112. * Sets the data of the sound from an audiobuffer
  36113. * @param audioBuffer The audioBuffer containing the data
  36114. */
  36115. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36116. /**
  36117. * Updates the current sounds options such as maxdistance, loop...
  36118. * @param options A JSON object containing values named as the object properties
  36119. */
  36120. updateOptions(options: ISoundOptions): void;
  36121. private _createSpatialParameters;
  36122. private _updateSpatialParameters;
  36123. /**
  36124. * Switch the panning model to HRTF:
  36125. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36126. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36127. */
  36128. switchPanningModelToHRTF(): void;
  36129. /**
  36130. * Switch the panning model to Equal Power:
  36131. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36132. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36133. */
  36134. switchPanningModelToEqualPower(): void;
  36135. private _switchPanningModel;
  36136. /**
  36137. * Connect this sound to a sound track audio node like gain...
  36138. * @param soundTrackAudioNode the sound track audio node to connect to
  36139. */
  36140. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36141. /**
  36142. * Transform this sound into a directional source
  36143. * @param coneInnerAngle Size of the inner cone in degree
  36144. * @param coneOuterAngle Size of the outer cone in degree
  36145. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36146. */
  36147. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36148. /**
  36149. * Gets or sets the inner angle for the directional cone.
  36150. */
  36151. /**
  36152. * Gets or sets the inner angle for the directional cone.
  36153. */
  36154. directionalConeInnerAngle: number;
  36155. /**
  36156. * Gets or sets the outer angle for the directional cone.
  36157. */
  36158. /**
  36159. * Gets or sets the outer angle for the directional cone.
  36160. */
  36161. directionalConeOuterAngle: number;
  36162. /**
  36163. * Sets the position of the emitter if spatial sound is enabled
  36164. * @param newPosition Defines the new posisiton
  36165. */
  36166. setPosition(newPosition: Vector3): void;
  36167. /**
  36168. * Sets the local direction of the emitter if spatial sound is enabled
  36169. * @param newLocalDirection Defines the new local direction
  36170. */
  36171. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36172. private _updateDirection;
  36173. /** @hidden */
  36174. updateDistanceFromListener(): void;
  36175. /**
  36176. * Sets a new custom attenuation function for the sound.
  36177. * @param callback Defines the function used for the attenuation
  36178. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36179. */
  36180. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36181. /**
  36182. * Play the sound
  36183. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36184. * @param offset (optional) Start the sound at a specific time in seconds
  36185. * @param length (optional) Sound duration (in seconds)
  36186. */
  36187. play(time?: number, offset?: number, length?: number): void;
  36188. private _onended;
  36189. /**
  36190. * Stop the sound
  36191. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36192. */
  36193. stop(time?: number): void;
  36194. /**
  36195. * Put the sound in pause
  36196. */
  36197. pause(): void;
  36198. /**
  36199. * Sets a dedicated volume for this sounds
  36200. * @param newVolume Define the new volume of the sound
  36201. * @param time Define time for gradual change to new volume
  36202. */
  36203. setVolume(newVolume: number, time?: number): void;
  36204. /**
  36205. * Set the sound play back rate
  36206. * @param newPlaybackRate Define the playback rate the sound should be played at
  36207. */
  36208. setPlaybackRate(newPlaybackRate: number): void;
  36209. /**
  36210. * Gets the volume of the sound.
  36211. * @returns the volume of the sound
  36212. */
  36213. getVolume(): number;
  36214. /**
  36215. * Attach the sound to a dedicated mesh
  36216. * @param transformNode The transform node to connect the sound with
  36217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36218. */
  36219. attachToMesh(transformNode: TransformNode): void;
  36220. /**
  36221. * Detach the sound from the previously attached mesh
  36222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36223. */
  36224. detachFromMesh(): void;
  36225. private _onRegisterAfterWorldMatrixUpdate;
  36226. /**
  36227. * Clone the current sound in the scene.
  36228. * @returns the new sound clone
  36229. */
  36230. clone(): Nullable<Sound>;
  36231. /**
  36232. * Gets the current underlying audio buffer containing the data
  36233. * @returns the audio buffer
  36234. */
  36235. getAudioBuffer(): Nullable<AudioBuffer>;
  36236. /**
  36237. * Serializes the Sound in a JSON representation
  36238. * @returns the JSON representation of the sound
  36239. */
  36240. serialize(): any;
  36241. /**
  36242. * Parse a JSON representation of a sound to innstantiate in a given scene
  36243. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36244. * @param scene Define the scene the new parsed sound should be created in
  36245. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36246. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36247. * @returns the newly parsed sound
  36248. */
  36249. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36250. }
  36251. }
  36252. declare module "babylonjs/Actions/directAudioActions" {
  36253. import { Action } from "babylonjs/Actions/action";
  36254. import { Condition } from "babylonjs/Actions/condition";
  36255. import { Sound } from "babylonjs/Audio/sound";
  36256. /**
  36257. * This defines an action helpful to play a defined sound on a triggered action.
  36258. */
  36259. export class PlaySoundAction extends Action {
  36260. private _sound;
  36261. /**
  36262. * Instantiate the action
  36263. * @param triggerOptions defines the trigger options
  36264. * @param sound defines the sound to play
  36265. * @param condition defines the trigger related conditions
  36266. */
  36267. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36268. /** @hidden */
  36269. _prepare(): void;
  36270. /**
  36271. * Execute the action and play the sound.
  36272. */
  36273. execute(): void;
  36274. /**
  36275. * Serializes the actions and its related information.
  36276. * @param parent defines the object to serialize in
  36277. * @returns the serialized object
  36278. */
  36279. serialize(parent: any): any;
  36280. }
  36281. /**
  36282. * This defines an action helpful to stop a defined sound on a triggered action.
  36283. */
  36284. export class StopSoundAction extends Action {
  36285. private _sound;
  36286. /**
  36287. * Instantiate the action
  36288. * @param triggerOptions defines the trigger options
  36289. * @param sound defines the sound to stop
  36290. * @param condition defines the trigger related conditions
  36291. */
  36292. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36293. /** @hidden */
  36294. _prepare(): void;
  36295. /**
  36296. * Execute the action and stop the sound.
  36297. */
  36298. execute(): void;
  36299. /**
  36300. * Serializes the actions and its related information.
  36301. * @param parent defines the object to serialize in
  36302. * @returns the serialized object
  36303. */
  36304. serialize(parent: any): any;
  36305. }
  36306. }
  36307. declare module "babylonjs/Actions/interpolateValueAction" {
  36308. import { Action } from "babylonjs/Actions/action";
  36309. import { Condition } from "babylonjs/Actions/condition";
  36310. import { Observable } from "babylonjs/Misc/observable";
  36311. /**
  36312. * This defines an action responsible to change the value of a property
  36313. * by interpolating between its current value and the newly set one once triggered.
  36314. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36315. */
  36316. export class InterpolateValueAction extends Action {
  36317. /**
  36318. * Defines the path of the property where the value should be interpolated
  36319. */
  36320. propertyPath: string;
  36321. /**
  36322. * Defines the target value at the end of the interpolation.
  36323. */
  36324. value: any;
  36325. /**
  36326. * Defines the time it will take for the property to interpolate to the value.
  36327. */
  36328. duration: number;
  36329. /**
  36330. * Defines if the other scene animations should be stopped when the action has been triggered
  36331. */
  36332. stopOtherAnimations?: boolean;
  36333. /**
  36334. * Defines a callback raised once the interpolation animation has been done.
  36335. */
  36336. onInterpolationDone?: () => void;
  36337. /**
  36338. * Observable triggered once the interpolation animation has been done.
  36339. */
  36340. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36341. private _target;
  36342. private _effectiveTarget;
  36343. private _property;
  36344. /**
  36345. * Instantiate the action
  36346. * @param triggerOptions defines the trigger options
  36347. * @param target defines the object containing the value to interpolate
  36348. * @param propertyPath defines the path to the property in the target object
  36349. * @param value defines the target value at the end of the interpolation
  36350. * @param duration deines the time it will take for the property to interpolate to the value.
  36351. * @param condition defines the trigger related conditions
  36352. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36353. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36354. */
  36355. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36356. /** @hidden */
  36357. _prepare(): void;
  36358. /**
  36359. * Execute the action starts the value interpolation.
  36360. */
  36361. execute(): void;
  36362. /**
  36363. * Serializes the actions and its related information.
  36364. * @param parent defines the object to serialize in
  36365. * @returns the serialized object
  36366. */
  36367. serialize(parent: any): any;
  36368. }
  36369. }
  36370. declare module "babylonjs/Actions/index" {
  36371. export * from "babylonjs/Actions/abstractActionManager";
  36372. export * from "babylonjs/Actions/action";
  36373. export * from "babylonjs/Actions/actionEvent";
  36374. export * from "babylonjs/Actions/actionManager";
  36375. export * from "babylonjs/Actions/condition";
  36376. export * from "babylonjs/Actions/directActions";
  36377. export * from "babylonjs/Actions/directAudioActions";
  36378. export * from "babylonjs/Actions/interpolateValueAction";
  36379. }
  36380. declare module "babylonjs/Animations/index" {
  36381. export * from "babylonjs/Animations/animatable";
  36382. export * from "babylonjs/Animations/animation";
  36383. export * from "babylonjs/Animations/animationGroup";
  36384. export * from "babylonjs/Animations/animationPropertiesOverride";
  36385. export * from "babylonjs/Animations/easing";
  36386. export * from "babylonjs/Animations/runtimeAnimation";
  36387. export * from "babylonjs/Animations/animationEvent";
  36388. export * from "babylonjs/Animations/animationGroup";
  36389. export * from "babylonjs/Animations/animationKey";
  36390. export * from "babylonjs/Animations/animationRange";
  36391. export * from "babylonjs/Animations/animatable.interface";
  36392. }
  36393. declare module "babylonjs/Audio/soundTrack" {
  36394. import { Sound } from "babylonjs/Audio/sound";
  36395. import { Analyser } from "babylonjs/Audio/analyser";
  36396. import { Scene } from "babylonjs/scene";
  36397. /**
  36398. * Options allowed during the creation of a sound track.
  36399. */
  36400. export interface ISoundTrackOptions {
  36401. /**
  36402. * The volume the sound track should take during creation
  36403. */
  36404. volume?: number;
  36405. /**
  36406. * Define if the sound track is the main sound track of the scene
  36407. */
  36408. mainTrack?: boolean;
  36409. }
  36410. /**
  36411. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36412. * It will be also used in a future release to apply effects on a specific track.
  36413. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36414. */
  36415. export class SoundTrack {
  36416. /**
  36417. * The unique identifier of the sound track in the scene.
  36418. */
  36419. id: number;
  36420. /**
  36421. * The list of sounds included in the sound track.
  36422. */
  36423. soundCollection: Array<Sound>;
  36424. private _outputAudioNode;
  36425. private _scene;
  36426. private _isMainTrack;
  36427. private _connectedAnalyser;
  36428. private _options;
  36429. private _isInitialized;
  36430. /**
  36431. * Creates a new sound track.
  36432. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36433. * @param scene Define the scene the sound track belongs to
  36434. * @param options
  36435. */
  36436. constructor(scene: Scene, options?: ISoundTrackOptions);
  36437. private _initializeSoundTrackAudioGraph;
  36438. /**
  36439. * Release the sound track and its associated resources
  36440. */
  36441. dispose(): void;
  36442. /**
  36443. * Adds a sound to this sound track
  36444. * @param sound define the cound to add
  36445. * @ignoreNaming
  36446. */
  36447. AddSound(sound: Sound): void;
  36448. /**
  36449. * Removes a sound to this sound track
  36450. * @param sound define the cound to remove
  36451. * @ignoreNaming
  36452. */
  36453. RemoveSound(sound: Sound): void;
  36454. /**
  36455. * Set a global volume for the full sound track.
  36456. * @param newVolume Define the new volume of the sound track
  36457. */
  36458. setVolume(newVolume: number): void;
  36459. /**
  36460. * Switch the panning model to HRTF:
  36461. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36463. */
  36464. switchPanningModelToHRTF(): void;
  36465. /**
  36466. * Switch the panning model to Equal Power:
  36467. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36469. */
  36470. switchPanningModelToEqualPower(): void;
  36471. /**
  36472. * Connect the sound track to an audio analyser allowing some amazing
  36473. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36474. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36475. * @param analyser The analyser to connect to the engine
  36476. */
  36477. connectToAnalyser(analyser: Analyser): void;
  36478. }
  36479. }
  36480. declare module "babylonjs/Audio/audioSceneComponent" {
  36481. import { Sound } from "babylonjs/Audio/sound";
  36482. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36483. import { Nullable } from "babylonjs/types";
  36484. import { Vector3 } from "babylonjs/Maths/math.vector";
  36485. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36486. import { Scene } from "babylonjs/scene";
  36487. import { AbstractScene } from "babylonjs/abstractScene";
  36488. import "babylonjs/Audio/audioEngine";
  36489. module "babylonjs/abstractScene" {
  36490. interface AbstractScene {
  36491. /**
  36492. * The list of sounds used in the scene.
  36493. */
  36494. sounds: Nullable<Array<Sound>>;
  36495. }
  36496. }
  36497. module "babylonjs/scene" {
  36498. interface Scene {
  36499. /**
  36500. * @hidden
  36501. * Backing field
  36502. */
  36503. _mainSoundTrack: SoundTrack;
  36504. /**
  36505. * The main sound track played by the scene.
  36506. * It cotains your primary collection of sounds.
  36507. */
  36508. mainSoundTrack: SoundTrack;
  36509. /**
  36510. * The list of sound tracks added to the scene
  36511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36512. */
  36513. soundTracks: Nullable<Array<SoundTrack>>;
  36514. /**
  36515. * Gets a sound using a given name
  36516. * @param name defines the name to search for
  36517. * @return the found sound or null if not found at all.
  36518. */
  36519. getSoundByName(name: string): Nullable<Sound>;
  36520. /**
  36521. * Gets or sets if audio support is enabled
  36522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36523. */
  36524. audioEnabled: boolean;
  36525. /**
  36526. * Gets or sets if audio will be output to headphones
  36527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36528. */
  36529. headphone: boolean;
  36530. /**
  36531. * Gets or sets custom audio listener position provider
  36532. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36533. */
  36534. audioListenerPositionProvider: Nullable<() => Vector3>;
  36535. }
  36536. }
  36537. /**
  36538. * Defines the sound scene component responsible to manage any sounds
  36539. * in a given scene.
  36540. */
  36541. export class AudioSceneComponent implements ISceneSerializableComponent {
  36542. /**
  36543. * The component name helpfull to identify the component in the list of scene components.
  36544. */
  36545. readonly name: string;
  36546. /**
  36547. * The scene the component belongs to.
  36548. */
  36549. scene: Scene;
  36550. private _audioEnabled;
  36551. /**
  36552. * Gets whether audio is enabled or not.
  36553. * Please use related enable/disable method to switch state.
  36554. */
  36555. readonly audioEnabled: boolean;
  36556. private _headphone;
  36557. /**
  36558. * Gets whether audio is outputing to headphone or not.
  36559. * Please use the according Switch methods to change output.
  36560. */
  36561. readonly headphone: boolean;
  36562. private _audioListenerPositionProvider;
  36563. /**
  36564. * Gets the current audio listener position provider
  36565. */
  36566. /**
  36567. * Sets a custom listener position for all sounds in the scene
  36568. * By default, this is the position of the first active camera
  36569. */
  36570. audioListenerPositionProvider: Nullable<() => Vector3>;
  36571. /**
  36572. * Creates a new instance of the component for the given scene
  36573. * @param scene Defines the scene to register the component in
  36574. */
  36575. constructor(scene: Scene);
  36576. /**
  36577. * Registers the component in a given scene
  36578. */
  36579. register(): void;
  36580. /**
  36581. * Rebuilds the elements related to this component in case of
  36582. * context lost for instance.
  36583. */
  36584. rebuild(): void;
  36585. /**
  36586. * Serializes the component data to the specified json object
  36587. * @param serializationObject The object to serialize to
  36588. */
  36589. serialize(serializationObject: any): void;
  36590. /**
  36591. * Adds all the elements from the container to the scene
  36592. * @param container the container holding the elements
  36593. */
  36594. addFromContainer(container: AbstractScene): void;
  36595. /**
  36596. * Removes all the elements in the container from the scene
  36597. * @param container contains the elements to remove
  36598. * @param dispose if the removed element should be disposed (default: false)
  36599. */
  36600. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36601. /**
  36602. * Disposes the component and the associated ressources.
  36603. */
  36604. dispose(): void;
  36605. /**
  36606. * Disables audio in the associated scene.
  36607. */
  36608. disableAudio(): void;
  36609. /**
  36610. * Enables audio in the associated scene.
  36611. */
  36612. enableAudio(): void;
  36613. /**
  36614. * Switch audio to headphone output.
  36615. */
  36616. switchAudioModeForHeadphones(): void;
  36617. /**
  36618. * Switch audio to normal speakers.
  36619. */
  36620. switchAudioModeForNormalSpeakers(): void;
  36621. private _afterRender;
  36622. }
  36623. }
  36624. declare module "babylonjs/Audio/weightedsound" {
  36625. import { Sound } from "babylonjs/Audio/sound";
  36626. /**
  36627. * Wraps one or more Sound objects and selects one with random weight for playback.
  36628. */
  36629. export class WeightedSound {
  36630. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36631. loop: boolean;
  36632. private _coneInnerAngle;
  36633. private _coneOuterAngle;
  36634. private _volume;
  36635. /** A Sound is currently playing. */
  36636. isPlaying: boolean;
  36637. /** A Sound is currently paused. */
  36638. isPaused: boolean;
  36639. private _sounds;
  36640. private _weights;
  36641. private _currentIndex?;
  36642. /**
  36643. * Creates a new WeightedSound from the list of sounds given.
  36644. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36645. * @param sounds Array of Sounds that will be selected from.
  36646. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36647. */
  36648. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36649. /**
  36650. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36651. */
  36652. /**
  36653. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36654. */
  36655. directionalConeInnerAngle: number;
  36656. /**
  36657. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36658. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36659. */
  36660. /**
  36661. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36662. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36663. */
  36664. directionalConeOuterAngle: number;
  36665. /**
  36666. * Playback volume.
  36667. */
  36668. /**
  36669. * Playback volume.
  36670. */
  36671. volume: number;
  36672. private _onended;
  36673. /**
  36674. * Suspend playback
  36675. */
  36676. pause(): void;
  36677. /**
  36678. * Stop playback
  36679. */
  36680. stop(): void;
  36681. /**
  36682. * Start playback.
  36683. * @param startOffset Position the clip head at a specific time in seconds.
  36684. */
  36685. play(startOffset?: number): void;
  36686. }
  36687. }
  36688. declare module "babylonjs/Audio/index" {
  36689. export * from "babylonjs/Audio/analyser";
  36690. export * from "babylonjs/Audio/audioEngine";
  36691. export * from "babylonjs/Audio/audioSceneComponent";
  36692. export * from "babylonjs/Audio/sound";
  36693. export * from "babylonjs/Audio/soundTrack";
  36694. export * from "babylonjs/Audio/weightedsound";
  36695. }
  36696. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36697. import { Behavior } from "babylonjs/Behaviors/behavior";
  36698. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36699. import { BackEase } from "babylonjs/Animations/easing";
  36700. /**
  36701. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36702. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36703. */
  36704. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36705. /**
  36706. * Gets the name of the behavior.
  36707. */
  36708. readonly name: string;
  36709. /**
  36710. * The easing function used by animations
  36711. */
  36712. static EasingFunction: BackEase;
  36713. /**
  36714. * The easing mode used by animations
  36715. */
  36716. static EasingMode: number;
  36717. /**
  36718. * The duration of the animation, in milliseconds
  36719. */
  36720. transitionDuration: number;
  36721. /**
  36722. * Length of the distance animated by the transition when lower radius is reached
  36723. */
  36724. lowerRadiusTransitionRange: number;
  36725. /**
  36726. * Length of the distance animated by the transition when upper radius is reached
  36727. */
  36728. upperRadiusTransitionRange: number;
  36729. private _autoTransitionRange;
  36730. /**
  36731. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36732. */
  36733. /**
  36734. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36735. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36736. */
  36737. autoTransitionRange: boolean;
  36738. private _attachedCamera;
  36739. private _onAfterCheckInputsObserver;
  36740. private _onMeshTargetChangedObserver;
  36741. /**
  36742. * Initializes the behavior.
  36743. */
  36744. init(): void;
  36745. /**
  36746. * Attaches the behavior to its arc rotate camera.
  36747. * @param camera Defines the camera to attach the behavior to
  36748. */
  36749. attach(camera: ArcRotateCamera): void;
  36750. /**
  36751. * Detaches the behavior from its current arc rotate camera.
  36752. */
  36753. detach(): void;
  36754. private _radiusIsAnimating;
  36755. private _radiusBounceTransition;
  36756. private _animatables;
  36757. private _cachedWheelPrecision;
  36758. /**
  36759. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36760. * @param radiusLimit The limit to check against.
  36761. * @return Bool to indicate if at limit.
  36762. */
  36763. private _isRadiusAtLimit;
  36764. /**
  36765. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36766. * @param radiusDelta The delta by which to animate to. Can be negative.
  36767. */
  36768. private _applyBoundRadiusAnimation;
  36769. /**
  36770. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36771. */
  36772. protected _clearAnimationLocks(): void;
  36773. /**
  36774. * Stops and removes all animations that have been applied to the camera
  36775. */
  36776. stopAllAnimations(): void;
  36777. }
  36778. }
  36779. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36780. import { Behavior } from "babylonjs/Behaviors/behavior";
  36781. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36782. import { ExponentialEase } from "babylonjs/Animations/easing";
  36783. import { Nullable } from "babylonjs/types";
  36784. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36785. import { Vector3 } from "babylonjs/Maths/math.vector";
  36786. /**
  36787. * 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.
  36788. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36789. */
  36790. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36791. /**
  36792. * Gets the name of the behavior.
  36793. */
  36794. readonly name: string;
  36795. private _mode;
  36796. private _radiusScale;
  36797. private _positionScale;
  36798. private _defaultElevation;
  36799. private _elevationReturnTime;
  36800. private _elevationReturnWaitTime;
  36801. private _zoomStopsAnimation;
  36802. private _framingTime;
  36803. /**
  36804. * The easing function used by animations
  36805. */
  36806. static EasingFunction: ExponentialEase;
  36807. /**
  36808. * The easing mode used by animations
  36809. */
  36810. static EasingMode: number;
  36811. /**
  36812. * Sets the current mode used by the behavior
  36813. */
  36814. /**
  36815. * Gets current mode used by the behavior.
  36816. */
  36817. mode: number;
  36818. /**
  36819. * Sets the scale applied to the radius (1 by default)
  36820. */
  36821. /**
  36822. * Gets the scale applied to the radius
  36823. */
  36824. radiusScale: number;
  36825. /**
  36826. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36827. */
  36828. /**
  36829. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36830. */
  36831. positionScale: number;
  36832. /**
  36833. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36834. * behaviour is triggered, in radians.
  36835. */
  36836. /**
  36837. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36838. * behaviour is triggered, in radians.
  36839. */
  36840. defaultElevation: number;
  36841. /**
  36842. * Sets the time (in milliseconds) taken to return to the default beta position.
  36843. * Negative value indicates camera should not return to default.
  36844. */
  36845. /**
  36846. * Gets the time (in milliseconds) taken to return to the default beta position.
  36847. * Negative value indicates camera should not return to default.
  36848. */
  36849. elevationReturnTime: number;
  36850. /**
  36851. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36852. */
  36853. /**
  36854. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36855. */
  36856. elevationReturnWaitTime: number;
  36857. /**
  36858. * Sets the flag that indicates if user zooming should stop animation.
  36859. */
  36860. /**
  36861. * Gets the flag that indicates if user zooming should stop animation.
  36862. */
  36863. zoomStopsAnimation: boolean;
  36864. /**
  36865. * Sets the transition time when framing the mesh, in milliseconds
  36866. */
  36867. /**
  36868. * Gets the transition time when framing the mesh, in milliseconds
  36869. */
  36870. framingTime: number;
  36871. /**
  36872. * Define if the behavior should automatically change the configured
  36873. * camera limits and sensibilities.
  36874. */
  36875. autoCorrectCameraLimitsAndSensibility: boolean;
  36876. private _onPrePointerObservableObserver;
  36877. private _onAfterCheckInputsObserver;
  36878. private _onMeshTargetChangedObserver;
  36879. private _attachedCamera;
  36880. private _isPointerDown;
  36881. private _lastInteractionTime;
  36882. /**
  36883. * Initializes the behavior.
  36884. */
  36885. init(): void;
  36886. /**
  36887. * Attaches the behavior to its arc rotate camera.
  36888. * @param camera Defines the camera to attach the behavior to
  36889. */
  36890. attach(camera: ArcRotateCamera): void;
  36891. /**
  36892. * Detaches the behavior from its current arc rotate camera.
  36893. */
  36894. detach(): void;
  36895. private _animatables;
  36896. private _betaIsAnimating;
  36897. private _betaTransition;
  36898. private _radiusTransition;
  36899. private _vectorTransition;
  36900. /**
  36901. * Targets the given mesh and updates zoom level accordingly.
  36902. * @param mesh The mesh to target.
  36903. * @param radius Optional. If a cached radius position already exists, overrides default.
  36904. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36905. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36906. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36907. */
  36908. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36909. /**
  36910. * Targets the given mesh with its children and updates zoom level accordingly.
  36911. * @param mesh The mesh to target.
  36912. * @param radius Optional. If a cached radius position already exists, overrides default.
  36913. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36914. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36915. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36916. */
  36917. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36918. /**
  36919. * Targets the given meshes with their children and updates zoom level accordingly.
  36920. * @param meshes The mesh to target.
  36921. * @param radius Optional. If a cached radius position already exists, overrides default.
  36922. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36923. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36924. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36925. */
  36926. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36927. /**
  36928. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36929. * @param minimumWorld Determines the smaller position of the bounding box extend
  36930. * @param maximumWorld Determines the bigger position of the bounding box extend
  36931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36933. */
  36934. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36935. /**
  36936. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36937. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36938. * frustum width.
  36939. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36940. * to fully enclose the mesh in the viewing frustum.
  36941. */
  36942. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36943. /**
  36944. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36945. * is automatically returned to its default position (expected to be above ground plane).
  36946. */
  36947. private _maintainCameraAboveGround;
  36948. /**
  36949. * Returns the frustum slope based on the canvas ratio and camera FOV
  36950. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36951. */
  36952. private _getFrustumSlope;
  36953. /**
  36954. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36955. */
  36956. private _clearAnimationLocks;
  36957. /**
  36958. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36959. */
  36960. private _applyUserInteraction;
  36961. /**
  36962. * Stops and removes all animations that have been applied to the camera
  36963. */
  36964. stopAllAnimations(): void;
  36965. /**
  36966. * Gets a value indicating if the user is moving the camera
  36967. */
  36968. readonly isUserIsMoving: boolean;
  36969. /**
  36970. * The camera can move all the way towards the mesh.
  36971. */
  36972. static IgnoreBoundsSizeMode: number;
  36973. /**
  36974. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36975. */
  36976. static FitFrustumSidesMode: number;
  36977. }
  36978. }
  36979. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36980. import { Nullable } from "babylonjs/types";
  36981. import { Camera } from "babylonjs/Cameras/camera";
  36982. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36983. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  36984. /**
  36985. * Base class for Camera Pointer Inputs.
  36986. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  36987. * for example usage.
  36988. */
  36989. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  36990. /**
  36991. * Defines the camera the input is attached to.
  36992. */
  36993. abstract camera: Camera;
  36994. /**
  36995. * Whether keyboard modifier keys are pressed at time of last mouse event.
  36996. */
  36997. protected _altKey: boolean;
  36998. protected _ctrlKey: boolean;
  36999. protected _metaKey: boolean;
  37000. protected _shiftKey: boolean;
  37001. /**
  37002. * Which mouse buttons were pressed at time of last mouse event.
  37003. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37004. */
  37005. protected _buttonsPressed: number;
  37006. /**
  37007. * Defines the buttons associated with the input to handle camera move.
  37008. */
  37009. buttons: number[];
  37010. /**
  37011. * Attach the input controls to a specific dom element to get the input from.
  37012. * @param element Defines the element the controls should be listened from
  37013. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37014. */
  37015. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37016. /**
  37017. * Detach the current controls from the specified dom element.
  37018. * @param element Defines the element to stop listening the inputs from
  37019. */
  37020. detachControl(element: Nullable<HTMLElement>): void;
  37021. /**
  37022. * Gets the class name of the current input.
  37023. * @returns the class name
  37024. */
  37025. getClassName(): string;
  37026. /**
  37027. * Get the friendly name associated with the input class.
  37028. * @returns the input friendly name
  37029. */
  37030. getSimpleName(): string;
  37031. /**
  37032. * Called on pointer POINTERDOUBLETAP event.
  37033. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37034. */
  37035. protected onDoubleTap(type: string): void;
  37036. /**
  37037. * Called on pointer POINTERMOVE event if only a single touch is active.
  37038. * Override this method to provide functionality.
  37039. */
  37040. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37041. /**
  37042. * Called on pointer POINTERMOVE event if multiple touches are active.
  37043. * Override this method to provide functionality.
  37044. */
  37045. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37046. /**
  37047. * Called on JS contextmenu event.
  37048. * Override this method to provide functionality.
  37049. */
  37050. protected onContextMenu(evt: PointerEvent): void;
  37051. /**
  37052. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37053. * press.
  37054. * Override this method to provide functionality.
  37055. */
  37056. protected onButtonDown(evt: PointerEvent): void;
  37057. /**
  37058. * Called each time a new POINTERUP event occurs. Ie, for each button
  37059. * release.
  37060. * Override this method to provide functionality.
  37061. */
  37062. protected onButtonUp(evt: PointerEvent): void;
  37063. /**
  37064. * Called when window becomes inactive.
  37065. * Override this method to provide functionality.
  37066. */
  37067. protected onLostFocus(): void;
  37068. private _pointerInput;
  37069. private _observer;
  37070. private _onLostFocus;
  37071. private pointA;
  37072. private pointB;
  37073. }
  37074. }
  37075. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37076. import { Nullable } from "babylonjs/types";
  37077. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37078. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37079. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37080. /**
  37081. * Manage the pointers inputs to control an arc rotate camera.
  37082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37083. */
  37084. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37085. /**
  37086. * Defines the camera the input is attached to.
  37087. */
  37088. camera: ArcRotateCamera;
  37089. /**
  37090. * Gets the class name of the current input.
  37091. * @returns the class name
  37092. */
  37093. getClassName(): string;
  37094. /**
  37095. * Defines the buttons associated with the input to handle camera move.
  37096. */
  37097. buttons: number[];
  37098. /**
  37099. * Defines the pointer angular sensibility along the X axis or how fast is
  37100. * the camera rotating.
  37101. */
  37102. angularSensibilityX: number;
  37103. /**
  37104. * Defines the pointer angular sensibility along the Y axis or how fast is
  37105. * the camera rotating.
  37106. */
  37107. angularSensibilityY: number;
  37108. /**
  37109. * Defines the pointer pinch precision or how fast is the camera zooming.
  37110. */
  37111. pinchPrecision: number;
  37112. /**
  37113. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37114. * from 0.
  37115. * It defines the percentage of current camera.radius to use as delta when
  37116. * pinch zoom is used.
  37117. */
  37118. pinchDeltaPercentage: number;
  37119. /**
  37120. * Defines the pointer panning sensibility or how fast is the camera moving.
  37121. */
  37122. panningSensibility: number;
  37123. /**
  37124. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37125. */
  37126. multiTouchPanning: boolean;
  37127. /**
  37128. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37129. * zoom (pinch) through multitouch.
  37130. */
  37131. multiTouchPanAndZoom: boolean;
  37132. /**
  37133. * Revers pinch action direction.
  37134. */
  37135. pinchInwards: boolean;
  37136. private _isPanClick;
  37137. private _twoFingerActivityCount;
  37138. private _isPinching;
  37139. /**
  37140. * Called on pointer POINTERMOVE event if only a single touch is active.
  37141. */
  37142. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37143. /**
  37144. * Called on pointer POINTERDOUBLETAP event.
  37145. */
  37146. protected onDoubleTap(type: string): void;
  37147. /**
  37148. * Called on pointer POINTERMOVE event if multiple touches are active.
  37149. */
  37150. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37151. /**
  37152. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37153. * press.
  37154. */
  37155. protected onButtonDown(evt: PointerEvent): void;
  37156. /**
  37157. * Called each time a new POINTERUP event occurs. Ie, for each button
  37158. * release.
  37159. */
  37160. protected onButtonUp(evt: PointerEvent): void;
  37161. /**
  37162. * Called when window becomes inactive.
  37163. */
  37164. protected onLostFocus(): void;
  37165. }
  37166. }
  37167. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37168. import { Nullable } from "babylonjs/types";
  37169. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37170. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37171. /**
  37172. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37174. */
  37175. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37176. /**
  37177. * Defines the camera the input is attached to.
  37178. */
  37179. camera: ArcRotateCamera;
  37180. /**
  37181. * Defines the list of key codes associated with the up action (increase alpha)
  37182. */
  37183. keysUp: number[];
  37184. /**
  37185. * Defines the list of key codes associated with the down action (decrease alpha)
  37186. */
  37187. keysDown: number[];
  37188. /**
  37189. * Defines the list of key codes associated with the left action (increase beta)
  37190. */
  37191. keysLeft: number[];
  37192. /**
  37193. * Defines the list of key codes associated with the right action (decrease beta)
  37194. */
  37195. keysRight: number[];
  37196. /**
  37197. * Defines the list of key codes associated with the reset action.
  37198. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37199. */
  37200. keysReset: number[];
  37201. /**
  37202. * Defines the panning sensibility of the inputs.
  37203. * (How fast is the camera paning)
  37204. */
  37205. panningSensibility: number;
  37206. /**
  37207. * Defines the zooming sensibility of the inputs.
  37208. * (How fast is the camera zooming)
  37209. */
  37210. zoomingSensibility: number;
  37211. /**
  37212. * Defines wether maintaining the alt key down switch the movement mode from
  37213. * orientation to zoom.
  37214. */
  37215. useAltToZoom: boolean;
  37216. /**
  37217. * Rotation speed of the camera
  37218. */
  37219. angularSpeed: number;
  37220. private _keys;
  37221. private _ctrlPressed;
  37222. private _altPressed;
  37223. private _onCanvasBlurObserver;
  37224. private _onKeyboardObserver;
  37225. private _engine;
  37226. private _scene;
  37227. /**
  37228. * Attach the input controls to a specific dom element to get the input from.
  37229. * @param element Defines the element the controls should be listened from
  37230. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37231. */
  37232. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37233. /**
  37234. * Detach the current controls from the specified dom element.
  37235. * @param element Defines the element to stop listening the inputs from
  37236. */
  37237. detachControl(element: Nullable<HTMLElement>): void;
  37238. /**
  37239. * Update the current camera state depending on the inputs that have been used this frame.
  37240. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37241. */
  37242. checkInputs(): void;
  37243. /**
  37244. * Gets the class name of the current intput.
  37245. * @returns the class name
  37246. */
  37247. getClassName(): string;
  37248. /**
  37249. * Get the friendly name associated with the input class.
  37250. * @returns the input friendly name
  37251. */
  37252. getSimpleName(): string;
  37253. }
  37254. }
  37255. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37256. import { Nullable } from "babylonjs/types";
  37257. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37258. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37259. /**
  37260. * Manage the mouse wheel inputs to control an arc rotate camera.
  37261. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37262. */
  37263. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37264. /**
  37265. * Defines the camera the input is attached to.
  37266. */
  37267. camera: ArcRotateCamera;
  37268. /**
  37269. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37270. */
  37271. wheelPrecision: number;
  37272. /**
  37273. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37274. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37275. */
  37276. wheelDeltaPercentage: number;
  37277. private _wheel;
  37278. private _observer;
  37279. private computeDeltaFromMouseWheelLegacyEvent;
  37280. /**
  37281. * Attach the input controls to a specific dom element to get the input from.
  37282. * @param element Defines the element the controls should be listened from
  37283. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37284. */
  37285. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37286. /**
  37287. * Detach the current controls from the specified dom element.
  37288. * @param element Defines the element to stop listening the inputs from
  37289. */
  37290. detachControl(element: Nullable<HTMLElement>): void;
  37291. /**
  37292. * Gets the class name of the current intput.
  37293. * @returns the class name
  37294. */
  37295. getClassName(): string;
  37296. /**
  37297. * Get the friendly name associated with the input class.
  37298. * @returns the input friendly name
  37299. */
  37300. getSimpleName(): string;
  37301. }
  37302. }
  37303. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37304. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37305. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37306. /**
  37307. * Default Inputs manager for the ArcRotateCamera.
  37308. * It groups all the default supported inputs for ease of use.
  37309. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37310. */
  37311. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37312. /**
  37313. * Instantiates a new ArcRotateCameraInputsManager.
  37314. * @param camera Defines the camera the inputs belong to
  37315. */
  37316. constructor(camera: ArcRotateCamera);
  37317. /**
  37318. * Add mouse wheel input support to the input manager.
  37319. * @returns the current input manager
  37320. */
  37321. addMouseWheel(): ArcRotateCameraInputsManager;
  37322. /**
  37323. * Add pointers input support to the input manager.
  37324. * @returns the current input manager
  37325. */
  37326. addPointers(): ArcRotateCameraInputsManager;
  37327. /**
  37328. * Add keyboard input support to the input manager.
  37329. * @returns the current input manager
  37330. */
  37331. addKeyboard(): ArcRotateCameraInputsManager;
  37332. }
  37333. }
  37334. declare module "babylonjs/Cameras/arcRotateCamera" {
  37335. import { Observable } from "babylonjs/Misc/observable";
  37336. import { Nullable } from "babylonjs/types";
  37337. import { Scene } from "babylonjs/scene";
  37338. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37339. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37340. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37341. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37342. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37343. import { Camera } from "babylonjs/Cameras/camera";
  37344. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37345. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37346. import { Collider } from "babylonjs/Collisions/collider";
  37347. /**
  37348. * This represents an orbital type of camera.
  37349. *
  37350. * 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.
  37351. * 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.
  37352. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37353. */
  37354. export class ArcRotateCamera extends TargetCamera {
  37355. /**
  37356. * Defines the rotation angle of the camera along the longitudinal axis.
  37357. */
  37358. alpha: number;
  37359. /**
  37360. * Defines the rotation angle of the camera along the latitudinal axis.
  37361. */
  37362. beta: number;
  37363. /**
  37364. * Defines the radius of the camera from it s target point.
  37365. */
  37366. radius: number;
  37367. protected _target: Vector3;
  37368. protected _targetHost: Nullable<AbstractMesh>;
  37369. /**
  37370. * Defines the target point of the camera.
  37371. * The camera looks towards it form the radius distance.
  37372. */
  37373. target: Vector3;
  37374. /**
  37375. * Define the current local position of the camera in the scene
  37376. */
  37377. position: Vector3;
  37378. protected _upVector: Vector3;
  37379. protected _upToYMatrix: Matrix;
  37380. protected _YToUpMatrix: Matrix;
  37381. /**
  37382. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37383. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37384. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37385. */
  37386. upVector: Vector3;
  37387. /**
  37388. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37389. */
  37390. setMatUp(): void;
  37391. /**
  37392. * Current inertia value on the longitudinal axis.
  37393. * The bigger this number the longer it will take for the camera to stop.
  37394. */
  37395. inertialAlphaOffset: number;
  37396. /**
  37397. * Current inertia value on the latitudinal axis.
  37398. * The bigger this number the longer it will take for the camera to stop.
  37399. */
  37400. inertialBetaOffset: number;
  37401. /**
  37402. * Current inertia value on the radius axis.
  37403. * The bigger this number the longer it will take for the camera to stop.
  37404. */
  37405. inertialRadiusOffset: number;
  37406. /**
  37407. * Minimum allowed angle on the longitudinal axis.
  37408. * This can help limiting how the Camera is able to move in the scene.
  37409. */
  37410. lowerAlphaLimit: Nullable<number>;
  37411. /**
  37412. * Maximum allowed angle on the longitudinal axis.
  37413. * This can help limiting how the Camera is able to move in the scene.
  37414. */
  37415. upperAlphaLimit: Nullable<number>;
  37416. /**
  37417. * Minimum allowed angle on the latitudinal axis.
  37418. * This can help limiting how the Camera is able to move in the scene.
  37419. */
  37420. lowerBetaLimit: number;
  37421. /**
  37422. * Maximum allowed angle on the latitudinal axis.
  37423. * This can help limiting how the Camera is able to move in the scene.
  37424. */
  37425. upperBetaLimit: number;
  37426. /**
  37427. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37428. * This can help limiting how the Camera is able to move in the scene.
  37429. */
  37430. lowerRadiusLimit: Nullable<number>;
  37431. /**
  37432. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37433. * This can help limiting how the Camera is able to move in the scene.
  37434. */
  37435. upperRadiusLimit: Nullable<number>;
  37436. /**
  37437. * Defines the current inertia value used during panning of the camera along the X axis.
  37438. */
  37439. inertialPanningX: number;
  37440. /**
  37441. * Defines the current inertia value used during panning of the camera along the Y axis.
  37442. */
  37443. inertialPanningY: number;
  37444. /**
  37445. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37446. * Basically if your fingers moves away from more than this distance you will be considered
  37447. * in pinch mode.
  37448. */
  37449. pinchToPanMaxDistance: number;
  37450. /**
  37451. * Defines the maximum distance the camera can pan.
  37452. * This could help keeping the cammera always in your scene.
  37453. */
  37454. panningDistanceLimit: Nullable<number>;
  37455. /**
  37456. * Defines the target of the camera before paning.
  37457. */
  37458. panningOriginTarget: Vector3;
  37459. /**
  37460. * Defines the value of the inertia used during panning.
  37461. * 0 would mean stop inertia and one would mean no decelleration at all.
  37462. */
  37463. panningInertia: number;
  37464. /**
  37465. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37466. */
  37467. angularSensibilityX: number;
  37468. /**
  37469. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37470. */
  37471. angularSensibilityY: number;
  37472. /**
  37473. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37474. */
  37475. pinchPrecision: number;
  37476. /**
  37477. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37478. * It will be used instead of pinchDeltaPrecision if different from 0.
  37479. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37480. */
  37481. pinchDeltaPercentage: number;
  37482. /**
  37483. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37484. */
  37485. panningSensibility: number;
  37486. /**
  37487. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37488. */
  37489. keysUp: number[];
  37490. /**
  37491. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37492. */
  37493. keysDown: number[];
  37494. /**
  37495. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37496. */
  37497. keysLeft: number[];
  37498. /**
  37499. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37500. */
  37501. keysRight: number[];
  37502. /**
  37503. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37504. */
  37505. wheelPrecision: number;
  37506. /**
  37507. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37508. * It will be used instead of pinchDeltaPrecision if different from 0.
  37509. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37510. */
  37511. wheelDeltaPercentage: number;
  37512. /**
  37513. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37514. */
  37515. zoomOnFactor: number;
  37516. /**
  37517. * Defines a screen offset for the camera position.
  37518. */
  37519. targetScreenOffset: Vector2;
  37520. /**
  37521. * Allows the camera to be completely reversed.
  37522. * If false the camera can not arrive upside down.
  37523. */
  37524. allowUpsideDown: boolean;
  37525. /**
  37526. * Define if double tap/click is used to restore the previously saved state of the camera.
  37527. */
  37528. useInputToRestoreState: boolean;
  37529. /** @hidden */
  37530. _viewMatrix: Matrix;
  37531. /** @hidden */
  37532. _useCtrlForPanning: boolean;
  37533. /** @hidden */
  37534. _panningMouseButton: number;
  37535. /**
  37536. * Defines the input associated to the camera.
  37537. */
  37538. inputs: ArcRotateCameraInputsManager;
  37539. /** @hidden */
  37540. _reset: () => void;
  37541. /**
  37542. * Defines the allowed panning axis.
  37543. */
  37544. panningAxis: Vector3;
  37545. protected _localDirection: Vector3;
  37546. protected _transformedDirection: Vector3;
  37547. private _bouncingBehavior;
  37548. /**
  37549. * Gets the bouncing behavior of the camera if it has been enabled.
  37550. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37551. */
  37552. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37553. /**
  37554. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37555. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37556. */
  37557. useBouncingBehavior: boolean;
  37558. private _framingBehavior;
  37559. /**
  37560. * Gets the framing behavior of the camera if it has been enabled.
  37561. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37562. */
  37563. readonly framingBehavior: Nullable<FramingBehavior>;
  37564. /**
  37565. * Defines if the framing behavior of the camera is enabled on the camera.
  37566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37567. */
  37568. useFramingBehavior: boolean;
  37569. private _autoRotationBehavior;
  37570. /**
  37571. * Gets the auto rotation behavior of the camera if it has been enabled.
  37572. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37573. */
  37574. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37575. /**
  37576. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37578. */
  37579. useAutoRotationBehavior: boolean;
  37580. /**
  37581. * Observable triggered when the mesh target has been changed on the camera.
  37582. */
  37583. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37584. /**
  37585. * Event raised when the camera is colliding with a mesh.
  37586. */
  37587. onCollide: (collidedMesh: AbstractMesh) => void;
  37588. /**
  37589. * Defines whether the camera should check collision with the objects oh the scene.
  37590. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37591. */
  37592. checkCollisions: boolean;
  37593. /**
  37594. * Defines the collision radius of the camera.
  37595. * This simulates a sphere around the camera.
  37596. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37597. */
  37598. collisionRadius: Vector3;
  37599. protected _collider: Collider;
  37600. protected _previousPosition: Vector3;
  37601. protected _collisionVelocity: Vector3;
  37602. protected _newPosition: Vector3;
  37603. protected _previousAlpha: number;
  37604. protected _previousBeta: number;
  37605. protected _previousRadius: number;
  37606. protected _collisionTriggered: boolean;
  37607. protected _targetBoundingCenter: Nullable<Vector3>;
  37608. private _computationVector;
  37609. /**
  37610. * Instantiates a new ArcRotateCamera in a given scene
  37611. * @param name Defines the name of the camera
  37612. * @param alpha Defines the camera rotation along the logitudinal axis
  37613. * @param beta Defines the camera rotation along the latitudinal axis
  37614. * @param radius Defines the camera distance from its target
  37615. * @param target Defines the camera target
  37616. * @param scene Defines the scene the camera belongs to
  37617. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37618. */
  37619. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37620. /** @hidden */
  37621. _initCache(): void;
  37622. /** @hidden */
  37623. _updateCache(ignoreParentClass?: boolean): void;
  37624. protected _getTargetPosition(): Vector3;
  37625. private _storedAlpha;
  37626. private _storedBeta;
  37627. private _storedRadius;
  37628. private _storedTarget;
  37629. private _storedTargetScreenOffset;
  37630. /**
  37631. * Stores the current state of the camera (alpha, beta, radius and target)
  37632. * @returns the camera itself
  37633. */
  37634. storeState(): Camera;
  37635. /**
  37636. * @hidden
  37637. * Restored camera state. You must call storeState() first
  37638. */
  37639. _restoreStateValues(): boolean;
  37640. /** @hidden */
  37641. _isSynchronizedViewMatrix(): boolean;
  37642. /**
  37643. * Attached controls to the current camera.
  37644. * @param element Defines the element the controls should be listened from
  37645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37646. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37647. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37648. */
  37649. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37650. /**
  37651. * Detach the current controls from the camera.
  37652. * The camera will stop reacting to inputs.
  37653. * @param element Defines the element to stop listening the inputs from
  37654. */
  37655. detachControl(element: HTMLElement): void;
  37656. /** @hidden */
  37657. _checkInputs(): void;
  37658. protected _checkLimits(): void;
  37659. /**
  37660. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37661. */
  37662. rebuildAnglesAndRadius(): void;
  37663. /**
  37664. * Use a position to define the current camera related information like alpha, beta and radius
  37665. * @param position Defines the position to set the camera at
  37666. */
  37667. setPosition(position: Vector3): void;
  37668. /**
  37669. * Defines the target the camera should look at.
  37670. * This will automatically adapt alpha beta and radius to fit within the new target.
  37671. * @param target Defines the new target as a Vector or a mesh
  37672. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37673. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37674. */
  37675. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37676. /** @hidden */
  37677. _getViewMatrix(): Matrix;
  37678. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37679. /**
  37680. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37681. * @param meshes Defines the mesh to zoom on
  37682. * @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)
  37683. */
  37684. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37685. /**
  37686. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37687. * The target will be changed but the radius
  37688. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37689. * @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)
  37690. */
  37691. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37692. min: Vector3;
  37693. max: Vector3;
  37694. distance: number;
  37695. }, doNotUpdateMaxZ?: boolean): void;
  37696. /**
  37697. * @override
  37698. * Override Camera.createRigCamera
  37699. */
  37700. createRigCamera(name: string, cameraIndex: number): Camera;
  37701. /**
  37702. * @hidden
  37703. * @override
  37704. * Override Camera._updateRigCameras
  37705. */
  37706. _updateRigCameras(): void;
  37707. /**
  37708. * Destroy the camera and release the current resources hold by it.
  37709. */
  37710. dispose(): void;
  37711. /**
  37712. * Gets the current object class name.
  37713. * @return the class name
  37714. */
  37715. getClassName(): string;
  37716. }
  37717. }
  37718. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37719. import { Behavior } from "babylonjs/Behaviors/behavior";
  37720. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37721. /**
  37722. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37723. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37724. */
  37725. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37726. /**
  37727. * Gets the name of the behavior.
  37728. */
  37729. readonly name: string;
  37730. private _zoomStopsAnimation;
  37731. private _idleRotationSpeed;
  37732. private _idleRotationWaitTime;
  37733. private _idleRotationSpinupTime;
  37734. /**
  37735. * Sets the flag that indicates if user zooming should stop animation.
  37736. */
  37737. /**
  37738. * Gets the flag that indicates if user zooming should stop animation.
  37739. */
  37740. zoomStopsAnimation: boolean;
  37741. /**
  37742. * Sets the default speed at which the camera rotates around the model.
  37743. */
  37744. /**
  37745. * Gets the default speed at which the camera rotates around the model.
  37746. */
  37747. idleRotationSpeed: number;
  37748. /**
  37749. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37750. */
  37751. /**
  37752. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37753. */
  37754. idleRotationWaitTime: number;
  37755. /**
  37756. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37757. */
  37758. /**
  37759. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37760. */
  37761. idleRotationSpinupTime: number;
  37762. /**
  37763. * Gets a value indicating if the camera is currently rotating because of this behavior
  37764. */
  37765. readonly rotationInProgress: boolean;
  37766. private _onPrePointerObservableObserver;
  37767. private _onAfterCheckInputsObserver;
  37768. private _attachedCamera;
  37769. private _isPointerDown;
  37770. private _lastFrameTime;
  37771. private _lastInteractionTime;
  37772. private _cameraRotationSpeed;
  37773. /**
  37774. * Initializes the behavior.
  37775. */
  37776. init(): void;
  37777. /**
  37778. * Attaches the behavior to its arc rotate camera.
  37779. * @param camera Defines the camera to attach the behavior to
  37780. */
  37781. attach(camera: ArcRotateCamera): void;
  37782. /**
  37783. * Detaches the behavior from its current arc rotate camera.
  37784. */
  37785. detach(): void;
  37786. /**
  37787. * Returns true if user is scrolling.
  37788. * @return true if user is scrolling.
  37789. */
  37790. private _userIsZooming;
  37791. private _lastFrameRadius;
  37792. private _shouldAnimationStopForInteraction;
  37793. /**
  37794. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37795. */
  37796. private _applyUserInteraction;
  37797. private _userIsMoving;
  37798. }
  37799. }
  37800. declare module "babylonjs/Behaviors/Cameras/index" {
  37801. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37802. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37803. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37804. }
  37805. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37806. import { Mesh } from "babylonjs/Meshes/mesh";
  37807. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37808. import { Behavior } from "babylonjs/Behaviors/behavior";
  37809. /**
  37810. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37811. */
  37812. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37813. private ui;
  37814. /**
  37815. * The name of the behavior
  37816. */
  37817. name: string;
  37818. /**
  37819. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37820. */
  37821. distanceAwayFromFace: number;
  37822. /**
  37823. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37824. */
  37825. distanceAwayFromBottomOfFace: number;
  37826. private _faceVectors;
  37827. private _target;
  37828. private _scene;
  37829. private _onRenderObserver;
  37830. private _tmpMatrix;
  37831. private _tmpVector;
  37832. /**
  37833. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37834. * @param ui The transform node that should be attched to the mesh
  37835. */
  37836. constructor(ui: TransformNode);
  37837. /**
  37838. * Initializes the behavior
  37839. */
  37840. init(): void;
  37841. private _closestFace;
  37842. private _zeroVector;
  37843. private _lookAtTmpMatrix;
  37844. private _lookAtToRef;
  37845. /**
  37846. * Attaches the AttachToBoxBehavior to the passed in mesh
  37847. * @param target The mesh that the specified node will be attached to
  37848. */
  37849. attach(target: Mesh): void;
  37850. /**
  37851. * Detaches the behavior from the mesh
  37852. */
  37853. detach(): void;
  37854. }
  37855. }
  37856. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37857. import { Behavior } from "babylonjs/Behaviors/behavior";
  37858. import { Mesh } from "babylonjs/Meshes/mesh";
  37859. /**
  37860. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37861. */
  37862. export class FadeInOutBehavior implements Behavior<Mesh> {
  37863. /**
  37864. * Time in milliseconds to delay before fading in (Default: 0)
  37865. */
  37866. delay: number;
  37867. /**
  37868. * Time in milliseconds for the mesh to fade in (Default: 300)
  37869. */
  37870. fadeInTime: number;
  37871. private _millisecondsPerFrame;
  37872. private _hovered;
  37873. private _hoverValue;
  37874. private _ownerNode;
  37875. /**
  37876. * Instatiates the FadeInOutBehavior
  37877. */
  37878. constructor();
  37879. /**
  37880. * The name of the behavior
  37881. */
  37882. readonly name: string;
  37883. /**
  37884. * Initializes the behavior
  37885. */
  37886. init(): void;
  37887. /**
  37888. * Attaches the fade behavior on the passed in mesh
  37889. * @param ownerNode The mesh that will be faded in/out once attached
  37890. */
  37891. attach(ownerNode: Mesh): void;
  37892. /**
  37893. * Detaches the behavior from the mesh
  37894. */
  37895. detach(): void;
  37896. /**
  37897. * Triggers the mesh to begin fading in or out
  37898. * @param value if the object should fade in or out (true to fade in)
  37899. */
  37900. fadeIn(value: boolean): void;
  37901. private _update;
  37902. private _setAllVisibility;
  37903. }
  37904. }
  37905. declare module "babylonjs/Misc/pivotTools" {
  37906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37907. /**
  37908. * Class containing a set of static utilities functions for managing Pivots
  37909. * @hidden
  37910. */
  37911. export class PivotTools {
  37912. private static _PivotCached;
  37913. private static _OldPivotPoint;
  37914. private static _PivotTranslation;
  37915. private static _PivotTmpVector;
  37916. /** @hidden */
  37917. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37918. /** @hidden */
  37919. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37920. }
  37921. }
  37922. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37923. import { Scene } from "babylonjs/scene";
  37924. import { Vector4 } from "babylonjs/Maths/math.vector";
  37925. import { Mesh } from "babylonjs/Meshes/mesh";
  37926. import { Nullable } from "babylonjs/types";
  37927. import { Plane } from "babylonjs/Maths/math.plane";
  37928. /**
  37929. * Class containing static functions to help procedurally build meshes
  37930. */
  37931. export class PlaneBuilder {
  37932. /**
  37933. * Creates a plane mesh
  37934. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37935. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37936. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37937. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37938. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  37939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37940. * @param name defines the name of the mesh
  37941. * @param options defines the options used to create the mesh
  37942. * @param scene defines the hosting scene
  37943. * @returns the plane mesh
  37944. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37945. */
  37946. static CreatePlane(name: string, options: {
  37947. size?: number;
  37948. width?: number;
  37949. height?: number;
  37950. sideOrientation?: number;
  37951. frontUVs?: Vector4;
  37952. backUVs?: Vector4;
  37953. updatable?: boolean;
  37954. sourcePlane?: Plane;
  37955. }, scene?: Nullable<Scene>): Mesh;
  37956. }
  37957. }
  37958. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37959. import { Behavior } from "babylonjs/Behaviors/behavior";
  37960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37961. import { Observable } from "babylonjs/Misc/observable";
  37962. import { Vector3 } from "babylonjs/Maths/math.vector";
  37963. import { Ray } from "babylonjs/Culling/ray";
  37964. import "babylonjs/Meshes/Builders/planeBuilder";
  37965. /**
  37966. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37967. */
  37968. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37969. private static _AnyMouseID;
  37970. /**
  37971. * Abstract mesh the behavior is set on
  37972. */
  37973. attachedNode: AbstractMesh;
  37974. private _dragPlane;
  37975. private _scene;
  37976. private _pointerObserver;
  37977. private _beforeRenderObserver;
  37978. private static _planeScene;
  37979. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37980. /**
  37981. * 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)
  37982. */
  37983. maxDragAngle: number;
  37984. /**
  37985. * @hidden
  37986. */
  37987. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  37988. /**
  37989. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  37990. */
  37991. currentDraggingPointerID: number;
  37992. /**
  37993. * The last position where the pointer hit the drag plane in world space
  37994. */
  37995. lastDragPosition: Vector3;
  37996. /**
  37997. * If the behavior is currently in a dragging state
  37998. */
  37999. dragging: boolean;
  38000. /**
  38001. * 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)
  38002. */
  38003. dragDeltaRatio: number;
  38004. /**
  38005. * If the drag plane orientation should be updated during the dragging (Default: true)
  38006. */
  38007. updateDragPlane: boolean;
  38008. private _debugMode;
  38009. private _moving;
  38010. /**
  38011. * Fires each time the attached mesh is dragged with the pointer
  38012. * * delta between last drag position and current drag position in world space
  38013. * * dragDistance along the drag axis
  38014. * * dragPlaneNormal normal of the current drag plane used during the drag
  38015. * * dragPlanePoint in world space where the drag intersects the drag plane
  38016. */
  38017. onDragObservable: Observable<{
  38018. delta: Vector3;
  38019. dragPlanePoint: Vector3;
  38020. dragPlaneNormal: Vector3;
  38021. dragDistance: number;
  38022. pointerId: number;
  38023. }>;
  38024. /**
  38025. * Fires each time a drag begins (eg. mouse down on mesh)
  38026. */
  38027. onDragStartObservable: Observable<{
  38028. dragPlanePoint: Vector3;
  38029. pointerId: number;
  38030. }>;
  38031. /**
  38032. * Fires each time a drag ends (eg. mouse release after drag)
  38033. */
  38034. onDragEndObservable: Observable<{
  38035. dragPlanePoint: Vector3;
  38036. pointerId: number;
  38037. }>;
  38038. /**
  38039. * If the attached mesh should be moved when dragged
  38040. */
  38041. moveAttached: boolean;
  38042. /**
  38043. * If the drag behavior will react to drag events (Default: true)
  38044. */
  38045. enabled: boolean;
  38046. /**
  38047. * If pointer events should start and release the drag (Default: true)
  38048. */
  38049. startAndReleaseDragOnPointerEvents: boolean;
  38050. /**
  38051. * If camera controls should be detached during the drag
  38052. */
  38053. detachCameraControls: boolean;
  38054. /**
  38055. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38056. */
  38057. useObjectOrienationForDragging: boolean;
  38058. private _options;
  38059. /**
  38060. * Creates a pointer drag behavior that can be attached to a mesh
  38061. * @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)
  38062. */
  38063. constructor(options?: {
  38064. dragAxis?: Vector3;
  38065. dragPlaneNormal?: Vector3;
  38066. });
  38067. /**
  38068. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38069. */
  38070. validateDrag: (targetPosition: Vector3) => boolean;
  38071. /**
  38072. * The name of the behavior
  38073. */
  38074. readonly name: string;
  38075. /**
  38076. * Initializes the behavior
  38077. */
  38078. init(): void;
  38079. private _tmpVector;
  38080. private _alternatePickedPoint;
  38081. private _worldDragAxis;
  38082. private _targetPosition;
  38083. private _attachedElement;
  38084. /**
  38085. * Attaches the drag behavior the passed in mesh
  38086. * @param ownerNode The mesh that will be dragged around once attached
  38087. * @param predicate Predicate to use for pick filtering
  38088. */
  38089. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38090. /**
  38091. * Force relase the drag action by code.
  38092. */
  38093. releaseDrag(): void;
  38094. private _startDragRay;
  38095. private _lastPointerRay;
  38096. /**
  38097. * Simulates the start of a pointer drag event on the behavior
  38098. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38099. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38100. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38101. */
  38102. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38103. private _startDrag;
  38104. private _dragDelta;
  38105. private _moveDrag;
  38106. private _pickWithRayOnDragPlane;
  38107. private _pointA;
  38108. private _pointB;
  38109. private _pointC;
  38110. private _lineA;
  38111. private _lineB;
  38112. private _localAxis;
  38113. private _lookAt;
  38114. private _updateDragPlanePosition;
  38115. /**
  38116. * Detaches the behavior from the mesh
  38117. */
  38118. detach(): void;
  38119. }
  38120. }
  38121. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38122. import { Mesh } from "babylonjs/Meshes/mesh";
  38123. import { Behavior } from "babylonjs/Behaviors/behavior";
  38124. /**
  38125. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38126. */
  38127. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38128. private _dragBehaviorA;
  38129. private _dragBehaviorB;
  38130. private _startDistance;
  38131. private _initialScale;
  38132. private _targetScale;
  38133. private _ownerNode;
  38134. private _sceneRenderObserver;
  38135. /**
  38136. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38137. */
  38138. constructor();
  38139. /**
  38140. * The name of the behavior
  38141. */
  38142. readonly name: string;
  38143. /**
  38144. * Initializes the behavior
  38145. */
  38146. init(): void;
  38147. private _getCurrentDistance;
  38148. /**
  38149. * Attaches the scale behavior the passed in mesh
  38150. * @param ownerNode The mesh that will be scaled around once attached
  38151. */
  38152. attach(ownerNode: Mesh): void;
  38153. /**
  38154. * Detaches the behavior from the mesh
  38155. */
  38156. detach(): void;
  38157. }
  38158. }
  38159. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38160. import { Behavior } from "babylonjs/Behaviors/behavior";
  38161. import { Mesh } from "babylonjs/Meshes/mesh";
  38162. import { Observable } from "babylonjs/Misc/observable";
  38163. /**
  38164. * 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
  38165. */
  38166. export class SixDofDragBehavior implements Behavior<Mesh> {
  38167. private static _virtualScene;
  38168. private _ownerNode;
  38169. private _sceneRenderObserver;
  38170. private _scene;
  38171. private _targetPosition;
  38172. private _virtualOriginMesh;
  38173. private _virtualDragMesh;
  38174. private _pointerObserver;
  38175. private _moving;
  38176. private _startingOrientation;
  38177. /**
  38178. * 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)
  38179. */
  38180. private zDragFactor;
  38181. /**
  38182. * If the object should rotate to face the drag origin
  38183. */
  38184. rotateDraggedObject: boolean;
  38185. /**
  38186. * If the behavior is currently in a dragging state
  38187. */
  38188. dragging: boolean;
  38189. /**
  38190. * 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)
  38191. */
  38192. dragDeltaRatio: number;
  38193. /**
  38194. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38195. */
  38196. currentDraggingPointerID: number;
  38197. /**
  38198. * If camera controls should be detached during the drag
  38199. */
  38200. detachCameraControls: boolean;
  38201. /**
  38202. * Fires each time a drag starts
  38203. */
  38204. onDragStartObservable: Observable<{}>;
  38205. /**
  38206. * Fires each time a drag ends (eg. mouse release after drag)
  38207. */
  38208. onDragEndObservable: Observable<{}>;
  38209. /**
  38210. * 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
  38211. */
  38212. constructor();
  38213. /**
  38214. * The name of the behavior
  38215. */
  38216. readonly name: string;
  38217. /**
  38218. * Initializes the behavior
  38219. */
  38220. init(): void;
  38221. /**
  38222. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38223. */
  38224. private readonly _pointerCamera;
  38225. /**
  38226. * Attaches the scale behavior the passed in mesh
  38227. * @param ownerNode The mesh that will be scaled around once attached
  38228. */
  38229. attach(ownerNode: Mesh): void;
  38230. /**
  38231. * Detaches the behavior from the mesh
  38232. */
  38233. detach(): void;
  38234. }
  38235. }
  38236. declare module "babylonjs/Behaviors/Meshes/index" {
  38237. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38238. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38239. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38240. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38241. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38242. }
  38243. declare module "babylonjs/Behaviors/index" {
  38244. export * from "babylonjs/Behaviors/behavior";
  38245. export * from "babylonjs/Behaviors/Cameras/index";
  38246. export * from "babylonjs/Behaviors/Meshes/index";
  38247. }
  38248. declare module "babylonjs/Bones/boneIKController" {
  38249. import { Bone } from "babylonjs/Bones/bone";
  38250. import { Vector3 } from "babylonjs/Maths/math.vector";
  38251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38252. import { Nullable } from "babylonjs/types";
  38253. /**
  38254. * Class used to apply inverse kinematics to bones
  38255. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38256. */
  38257. export class BoneIKController {
  38258. private static _tmpVecs;
  38259. private static _tmpQuat;
  38260. private static _tmpMats;
  38261. /**
  38262. * Gets or sets the target mesh
  38263. */
  38264. targetMesh: AbstractMesh;
  38265. /** Gets or sets the mesh used as pole */
  38266. poleTargetMesh: AbstractMesh;
  38267. /**
  38268. * Gets or sets the bone used as pole
  38269. */
  38270. poleTargetBone: Nullable<Bone>;
  38271. /**
  38272. * Gets or sets the target position
  38273. */
  38274. targetPosition: Vector3;
  38275. /**
  38276. * Gets or sets the pole target position
  38277. */
  38278. poleTargetPosition: Vector3;
  38279. /**
  38280. * Gets or sets the pole target local offset
  38281. */
  38282. poleTargetLocalOffset: Vector3;
  38283. /**
  38284. * Gets or sets the pole angle
  38285. */
  38286. poleAngle: number;
  38287. /**
  38288. * Gets or sets the mesh associated with the controller
  38289. */
  38290. mesh: AbstractMesh;
  38291. /**
  38292. * 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)
  38293. */
  38294. slerpAmount: number;
  38295. private _bone1Quat;
  38296. private _bone1Mat;
  38297. private _bone2Ang;
  38298. private _bone1;
  38299. private _bone2;
  38300. private _bone1Length;
  38301. private _bone2Length;
  38302. private _maxAngle;
  38303. private _maxReach;
  38304. private _rightHandedSystem;
  38305. private _bendAxis;
  38306. private _slerping;
  38307. private _adjustRoll;
  38308. /**
  38309. * Gets or sets maximum allowed angle
  38310. */
  38311. maxAngle: number;
  38312. /**
  38313. * Creates a new BoneIKController
  38314. * @param mesh defines the mesh to control
  38315. * @param bone defines the bone to control
  38316. * @param options defines options to set up the controller
  38317. */
  38318. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38319. targetMesh?: AbstractMesh;
  38320. poleTargetMesh?: AbstractMesh;
  38321. poleTargetBone?: Bone;
  38322. poleTargetLocalOffset?: Vector3;
  38323. poleAngle?: number;
  38324. bendAxis?: Vector3;
  38325. maxAngle?: number;
  38326. slerpAmount?: number;
  38327. });
  38328. private _setMaxAngle;
  38329. /**
  38330. * Force the controller to update the bones
  38331. */
  38332. update(): void;
  38333. }
  38334. }
  38335. declare module "babylonjs/Bones/boneLookController" {
  38336. import { Vector3 } from "babylonjs/Maths/math.vector";
  38337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38338. import { Bone } from "babylonjs/Bones/bone";
  38339. import { Space } from "babylonjs/Maths/math.axis";
  38340. /**
  38341. * Class used to make a bone look toward a point in space
  38342. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38343. */
  38344. export class BoneLookController {
  38345. private static _tmpVecs;
  38346. private static _tmpQuat;
  38347. private static _tmpMats;
  38348. /**
  38349. * The target Vector3 that the bone will look at
  38350. */
  38351. target: Vector3;
  38352. /**
  38353. * The mesh that the bone is attached to
  38354. */
  38355. mesh: AbstractMesh;
  38356. /**
  38357. * The bone that will be looking to the target
  38358. */
  38359. bone: Bone;
  38360. /**
  38361. * The up axis of the coordinate system that is used when the bone is rotated
  38362. */
  38363. upAxis: Vector3;
  38364. /**
  38365. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38366. */
  38367. upAxisSpace: Space;
  38368. /**
  38369. * Used to make an adjustment to the yaw of the bone
  38370. */
  38371. adjustYaw: number;
  38372. /**
  38373. * Used to make an adjustment to the pitch of the bone
  38374. */
  38375. adjustPitch: number;
  38376. /**
  38377. * Used to make an adjustment to the roll of the bone
  38378. */
  38379. adjustRoll: number;
  38380. /**
  38381. * 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)
  38382. */
  38383. slerpAmount: number;
  38384. private _minYaw;
  38385. private _maxYaw;
  38386. private _minPitch;
  38387. private _maxPitch;
  38388. private _minYawSin;
  38389. private _minYawCos;
  38390. private _maxYawSin;
  38391. private _maxYawCos;
  38392. private _midYawConstraint;
  38393. private _minPitchTan;
  38394. private _maxPitchTan;
  38395. private _boneQuat;
  38396. private _slerping;
  38397. private _transformYawPitch;
  38398. private _transformYawPitchInv;
  38399. private _firstFrameSkipped;
  38400. private _yawRange;
  38401. private _fowardAxis;
  38402. /**
  38403. * Gets or sets the minimum yaw angle that the bone can look to
  38404. */
  38405. minYaw: number;
  38406. /**
  38407. * Gets or sets the maximum yaw angle that the bone can look to
  38408. */
  38409. maxYaw: number;
  38410. /**
  38411. * Gets or sets the minimum pitch angle that the bone can look to
  38412. */
  38413. minPitch: number;
  38414. /**
  38415. * Gets or sets the maximum pitch angle that the bone can look to
  38416. */
  38417. maxPitch: number;
  38418. /**
  38419. * Create a BoneLookController
  38420. * @param mesh the mesh that the bone belongs to
  38421. * @param bone the bone that will be looking to the target
  38422. * @param target the target Vector3 to look at
  38423. * @param options optional settings:
  38424. * * maxYaw: the maximum angle the bone will yaw to
  38425. * * minYaw: the minimum angle the bone will yaw to
  38426. * * maxPitch: the maximum angle the bone will pitch to
  38427. * * minPitch: the minimum angle the bone will yaw to
  38428. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38429. * * upAxis: the up axis of the coordinate system
  38430. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38431. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38432. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38433. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38434. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38435. * * adjustRoll: used to make an adjustment to the roll of the bone
  38436. **/
  38437. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38438. maxYaw?: number;
  38439. minYaw?: number;
  38440. maxPitch?: number;
  38441. minPitch?: number;
  38442. slerpAmount?: number;
  38443. upAxis?: Vector3;
  38444. upAxisSpace?: Space;
  38445. yawAxis?: Vector3;
  38446. pitchAxis?: Vector3;
  38447. adjustYaw?: number;
  38448. adjustPitch?: number;
  38449. adjustRoll?: number;
  38450. });
  38451. /**
  38452. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38453. */
  38454. update(): void;
  38455. private _getAngleDiff;
  38456. private _getAngleBetween;
  38457. private _isAngleBetween;
  38458. }
  38459. }
  38460. declare module "babylonjs/Bones/index" {
  38461. export * from "babylonjs/Bones/bone";
  38462. export * from "babylonjs/Bones/boneIKController";
  38463. export * from "babylonjs/Bones/boneLookController";
  38464. export * from "babylonjs/Bones/skeleton";
  38465. }
  38466. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38467. import { Nullable } from "babylonjs/types";
  38468. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38469. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38470. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38471. /**
  38472. * Manage the gamepad inputs to control an arc rotate camera.
  38473. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38474. */
  38475. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38476. /**
  38477. * Defines the camera the input is attached to.
  38478. */
  38479. camera: ArcRotateCamera;
  38480. /**
  38481. * Defines the gamepad the input is gathering event from.
  38482. */
  38483. gamepad: Nullable<Gamepad>;
  38484. /**
  38485. * Defines the gamepad rotation sensiblity.
  38486. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38487. */
  38488. gamepadRotationSensibility: number;
  38489. /**
  38490. * Defines the gamepad move sensiblity.
  38491. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38492. */
  38493. gamepadMoveSensibility: number;
  38494. private _yAxisScale;
  38495. /**
  38496. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38497. */
  38498. invertYAxis: boolean;
  38499. private _onGamepadConnectedObserver;
  38500. private _onGamepadDisconnectedObserver;
  38501. /**
  38502. * Attach the input controls to a specific dom element to get the input from.
  38503. * @param element Defines the element the controls should be listened from
  38504. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38505. */
  38506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38507. /**
  38508. * Detach the current controls from the specified dom element.
  38509. * @param element Defines the element to stop listening the inputs from
  38510. */
  38511. detachControl(element: Nullable<HTMLElement>): void;
  38512. /**
  38513. * Update the current camera state depending on the inputs that have been used this frame.
  38514. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38515. */
  38516. checkInputs(): void;
  38517. /**
  38518. * Gets the class name of the current intput.
  38519. * @returns the class name
  38520. */
  38521. getClassName(): string;
  38522. /**
  38523. * Get the friendly name associated with the input class.
  38524. * @returns the input friendly name
  38525. */
  38526. getSimpleName(): string;
  38527. }
  38528. }
  38529. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38530. import { Nullable } from "babylonjs/types";
  38531. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38532. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38533. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38534. interface ArcRotateCameraInputsManager {
  38535. /**
  38536. * Add orientation input support to the input manager.
  38537. * @returns the current input manager
  38538. */
  38539. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38540. }
  38541. }
  38542. /**
  38543. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38544. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38545. */
  38546. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38547. /**
  38548. * Defines the camera the input is attached to.
  38549. */
  38550. camera: ArcRotateCamera;
  38551. /**
  38552. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38553. */
  38554. alphaCorrection: number;
  38555. /**
  38556. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38557. */
  38558. gammaCorrection: number;
  38559. private _alpha;
  38560. private _gamma;
  38561. private _dirty;
  38562. private _deviceOrientationHandler;
  38563. /**
  38564. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38565. */
  38566. constructor();
  38567. /**
  38568. * Attach the input controls to a specific dom element to get the input from.
  38569. * @param element Defines the element the controls should be listened from
  38570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38571. */
  38572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38573. /** @hidden */
  38574. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38575. /**
  38576. * Update the current camera state depending on the inputs that have been used this frame.
  38577. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38578. */
  38579. checkInputs(): void;
  38580. /**
  38581. * Detach the current controls from the specified dom element.
  38582. * @param element Defines the element to stop listening the inputs from
  38583. */
  38584. detachControl(element: Nullable<HTMLElement>): void;
  38585. /**
  38586. * Gets the class name of the current intput.
  38587. * @returns the class name
  38588. */
  38589. getClassName(): string;
  38590. /**
  38591. * Get the friendly name associated with the input class.
  38592. * @returns the input friendly name
  38593. */
  38594. getSimpleName(): string;
  38595. }
  38596. }
  38597. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38598. import { Nullable } from "babylonjs/types";
  38599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38600. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38601. /**
  38602. * Listen to mouse events to control the camera.
  38603. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38604. */
  38605. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38606. /**
  38607. * Defines the camera the input is attached to.
  38608. */
  38609. camera: FlyCamera;
  38610. /**
  38611. * Defines if touch is enabled. (Default is true.)
  38612. */
  38613. touchEnabled: boolean;
  38614. /**
  38615. * Defines the buttons associated with the input to handle camera rotation.
  38616. */
  38617. buttons: number[];
  38618. /**
  38619. * Assign buttons for Yaw control.
  38620. */
  38621. buttonsYaw: number[];
  38622. /**
  38623. * Assign buttons for Pitch control.
  38624. */
  38625. buttonsPitch: number[];
  38626. /**
  38627. * Assign buttons for Roll control.
  38628. */
  38629. buttonsRoll: number[];
  38630. /**
  38631. * Detect if any button is being pressed while mouse is moved.
  38632. * -1 = Mouse locked.
  38633. * 0 = Left button.
  38634. * 1 = Middle Button.
  38635. * 2 = Right Button.
  38636. */
  38637. activeButton: number;
  38638. /**
  38639. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38640. * Higher values reduce its sensitivity.
  38641. */
  38642. angularSensibility: number;
  38643. private _mousemoveCallback;
  38644. private _observer;
  38645. private _rollObserver;
  38646. private previousPosition;
  38647. private noPreventDefault;
  38648. private element;
  38649. /**
  38650. * Listen to mouse events to control the camera.
  38651. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38652. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38653. */
  38654. constructor(touchEnabled?: boolean);
  38655. /**
  38656. * Attach the mouse control to the HTML DOM element.
  38657. * @param element Defines the element that listens to the input events.
  38658. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38659. */
  38660. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38661. /**
  38662. * Detach the current controls from the specified dom element.
  38663. * @param element Defines the element to stop listening the inputs from
  38664. */
  38665. detachControl(element: Nullable<HTMLElement>): void;
  38666. /**
  38667. * Gets the class name of the current input.
  38668. * @returns the class name.
  38669. */
  38670. getClassName(): string;
  38671. /**
  38672. * Get the friendly name associated with the input class.
  38673. * @returns the input's friendly name.
  38674. */
  38675. getSimpleName(): string;
  38676. private _pointerInput;
  38677. private _onMouseMove;
  38678. /**
  38679. * Rotate camera by mouse offset.
  38680. */
  38681. private rotateCamera;
  38682. }
  38683. }
  38684. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38685. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38686. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38687. /**
  38688. * Default Inputs manager for the FlyCamera.
  38689. * It groups all the default supported inputs for ease of use.
  38690. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38691. */
  38692. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38693. /**
  38694. * Instantiates a new FlyCameraInputsManager.
  38695. * @param camera Defines the camera the inputs belong to.
  38696. */
  38697. constructor(camera: FlyCamera);
  38698. /**
  38699. * Add keyboard input support to the input manager.
  38700. * @returns the new FlyCameraKeyboardMoveInput().
  38701. */
  38702. addKeyboard(): FlyCameraInputsManager;
  38703. /**
  38704. * Add mouse input support to the input manager.
  38705. * @param touchEnabled Enable touch screen support.
  38706. * @returns the new FlyCameraMouseInput().
  38707. */
  38708. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38709. }
  38710. }
  38711. declare module "babylonjs/Cameras/flyCamera" {
  38712. import { Scene } from "babylonjs/scene";
  38713. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38715. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38716. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38717. /**
  38718. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38719. * such as in a 3D Space Shooter or a Flight Simulator.
  38720. */
  38721. export class FlyCamera extends TargetCamera {
  38722. /**
  38723. * Define the collision ellipsoid of the camera.
  38724. * This is helpful for simulating a camera body, like a player's body.
  38725. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38726. */
  38727. ellipsoid: Vector3;
  38728. /**
  38729. * Define an offset for the position of the ellipsoid around the camera.
  38730. * This can be helpful if the camera is attached away from the player's body center,
  38731. * such as at its head.
  38732. */
  38733. ellipsoidOffset: Vector3;
  38734. /**
  38735. * Enable or disable collisions of the camera with the rest of the scene objects.
  38736. */
  38737. checkCollisions: boolean;
  38738. /**
  38739. * Enable or disable gravity on the camera.
  38740. */
  38741. applyGravity: boolean;
  38742. /**
  38743. * Define the current direction the camera is moving to.
  38744. */
  38745. cameraDirection: Vector3;
  38746. /**
  38747. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38748. * This overrides and empties cameraRotation.
  38749. */
  38750. rotationQuaternion: Quaternion;
  38751. /**
  38752. * Track Roll to maintain the wanted Rolling when looking around.
  38753. */
  38754. _trackRoll: number;
  38755. /**
  38756. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38757. */
  38758. rollCorrect: number;
  38759. /**
  38760. * Mimic a banked turn, Rolling the camera when Yawing.
  38761. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38762. */
  38763. bankedTurn: boolean;
  38764. /**
  38765. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38766. */
  38767. bankedTurnLimit: number;
  38768. /**
  38769. * Value of 0 disables the banked Roll.
  38770. * Value of 1 is equal to the Yaw angle in radians.
  38771. */
  38772. bankedTurnMultiplier: number;
  38773. /**
  38774. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38775. */
  38776. inputs: FlyCameraInputsManager;
  38777. /**
  38778. * Gets the input sensibility for mouse input.
  38779. * Higher values reduce sensitivity.
  38780. */
  38781. /**
  38782. * Sets the input sensibility for a mouse input.
  38783. * Higher values reduce sensitivity.
  38784. */
  38785. angularSensibility: number;
  38786. /**
  38787. * Get the keys for camera movement forward.
  38788. */
  38789. /**
  38790. * Set the keys for camera movement forward.
  38791. */
  38792. keysForward: number[];
  38793. /**
  38794. * Get the keys for camera movement backward.
  38795. */
  38796. keysBackward: number[];
  38797. /**
  38798. * Get the keys for camera movement up.
  38799. */
  38800. /**
  38801. * Set the keys for camera movement up.
  38802. */
  38803. keysUp: number[];
  38804. /**
  38805. * Get the keys for camera movement down.
  38806. */
  38807. /**
  38808. * Set the keys for camera movement down.
  38809. */
  38810. keysDown: number[];
  38811. /**
  38812. * Get the keys for camera movement left.
  38813. */
  38814. /**
  38815. * Set the keys for camera movement left.
  38816. */
  38817. keysLeft: number[];
  38818. /**
  38819. * Set the keys for camera movement right.
  38820. */
  38821. /**
  38822. * Set the keys for camera movement right.
  38823. */
  38824. keysRight: number[];
  38825. /**
  38826. * Event raised when the camera collides with a mesh in the scene.
  38827. */
  38828. onCollide: (collidedMesh: AbstractMesh) => void;
  38829. private _collider;
  38830. private _needMoveForGravity;
  38831. private _oldPosition;
  38832. private _diffPosition;
  38833. private _newPosition;
  38834. /** @hidden */
  38835. _localDirection: Vector3;
  38836. /** @hidden */
  38837. _transformedDirection: Vector3;
  38838. /**
  38839. * Instantiates a FlyCamera.
  38840. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38841. * such as in a 3D Space Shooter or a Flight Simulator.
  38842. * @param name Define the name of the camera in the scene.
  38843. * @param position Define the starting position of the camera in the scene.
  38844. * @param scene Define the scene the camera belongs to.
  38845. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38846. */
  38847. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38848. /**
  38849. * Attach a control to the HTML DOM element.
  38850. * @param element Defines the element that listens to the input events.
  38851. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38852. */
  38853. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38854. /**
  38855. * Detach a control from the HTML DOM element.
  38856. * The camera will stop reacting to that input.
  38857. * @param element Defines the element that listens to the input events.
  38858. */
  38859. detachControl(element: HTMLElement): void;
  38860. private _collisionMask;
  38861. /**
  38862. * Get the mask that the camera ignores in collision events.
  38863. */
  38864. /**
  38865. * Set the mask that the camera ignores in collision events.
  38866. */
  38867. collisionMask: number;
  38868. /** @hidden */
  38869. _collideWithWorld(displacement: Vector3): void;
  38870. /** @hidden */
  38871. private _onCollisionPositionChange;
  38872. /** @hidden */
  38873. _checkInputs(): void;
  38874. /** @hidden */
  38875. _decideIfNeedsToMove(): boolean;
  38876. /** @hidden */
  38877. _updatePosition(): void;
  38878. /**
  38879. * Restore the Roll to its target value at the rate specified.
  38880. * @param rate - Higher means slower restoring.
  38881. * @hidden
  38882. */
  38883. restoreRoll(rate: number): void;
  38884. /**
  38885. * Destroy the camera and release the current resources held by it.
  38886. */
  38887. dispose(): void;
  38888. /**
  38889. * Get the current object class name.
  38890. * @returns the class name.
  38891. */
  38892. getClassName(): string;
  38893. }
  38894. }
  38895. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38896. import { Nullable } from "babylonjs/types";
  38897. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38898. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38899. /**
  38900. * Listen to keyboard events to control the camera.
  38901. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38902. */
  38903. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38904. /**
  38905. * Defines the camera the input is attached to.
  38906. */
  38907. camera: FlyCamera;
  38908. /**
  38909. * The list of keyboard keys used to control the forward move of the camera.
  38910. */
  38911. keysForward: number[];
  38912. /**
  38913. * The list of keyboard keys used to control the backward move of the camera.
  38914. */
  38915. keysBackward: number[];
  38916. /**
  38917. * The list of keyboard keys used to control the forward move of the camera.
  38918. */
  38919. keysUp: number[];
  38920. /**
  38921. * The list of keyboard keys used to control the backward move of the camera.
  38922. */
  38923. keysDown: number[];
  38924. /**
  38925. * The list of keyboard keys used to control the right strafe move of the camera.
  38926. */
  38927. keysRight: number[];
  38928. /**
  38929. * The list of keyboard keys used to control the left strafe move of the camera.
  38930. */
  38931. keysLeft: number[];
  38932. private _keys;
  38933. private _onCanvasBlurObserver;
  38934. private _onKeyboardObserver;
  38935. private _engine;
  38936. private _scene;
  38937. /**
  38938. * Attach the input controls to a specific dom element to get the input from.
  38939. * @param element Defines the element the controls should be listened from
  38940. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38941. */
  38942. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38943. /**
  38944. * Detach the current controls from the specified dom element.
  38945. * @param element Defines the element to stop listening the inputs from
  38946. */
  38947. detachControl(element: Nullable<HTMLElement>): void;
  38948. /**
  38949. * Gets the class name of the current intput.
  38950. * @returns the class name
  38951. */
  38952. getClassName(): string;
  38953. /** @hidden */
  38954. _onLostFocus(e: FocusEvent): void;
  38955. /**
  38956. * Get the friendly name associated with the input class.
  38957. * @returns the input friendly name
  38958. */
  38959. getSimpleName(): string;
  38960. /**
  38961. * Update the current camera state depending on the inputs that have been used this frame.
  38962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38963. */
  38964. checkInputs(): void;
  38965. }
  38966. }
  38967. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38968. import { Nullable } from "babylonjs/types";
  38969. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38970. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38971. /**
  38972. * Manage the mouse wheel inputs to control a follow camera.
  38973. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38974. */
  38975. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38976. /**
  38977. * Defines the camera the input is attached to.
  38978. */
  38979. camera: FollowCamera;
  38980. /**
  38981. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38982. */
  38983. axisControlRadius: boolean;
  38984. /**
  38985. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  38986. */
  38987. axisControlHeight: boolean;
  38988. /**
  38989. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  38990. */
  38991. axisControlRotation: boolean;
  38992. /**
  38993. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  38994. * relation to mouseWheel events.
  38995. */
  38996. wheelPrecision: number;
  38997. /**
  38998. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  38999. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39000. */
  39001. wheelDeltaPercentage: number;
  39002. private _wheel;
  39003. private _observer;
  39004. /**
  39005. * Attach the input controls to a specific dom element to get the input from.
  39006. * @param element Defines the element the controls should be listened from
  39007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39008. */
  39009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39010. /**
  39011. * Detach the current controls from the specified dom element.
  39012. * @param element Defines the element to stop listening the inputs from
  39013. */
  39014. detachControl(element: Nullable<HTMLElement>): void;
  39015. /**
  39016. * Gets the class name of the current intput.
  39017. * @returns the class name
  39018. */
  39019. getClassName(): string;
  39020. /**
  39021. * Get the friendly name associated with the input class.
  39022. * @returns the input friendly name
  39023. */
  39024. getSimpleName(): string;
  39025. }
  39026. }
  39027. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39028. import { Nullable } from "babylonjs/types";
  39029. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39030. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39031. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39032. /**
  39033. * Manage the pointers inputs to control an follow camera.
  39034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39035. */
  39036. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39037. /**
  39038. * Defines the camera the input is attached to.
  39039. */
  39040. camera: FollowCamera;
  39041. /**
  39042. * Gets the class name of the current input.
  39043. * @returns the class name
  39044. */
  39045. getClassName(): string;
  39046. /**
  39047. * Defines the pointer angular sensibility along the X axis or how fast is
  39048. * the camera rotating.
  39049. * A negative number will reverse the axis direction.
  39050. */
  39051. angularSensibilityX: number;
  39052. /**
  39053. * Defines the pointer angular sensibility along the Y axis or how fast is
  39054. * the camera rotating.
  39055. * A negative number will reverse the axis direction.
  39056. */
  39057. angularSensibilityY: number;
  39058. /**
  39059. * Defines the pointer pinch precision or how fast is the camera zooming.
  39060. * A negative number will reverse the axis direction.
  39061. */
  39062. pinchPrecision: number;
  39063. /**
  39064. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39065. * from 0.
  39066. * It defines the percentage of current camera.radius to use as delta when
  39067. * pinch zoom is used.
  39068. */
  39069. pinchDeltaPercentage: number;
  39070. /**
  39071. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39072. */
  39073. axisXControlRadius: boolean;
  39074. /**
  39075. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39076. */
  39077. axisXControlHeight: boolean;
  39078. /**
  39079. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39080. */
  39081. axisXControlRotation: boolean;
  39082. /**
  39083. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39084. */
  39085. axisYControlRadius: boolean;
  39086. /**
  39087. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39088. */
  39089. axisYControlHeight: boolean;
  39090. /**
  39091. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39092. */
  39093. axisYControlRotation: boolean;
  39094. /**
  39095. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39096. */
  39097. axisPinchControlRadius: boolean;
  39098. /**
  39099. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39100. */
  39101. axisPinchControlHeight: boolean;
  39102. /**
  39103. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39104. */
  39105. axisPinchControlRotation: boolean;
  39106. /**
  39107. * Log error messages if basic misconfiguration has occurred.
  39108. */
  39109. warningEnable: boolean;
  39110. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39111. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39112. private _warningCounter;
  39113. private _warning;
  39114. }
  39115. }
  39116. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39117. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39118. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39119. /**
  39120. * Default Inputs manager for the FollowCamera.
  39121. * It groups all the default supported inputs for ease of use.
  39122. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39123. */
  39124. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39125. /**
  39126. * Instantiates a new FollowCameraInputsManager.
  39127. * @param camera Defines the camera the inputs belong to
  39128. */
  39129. constructor(camera: FollowCamera);
  39130. /**
  39131. * Add keyboard input support to the input manager.
  39132. * @returns the current input manager
  39133. */
  39134. addKeyboard(): FollowCameraInputsManager;
  39135. /**
  39136. * Add mouse wheel input support to the input manager.
  39137. * @returns the current input manager
  39138. */
  39139. addMouseWheel(): FollowCameraInputsManager;
  39140. /**
  39141. * Add pointers input support to the input manager.
  39142. * @returns the current input manager
  39143. */
  39144. addPointers(): FollowCameraInputsManager;
  39145. /**
  39146. * Add orientation input support to the input manager.
  39147. * @returns the current input manager
  39148. */
  39149. addVRDeviceOrientation(): FollowCameraInputsManager;
  39150. }
  39151. }
  39152. declare module "babylonjs/Cameras/followCamera" {
  39153. import { Nullable } from "babylonjs/types";
  39154. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39155. import { Scene } from "babylonjs/scene";
  39156. import { Vector3 } from "babylonjs/Maths/math.vector";
  39157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39158. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39159. /**
  39160. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39161. * an arc rotate version arcFollowCamera are available.
  39162. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39163. */
  39164. export class FollowCamera extends TargetCamera {
  39165. /**
  39166. * Distance the follow camera should follow an object at
  39167. */
  39168. radius: number;
  39169. /**
  39170. * Minimum allowed distance of the camera to the axis of rotation
  39171. * (The camera can not get closer).
  39172. * This can help limiting how the Camera is able to move in the scene.
  39173. */
  39174. lowerRadiusLimit: Nullable<number>;
  39175. /**
  39176. * Maximum allowed distance of the camera to the axis of rotation
  39177. * (The camera can not get further).
  39178. * This can help limiting how the Camera is able to move in the scene.
  39179. */
  39180. upperRadiusLimit: Nullable<number>;
  39181. /**
  39182. * Define a rotation offset between the camera and the object it follows
  39183. */
  39184. rotationOffset: number;
  39185. /**
  39186. * Minimum allowed angle to camera position relative to target object.
  39187. * This can help limiting how the Camera is able to move in the scene.
  39188. */
  39189. lowerRotationOffsetLimit: Nullable<number>;
  39190. /**
  39191. * Maximum allowed angle to camera position relative to target object.
  39192. * This can help limiting how the Camera is able to move in the scene.
  39193. */
  39194. upperRotationOffsetLimit: Nullable<number>;
  39195. /**
  39196. * Define a height offset between the camera and the object it follows.
  39197. * It can help following an object from the top (like a car chaing a plane)
  39198. */
  39199. heightOffset: number;
  39200. /**
  39201. * Minimum allowed height of camera position relative to target object.
  39202. * This can help limiting how the Camera is able to move in the scene.
  39203. */
  39204. lowerHeightOffsetLimit: Nullable<number>;
  39205. /**
  39206. * Maximum allowed height of camera position relative to target object.
  39207. * This can help limiting how the Camera is able to move in the scene.
  39208. */
  39209. upperHeightOffsetLimit: Nullable<number>;
  39210. /**
  39211. * Define how fast the camera can accelerate to follow it s target.
  39212. */
  39213. cameraAcceleration: number;
  39214. /**
  39215. * Define the speed limit of the camera following an object.
  39216. */
  39217. maxCameraSpeed: number;
  39218. /**
  39219. * Define the target of the camera.
  39220. */
  39221. lockedTarget: Nullable<AbstractMesh>;
  39222. /**
  39223. * Defines the input associated with the camera.
  39224. */
  39225. inputs: FollowCameraInputsManager;
  39226. /**
  39227. * Instantiates the follow camera.
  39228. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39229. * @param name Define the name of the camera in the scene
  39230. * @param position Define the position of the camera
  39231. * @param scene Define the scene the camera belong to
  39232. * @param lockedTarget Define the target of the camera
  39233. */
  39234. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39235. private _follow;
  39236. /**
  39237. * Attached controls to the current camera.
  39238. * @param element Defines the element the controls should be listened from
  39239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39240. */
  39241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39242. /**
  39243. * Detach the current controls from the camera.
  39244. * The camera will stop reacting to inputs.
  39245. * @param element Defines the element to stop listening the inputs from
  39246. */
  39247. detachControl(element: HTMLElement): void;
  39248. /** @hidden */
  39249. _checkInputs(): void;
  39250. private _checkLimits;
  39251. /**
  39252. * Gets the camera class name.
  39253. * @returns the class name
  39254. */
  39255. getClassName(): string;
  39256. }
  39257. /**
  39258. * Arc Rotate version of the follow camera.
  39259. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39260. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39261. */
  39262. export class ArcFollowCamera extends TargetCamera {
  39263. /** The longitudinal angle of the camera */
  39264. alpha: number;
  39265. /** The latitudinal angle of the camera */
  39266. beta: number;
  39267. /** The radius of the camera from its target */
  39268. radius: number;
  39269. /** Define the camera target (the messh it should follow) */
  39270. target: Nullable<AbstractMesh>;
  39271. private _cartesianCoordinates;
  39272. /**
  39273. * Instantiates a new ArcFollowCamera
  39274. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39275. * @param name Define the name of the camera
  39276. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39277. * @param beta Define the rotation angle of the camera around the elevation axis
  39278. * @param radius Define the radius of the camera from its target point
  39279. * @param target Define the target of the camera
  39280. * @param scene Define the scene the camera belongs to
  39281. */
  39282. constructor(name: string,
  39283. /** The longitudinal angle of the camera */
  39284. alpha: number,
  39285. /** The latitudinal angle of the camera */
  39286. beta: number,
  39287. /** The radius of the camera from its target */
  39288. radius: number,
  39289. /** Define the camera target (the messh it should follow) */
  39290. target: Nullable<AbstractMesh>, scene: Scene);
  39291. private _follow;
  39292. /** @hidden */
  39293. _checkInputs(): void;
  39294. /**
  39295. * Returns the class name of the object.
  39296. * It is mostly used internally for serialization purposes.
  39297. */
  39298. getClassName(): string;
  39299. }
  39300. }
  39301. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39302. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39303. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39304. import { Nullable } from "babylonjs/types";
  39305. /**
  39306. * Manage the keyboard inputs to control the movement of a follow camera.
  39307. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39308. */
  39309. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39310. /**
  39311. * Defines the camera the input is attached to.
  39312. */
  39313. camera: FollowCamera;
  39314. /**
  39315. * Defines the list of key codes associated with the up action (increase heightOffset)
  39316. */
  39317. keysHeightOffsetIncr: number[];
  39318. /**
  39319. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39320. */
  39321. keysHeightOffsetDecr: number[];
  39322. /**
  39323. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39324. */
  39325. keysHeightOffsetModifierAlt: boolean;
  39326. /**
  39327. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39328. */
  39329. keysHeightOffsetModifierCtrl: boolean;
  39330. /**
  39331. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39332. */
  39333. keysHeightOffsetModifierShift: boolean;
  39334. /**
  39335. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39336. */
  39337. keysRotationOffsetIncr: number[];
  39338. /**
  39339. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39340. */
  39341. keysRotationOffsetDecr: number[];
  39342. /**
  39343. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39344. */
  39345. keysRotationOffsetModifierAlt: boolean;
  39346. /**
  39347. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39348. */
  39349. keysRotationOffsetModifierCtrl: boolean;
  39350. /**
  39351. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39352. */
  39353. keysRotationOffsetModifierShift: boolean;
  39354. /**
  39355. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39356. */
  39357. keysRadiusIncr: number[];
  39358. /**
  39359. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39360. */
  39361. keysRadiusDecr: number[];
  39362. /**
  39363. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39364. */
  39365. keysRadiusModifierAlt: boolean;
  39366. /**
  39367. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39368. */
  39369. keysRadiusModifierCtrl: boolean;
  39370. /**
  39371. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39372. */
  39373. keysRadiusModifierShift: boolean;
  39374. /**
  39375. * Defines the rate of change of heightOffset.
  39376. */
  39377. heightSensibility: number;
  39378. /**
  39379. * Defines the rate of change of rotationOffset.
  39380. */
  39381. rotationSensibility: number;
  39382. /**
  39383. * Defines the rate of change of radius.
  39384. */
  39385. radiusSensibility: number;
  39386. private _keys;
  39387. private _ctrlPressed;
  39388. private _altPressed;
  39389. private _shiftPressed;
  39390. private _onCanvasBlurObserver;
  39391. private _onKeyboardObserver;
  39392. private _engine;
  39393. private _scene;
  39394. /**
  39395. * Attach the input controls to a specific dom element to get the input from.
  39396. * @param element Defines the element the controls should be listened from
  39397. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39398. */
  39399. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39400. /**
  39401. * Detach the current controls from the specified dom element.
  39402. * @param element Defines the element to stop listening the inputs from
  39403. */
  39404. detachControl(element: Nullable<HTMLElement>): void;
  39405. /**
  39406. * Update the current camera state depending on the inputs that have been used this frame.
  39407. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39408. */
  39409. checkInputs(): void;
  39410. /**
  39411. * Gets the class name of the current input.
  39412. * @returns the class name
  39413. */
  39414. getClassName(): string;
  39415. /**
  39416. * Get the friendly name associated with the input class.
  39417. * @returns the input friendly name
  39418. */
  39419. getSimpleName(): string;
  39420. /**
  39421. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39422. * allow modification of the heightOffset value.
  39423. */
  39424. private _modifierHeightOffset;
  39425. /**
  39426. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39427. * allow modification of the rotationOffset value.
  39428. */
  39429. private _modifierRotationOffset;
  39430. /**
  39431. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39432. * allow modification of the radius value.
  39433. */
  39434. private _modifierRadius;
  39435. }
  39436. }
  39437. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39438. import { Nullable } from "babylonjs/types";
  39439. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39440. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39441. import { Observable } from "babylonjs/Misc/observable";
  39442. module "babylonjs/Cameras/freeCameraInputsManager" {
  39443. interface FreeCameraInputsManager {
  39444. /**
  39445. * @hidden
  39446. */
  39447. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39448. /**
  39449. * Add orientation input support to the input manager.
  39450. * @returns the current input manager
  39451. */
  39452. addDeviceOrientation(): FreeCameraInputsManager;
  39453. }
  39454. }
  39455. /**
  39456. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39457. * Screen rotation is taken into account.
  39458. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39459. */
  39460. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39461. private _camera;
  39462. private _screenOrientationAngle;
  39463. private _constantTranform;
  39464. private _screenQuaternion;
  39465. private _alpha;
  39466. private _beta;
  39467. private _gamma;
  39468. /**
  39469. * Can be used to detect if a device orientation sensor is availible on a device
  39470. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39471. * @returns a promise that will resolve on orientation change
  39472. */
  39473. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39474. /**
  39475. * @hidden
  39476. */
  39477. _onDeviceOrientationChangedObservable: Observable<void>;
  39478. /**
  39479. * Instantiates a new input
  39480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39481. */
  39482. constructor();
  39483. /**
  39484. * Define the camera controlled by the input.
  39485. */
  39486. camera: FreeCamera;
  39487. /**
  39488. * Attach the input controls to a specific dom element to get the input from.
  39489. * @param element Defines the element the controls should be listened from
  39490. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39491. */
  39492. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39493. private _orientationChanged;
  39494. private _deviceOrientation;
  39495. /**
  39496. * Detach the current controls from the specified dom element.
  39497. * @param element Defines the element to stop listening the inputs from
  39498. */
  39499. detachControl(element: Nullable<HTMLElement>): void;
  39500. /**
  39501. * Update the current camera state depending on the inputs that have been used this frame.
  39502. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39503. */
  39504. checkInputs(): void;
  39505. /**
  39506. * Gets the class name of the current intput.
  39507. * @returns the class name
  39508. */
  39509. getClassName(): string;
  39510. /**
  39511. * Get the friendly name associated with the input class.
  39512. * @returns the input friendly name
  39513. */
  39514. getSimpleName(): string;
  39515. }
  39516. }
  39517. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39518. import { Nullable } from "babylonjs/types";
  39519. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39520. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39521. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39522. /**
  39523. * Manage the gamepad inputs to control a free camera.
  39524. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39525. */
  39526. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39527. /**
  39528. * Define the camera the input is attached to.
  39529. */
  39530. camera: FreeCamera;
  39531. /**
  39532. * Define the Gamepad controlling the input
  39533. */
  39534. gamepad: Nullable<Gamepad>;
  39535. /**
  39536. * Defines the gamepad rotation sensiblity.
  39537. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39538. */
  39539. gamepadAngularSensibility: number;
  39540. /**
  39541. * Defines the gamepad move sensiblity.
  39542. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39543. */
  39544. gamepadMoveSensibility: number;
  39545. private _yAxisScale;
  39546. /**
  39547. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39548. */
  39549. invertYAxis: boolean;
  39550. private _onGamepadConnectedObserver;
  39551. private _onGamepadDisconnectedObserver;
  39552. private _cameraTransform;
  39553. private _deltaTransform;
  39554. private _vector3;
  39555. private _vector2;
  39556. /**
  39557. * Attach the input controls to a specific dom element to get the input from.
  39558. * @param element Defines the element the controls should be listened from
  39559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39560. */
  39561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39562. /**
  39563. * Detach the current controls from the specified dom element.
  39564. * @param element Defines the element to stop listening the inputs from
  39565. */
  39566. detachControl(element: Nullable<HTMLElement>): void;
  39567. /**
  39568. * Update the current camera state depending on the inputs that have been used this frame.
  39569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39570. */
  39571. checkInputs(): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Misc/virtualJoystick" {
  39585. import { Nullable } from "babylonjs/types";
  39586. import { Vector3 } from "babylonjs/Maths/math.vector";
  39587. /**
  39588. * Defines the potential axis of a Joystick
  39589. */
  39590. export enum JoystickAxis {
  39591. /** X axis */
  39592. X = 0,
  39593. /** Y axis */
  39594. Y = 1,
  39595. /** Z axis */
  39596. Z = 2
  39597. }
  39598. /**
  39599. * Class used to define virtual joystick (used in touch mode)
  39600. */
  39601. export class VirtualJoystick {
  39602. /**
  39603. * Gets or sets a boolean indicating that left and right values must be inverted
  39604. */
  39605. reverseLeftRight: boolean;
  39606. /**
  39607. * Gets or sets a boolean indicating that up and down values must be inverted
  39608. */
  39609. reverseUpDown: boolean;
  39610. /**
  39611. * Gets the offset value for the position (ie. the change of the position value)
  39612. */
  39613. deltaPosition: Vector3;
  39614. /**
  39615. * Gets a boolean indicating if the virtual joystick was pressed
  39616. */
  39617. pressed: boolean;
  39618. /**
  39619. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39620. */
  39621. static Canvas: Nullable<HTMLCanvasElement>;
  39622. private static _globalJoystickIndex;
  39623. private static vjCanvasContext;
  39624. private static vjCanvasWidth;
  39625. private static vjCanvasHeight;
  39626. private static halfWidth;
  39627. private _action;
  39628. private _axisTargetedByLeftAndRight;
  39629. private _axisTargetedByUpAndDown;
  39630. private _joystickSensibility;
  39631. private _inversedSensibility;
  39632. private _joystickPointerID;
  39633. private _joystickColor;
  39634. private _joystickPointerPos;
  39635. private _joystickPreviousPointerPos;
  39636. private _joystickPointerStartPos;
  39637. private _deltaJoystickVector;
  39638. private _leftJoystick;
  39639. private _touches;
  39640. private _onPointerDownHandlerRef;
  39641. private _onPointerMoveHandlerRef;
  39642. private _onPointerUpHandlerRef;
  39643. private _onResize;
  39644. /**
  39645. * Creates a new virtual joystick
  39646. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39647. */
  39648. constructor(leftJoystick?: boolean);
  39649. /**
  39650. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39651. * @param newJoystickSensibility defines the new sensibility
  39652. */
  39653. setJoystickSensibility(newJoystickSensibility: number): void;
  39654. private _onPointerDown;
  39655. private _onPointerMove;
  39656. private _onPointerUp;
  39657. /**
  39658. * Change the color of the virtual joystick
  39659. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39660. */
  39661. setJoystickColor(newColor: string): void;
  39662. /**
  39663. * Defines a callback to call when the joystick is touched
  39664. * @param action defines the callback
  39665. */
  39666. setActionOnTouch(action: () => any): void;
  39667. /**
  39668. * Defines which axis you'd like to control for left & right
  39669. * @param axis defines the axis to use
  39670. */
  39671. setAxisForLeftRight(axis: JoystickAxis): void;
  39672. /**
  39673. * Defines which axis you'd like to control for up & down
  39674. * @param axis defines the axis to use
  39675. */
  39676. setAxisForUpDown(axis: JoystickAxis): void;
  39677. private _drawVirtualJoystick;
  39678. /**
  39679. * Release internal HTML canvas
  39680. */
  39681. releaseCanvas(): void;
  39682. }
  39683. }
  39684. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39685. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39686. import { Nullable } from "babylonjs/types";
  39687. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39688. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39689. module "babylonjs/Cameras/freeCameraInputsManager" {
  39690. interface FreeCameraInputsManager {
  39691. /**
  39692. * Add virtual joystick input support to the input manager.
  39693. * @returns the current input manager
  39694. */
  39695. addVirtualJoystick(): FreeCameraInputsManager;
  39696. }
  39697. }
  39698. /**
  39699. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39700. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39701. */
  39702. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39703. /**
  39704. * Defines the camera the input is attached to.
  39705. */
  39706. camera: FreeCamera;
  39707. private _leftjoystick;
  39708. private _rightjoystick;
  39709. /**
  39710. * Gets the left stick of the virtual joystick.
  39711. * @returns The virtual Joystick
  39712. */
  39713. getLeftJoystick(): VirtualJoystick;
  39714. /**
  39715. * Gets the right stick of the virtual joystick.
  39716. * @returns The virtual Joystick
  39717. */
  39718. getRightJoystick(): VirtualJoystick;
  39719. /**
  39720. * Update the current camera state depending on the inputs that have been used this frame.
  39721. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39722. */
  39723. checkInputs(): void;
  39724. /**
  39725. * Attach the input controls to a specific dom element to get the input from.
  39726. * @param element Defines the element the controls should be listened from
  39727. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39728. */
  39729. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39730. /**
  39731. * Detach the current controls from the specified dom element.
  39732. * @param element Defines the element to stop listening the inputs from
  39733. */
  39734. detachControl(element: Nullable<HTMLElement>): void;
  39735. /**
  39736. * Gets the class name of the current intput.
  39737. * @returns the class name
  39738. */
  39739. getClassName(): string;
  39740. /**
  39741. * Get the friendly name associated with the input class.
  39742. * @returns the input friendly name
  39743. */
  39744. getSimpleName(): string;
  39745. }
  39746. }
  39747. declare module "babylonjs/Cameras/Inputs/index" {
  39748. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39749. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39750. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39751. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39752. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39753. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39754. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39755. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39756. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39757. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39758. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39759. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39760. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39761. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39762. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39763. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39764. }
  39765. declare module "babylonjs/Cameras/touchCamera" {
  39766. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39767. import { Scene } from "babylonjs/scene";
  39768. import { Vector3 } from "babylonjs/Maths/math.vector";
  39769. /**
  39770. * This represents a FPS type of camera controlled by touch.
  39771. * This is like a universal camera minus the Gamepad controls.
  39772. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39773. */
  39774. export class TouchCamera extends FreeCamera {
  39775. /**
  39776. * Defines the touch sensibility for rotation.
  39777. * The higher the faster.
  39778. */
  39779. touchAngularSensibility: number;
  39780. /**
  39781. * Defines the touch sensibility for move.
  39782. * The higher the faster.
  39783. */
  39784. touchMoveSensibility: number;
  39785. /**
  39786. * Instantiates a new touch camera.
  39787. * This represents a FPS type of camera controlled by touch.
  39788. * This is like a universal camera minus the Gamepad controls.
  39789. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39790. * @param name Define the name of the camera in the scene
  39791. * @param position Define the start position of the camera in the scene
  39792. * @param scene Define the scene the camera belongs to
  39793. */
  39794. constructor(name: string, position: Vector3, scene: Scene);
  39795. /**
  39796. * Gets the current object class name.
  39797. * @return the class name
  39798. */
  39799. getClassName(): string;
  39800. /** @hidden */
  39801. _setupInputs(): void;
  39802. }
  39803. }
  39804. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39805. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39806. import { Scene } from "babylonjs/scene";
  39807. import { Vector3 } from "babylonjs/Maths/math.vector";
  39808. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39809. import { Axis } from "babylonjs/Maths/math.axis";
  39810. /**
  39811. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39812. * being tilted forward or back and left or right.
  39813. */
  39814. export class DeviceOrientationCamera extends FreeCamera {
  39815. private _initialQuaternion;
  39816. private _quaternionCache;
  39817. private _tmpDragQuaternion;
  39818. private _disablePointerInputWhenUsingDeviceOrientation;
  39819. /**
  39820. * Creates a new device orientation camera
  39821. * @param name The name of the camera
  39822. * @param position The start position camera
  39823. * @param scene The scene the camera belongs to
  39824. */
  39825. constructor(name: string, position: Vector3, scene: Scene);
  39826. /**
  39827. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39828. */
  39829. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39830. private _dragFactor;
  39831. /**
  39832. * Enabled turning on the y axis when the orientation sensor is active
  39833. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39834. */
  39835. enableHorizontalDragging(dragFactor?: number): void;
  39836. /**
  39837. * Gets the current instance class name ("DeviceOrientationCamera").
  39838. * This helps avoiding instanceof at run time.
  39839. * @returns the class name
  39840. */
  39841. getClassName(): string;
  39842. /**
  39843. * @hidden
  39844. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39845. */
  39846. _checkInputs(): void;
  39847. /**
  39848. * Reset the camera to its default orientation on the specified axis only.
  39849. * @param axis The axis to reset
  39850. */
  39851. resetToCurrentRotation(axis?: Axis): void;
  39852. }
  39853. }
  39854. declare module "babylonjs/Gamepads/xboxGamepad" {
  39855. import { Observable } from "babylonjs/Misc/observable";
  39856. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39857. /**
  39858. * Defines supported buttons for XBox360 compatible gamepads
  39859. */
  39860. export enum Xbox360Button {
  39861. /** A */
  39862. A = 0,
  39863. /** B */
  39864. B = 1,
  39865. /** X */
  39866. X = 2,
  39867. /** Y */
  39868. Y = 3,
  39869. /** Start */
  39870. Start = 4,
  39871. /** Back */
  39872. Back = 5,
  39873. /** Left button */
  39874. LB = 6,
  39875. /** Right button */
  39876. RB = 7,
  39877. /** Left stick */
  39878. LeftStick = 8,
  39879. /** Right stick */
  39880. RightStick = 9
  39881. }
  39882. /** Defines values for XBox360 DPad */
  39883. export enum Xbox360Dpad {
  39884. /** Up */
  39885. Up = 0,
  39886. /** Down */
  39887. Down = 1,
  39888. /** Left */
  39889. Left = 2,
  39890. /** Right */
  39891. Right = 3
  39892. }
  39893. /**
  39894. * Defines a XBox360 gamepad
  39895. */
  39896. export class Xbox360Pad extends Gamepad {
  39897. private _leftTrigger;
  39898. private _rightTrigger;
  39899. private _onlefttriggerchanged;
  39900. private _onrighttriggerchanged;
  39901. private _onbuttondown;
  39902. private _onbuttonup;
  39903. private _ondpaddown;
  39904. private _ondpadup;
  39905. /** Observable raised when a button is pressed */
  39906. onButtonDownObservable: Observable<Xbox360Button>;
  39907. /** Observable raised when a button is released */
  39908. onButtonUpObservable: Observable<Xbox360Button>;
  39909. /** Observable raised when a pad is pressed */
  39910. onPadDownObservable: Observable<Xbox360Dpad>;
  39911. /** Observable raised when a pad is released */
  39912. onPadUpObservable: Observable<Xbox360Dpad>;
  39913. private _buttonA;
  39914. private _buttonB;
  39915. private _buttonX;
  39916. private _buttonY;
  39917. private _buttonBack;
  39918. private _buttonStart;
  39919. private _buttonLB;
  39920. private _buttonRB;
  39921. private _buttonLeftStick;
  39922. private _buttonRightStick;
  39923. private _dPadUp;
  39924. private _dPadDown;
  39925. private _dPadLeft;
  39926. private _dPadRight;
  39927. private _isXboxOnePad;
  39928. /**
  39929. * Creates a new XBox360 gamepad object
  39930. * @param id defines the id of this gamepad
  39931. * @param index defines its index
  39932. * @param gamepad defines the internal HTML gamepad object
  39933. * @param xboxOne defines if it is a XBox One gamepad
  39934. */
  39935. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39936. /**
  39937. * Defines the callback to call when left trigger is pressed
  39938. * @param callback defines the callback to use
  39939. */
  39940. onlefttriggerchanged(callback: (value: number) => void): void;
  39941. /**
  39942. * Defines the callback to call when right trigger is pressed
  39943. * @param callback defines the callback to use
  39944. */
  39945. onrighttriggerchanged(callback: (value: number) => void): void;
  39946. /**
  39947. * Gets the left trigger value
  39948. */
  39949. /**
  39950. * Sets the left trigger value
  39951. */
  39952. leftTrigger: number;
  39953. /**
  39954. * Gets the right trigger value
  39955. */
  39956. /**
  39957. * Sets the right trigger value
  39958. */
  39959. rightTrigger: number;
  39960. /**
  39961. * Defines the callback to call when a button is pressed
  39962. * @param callback defines the callback to use
  39963. */
  39964. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39965. /**
  39966. * Defines the callback to call when a button is released
  39967. * @param callback defines the callback to use
  39968. */
  39969. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39970. /**
  39971. * Defines the callback to call when a pad is pressed
  39972. * @param callback defines the callback to use
  39973. */
  39974. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39975. /**
  39976. * Defines the callback to call when a pad is released
  39977. * @param callback defines the callback to use
  39978. */
  39979. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39980. private _setButtonValue;
  39981. private _setDPadValue;
  39982. /**
  39983. * Gets the value of the `A` button
  39984. */
  39985. /**
  39986. * Sets the value of the `A` button
  39987. */
  39988. buttonA: number;
  39989. /**
  39990. * Gets the value of the `B` button
  39991. */
  39992. /**
  39993. * Sets the value of the `B` button
  39994. */
  39995. buttonB: number;
  39996. /**
  39997. * Gets the value of the `X` button
  39998. */
  39999. /**
  40000. * Sets the value of the `X` button
  40001. */
  40002. buttonX: number;
  40003. /**
  40004. * Gets the value of the `Y` button
  40005. */
  40006. /**
  40007. * Sets the value of the `Y` button
  40008. */
  40009. buttonY: number;
  40010. /**
  40011. * Gets the value of the `Start` button
  40012. */
  40013. /**
  40014. * Sets the value of the `Start` button
  40015. */
  40016. buttonStart: number;
  40017. /**
  40018. * Gets the value of the `Back` button
  40019. */
  40020. /**
  40021. * Sets the value of the `Back` button
  40022. */
  40023. buttonBack: number;
  40024. /**
  40025. * Gets the value of the `Left` button
  40026. */
  40027. /**
  40028. * Sets the value of the `Left` button
  40029. */
  40030. buttonLB: number;
  40031. /**
  40032. * Gets the value of the `Right` button
  40033. */
  40034. /**
  40035. * Sets the value of the `Right` button
  40036. */
  40037. buttonRB: number;
  40038. /**
  40039. * Gets the value of the Left joystick
  40040. */
  40041. /**
  40042. * Sets the value of the Left joystick
  40043. */
  40044. buttonLeftStick: number;
  40045. /**
  40046. * Gets the value of the Right joystick
  40047. */
  40048. /**
  40049. * Sets the value of the Right joystick
  40050. */
  40051. buttonRightStick: number;
  40052. /**
  40053. * Gets the value of D-pad up
  40054. */
  40055. /**
  40056. * Sets the value of D-pad up
  40057. */
  40058. dPadUp: number;
  40059. /**
  40060. * Gets the value of D-pad down
  40061. */
  40062. /**
  40063. * Sets the value of D-pad down
  40064. */
  40065. dPadDown: number;
  40066. /**
  40067. * Gets the value of D-pad left
  40068. */
  40069. /**
  40070. * Sets the value of D-pad left
  40071. */
  40072. dPadLeft: number;
  40073. /**
  40074. * Gets the value of D-pad right
  40075. */
  40076. /**
  40077. * Sets the value of D-pad right
  40078. */
  40079. dPadRight: number;
  40080. /**
  40081. * Force the gamepad to synchronize with device values
  40082. */
  40083. update(): void;
  40084. /**
  40085. * Disposes the gamepad
  40086. */
  40087. dispose(): void;
  40088. }
  40089. }
  40090. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40091. import { Observable } from "babylonjs/Misc/observable";
  40092. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40093. /**
  40094. * Defines supported buttons for DualShock compatible gamepads
  40095. */
  40096. export enum DualShockButton {
  40097. /** Cross */
  40098. Cross = 0,
  40099. /** Circle */
  40100. Circle = 1,
  40101. /** Square */
  40102. Square = 2,
  40103. /** Triangle */
  40104. Triangle = 3,
  40105. /** Options */
  40106. Options = 4,
  40107. /** Share */
  40108. Share = 5,
  40109. /** L1 */
  40110. L1 = 6,
  40111. /** R1 */
  40112. R1 = 7,
  40113. /** Left stick */
  40114. LeftStick = 8,
  40115. /** Right stick */
  40116. RightStick = 9
  40117. }
  40118. /** Defines values for DualShock DPad */
  40119. export enum DualShockDpad {
  40120. /** Up */
  40121. Up = 0,
  40122. /** Down */
  40123. Down = 1,
  40124. /** Left */
  40125. Left = 2,
  40126. /** Right */
  40127. Right = 3
  40128. }
  40129. /**
  40130. * Defines a DualShock gamepad
  40131. */
  40132. export class DualShockPad extends Gamepad {
  40133. private _leftTrigger;
  40134. private _rightTrigger;
  40135. private _onlefttriggerchanged;
  40136. private _onrighttriggerchanged;
  40137. private _onbuttondown;
  40138. private _onbuttonup;
  40139. private _ondpaddown;
  40140. private _ondpadup;
  40141. /** Observable raised when a button is pressed */
  40142. onButtonDownObservable: Observable<DualShockButton>;
  40143. /** Observable raised when a button is released */
  40144. onButtonUpObservable: Observable<DualShockButton>;
  40145. /** Observable raised when a pad is pressed */
  40146. onPadDownObservable: Observable<DualShockDpad>;
  40147. /** Observable raised when a pad is released */
  40148. onPadUpObservable: Observable<DualShockDpad>;
  40149. private _buttonCross;
  40150. private _buttonCircle;
  40151. private _buttonSquare;
  40152. private _buttonTriangle;
  40153. private _buttonShare;
  40154. private _buttonOptions;
  40155. private _buttonL1;
  40156. private _buttonR1;
  40157. private _buttonLeftStick;
  40158. private _buttonRightStick;
  40159. private _dPadUp;
  40160. private _dPadDown;
  40161. private _dPadLeft;
  40162. private _dPadRight;
  40163. /**
  40164. * Creates a new DualShock gamepad object
  40165. * @param id defines the id of this gamepad
  40166. * @param index defines its index
  40167. * @param gamepad defines the internal HTML gamepad object
  40168. */
  40169. constructor(id: string, index: number, gamepad: any);
  40170. /**
  40171. * Defines the callback to call when left trigger is pressed
  40172. * @param callback defines the callback to use
  40173. */
  40174. onlefttriggerchanged(callback: (value: number) => void): void;
  40175. /**
  40176. * Defines the callback to call when right trigger is pressed
  40177. * @param callback defines the callback to use
  40178. */
  40179. onrighttriggerchanged(callback: (value: number) => void): void;
  40180. /**
  40181. * Gets the left trigger value
  40182. */
  40183. /**
  40184. * Sets the left trigger value
  40185. */
  40186. leftTrigger: number;
  40187. /**
  40188. * Gets the right trigger value
  40189. */
  40190. /**
  40191. * Sets the right trigger value
  40192. */
  40193. rightTrigger: number;
  40194. /**
  40195. * Defines the callback to call when a button is pressed
  40196. * @param callback defines the callback to use
  40197. */
  40198. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40199. /**
  40200. * Defines the callback to call when a button is released
  40201. * @param callback defines the callback to use
  40202. */
  40203. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40204. /**
  40205. * Defines the callback to call when a pad is pressed
  40206. * @param callback defines the callback to use
  40207. */
  40208. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40209. /**
  40210. * Defines the callback to call when a pad is released
  40211. * @param callback defines the callback to use
  40212. */
  40213. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40214. private _setButtonValue;
  40215. private _setDPadValue;
  40216. /**
  40217. * Gets the value of the `Cross` button
  40218. */
  40219. /**
  40220. * Sets the value of the `Cross` button
  40221. */
  40222. buttonCross: number;
  40223. /**
  40224. * Gets the value of the `Circle` button
  40225. */
  40226. /**
  40227. * Sets the value of the `Circle` button
  40228. */
  40229. buttonCircle: number;
  40230. /**
  40231. * Gets the value of the `Square` button
  40232. */
  40233. /**
  40234. * Sets the value of the `Square` button
  40235. */
  40236. buttonSquare: number;
  40237. /**
  40238. * Gets the value of the `Triangle` button
  40239. */
  40240. /**
  40241. * Sets the value of the `Triangle` button
  40242. */
  40243. buttonTriangle: number;
  40244. /**
  40245. * Gets the value of the `Options` button
  40246. */
  40247. /**
  40248. * Sets the value of the `Options` button
  40249. */
  40250. buttonOptions: number;
  40251. /**
  40252. * Gets the value of the `Share` button
  40253. */
  40254. /**
  40255. * Sets the value of the `Share` button
  40256. */
  40257. buttonShare: number;
  40258. /**
  40259. * Gets the value of the `L1` button
  40260. */
  40261. /**
  40262. * Sets the value of the `L1` button
  40263. */
  40264. buttonL1: number;
  40265. /**
  40266. * Gets the value of the `R1` button
  40267. */
  40268. /**
  40269. * Sets the value of the `R1` button
  40270. */
  40271. buttonR1: number;
  40272. /**
  40273. * Gets the value of the Left joystick
  40274. */
  40275. /**
  40276. * Sets the value of the Left joystick
  40277. */
  40278. buttonLeftStick: number;
  40279. /**
  40280. * Gets the value of the Right joystick
  40281. */
  40282. /**
  40283. * Sets the value of the Right joystick
  40284. */
  40285. buttonRightStick: number;
  40286. /**
  40287. * Gets the value of D-pad up
  40288. */
  40289. /**
  40290. * Sets the value of D-pad up
  40291. */
  40292. dPadUp: number;
  40293. /**
  40294. * Gets the value of D-pad down
  40295. */
  40296. /**
  40297. * Sets the value of D-pad down
  40298. */
  40299. dPadDown: number;
  40300. /**
  40301. * Gets the value of D-pad left
  40302. */
  40303. /**
  40304. * Sets the value of D-pad left
  40305. */
  40306. dPadLeft: number;
  40307. /**
  40308. * Gets the value of D-pad right
  40309. */
  40310. /**
  40311. * Sets the value of D-pad right
  40312. */
  40313. dPadRight: number;
  40314. /**
  40315. * Force the gamepad to synchronize with device values
  40316. */
  40317. update(): void;
  40318. /**
  40319. * Disposes the gamepad
  40320. */
  40321. dispose(): void;
  40322. }
  40323. }
  40324. declare module "babylonjs/Gamepads/gamepadManager" {
  40325. import { Observable } from "babylonjs/Misc/observable";
  40326. import { Nullable } from "babylonjs/types";
  40327. import { Scene } from "babylonjs/scene";
  40328. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40329. /**
  40330. * Manager for handling gamepads
  40331. */
  40332. export class GamepadManager {
  40333. private _scene?;
  40334. private _babylonGamepads;
  40335. private _oneGamepadConnected;
  40336. /** @hidden */
  40337. _isMonitoring: boolean;
  40338. private _gamepadEventSupported;
  40339. private _gamepadSupport;
  40340. /**
  40341. * observable to be triggered when the gamepad controller has been connected
  40342. */
  40343. onGamepadConnectedObservable: Observable<Gamepad>;
  40344. /**
  40345. * observable to be triggered when the gamepad controller has been disconnected
  40346. */
  40347. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40348. private _onGamepadConnectedEvent;
  40349. private _onGamepadDisconnectedEvent;
  40350. /**
  40351. * Initializes the gamepad manager
  40352. * @param _scene BabylonJS scene
  40353. */
  40354. constructor(_scene?: Scene | undefined);
  40355. /**
  40356. * The gamepads in the game pad manager
  40357. */
  40358. readonly gamepads: Gamepad[];
  40359. /**
  40360. * Get the gamepad controllers based on type
  40361. * @param type The type of gamepad controller
  40362. * @returns Nullable gamepad
  40363. */
  40364. getGamepadByType(type?: number): Nullable<Gamepad>;
  40365. /**
  40366. * Disposes the gamepad manager
  40367. */
  40368. dispose(): void;
  40369. private _addNewGamepad;
  40370. private _startMonitoringGamepads;
  40371. private _stopMonitoringGamepads;
  40372. /** @hidden */
  40373. _checkGamepadsStatus(): void;
  40374. private _updateGamepadObjects;
  40375. }
  40376. }
  40377. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40378. import { Nullable } from "babylonjs/types";
  40379. import { Scene } from "babylonjs/scene";
  40380. import { ISceneComponent } from "babylonjs/sceneComponent";
  40381. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40382. module "babylonjs/scene" {
  40383. interface Scene {
  40384. /** @hidden */
  40385. _gamepadManager: Nullable<GamepadManager>;
  40386. /**
  40387. * Gets the gamepad manager associated with the scene
  40388. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40389. */
  40390. gamepadManager: GamepadManager;
  40391. }
  40392. }
  40393. module "babylonjs/Cameras/freeCameraInputsManager" {
  40394. /**
  40395. * Interface representing a free camera inputs manager
  40396. */
  40397. interface FreeCameraInputsManager {
  40398. /**
  40399. * Adds gamepad input support to the FreeCameraInputsManager.
  40400. * @returns the FreeCameraInputsManager
  40401. */
  40402. addGamepad(): FreeCameraInputsManager;
  40403. }
  40404. }
  40405. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40406. /**
  40407. * Interface representing an arc rotate camera inputs manager
  40408. */
  40409. interface ArcRotateCameraInputsManager {
  40410. /**
  40411. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40412. * @returns the camera inputs manager
  40413. */
  40414. addGamepad(): ArcRotateCameraInputsManager;
  40415. }
  40416. }
  40417. /**
  40418. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40419. */
  40420. export class GamepadSystemSceneComponent implements ISceneComponent {
  40421. /**
  40422. * The component name helpfull to identify the component in the list of scene components.
  40423. */
  40424. readonly name: string;
  40425. /**
  40426. * The scene the component belongs to.
  40427. */
  40428. scene: Scene;
  40429. /**
  40430. * Creates a new instance of the component for the given scene
  40431. * @param scene Defines the scene to register the component in
  40432. */
  40433. constructor(scene: Scene);
  40434. /**
  40435. * Registers the component in a given scene
  40436. */
  40437. register(): void;
  40438. /**
  40439. * Rebuilds the elements related to this component in case of
  40440. * context lost for instance.
  40441. */
  40442. rebuild(): void;
  40443. /**
  40444. * Disposes the component and the associated ressources
  40445. */
  40446. dispose(): void;
  40447. private _beforeCameraUpdate;
  40448. }
  40449. }
  40450. declare module "babylonjs/Cameras/universalCamera" {
  40451. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40452. import { Scene } from "babylonjs/scene";
  40453. import { Vector3 } from "babylonjs/Maths/math.vector";
  40454. import "babylonjs/Gamepads/gamepadSceneComponent";
  40455. /**
  40456. * 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,
  40457. * which still works and will still be found in many Playgrounds.
  40458. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40459. */
  40460. export class UniversalCamera extends TouchCamera {
  40461. /**
  40462. * Defines the gamepad rotation sensiblity.
  40463. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40464. */
  40465. gamepadAngularSensibility: number;
  40466. /**
  40467. * Defines the gamepad move sensiblity.
  40468. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40469. */
  40470. gamepadMoveSensibility: number;
  40471. /**
  40472. * 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,
  40473. * which still works and will still be found in many Playgrounds.
  40474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40475. * @param name Define the name of the camera in the scene
  40476. * @param position Define the start position of the camera in the scene
  40477. * @param scene Define the scene the camera belongs to
  40478. */
  40479. constructor(name: string, position: Vector3, scene: Scene);
  40480. /**
  40481. * Gets the current object class name.
  40482. * @return the class name
  40483. */
  40484. getClassName(): string;
  40485. }
  40486. }
  40487. declare module "babylonjs/Cameras/gamepadCamera" {
  40488. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40489. import { Scene } from "babylonjs/scene";
  40490. import { Vector3 } from "babylonjs/Maths/math.vector";
  40491. /**
  40492. * This represents a FPS type of camera. This is only here for back compat purpose.
  40493. * Please use the UniversalCamera instead as both are identical.
  40494. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40495. */
  40496. export class GamepadCamera extends UniversalCamera {
  40497. /**
  40498. * Instantiates a new Gamepad Camera
  40499. * This represents a FPS type of camera. This is only here for back compat purpose.
  40500. * Please use the UniversalCamera instead as both are identical.
  40501. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40502. * @param name Define the name of the camera in the scene
  40503. * @param position Define the start position of the camera in the scene
  40504. * @param scene Define the scene the camera belongs to
  40505. */
  40506. constructor(name: string, position: Vector3, scene: Scene);
  40507. /**
  40508. * Gets the current object class name.
  40509. * @return the class name
  40510. */
  40511. getClassName(): string;
  40512. }
  40513. }
  40514. declare module "babylonjs/Shaders/pass.fragment" {
  40515. /** @hidden */
  40516. export var passPixelShader: {
  40517. name: string;
  40518. shader: string;
  40519. };
  40520. }
  40521. declare module "babylonjs/Shaders/passCube.fragment" {
  40522. /** @hidden */
  40523. export var passCubePixelShader: {
  40524. name: string;
  40525. shader: string;
  40526. };
  40527. }
  40528. declare module "babylonjs/PostProcesses/passPostProcess" {
  40529. import { Nullable } from "babylonjs/types";
  40530. import { Camera } from "babylonjs/Cameras/camera";
  40531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40532. import { Engine } from "babylonjs/Engines/engine";
  40533. import "babylonjs/Shaders/pass.fragment";
  40534. import "babylonjs/Shaders/passCube.fragment";
  40535. /**
  40536. * PassPostProcess which produces an output the same as it's input
  40537. */
  40538. export class PassPostProcess extends PostProcess {
  40539. /**
  40540. * Creates the PassPostProcess
  40541. * @param name The name of the effect.
  40542. * @param options The required width/height ratio to downsize to before computing the render pass.
  40543. * @param camera The camera to apply the render pass to.
  40544. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40545. * @param engine The engine which the post process will be applied. (default: current engine)
  40546. * @param reusable If the post process can be reused on the same frame. (default: false)
  40547. * @param textureType The type of texture to be used when performing the post processing.
  40548. * @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)
  40549. */
  40550. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40551. }
  40552. /**
  40553. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40554. */
  40555. export class PassCubePostProcess extends PostProcess {
  40556. private _face;
  40557. /**
  40558. * Gets or sets the cube face to display.
  40559. * * 0 is +X
  40560. * * 1 is -X
  40561. * * 2 is +Y
  40562. * * 3 is -Y
  40563. * * 4 is +Z
  40564. * * 5 is -Z
  40565. */
  40566. face: number;
  40567. /**
  40568. * Creates the PassCubePostProcess
  40569. * @param name The name of the effect.
  40570. * @param options The required width/height ratio to downsize to before computing the render pass.
  40571. * @param camera The camera to apply the render pass to.
  40572. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40573. * @param engine The engine which the post process will be applied. (default: current engine)
  40574. * @param reusable If the post process can be reused on the same frame. (default: false)
  40575. * @param textureType The type of texture to be used when performing the post processing.
  40576. * @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)
  40577. */
  40578. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40579. }
  40580. }
  40581. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40582. /** @hidden */
  40583. export var anaglyphPixelShader: {
  40584. name: string;
  40585. shader: string;
  40586. };
  40587. }
  40588. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40589. import { Engine } from "babylonjs/Engines/engine";
  40590. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40591. import { Camera } from "babylonjs/Cameras/camera";
  40592. import "babylonjs/Shaders/anaglyph.fragment";
  40593. /**
  40594. * Postprocess used to generate anaglyphic rendering
  40595. */
  40596. export class AnaglyphPostProcess extends PostProcess {
  40597. private _passedProcess;
  40598. /**
  40599. * Creates a new AnaglyphPostProcess
  40600. * @param name defines postprocess name
  40601. * @param options defines creation options or target ratio scale
  40602. * @param rigCameras defines cameras using this postprocess
  40603. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40604. * @param engine defines hosting engine
  40605. * @param reusable defines if the postprocess will be reused multiple times per frame
  40606. */
  40607. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40608. }
  40609. }
  40610. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40611. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40612. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40613. import { Scene } from "babylonjs/scene";
  40614. import { Vector3 } from "babylonjs/Maths/math.vector";
  40615. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40616. /**
  40617. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40618. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40619. */
  40620. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40621. /**
  40622. * Creates a new AnaglyphArcRotateCamera
  40623. * @param name defines camera name
  40624. * @param alpha defines alpha angle (in radians)
  40625. * @param beta defines beta angle (in radians)
  40626. * @param radius defines radius
  40627. * @param target defines camera target
  40628. * @param interaxialDistance defines distance between each color axis
  40629. * @param scene defines the hosting scene
  40630. */
  40631. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40632. /**
  40633. * Gets camera class name
  40634. * @returns AnaglyphArcRotateCamera
  40635. */
  40636. getClassName(): string;
  40637. }
  40638. }
  40639. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40640. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40641. import { Scene } from "babylonjs/scene";
  40642. import { Vector3 } from "babylonjs/Maths/math.vector";
  40643. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40644. /**
  40645. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40646. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40647. */
  40648. export class AnaglyphFreeCamera extends FreeCamera {
  40649. /**
  40650. * Creates a new AnaglyphFreeCamera
  40651. * @param name defines camera name
  40652. * @param position defines initial position
  40653. * @param interaxialDistance defines distance between each color axis
  40654. * @param scene defines the hosting scene
  40655. */
  40656. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40657. /**
  40658. * Gets camera class name
  40659. * @returns AnaglyphFreeCamera
  40660. */
  40661. getClassName(): string;
  40662. }
  40663. }
  40664. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40665. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40666. import { Scene } from "babylonjs/scene";
  40667. import { Vector3 } from "babylonjs/Maths/math.vector";
  40668. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40669. /**
  40670. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40671. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40672. */
  40673. export class AnaglyphGamepadCamera extends GamepadCamera {
  40674. /**
  40675. * Creates a new AnaglyphGamepadCamera
  40676. * @param name defines camera name
  40677. * @param position defines initial position
  40678. * @param interaxialDistance defines distance between each color axis
  40679. * @param scene defines the hosting scene
  40680. */
  40681. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40682. /**
  40683. * Gets camera class name
  40684. * @returns AnaglyphGamepadCamera
  40685. */
  40686. getClassName(): string;
  40687. }
  40688. }
  40689. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40690. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40691. import { Scene } from "babylonjs/scene";
  40692. import { Vector3 } from "babylonjs/Maths/math.vector";
  40693. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40694. /**
  40695. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40696. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40697. */
  40698. export class AnaglyphUniversalCamera extends UniversalCamera {
  40699. /**
  40700. * Creates a new AnaglyphUniversalCamera
  40701. * @param name defines camera name
  40702. * @param position defines initial position
  40703. * @param interaxialDistance defines distance between each color axis
  40704. * @param scene defines the hosting scene
  40705. */
  40706. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40707. /**
  40708. * Gets camera class name
  40709. * @returns AnaglyphUniversalCamera
  40710. */
  40711. getClassName(): string;
  40712. }
  40713. }
  40714. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40715. /** @hidden */
  40716. export var stereoscopicInterlacePixelShader: {
  40717. name: string;
  40718. shader: string;
  40719. };
  40720. }
  40721. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40722. import { Camera } from "babylonjs/Cameras/camera";
  40723. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40724. import { Engine } from "babylonjs/Engines/engine";
  40725. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40726. /**
  40727. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40728. */
  40729. export class StereoscopicInterlacePostProcess extends PostProcess {
  40730. private _stepSize;
  40731. private _passedProcess;
  40732. /**
  40733. * Initializes a StereoscopicInterlacePostProcess
  40734. * @param name The name of the effect.
  40735. * @param rigCameras The rig cameras to be appled to the post process
  40736. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40738. * @param engine The engine which the post process will be applied. (default: current engine)
  40739. * @param reusable If the post process can be reused on the same frame. (default: false)
  40740. */
  40741. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40742. }
  40743. }
  40744. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40745. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40746. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40747. import { Scene } from "babylonjs/scene";
  40748. import { Vector3 } from "babylonjs/Maths/math.vector";
  40749. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40750. /**
  40751. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40752. * @see http://doc.babylonjs.com/features/cameras
  40753. */
  40754. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40755. /**
  40756. * Creates a new StereoscopicArcRotateCamera
  40757. * @param name defines camera name
  40758. * @param alpha defines alpha angle (in radians)
  40759. * @param beta defines beta angle (in radians)
  40760. * @param radius defines radius
  40761. * @param target defines camera target
  40762. * @param interaxialDistance defines distance between each color axis
  40763. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40764. * @param scene defines the hosting scene
  40765. */
  40766. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40767. /**
  40768. * Gets camera class name
  40769. * @returns StereoscopicArcRotateCamera
  40770. */
  40771. getClassName(): string;
  40772. }
  40773. }
  40774. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40775. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40776. import { Scene } from "babylonjs/scene";
  40777. import { Vector3 } from "babylonjs/Maths/math.vector";
  40778. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40779. /**
  40780. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40781. * @see http://doc.babylonjs.com/features/cameras
  40782. */
  40783. export class StereoscopicFreeCamera extends FreeCamera {
  40784. /**
  40785. * Creates a new StereoscopicFreeCamera
  40786. * @param name defines camera name
  40787. * @param position defines initial position
  40788. * @param interaxialDistance defines distance between each color axis
  40789. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40790. * @param scene defines the hosting scene
  40791. */
  40792. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40793. /**
  40794. * Gets camera class name
  40795. * @returns StereoscopicFreeCamera
  40796. */
  40797. getClassName(): string;
  40798. }
  40799. }
  40800. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40801. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40802. import { Scene } from "babylonjs/scene";
  40803. import { Vector3 } from "babylonjs/Maths/math.vector";
  40804. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40805. /**
  40806. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40807. * @see http://doc.babylonjs.com/features/cameras
  40808. */
  40809. export class StereoscopicGamepadCamera extends GamepadCamera {
  40810. /**
  40811. * Creates a new StereoscopicGamepadCamera
  40812. * @param name defines camera name
  40813. * @param position defines initial position
  40814. * @param interaxialDistance defines distance between each color axis
  40815. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40816. * @param scene defines the hosting scene
  40817. */
  40818. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40819. /**
  40820. * Gets camera class name
  40821. * @returns StereoscopicGamepadCamera
  40822. */
  40823. getClassName(): string;
  40824. }
  40825. }
  40826. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40827. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40828. import { Scene } from "babylonjs/scene";
  40829. import { Vector3 } from "babylonjs/Maths/math.vector";
  40830. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40831. /**
  40832. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40833. * @see http://doc.babylonjs.com/features/cameras
  40834. */
  40835. export class StereoscopicUniversalCamera extends UniversalCamera {
  40836. /**
  40837. * Creates a new StereoscopicUniversalCamera
  40838. * @param name defines camera name
  40839. * @param position defines initial position
  40840. * @param interaxialDistance defines distance between each color axis
  40841. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40842. * @param scene defines the hosting scene
  40843. */
  40844. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40845. /**
  40846. * Gets camera class name
  40847. * @returns StereoscopicUniversalCamera
  40848. */
  40849. getClassName(): string;
  40850. }
  40851. }
  40852. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40853. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40854. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40855. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40856. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40857. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40858. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40859. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40860. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40861. }
  40862. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40864. import { Scene } from "babylonjs/scene";
  40865. import { Vector3 } from "babylonjs/Maths/math.vector";
  40866. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40867. /**
  40868. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40869. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40870. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40871. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40872. */
  40873. export class VirtualJoysticksCamera extends FreeCamera {
  40874. /**
  40875. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40876. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40877. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40878. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40879. * @param name Define the name of the camera in the scene
  40880. * @param position Define the start position of the camera in the scene
  40881. * @param scene Define the scene the camera belongs to
  40882. */
  40883. constructor(name: string, position: Vector3, scene: Scene);
  40884. /**
  40885. * Gets the current object class name.
  40886. * @return the class name
  40887. */
  40888. getClassName(): string;
  40889. }
  40890. }
  40891. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40892. import { Matrix } from "babylonjs/Maths/math.vector";
  40893. /**
  40894. * This represents all the required metrics to create a VR camera.
  40895. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40896. */
  40897. export class VRCameraMetrics {
  40898. /**
  40899. * Define the horizontal resolution off the screen.
  40900. */
  40901. hResolution: number;
  40902. /**
  40903. * Define the vertical resolution off the screen.
  40904. */
  40905. vResolution: number;
  40906. /**
  40907. * Define the horizontal screen size.
  40908. */
  40909. hScreenSize: number;
  40910. /**
  40911. * Define the vertical screen size.
  40912. */
  40913. vScreenSize: number;
  40914. /**
  40915. * Define the vertical screen center position.
  40916. */
  40917. vScreenCenter: number;
  40918. /**
  40919. * Define the distance of the eyes to the screen.
  40920. */
  40921. eyeToScreenDistance: number;
  40922. /**
  40923. * Define the distance between both lenses
  40924. */
  40925. lensSeparationDistance: number;
  40926. /**
  40927. * Define the distance between both viewer's eyes.
  40928. */
  40929. interpupillaryDistance: number;
  40930. /**
  40931. * Define the distortion factor of the VR postprocess.
  40932. * Please, touch with care.
  40933. */
  40934. distortionK: number[];
  40935. /**
  40936. * Define the chromatic aberration correction factors for the VR post process.
  40937. */
  40938. chromaAbCorrection: number[];
  40939. /**
  40940. * Define the scale factor of the post process.
  40941. * The smaller the better but the slower.
  40942. */
  40943. postProcessScaleFactor: number;
  40944. /**
  40945. * Define an offset for the lens center.
  40946. */
  40947. lensCenterOffset: number;
  40948. /**
  40949. * Define if the current vr camera should compensate the distortion of the lense or not.
  40950. */
  40951. compensateDistortion: boolean;
  40952. /**
  40953. * Defines if multiview should be enabled when rendering (Default: false)
  40954. */
  40955. multiviewEnabled: boolean;
  40956. /**
  40957. * Gets the rendering aspect ratio based on the provided resolutions.
  40958. */
  40959. readonly aspectRatio: number;
  40960. /**
  40961. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40962. */
  40963. readonly aspectRatioFov: number;
  40964. /**
  40965. * @hidden
  40966. */
  40967. readonly leftHMatrix: Matrix;
  40968. /**
  40969. * @hidden
  40970. */
  40971. readonly rightHMatrix: Matrix;
  40972. /**
  40973. * @hidden
  40974. */
  40975. readonly leftPreViewMatrix: Matrix;
  40976. /**
  40977. * @hidden
  40978. */
  40979. readonly rightPreViewMatrix: Matrix;
  40980. /**
  40981. * Get the default VRMetrics based on the most generic setup.
  40982. * @returns the default vr metrics
  40983. */
  40984. static GetDefault(): VRCameraMetrics;
  40985. }
  40986. }
  40987. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  40988. /** @hidden */
  40989. export var vrDistortionCorrectionPixelShader: {
  40990. name: string;
  40991. shader: string;
  40992. };
  40993. }
  40994. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  40995. import { Camera } from "babylonjs/Cameras/camera";
  40996. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40997. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40998. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  40999. /**
  41000. * VRDistortionCorrectionPostProcess used for mobile VR
  41001. */
  41002. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41003. private _isRightEye;
  41004. private _distortionFactors;
  41005. private _postProcessScaleFactor;
  41006. private _lensCenterOffset;
  41007. private _scaleIn;
  41008. private _scaleFactor;
  41009. private _lensCenter;
  41010. /**
  41011. * Initializes the VRDistortionCorrectionPostProcess
  41012. * @param name The name of the effect.
  41013. * @param camera The camera to apply the render pass to.
  41014. * @param isRightEye If this is for the right eye distortion
  41015. * @param vrMetrics All the required metrics for the VR camera
  41016. */
  41017. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41018. }
  41019. }
  41020. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41021. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41022. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41023. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41024. import { Scene } from "babylonjs/scene";
  41025. import { Vector3 } from "babylonjs/Maths/math.vector";
  41026. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41027. import "babylonjs/Cameras/RigModes/vrRigMode";
  41028. /**
  41029. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41030. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41031. */
  41032. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41033. /**
  41034. * Creates a new VRDeviceOrientationArcRotateCamera
  41035. * @param name defines camera name
  41036. * @param alpha defines the camera rotation along the logitudinal axis
  41037. * @param beta defines the camera rotation along the latitudinal axis
  41038. * @param radius defines the camera distance from its target
  41039. * @param target defines the camera target
  41040. * @param scene defines the scene the camera belongs to
  41041. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41042. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41043. */
  41044. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41045. /**
  41046. * Gets camera class name
  41047. * @returns VRDeviceOrientationArcRotateCamera
  41048. */
  41049. getClassName(): string;
  41050. }
  41051. }
  41052. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41053. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41054. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41055. import { Scene } from "babylonjs/scene";
  41056. import { Vector3 } from "babylonjs/Maths/math.vector";
  41057. import "babylonjs/Cameras/RigModes/vrRigMode";
  41058. /**
  41059. * Camera used to simulate VR rendering (based on FreeCamera)
  41060. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41061. */
  41062. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41063. /**
  41064. * Creates a new VRDeviceOrientationFreeCamera
  41065. * @param name defines camera name
  41066. * @param position defines the start position of the camera
  41067. * @param scene defines the scene the camera belongs to
  41068. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41069. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41070. */
  41071. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41072. /**
  41073. * Gets camera class name
  41074. * @returns VRDeviceOrientationFreeCamera
  41075. */
  41076. getClassName(): string;
  41077. }
  41078. }
  41079. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41080. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41081. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41082. import { Scene } from "babylonjs/scene";
  41083. import { Vector3 } from "babylonjs/Maths/math.vector";
  41084. import "babylonjs/Gamepads/gamepadSceneComponent";
  41085. /**
  41086. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41087. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41088. */
  41089. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41090. /**
  41091. * Creates a new VRDeviceOrientationGamepadCamera
  41092. * @param name defines camera name
  41093. * @param position defines the start position of the camera
  41094. * @param scene defines the scene the camera belongs to
  41095. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41096. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41097. */
  41098. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41099. /**
  41100. * Gets camera class name
  41101. * @returns VRDeviceOrientationGamepadCamera
  41102. */
  41103. getClassName(): string;
  41104. }
  41105. }
  41106. declare module "babylonjs/Materials/pushMaterial" {
  41107. import { Nullable } from "babylonjs/types";
  41108. import { Scene } from "babylonjs/scene";
  41109. import { Matrix } from "babylonjs/Maths/math.vector";
  41110. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41111. import { Mesh } from "babylonjs/Meshes/mesh";
  41112. import { Material } from "babylonjs/Materials/material";
  41113. import { Effect } from "babylonjs/Materials/effect";
  41114. /**
  41115. * Base class of materials working in push mode in babylon JS
  41116. * @hidden
  41117. */
  41118. export class PushMaterial extends Material {
  41119. protected _activeEffect: Effect;
  41120. protected _normalMatrix: Matrix;
  41121. /**
  41122. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41123. * This means that the material can keep using a previous shader while a new one is being compiled.
  41124. * This is mostly used when shader parallel compilation is supported (true by default)
  41125. */
  41126. allowShaderHotSwapping: boolean;
  41127. constructor(name: string, scene: Scene);
  41128. getEffect(): Effect;
  41129. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41130. /**
  41131. * Binds the given world matrix to the active effect
  41132. *
  41133. * @param world the matrix to bind
  41134. */
  41135. bindOnlyWorldMatrix(world: Matrix): void;
  41136. /**
  41137. * Binds the given normal matrix to the active effect
  41138. *
  41139. * @param normalMatrix the matrix to bind
  41140. */
  41141. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41142. bind(world: Matrix, mesh?: Mesh): void;
  41143. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41144. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41145. }
  41146. }
  41147. declare module "babylonjs/Materials/materialFlags" {
  41148. /**
  41149. * This groups all the flags used to control the materials channel.
  41150. */
  41151. export class MaterialFlags {
  41152. private static _DiffuseTextureEnabled;
  41153. /**
  41154. * Are diffuse textures enabled in the application.
  41155. */
  41156. static DiffuseTextureEnabled: boolean;
  41157. private static _AmbientTextureEnabled;
  41158. /**
  41159. * Are ambient textures enabled in the application.
  41160. */
  41161. static AmbientTextureEnabled: boolean;
  41162. private static _OpacityTextureEnabled;
  41163. /**
  41164. * Are opacity textures enabled in the application.
  41165. */
  41166. static OpacityTextureEnabled: boolean;
  41167. private static _ReflectionTextureEnabled;
  41168. /**
  41169. * Are reflection textures enabled in the application.
  41170. */
  41171. static ReflectionTextureEnabled: boolean;
  41172. private static _EmissiveTextureEnabled;
  41173. /**
  41174. * Are emissive textures enabled in the application.
  41175. */
  41176. static EmissiveTextureEnabled: boolean;
  41177. private static _SpecularTextureEnabled;
  41178. /**
  41179. * Are specular textures enabled in the application.
  41180. */
  41181. static SpecularTextureEnabled: boolean;
  41182. private static _BumpTextureEnabled;
  41183. /**
  41184. * Are bump textures enabled in the application.
  41185. */
  41186. static BumpTextureEnabled: boolean;
  41187. private static _LightmapTextureEnabled;
  41188. /**
  41189. * Are lightmap textures enabled in the application.
  41190. */
  41191. static LightmapTextureEnabled: boolean;
  41192. private static _RefractionTextureEnabled;
  41193. /**
  41194. * Are refraction textures enabled in the application.
  41195. */
  41196. static RefractionTextureEnabled: boolean;
  41197. private static _ColorGradingTextureEnabled;
  41198. /**
  41199. * Are color grading textures enabled in the application.
  41200. */
  41201. static ColorGradingTextureEnabled: boolean;
  41202. private static _FresnelEnabled;
  41203. /**
  41204. * Are fresnels enabled in the application.
  41205. */
  41206. static FresnelEnabled: boolean;
  41207. private static _ClearCoatTextureEnabled;
  41208. /**
  41209. * Are clear coat textures enabled in the application.
  41210. */
  41211. static ClearCoatTextureEnabled: boolean;
  41212. private static _ClearCoatBumpTextureEnabled;
  41213. /**
  41214. * Are clear coat bump textures enabled in the application.
  41215. */
  41216. static ClearCoatBumpTextureEnabled: boolean;
  41217. private static _ClearCoatTintTextureEnabled;
  41218. /**
  41219. * Are clear coat tint textures enabled in the application.
  41220. */
  41221. static ClearCoatTintTextureEnabled: boolean;
  41222. private static _SheenTextureEnabled;
  41223. /**
  41224. * Are sheen textures enabled in the application.
  41225. */
  41226. static SheenTextureEnabled: boolean;
  41227. private static _AnisotropicTextureEnabled;
  41228. /**
  41229. * Are anisotropic textures enabled in the application.
  41230. */
  41231. static AnisotropicTextureEnabled: boolean;
  41232. private static _ThicknessTextureEnabled;
  41233. /**
  41234. * Are thickness textures enabled in the application.
  41235. */
  41236. static ThicknessTextureEnabled: boolean;
  41237. }
  41238. }
  41239. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41240. /** @hidden */
  41241. export var defaultFragmentDeclaration: {
  41242. name: string;
  41243. shader: string;
  41244. };
  41245. }
  41246. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41247. /** @hidden */
  41248. export var defaultUboDeclaration: {
  41249. name: string;
  41250. shader: string;
  41251. };
  41252. }
  41253. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41254. /** @hidden */
  41255. export var lightFragmentDeclaration: {
  41256. name: string;
  41257. shader: string;
  41258. };
  41259. }
  41260. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41261. /** @hidden */
  41262. export var lightUboDeclaration: {
  41263. name: string;
  41264. shader: string;
  41265. };
  41266. }
  41267. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41268. /** @hidden */
  41269. export var lightsFragmentFunctions: {
  41270. name: string;
  41271. shader: string;
  41272. };
  41273. }
  41274. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41275. /** @hidden */
  41276. export var shadowsFragmentFunctions: {
  41277. name: string;
  41278. shader: string;
  41279. };
  41280. }
  41281. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41282. /** @hidden */
  41283. export var fresnelFunction: {
  41284. name: string;
  41285. shader: string;
  41286. };
  41287. }
  41288. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41289. /** @hidden */
  41290. export var reflectionFunction: {
  41291. name: string;
  41292. shader: string;
  41293. };
  41294. }
  41295. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41296. /** @hidden */
  41297. export var bumpFragmentFunctions: {
  41298. name: string;
  41299. shader: string;
  41300. };
  41301. }
  41302. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41303. /** @hidden */
  41304. export var logDepthDeclaration: {
  41305. name: string;
  41306. shader: string;
  41307. };
  41308. }
  41309. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41310. /** @hidden */
  41311. export var bumpFragment: {
  41312. name: string;
  41313. shader: string;
  41314. };
  41315. }
  41316. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41317. /** @hidden */
  41318. export var depthPrePass: {
  41319. name: string;
  41320. shader: string;
  41321. };
  41322. }
  41323. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41324. /** @hidden */
  41325. export var lightFragment: {
  41326. name: string;
  41327. shader: string;
  41328. };
  41329. }
  41330. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41331. /** @hidden */
  41332. export var logDepthFragment: {
  41333. name: string;
  41334. shader: string;
  41335. };
  41336. }
  41337. declare module "babylonjs/Shaders/default.fragment" {
  41338. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41339. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41340. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41341. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41342. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41343. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41344. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41345. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41346. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41347. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41348. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41349. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41351. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41352. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41353. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41354. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41355. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41356. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41357. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41358. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41359. /** @hidden */
  41360. export var defaultPixelShader: {
  41361. name: string;
  41362. shader: string;
  41363. };
  41364. }
  41365. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41366. /** @hidden */
  41367. export var defaultVertexDeclaration: {
  41368. name: string;
  41369. shader: string;
  41370. };
  41371. }
  41372. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41373. /** @hidden */
  41374. export var bumpVertexDeclaration: {
  41375. name: string;
  41376. shader: string;
  41377. };
  41378. }
  41379. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41380. /** @hidden */
  41381. export var bumpVertex: {
  41382. name: string;
  41383. shader: string;
  41384. };
  41385. }
  41386. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41387. /** @hidden */
  41388. export var fogVertex: {
  41389. name: string;
  41390. shader: string;
  41391. };
  41392. }
  41393. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41394. /** @hidden */
  41395. export var shadowsVertex: {
  41396. name: string;
  41397. shader: string;
  41398. };
  41399. }
  41400. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41401. /** @hidden */
  41402. export var pointCloudVertex: {
  41403. name: string;
  41404. shader: string;
  41405. };
  41406. }
  41407. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41408. /** @hidden */
  41409. export var logDepthVertex: {
  41410. name: string;
  41411. shader: string;
  41412. };
  41413. }
  41414. declare module "babylonjs/Shaders/default.vertex" {
  41415. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41416. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41417. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41418. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41419. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41420. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41421. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41422. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41423. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41424. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41425. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41426. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41427. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41429. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41430. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41431. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41432. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41433. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41434. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41435. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41436. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41437. /** @hidden */
  41438. export var defaultVertexShader: {
  41439. name: string;
  41440. shader: string;
  41441. };
  41442. }
  41443. declare module "babylonjs/Materials/standardMaterial" {
  41444. import { SmartArray } from "babylonjs/Misc/smartArray";
  41445. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41446. import { Nullable } from "babylonjs/types";
  41447. import { Scene } from "babylonjs/scene";
  41448. import { Matrix } from "babylonjs/Maths/math.vector";
  41449. import { Color3 } from "babylonjs/Maths/math.color";
  41450. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41451. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41452. import { Mesh } from "babylonjs/Meshes/mesh";
  41453. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41454. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41455. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41456. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41457. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41458. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41460. import "babylonjs/Shaders/default.fragment";
  41461. import "babylonjs/Shaders/default.vertex";
  41462. /** @hidden */
  41463. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41464. MAINUV1: boolean;
  41465. MAINUV2: boolean;
  41466. DIFFUSE: boolean;
  41467. DIFFUSEDIRECTUV: number;
  41468. AMBIENT: boolean;
  41469. AMBIENTDIRECTUV: number;
  41470. OPACITY: boolean;
  41471. OPACITYDIRECTUV: number;
  41472. OPACITYRGB: boolean;
  41473. REFLECTION: boolean;
  41474. EMISSIVE: boolean;
  41475. EMISSIVEDIRECTUV: number;
  41476. SPECULAR: boolean;
  41477. SPECULARDIRECTUV: number;
  41478. BUMP: boolean;
  41479. BUMPDIRECTUV: number;
  41480. PARALLAX: boolean;
  41481. PARALLAXOCCLUSION: boolean;
  41482. SPECULAROVERALPHA: boolean;
  41483. CLIPPLANE: boolean;
  41484. CLIPPLANE2: boolean;
  41485. CLIPPLANE3: boolean;
  41486. CLIPPLANE4: boolean;
  41487. ALPHATEST: boolean;
  41488. DEPTHPREPASS: boolean;
  41489. ALPHAFROMDIFFUSE: boolean;
  41490. POINTSIZE: boolean;
  41491. FOG: boolean;
  41492. SPECULARTERM: boolean;
  41493. DIFFUSEFRESNEL: boolean;
  41494. OPACITYFRESNEL: boolean;
  41495. REFLECTIONFRESNEL: boolean;
  41496. REFRACTIONFRESNEL: boolean;
  41497. EMISSIVEFRESNEL: boolean;
  41498. FRESNEL: boolean;
  41499. NORMAL: boolean;
  41500. UV1: boolean;
  41501. UV2: boolean;
  41502. VERTEXCOLOR: boolean;
  41503. VERTEXALPHA: boolean;
  41504. NUM_BONE_INFLUENCERS: number;
  41505. BonesPerMesh: number;
  41506. BONETEXTURE: boolean;
  41507. INSTANCES: boolean;
  41508. GLOSSINESS: boolean;
  41509. ROUGHNESS: boolean;
  41510. EMISSIVEASILLUMINATION: boolean;
  41511. LINKEMISSIVEWITHDIFFUSE: boolean;
  41512. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41513. LIGHTMAP: boolean;
  41514. LIGHTMAPDIRECTUV: number;
  41515. OBJECTSPACE_NORMALMAP: boolean;
  41516. USELIGHTMAPASSHADOWMAP: boolean;
  41517. REFLECTIONMAP_3D: boolean;
  41518. REFLECTIONMAP_SPHERICAL: boolean;
  41519. REFLECTIONMAP_PLANAR: boolean;
  41520. REFLECTIONMAP_CUBIC: boolean;
  41521. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41522. REFLECTIONMAP_PROJECTION: boolean;
  41523. REFLECTIONMAP_SKYBOX: boolean;
  41524. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41525. REFLECTIONMAP_EXPLICIT: boolean;
  41526. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41527. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41528. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41529. INVERTCUBICMAP: boolean;
  41530. LOGARITHMICDEPTH: boolean;
  41531. REFRACTION: boolean;
  41532. REFRACTIONMAP_3D: boolean;
  41533. REFLECTIONOVERALPHA: boolean;
  41534. TWOSIDEDLIGHTING: boolean;
  41535. SHADOWFLOAT: boolean;
  41536. MORPHTARGETS: boolean;
  41537. MORPHTARGETS_NORMAL: boolean;
  41538. MORPHTARGETS_TANGENT: boolean;
  41539. MORPHTARGETS_UV: boolean;
  41540. NUM_MORPH_INFLUENCERS: number;
  41541. NONUNIFORMSCALING: boolean;
  41542. PREMULTIPLYALPHA: boolean;
  41543. IMAGEPROCESSING: boolean;
  41544. VIGNETTE: boolean;
  41545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41546. VIGNETTEBLENDMODEOPAQUE: boolean;
  41547. TONEMAPPING: boolean;
  41548. TONEMAPPING_ACES: boolean;
  41549. CONTRAST: boolean;
  41550. COLORCURVES: boolean;
  41551. COLORGRADING: boolean;
  41552. COLORGRADING3D: boolean;
  41553. SAMPLER3DGREENDEPTH: boolean;
  41554. SAMPLER3DBGRMAP: boolean;
  41555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41556. MULTIVIEW: boolean;
  41557. /**
  41558. * If the reflection texture on this material is in linear color space
  41559. * @hidden
  41560. */
  41561. IS_REFLECTION_LINEAR: boolean;
  41562. /**
  41563. * If the refraction texture on this material is in linear color space
  41564. * @hidden
  41565. */
  41566. IS_REFRACTION_LINEAR: boolean;
  41567. EXPOSURE: boolean;
  41568. constructor();
  41569. setReflectionMode(modeToEnable: string): void;
  41570. }
  41571. /**
  41572. * This is the default material used in Babylon. It is the best trade off between quality
  41573. * and performances.
  41574. * @see http://doc.babylonjs.com/babylon101/materials
  41575. */
  41576. export class StandardMaterial extends PushMaterial {
  41577. private _diffuseTexture;
  41578. /**
  41579. * The basic texture of the material as viewed under a light.
  41580. */
  41581. diffuseTexture: Nullable<BaseTexture>;
  41582. private _ambientTexture;
  41583. /**
  41584. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41585. */
  41586. ambientTexture: Nullable<BaseTexture>;
  41587. private _opacityTexture;
  41588. /**
  41589. * Define the transparency of the material from a texture.
  41590. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41591. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41592. */
  41593. opacityTexture: Nullable<BaseTexture>;
  41594. private _reflectionTexture;
  41595. /**
  41596. * Define the texture used to display the reflection.
  41597. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41598. */
  41599. reflectionTexture: Nullable<BaseTexture>;
  41600. private _emissiveTexture;
  41601. /**
  41602. * Define texture of the material as if self lit.
  41603. * This will be mixed in the final result even in the absence of light.
  41604. */
  41605. emissiveTexture: Nullable<BaseTexture>;
  41606. private _specularTexture;
  41607. /**
  41608. * Define how the color and intensity of the highlight given by the light in the material.
  41609. */
  41610. specularTexture: Nullable<BaseTexture>;
  41611. private _bumpTexture;
  41612. /**
  41613. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41614. * 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.
  41615. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41616. */
  41617. bumpTexture: Nullable<BaseTexture>;
  41618. private _lightmapTexture;
  41619. /**
  41620. * Complex lighting can be computationally expensive to compute at runtime.
  41621. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41622. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41623. */
  41624. lightmapTexture: Nullable<BaseTexture>;
  41625. private _refractionTexture;
  41626. /**
  41627. * Define the texture used to display the refraction.
  41628. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41629. */
  41630. refractionTexture: Nullable<BaseTexture>;
  41631. /**
  41632. * The color of the material lit by the environmental background lighting.
  41633. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41634. */
  41635. ambientColor: Color3;
  41636. /**
  41637. * The basic color of the material as viewed under a light.
  41638. */
  41639. diffuseColor: Color3;
  41640. /**
  41641. * Define how the color and intensity of the highlight given by the light in the material.
  41642. */
  41643. specularColor: Color3;
  41644. /**
  41645. * Define the color of the material as if self lit.
  41646. * This will be mixed in the final result even in the absence of light.
  41647. */
  41648. emissiveColor: Color3;
  41649. /**
  41650. * Defines how sharp are the highlights in the material.
  41651. * The bigger the value the sharper giving a more glossy feeling to the result.
  41652. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41653. */
  41654. specularPower: number;
  41655. private _useAlphaFromDiffuseTexture;
  41656. /**
  41657. * Does the transparency come from the diffuse texture alpha channel.
  41658. */
  41659. useAlphaFromDiffuseTexture: boolean;
  41660. private _useEmissiveAsIllumination;
  41661. /**
  41662. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41663. */
  41664. useEmissiveAsIllumination: boolean;
  41665. private _linkEmissiveWithDiffuse;
  41666. /**
  41667. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41668. * the emissive level when the final color is close to one.
  41669. */
  41670. linkEmissiveWithDiffuse: boolean;
  41671. private _useSpecularOverAlpha;
  41672. /**
  41673. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41674. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41675. */
  41676. useSpecularOverAlpha: boolean;
  41677. private _useReflectionOverAlpha;
  41678. /**
  41679. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41680. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41681. */
  41682. useReflectionOverAlpha: boolean;
  41683. private _disableLighting;
  41684. /**
  41685. * Does lights from the scene impacts this material.
  41686. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41687. */
  41688. disableLighting: boolean;
  41689. private _useObjectSpaceNormalMap;
  41690. /**
  41691. * Allows using an object space normal map (instead of tangent space).
  41692. */
  41693. useObjectSpaceNormalMap: boolean;
  41694. private _useParallax;
  41695. /**
  41696. * Is parallax enabled or not.
  41697. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41698. */
  41699. useParallax: boolean;
  41700. private _useParallaxOcclusion;
  41701. /**
  41702. * Is parallax occlusion enabled or not.
  41703. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41704. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41705. */
  41706. useParallaxOcclusion: boolean;
  41707. /**
  41708. * 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.
  41709. */
  41710. parallaxScaleBias: number;
  41711. private _roughness;
  41712. /**
  41713. * Helps to define how blurry the reflections should appears in the material.
  41714. */
  41715. roughness: number;
  41716. /**
  41717. * In case of refraction, define the value of the index of refraction.
  41718. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41719. */
  41720. indexOfRefraction: number;
  41721. /**
  41722. * Invert the refraction texture alongside the y axis.
  41723. * It can be useful with procedural textures or probe for instance.
  41724. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41725. */
  41726. invertRefractionY: boolean;
  41727. /**
  41728. * Defines the alpha limits in alpha test mode.
  41729. */
  41730. alphaCutOff: number;
  41731. private _useLightmapAsShadowmap;
  41732. /**
  41733. * In case of light mapping, define whether the map contains light or shadow informations.
  41734. */
  41735. useLightmapAsShadowmap: boolean;
  41736. private _diffuseFresnelParameters;
  41737. /**
  41738. * Define the diffuse fresnel parameters of the material.
  41739. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41740. */
  41741. diffuseFresnelParameters: FresnelParameters;
  41742. private _opacityFresnelParameters;
  41743. /**
  41744. * Define the opacity fresnel parameters of the material.
  41745. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41746. */
  41747. opacityFresnelParameters: FresnelParameters;
  41748. private _reflectionFresnelParameters;
  41749. /**
  41750. * Define the reflection fresnel parameters of the material.
  41751. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41752. */
  41753. reflectionFresnelParameters: FresnelParameters;
  41754. private _refractionFresnelParameters;
  41755. /**
  41756. * Define the refraction fresnel parameters of the material.
  41757. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41758. */
  41759. refractionFresnelParameters: FresnelParameters;
  41760. private _emissiveFresnelParameters;
  41761. /**
  41762. * Define the emissive fresnel parameters of the material.
  41763. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41764. */
  41765. emissiveFresnelParameters: FresnelParameters;
  41766. private _useReflectionFresnelFromSpecular;
  41767. /**
  41768. * If true automatically deducts the fresnels values from the material specularity.
  41769. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41770. */
  41771. useReflectionFresnelFromSpecular: boolean;
  41772. private _useGlossinessFromSpecularMapAlpha;
  41773. /**
  41774. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41775. */
  41776. useGlossinessFromSpecularMapAlpha: boolean;
  41777. private _maxSimultaneousLights;
  41778. /**
  41779. * Defines the maximum number of lights that can be used in the material
  41780. */
  41781. maxSimultaneousLights: number;
  41782. private _invertNormalMapX;
  41783. /**
  41784. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41785. */
  41786. invertNormalMapX: boolean;
  41787. private _invertNormalMapY;
  41788. /**
  41789. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41790. */
  41791. invertNormalMapY: boolean;
  41792. private _twoSidedLighting;
  41793. /**
  41794. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41795. */
  41796. twoSidedLighting: boolean;
  41797. /**
  41798. * Default configuration related to image processing available in the standard Material.
  41799. */
  41800. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41801. /**
  41802. * Gets the image processing configuration used either in this material.
  41803. */
  41804. /**
  41805. * Sets the Default image processing configuration used either in the this material.
  41806. *
  41807. * If sets to null, the scene one is in use.
  41808. */
  41809. imageProcessingConfiguration: ImageProcessingConfiguration;
  41810. /**
  41811. * Keep track of the image processing observer to allow dispose and replace.
  41812. */
  41813. private _imageProcessingObserver;
  41814. /**
  41815. * Attaches a new image processing configuration to the Standard Material.
  41816. * @param configuration
  41817. */
  41818. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41819. /**
  41820. * Gets wether the color curves effect is enabled.
  41821. */
  41822. /**
  41823. * Sets wether the color curves effect is enabled.
  41824. */
  41825. cameraColorCurvesEnabled: boolean;
  41826. /**
  41827. * Gets wether the color grading effect is enabled.
  41828. */
  41829. /**
  41830. * Gets wether the color grading effect is enabled.
  41831. */
  41832. cameraColorGradingEnabled: boolean;
  41833. /**
  41834. * Gets wether tonemapping is enabled or not.
  41835. */
  41836. /**
  41837. * Sets wether tonemapping is enabled or not
  41838. */
  41839. cameraToneMappingEnabled: boolean;
  41840. /**
  41841. * The camera exposure used on this material.
  41842. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41843. * This corresponds to a photographic exposure.
  41844. */
  41845. /**
  41846. * The camera exposure used on this material.
  41847. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41848. * This corresponds to a photographic exposure.
  41849. */
  41850. cameraExposure: number;
  41851. /**
  41852. * Gets The camera contrast used on this material.
  41853. */
  41854. /**
  41855. * Sets The camera contrast used on this material.
  41856. */
  41857. cameraContrast: number;
  41858. /**
  41859. * Gets the Color Grading 2D Lookup Texture.
  41860. */
  41861. /**
  41862. * Sets the Color Grading 2D Lookup Texture.
  41863. */
  41864. cameraColorGradingTexture: Nullable<BaseTexture>;
  41865. /**
  41866. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41867. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41868. * 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;
  41869. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41870. */
  41871. /**
  41872. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41873. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41874. * 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;
  41875. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41876. */
  41877. cameraColorCurves: Nullable<ColorCurves>;
  41878. /**
  41879. * Custom callback helping to override the default shader used in the material.
  41880. */
  41881. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41882. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41883. protected _worldViewProjectionMatrix: Matrix;
  41884. protected _globalAmbientColor: Color3;
  41885. protected _useLogarithmicDepth: boolean;
  41886. protected _rebuildInParallel: boolean;
  41887. /**
  41888. * Instantiates a new standard material.
  41889. * This is the default material used in Babylon. It is the best trade off between quality
  41890. * and performances.
  41891. * @see http://doc.babylonjs.com/babylon101/materials
  41892. * @param name Define the name of the material in the scene
  41893. * @param scene Define the scene the material belong to
  41894. */
  41895. constructor(name: string, scene: Scene);
  41896. /**
  41897. * Gets a boolean indicating that current material needs to register RTT
  41898. */
  41899. readonly hasRenderTargetTextures: boolean;
  41900. /**
  41901. * Gets the current class name of the material e.g. "StandardMaterial"
  41902. * Mainly use in serialization.
  41903. * @returns the class name
  41904. */
  41905. getClassName(): string;
  41906. /**
  41907. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41908. * You can try switching to logarithmic depth.
  41909. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41910. */
  41911. useLogarithmicDepth: boolean;
  41912. /**
  41913. * Specifies if the material will require alpha blending
  41914. * @returns a boolean specifying if alpha blending is needed
  41915. */
  41916. needAlphaBlending(): boolean;
  41917. /**
  41918. * Specifies if this material should be rendered in alpha test mode
  41919. * @returns a boolean specifying if an alpha test is needed.
  41920. */
  41921. needAlphaTesting(): boolean;
  41922. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41923. /**
  41924. * Get the texture used for alpha test purpose.
  41925. * @returns the diffuse texture in case of the standard material.
  41926. */
  41927. getAlphaTestTexture(): Nullable<BaseTexture>;
  41928. /**
  41929. * Get if the submesh is ready to be used and all its information available.
  41930. * Child classes can use it to update shaders
  41931. * @param mesh defines the mesh to check
  41932. * @param subMesh defines which submesh to check
  41933. * @param useInstances specifies that instances should be used
  41934. * @returns a boolean indicating that the submesh is ready or not
  41935. */
  41936. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41937. /**
  41938. * Builds the material UBO layouts.
  41939. * Used internally during the effect preparation.
  41940. */
  41941. buildUniformLayout(): void;
  41942. /**
  41943. * Unbinds the material from the mesh
  41944. */
  41945. unbind(): void;
  41946. /**
  41947. * Binds the submesh to this material by preparing the effect and shader to draw
  41948. * @param world defines the world transformation matrix
  41949. * @param mesh defines the mesh containing the submesh
  41950. * @param subMesh defines the submesh to bind the material to
  41951. */
  41952. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41953. /**
  41954. * Get the list of animatables in the material.
  41955. * @returns the list of animatables object used in the material
  41956. */
  41957. getAnimatables(): IAnimatable[];
  41958. /**
  41959. * Gets the active textures from the material
  41960. * @returns an array of textures
  41961. */
  41962. getActiveTextures(): BaseTexture[];
  41963. /**
  41964. * Specifies if the material uses a texture
  41965. * @param texture defines the texture to check against the material
  41966. * @returns a boolean specifying if the material uses the texture
  41967. */
  41968. hasTexture(texture: BaseTexture): boolean;
  41969. /**
  41970. * Disposes the material
  41971. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41972. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41973. */
  41974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41975. /**
  41976. * Makes a duplicate of the material, and gives it a new name
  41977. * @param name defines the new name for the duplicated material
  41978. * @returns the cloned material
  41979. */
  41980. clone(name: string): StandardMaterial;
  41981. /**
  41982. * Serializes this material in a JSON representation
  41983. * @returns the serialized material object
  41984. */
  41985. serialize(): any;
  41986. /**
  41987. * Creates a standard material from parsed material data
  41988. * @param source defines the JSON representation of the material
  41989. * @param scene defines the hosting scene
  41990. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  41991. * @returns a new standard material
  41992. */
  41993. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  41994. /**
  41995. * Are diffuse textures enabled in the application.
  41996. */
  41997. static DiffuseTextureEnabled: boolean;
  41998. /**
  41999. * Are ambient textures enabled in the application.
  42000. */
  42001. static AmbientTextureEnabled: boolean;
  42002. /**
  42003. * Are opacity textures enabled in the application.
  42004. */
  42005. static OpacityTextureEnabled: boolean;
  42006. /**
  42007. * Are reflection textures enabled in the application.
  42008. */
  42009. static ReflectionTextureEnabled: boolean;
  42010. /**
  42011. * Are emissive textures enabled in the application.
  42012. */
  42013. static EmissiveTextureEnabled: boolean;
  42014. /**
  42015. * Are specular textures enabled in the application.
  42016. */
  42017. static SpecularTextureEnabled: boolean;
  42018. /**
  42019. * Are bump textures enabled in the application.
  42020. */
  42021. static BumpTextureEnabled: boolean;
  42022. /**
  42023. * Are lightmap textures enabled in the application.
  42024. */
  42025. static LightmapTextureEnabled: boolean;
  42026. /**
  42027. * Are refraction textures enabled in the application.
  42028. */
  42029. static RefractionTextureEnabled: boolean;
  42030. /**
  42031. * Are color grading textures enabled in the application.
  42032. */
  42033. static ColorGradingTextureEnabled: boolean;
  42034. /**
  42035. * Are fresnels enabled in the application.
  42036. */
  42037. static FresnelEnabled: boolean;
  42038. }
  42039. }
  42040. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42041. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42042. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42043. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42044. /** @hidden */
  42045. export var imageProcessingPixelShader: {
  42046. name: string;
  42047. shader: string;
  42048. };
  42049. }
  42050. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42051. import { Nullable } from "babylonjs/types";
  42052. import { Color4 } from "babylonjs/Maths/math.color";
  42053. import { Camera } from "babylonjs/Cameras/camera";
  42054. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42055. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42056. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42057. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42058. import { Engine } from "babylonjs/Engines/engine";
  42059. import "babylonjs/Shaders/imageProcessing.fragment";
  42060. import "babylonjs/Shaders/postprocess.vertex";
  42061. /**
  42062. * ImageProcessingPostProcess
  42063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42064. */
  42065. export class ImageProcessingPostProcess extends PostProcess {
  42066. /**
  42067. * Default configuration related to image processing available in the PBR Material.
  42068. */
  42069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42070. /**
  42071. * Gets the image processing configuration used either in this material.
  42072. */
  42073. /**
  42074. * Sets the Default image processing configuration used either in the this material.
  42075. *
  42076. * If sets to null, the scene one is in use.
  42077. */
  42078. imageProcessingConfiguration: ImageProcessingConfiguration;
  42079. /**
  42080. * Keep track of the image processing observer to allow dispose and replace.
  42081. */
  42082. private _imageProcessingObserver;
  42083. /**
  42084. * Attaches a new image processing configuration to the PBR Material.
  42085. * @param configuration
  42086. */
  42087. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42088. /**
  42089. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42090. */
  42091. /**
  42092. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42093. */
  42094. colorCurves: Nullable<ColorCurves>;
  42095. /**
  42096. * Gets wether the color curves effect is enabled.
  42097. */
  42098. /**
  42099. * Sets wether the color curves effect is enabled.
  42100. */
  42101. colorCurvesEnabled: boolean;
  42102. /**
  42103. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42104. */
  42105. /**
  42106. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42107. */
  42108. colorGradingTexture: Nullable<BaseTexture>;
  42109. /**
  42110. * Gets wether the color grading effect is enabled.
  42111. */
  42112. /**
  42113. * Gets wether the color grading effect is enabled.
  42114. */
  42115. colorGradingEnabled: boolean;
  42116. /**
  42117. * Gets exposure used in the effect.
  42118. */
  42119. /**
  42120. * Sets exposure used in the effect.
  42121. */
  42122. exposure: number;
  42123. /**
  42124. * Gets wether tonemapping is enabled or not.
  42125. */
  42126. /**
  42127. * Sets wether tonemapping is enabled or not
  42128. */
  42129. toneMappingEnabled: boolean;
  42130. /**
  42131. * Gets the type of tone mapping effect.
  42132. */
  42133. /**
  42134. * Sets the type of tone mapping effect.
  42135. */
  42136. toneMappingType: number;
  42137. /**
  42138. * Gets contrast used in the effect.
  42139. */
  42140. /**
  42141. * Sets contrast used in the effect.
  42142. */
  42143. contrast: number;
  42144. /**
  42145. * Gets Vignette stretch size.
  42146. */
  42147. /**
  42148. * Sets Vignette stretch size.
  42149. */
  42150. vignetteStretch: number;
  42151. /**
  42152. * Gets Vignette centre X Offset.
  42153. */
  42154. /**
  42155. * Sets Vignette centre X Offset.
  42156. */
  42157. vignetteCentreX: number;
  42158. /**
  42159. * Gets Vignette centre Y Offset.
  42160. */
  42161. /**
  42162. * Sets Vignette centre Y Offset.
  42163. */
  42164. vignetteCentreY: number;
  42165. /**
  42166. * Gets Vignette weight or intensity of the vignette effect.
  42167. */
  42168. /**
  42169. * Sets Vignette weight or intensity of the vignette effect.
  42170. */
  42171. vignetteWeight: number;
  42172. /**
  42173. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42174. * if vignetteEnabled is set to true.
  42175. */
  42176. /**
  42177. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42178. * if vignetteEnabled is set to true.
  42179. */
  42180. vignetteColor: Color4;
  42181. /**
  42182. * Gets Camera field of view used by the Vignette effect.
  42183. */
  42184. /**
  42185. * Sets Camera field of view used by the Vignette effect.
  42186. */
  42187. vignetteCameraFov: number;
  42188. /**
  42189. * Gets the vignette blend mode allowing different kind of effect.
  42190. */
  42191. /**
  42192. * Sets the vignette blend mode allowing different kind of effect.
  42193. */
  42194. vignetteBlendMode: number;
  42195. /**
  42196. * Gets wether the vignette effect is enabled.
  42197. */
  42198. /**
  42199. * Sets wether the vignette effect is enabled.
  42200. */
  42201. vignetteEnabled: boolean;
  42202. private _fromLinearSpace;
  42203. /**
  42204. * Gets wether the input of the processing is in Gamma or Linear Space.
  42205. */
  42206. /**
  42207. * Sets wether the input of the processing is in Gamma or Linear Space.
  42208. */
  42209. fromLinearSpace: boolean;
  42210. /**
  42211. * Defines cache preventing GC.
  42212. */
  42213. private _defines;
  42214. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42215. /**
  42216. * "ImageProcessingPostProcess"
  42217. * @returns "ImageProcessingPostProcess"
  42218. */
  42219. getClassName(): string;
  42220. protected _updateParameters(): void;
  42221. dispose(camera?: Camera): void;
  42222. }
  42223. }
  42224. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42225. import { Scene } from "babylonjs/scene";
  42226. import { Color3 } from "babylonjs/Maths/math.color";
  42227. import { Mesh } from "babylonjs/Meshes/mesh";
  42228. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42229. import { Nullable } from "babylonjs/types";
  42230. /**
  42231. * Class containing static functions to help procedurally build meshes
  42232. */
  42233. export class GroundBuilder {
  42234. /**
  42235. * Creates a ground mesh
  42236. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42237. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42238. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42239. * @param name defines the name of the mesh
  42240. * @param options defines the options used to create the mesh
  42241. * @param scene defines the hosting scene
  42242. * @returns the ground mesh
  42243. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42244. */
  42245. static CreateGround(name: string, options: {
  42246. width?: number;
  42247. height?: number;
  42248. subdivisions?: number;
  42249. subdivisionsX?: number;
  42250. subdivisionsY?: number;
  42251. updatable?: boolean;
  42252. }, scene: any): Mesh;
  42253. /**
  42254. * Creates a tiled ground mesh
  42255. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42256. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42257. * * 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
  42258. * * 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
  42259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42260. * @param name defines the name of the mesh
  42261. * @param options defines the options used to create the mesh
  42262. * @param scene defines the hosting scene
  42263. * @returns the tiled ground mesh
  42264. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42265. */
  42266. static CreateTiledGround(name: string, options: {
  42267. xmin: number;
  42268. zmin: number;
  42269. xmax: number;
  42270. zmax: number;
  42271. subdivisions?: {
  42272. w: number;
  42273. h: number;
  42274. };
  42275. precision?: {
  42276. w: number;
  42277. h: number;
  42278. };
  42279. updatable?: boolean;
  42280. }, scene?: Nullable<Scene>): Mesh;
  42281. /**
  42282. * Creates a ground mesh from a height map
  42283. * * The parameter `url` sets the URL of the height map image resource.
  42284. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42285. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42286. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42287. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42288. * * 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.
  42289. * * 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).
  42290. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42292. * @param name defines the name of the mesh
  42293. * @param url defines the url to the height map
  42294. * @param options defines the options used to create the mesh
  42295. * @param scene defines the hosting scene
  42296. * @returns the ground mesh
  42297. * @see https://doc.babylonjs.com/babylon101/height_map
  42298. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42299. */
  42300. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42301. width?: number;
  42302. height?: number;
  42303. subdivisions?: number;
  42304. minHeight?: number;
  42305. maxHeight?: number;
  42306. colorFilter?: Color3;
  42307. alphaFilter?: number;
  42308. updatable?: boolean;
  42309. onReady?: (mesh: GroundMesh) => void;
  42310. }, scene?: Nullable<Scene>): GroundMesh;
  42311. }
  42312. }
  42313. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42314. import { Vector4 } from "babylonjs/Maths/math.vector";
  42315. import { Mesh } from "babylonjs/Meshes/mesh";
  42316. /**
  42317. * Class containing static functions to help procedurally build meshes
  42318. */
  42319. export class TorusBuilder {
  42320. /**
  42321. * Creates a torus mesh
  42322. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42323. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42324. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42325. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42326. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42327. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42328. * @param name defines the name of the mesh
  42329. * @param options defines the options used to create the mesh
  42330. * @param scene defines the hosting scene
  42331. * @returns the torus mesh
  42332. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42333. */
  42334. static CreateTorus(name: string, options: {
  42335. diameter?: number;
  42336. thickness?: number;
  42337. tessellation?: number;
  42338. updatable?: boolean;
  42339. sideOrientation?: number;
  42340. frontUVs?: Vector4;
  42341. backUVs?: Vector4;
  42342. }, scene: any): Mesh;
  42343. }
  42344. }
  42345. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42346. import { Vector4 } from "babylonjs/Maths/math.vector";
  42347. import { Color4 } from "babylonjs/Maths/math.color";
  42348. import { Mesh } from "babylonjs/Meshes/mesh";
  42349. /**
  42350. * Class containing static functions to help procedurally build meshes
  42351. */
  42352. export class CylinderBuilder {
  42353. /**
  42354. * Creates a cylinder or a cone mesh
  42355. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42356. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42357. * * 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.
  42358. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42359. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42360. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42361. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42362. * * 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).
  42363. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42364. * * 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).
  42365. * * 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
  42366. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42367. * * 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
  42368. * * 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.
  42369. * * If `enclose` is false, a ring surface is one element.
  42370. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42371. * * 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
  42372. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42373. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42374. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42375. * @param name defines the name of the mesh
  42376. * @param options defines the options used to create the mesh
  42377. * @param scene defines the hosting scene
  42378. * @returns the cylinder mesh
  42379. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42380. */
  42381. static CreateCylinder(name: string, options: {
  42382. height?: number;
  42383. diameterTop?: number;
  42384. diameterBottom?: number;
  42385. diameter?: number;
  42386. tessellation?: number;
  42387. subdivisions?: number;
  42388. arc?: number;
  42389. faceColors?: Color4[];
  42390. faceUV?: Vector4[];
  42391. updatable?: boolean;
  42392. hasRings?: boolean;
  42393. enclose?: boolean;
  42394. cap?: number;
  42395. sideOrientation?: number;
  42396. frontUVs?: Vector4;
  42397. backUVs?: Vector4;
  42398. }, scene: any): Mesh;
  42399. }
  42400. }
  42401. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42402. import { Observable } from "babylonjs/Misc/observable";
  42403. import { Nullable } from "babylonjs/types";
  42404. import { Camera } from "babylonjs/Cameras/camera";
  42405. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42406. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42407. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42408. import { Scene } from "babylonjs/scene";
  42409. import { Vector3 } from "babylonjs/Maths/math.vector";
  42410. import { Color3 } from "babylonjs/Maths/math.color";
  42411. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42413. import { Mesh } from "babylonjs/Meshes/mesh";
  42414. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42415. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42416. import "babylonjs/Meshes/Builders/groundBuilder";
  42417. import "babylonjs/Meshes/Builders/torusBuilder";
  42418. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42419. import "babylonjs/Gamepads/gamepadSceneComponent";
  42420. import "babylonjs/Animations/animatable";
  42421. /**
  42422. * Options to modify the vr teleportation behavior.
  42423. */
  42424. export interface VRTeleportationOptions {
  42425. /**
  42426. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42427. */
  42428. floorMeshName?: string;
  42429. /**
  42430. * A list of meshes to be used as the teleportation floor. (default: empty)
  42431. */
  42432. floorMeshes?: Mesh[];
  42433. }
  42434. /**
  42435. * Options to modify the vr experience helper's behavior.
  42436. */
  42437. export interface VRExperienceHelperOptions extends WebVROptions {
  42438. /**
  42439. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42440. */
  42441. createDeviceOrientationCamera?: boolean;
  42442. /**
  42443. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42444. */
  42445. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42446. /**
  42447. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42448. */
  42449. laserToggle?: boolean;
  42450. /**
  42451. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42452. */
  42453. floorMeshes?: Mesh[];
  42454. /**
  42455. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42456. */
  42457. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42458. }
  42459. /**
  42460. * Event containing information after VR has been entered
  42461. */
  42462. export class OnAfterEnteringVRObservableEvent {
  42463. /**
  42464. * If entering vr was successful
  42465. */
  42466. success: boolean;
  42467. }
  42468. /**
  42469. * Helps to quickly add VR support to an existing scene.
  42470. * See http://doc.babylonjs.com/how_to/webvr_helper
  42471. */
  42472. export class VRExperienceHelper {
  42473. /** Options to modify the vr experience helper's behavior. */
  42474. webVROptions: VRExperienceHelperOptions;
  42475. private _scene;
  42476. private _position;
  42477. private _btnVR;
  42478. private _btnVRDisplayed;
  42479. private _webVRsupported;
  42480. private _webVRready;
  42481. private _webVRrequesting;
  42482. private _webVRpresenting;
  42483. private _hasEnteredVR;
  42484. private _fullscreenVRpresenting;
  42485. private _canvas;
  42486. private _webVRCamera;
  42487. private _vrDeviceOrientationCamera;
  42488. private _deviceOrientationCamera;
  42489. private _existingCamera;
  42490. private _onKeyDown;
  42491. private _onVrDisplayPresentChange;
  42492. private _onVRDisplayChanged;
  42493. private _onVRRequestPresentStart;
  42494. private _onVRRequestPresentComplete;
  42495. /**
  42496. * 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)
  42497. */
  42498. enableGazeEvenWhenNoPointerLock: boolean;
  42499. /**
  42500. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42501. */
  42502. exitVROnDoubleTap: boolean;
  42503. /**
  42504. * Observable raised right before entering VR.
  42505. */
  42506. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42507. /**
  42508. * Observable raised when entering VR has completed.
  42509. */
  42510. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42511. /**
  42512. * Observable raised when exiting VR.
  42513. */
  42514. onExitingVRObservable: Observable<VRExperienceHelper>;
  42515. /**
  42516. * Observable raised when controller mesh is loaded.
  42517. */
  42518. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42519. /** Return this.onEnteringVRObservable
  42520. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42521. */
  42522. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42523. /** Return this.onExitingVRObservable
  42524. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42525. */
  42526. readonly onExitingVR: Observable<VRExperienceHelper>;
  42527. /** Return this.onControllerMeshLoadedObservable
  42528. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42529. */
  42530. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42531. private _rayLength;
  42532. private _useCustomVRButton;
  42533. private _teleportationRequested;
  42534. private _teleportActive;
  42535. private _floorMeshName;
  42536. private _floorMeshesCollection;
  42537. private _rotationAllowed;
  42538. private _teleportBackwardsVector;
  42539. private _teleportationTarget;
  42540. private _isDefaultTeleportationTarget;
  42541. private _postProcessMove;
  42542. private _teleportationFillColor;
  42543. private _teleportationBorderColor;
  42544. private _rotationAngle;
  42545. private _haloCenter;
  42546. private _cameraGazer;
  42547. private _padSensibilityUp;
  42548. private _padSensibilityDown;
  42549. private _leftController;
  42550. private _rightController;
  42551. /**
  42552. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42553. */
  42554. onNewMeshSelected: Observable<AbstractMesh>;
  42555. /**
  42556. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42557. * This observable will provide the mesh and the controller used to select the mesh
  42558. */
  42559. onMeshSelectedWithController: Observable<{
  42560. mesh: AbstractMesh;
  42561. controller: WebVRController;
  42562. }>;
  42563. /**
  42564. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42565. */
  42566. onNewMeshPicked: Observable<PickingInfo>;
  42567. private _circleEase;
  42568. /**
  42569. * Observable raised before camera teleportation
  42570. */
  42571. onBeforeCameraTeleport: Observable<Vector3>;
  42572. /**
  42573. * Observable raised after camera teleportation
  42574. */
  42575. onAfterCameraTeleport: Observable<Vector3>;
  42576. /**
  42577. * Observable raised when current selected mesh gets unselected
  42578. */
  42579. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42580. private _raySelectionPredicate;
  42581. /**
  42582. * To be optionaly changed by user to define custom ray selection
  42583. */
  42584. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42585. /**
  42586. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42587. */
  42588. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42589. /**
  42590. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42591. */
  42592. teleportationEnabled: boolean;
  42593. private _defaultHeight;
  42594. private _teleportationInitialized;
  42595. private _interactionsEnabled;
  42596. private _interactionsRequested;
  42597. private _displayGaze;
  42598. private _displayLaserPointer;
  42599. /**
  42600. * The mesh used to display where the user is going to teleport.
  42601. */
  42602. /**
  42603. * Sets the mesh to be used to display where the user is going to teleport.
  42604. */
  42605. teleportationTarget: Mesh;
  42606. /**
  42607. * 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
  42608. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42609. * See http://doc.babylonjs.com/resources/baking_transformations
  42610. */
  42611. gazeTrackerMesh: Mesh;
  42612. /**
  42613. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42614. */
  42615. updateGazeTrackerScale: boolean;
  42616. /**
  42617. * If the gaze trackers color should be updated when selecting meshes
  42618. */
  42619. updateGazeTrackerColor: boolean;
  42620. /**
  42621. * If the controller laser color should be updated when selecting meshes
  42622. */
  42623. updateControllerLaserColor: boolean;
  42624. /**
  42625. * The gaze tracking mesh corresponding to the left controller
  42626. */
  42627. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42628. /**
  42629. * The gaze tracking mesh corresponding to the right controller
  42630. */
  42631. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42632. /**
  42633. * If the ray of the gaze should be displayed.
  42634. */
  42635. /**
  42636. * Sets if the ray of the gaze should be displayed.
  42637. */
  42638. displayGaze: boolean;
  42639. /**
  42640. * If the ray of the LaserPointer should be displayed.
  42641. */
  42642. /**
  42643. * Sets if the ray of the LaserPointer should be displayed.
  42644. */
  42645. displayLaserPointer: boolean;
  42646. /**
  42647. * The deviceOrientationCamera used as the camera when not in VR.
  42648. */
  42649. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42650. /**
  42651. * Based on the current WebVR support, returns the current VR camera used.
  42652. */
  42653. readonly currentVRCamera: Nullable<Camera>;
  42654. /**
  42655. * The webVRCamera which is used when in VR.
  42656. */
  42657. readonly webVRCamera: WebVRFreeCamera;
  42658. /**
  42659. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42660. */
  42661. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42662. /**
  42663. * The html button that is used to trigger entering into VR.
  42664. */
  42665. readonly vrButton: Nullable<HTMLButtonElement>;
  42666. private readonly _teleportationRequestInitiated;
  42667. /**
  42668. * Defines wether or not Pointer lock should be requested when switching to
  42669. * full screen.
  42670. */
  42671. requestPointerLockOnFullScreen: boolean;
  42672. /**
  42673. * Instantiates a VRExperienceHelper.
  42674. * Helps to quickly add VR support to an existing scene.
  42675. * @param scene The scene the VRExperienceHelper belongs to.
  42676. * @param webVROptions Options to modify the vr experience helper's behavior.
  42677. */
  42678. constructor(scene: Scene,
  42679. /** Options to modify the vr experience helper's behavior. */
  42680. webVROptions?: VRExperienceHelperOptions);
  42681. private _onDefaultMeshLoaded;
  42682. private _onResize;
  42683. private _onFullscreenChange;
  42684. /**
  42685. * Gets a value indicating if we are currently in VR mode.
  42686. */
  42687. readonly isInVRMode: boolean;
  42688. private onVrDisplayPresentChange;
  42689. private onVRDisplayChanged;
  42690. private moveButtonToBottomRight;
  42691. private displayVRButton;
  42692. private updateButtonVisibility;
  42693. private _cachedAngularSensibility;
  42694. /**
  42695. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42696. * Otherwise, will use the fullscreen API.
  42697. */
  42698. enterVR(): void;
  42699. /**
  42700. * Attempt to exit VR, or fullscreen.
  42701. */
  42702. exitVR(): void;
  42703. /**
  42704. * The position of the vr experience helper.
  42705. */
  42706. /**
  42707. * Sets the position of the vr experience helper.
  42708. */
  42709. position: Vector3;
  42710. /**
  42711. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42712. */
  42713. enableInteractions(): void;
  42714. private readonly _noControllerIsActive;
  42715. private beforeRender;
  42716. private _isTeleportationFloor;
  42717. /**
  42718. * Adds a floor mesh to be used for teleportation.
  42719. * @param floorMesh the mesh to be used for teleportation.
  42720. */
  42721. addFloorMesh(floorMesh: Mesh): void;
  42722. /**
  42723. * Removes a floor mesh from being used for teleportation.
  42724. * @param floorMesh the mesh to be removed.
  42725. */
  42726. removeFloorMesh(floorMesh: Mesh): void;
  42727. /**
  42728. * Enables interactions and teleportation using the VR controllers and gaze.
  42729. * @param vrTeleportationOptions options to modify teleportation behavior.
  42730. */
  42731. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42732. private _onNewGamepadConnected;
  42733. private _tryEnableInteractionOnController;
  42734. private _onNewGamepadDisconnected;
  42735. private _enableInteractionOnController;
  42736. private _checkTeleportWithRay;
  42737. private _checkRotate;
  42738. private _checkTeleportBackwards;
  42739. private _enableTeleportationOnController;
  42740. private _createTeleportationCircles;
  42741. private _displayTeleportationTarget;
  42742. private _hideTeleportationTarget;
  42743. private _rotateCamera;
  42744. private _moveTeleportationSelectorTo;
  42745. private _workingVector;
  42746. private _workingQuaternion;
  42747. private _workingMatrix;
  42748. /**
  42749. * Teleports the users feet to the desired location
  42750. * @param location The location where the user's feet should be placed
  42751. */
  42752. teleportCamera(location: Vector3): void;
  42753. private _convertNormalToDirectionOfRay;
  42754. private _castRayAndSelectObject;
  42755. private _notifySelectedMeshUnselected;
  42756. /**
  42757. * Sets the color of the laser ray from the vr controllers.
  42758. * @param color new color for the ray.
  42759. */
  42760. changeLaserColor(color: Color3): void;
  42761. /**
  42762. * Sets the color of the ray from the vr headsets gaze.
  42763. * @param color new color for the ray.
  42764. */
  42765. changeGazeColor(color: Color3): void;
  42766. /**
  42767. * Exits VR and disposes of the vr experience helper
  42768. */
  42769. dispose(): void;
  42770. /**
  42771. * Gets the name of the VRExperienceHelper class
  42772. * @returns "VRExperienceHelper"
  42773. */
  42774. getClassName(): string;
  42775. }
  42776. }
  42777. declare module "babylonjs/Cameras/VR/index" {
  42778. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42779. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42780. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42781. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42782. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42783. export * from "babylonjs/Cameras/VR/webVRCamera";
  42784. }
  42785. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42786. import { Observable } from "babylonjs/Misc/observable";
  42787. import { Nullable } from "babylonjs/types";
  42788. import { IDisposable, Scene } from "babylonjs/scene";
  42789. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42790. /**
  42791. * Manages an XRSession to work with Babylon's engine
  42792. * @see https://doc.babylonjs.com/how_to/webxr
  42793. */
  42794. export class WebXRSessionManager implements IDisposable {
  42795. private scene;
  42796. /**
  42797. * Fires every time a new xrFrame arrives which can be used to update the camera
  42798. */
  42799. onXRFrameObservable: Observable<any>;
  42800. /**
  42801. * Fires when the xr session is ended either by the device or manually done
  42802. */
  42803. onXRSessionEnded: Observable<any>;
  42804. /**
  42805. * Underlying xr session
  42806. */
  42807. session: XRSession;
  42808. /**
  42809. * Type of reference space used when creating the session
  42810. */
  42811. referenceSpace: XRReferenceSpace;
  42812. /** @hidden */
  42813. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42814. /**
  42815. * Current XR frame
  42816. */
  42817. currentFrame: Nullable<XRFrame>;
  42818. private _xrNavigator;
  42819. private baseLayer;
  42820. /**
  42821. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42822. * @param scene The scene which the session should be created for
  42823. */
  42824. constructor(scene: Scene);
  42825. /**
  42826. * Initializes the manager
  42827. * After initialization enterXR can be called to start an XR session
  42828. * @returns Promise which resolves after it is initialized
  42829. */
  42830. initializeAsync(): Promise<void>;
  42831. /**
  42832. * Initializes an xr session
  42833. * @param xrSessionMode mode to initialize
  42834. * @returns a promise which will resolve once the session has been initialized
  42835. */
  42836. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42837. /**
  42838. * Sets the reference space on the xr session
  42839. * @param referenceSpace space to set
  42840. * @returns a promise that will resolve once the reference space has been set
  42841. */
  42842. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42843. /**
  42844. * Updates the render state of the session
  42845. * @param state state to set
  42846. * @returns a promise that resolves once the render state has been updated
  42847. */
  42848. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42849. /**
  42850. * Starts rendering to the xr layer
  42851. * @returns a promise that will resolve once rendering has started
  42852. */
  42853. startRenderingToXRAsync(): Promise<void>;
  42854. /**
  42855. * Stops the xrSession and restores the renderloop
  42856. * @returns Promise which resolves after it exits XR
  42857. */
  42858. exitXRAsync(): Promise<unknown>;
  42859. /**
  42860. * Checks if a session would be supported for the creation options specified
  42861. * @param sessionMode session mode to check if supported eg. immersive-vr
  42862. * @returns true if supported
  42863. */
  42864. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42865. /**
  42866. * @hidden
  42867. * Converts the render layer of xrSession to a render target
  42868. * @param session session to create render target for
  42869. * @param scene scene the new render target should be created for
  42870. */
  42871. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42872. /**
  42873. * Disposes of the session manager
  42874. */
  42875. dispose(): void;
  42876. }
  42877. }
  42878. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42879. import { Scene } from "babylonjs/scene";
  42880. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42881. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42882. /**
  42883. * WebXR Camera which holds the views for the xrSession
  42884. * @see https://doc.babylonjs.com/how_to/webxr
  42885. */
  42886. export class WebXRCamera extends FreeCamera {
  42887. private static _TmpMatrix;
  42888. /**
  42889. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42890. * @param name the name of the camera
  42891. * @param scene the scene to add the camera to
  42892. */
  42893. constructor(name: string, scene: Scene);
  42894. private _updateNumberOfRigCameras;
  42895. /** @hidden */
  42896. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42897. /**
  42898. * Updates the cameras position from the current pose information of the XR session
  42899. * @param xrSessionManager the session containing pose information
  42900. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42901. */
  42902. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42903. }
  42904. }
  42905. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42906. import { Nullable } from "babylonjs/types";
  42907. import { IDisposable } from "babylonjs/scene";
  42908. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42909. /**
  42910. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42911. */
  42912. export class WebXRManagedOutputCanvas implements IDisposable {
  42913. private helper;
  42914. private _canvas;
  42915. /**
  42916. * xrpresent context of the canvas which can be used to display/mirror xr content
  42917. */
  42918. canvasContext: WebGLRenderingContext;
  42919. /**
  42920. * xr layer for the canvas
  42921. */
  42922. xrLayer: Nullable<XRWebGLLayer>;
  42923. /**
  42924. * Initializes the xr layer for the session
  42925. * @param xrSession xr session
  42926. * @returns a promise that will resolve once the XR Layer has been created
  42927. */
  42928. initializeXRLayerAsync(xrSession: any): any;
  42929. /**
  42930. * Initializes the canvas to be added/removed upon entering/exiting xr
  42931. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42932. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42933. */
  42934. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42935. /**
  42936. * Disposes of the object
  42937. */
  42938. dispose(): void;
  42939. private _setManagedOutputCanvas;
  42940. private _addCanvas;
  42941. private _removeCanvas;
  42942. }
  42943. }
  42944. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42945. import { Observable } from "babylonjs/Misc/observable";
  42946. import { IDisposable, Scene } from "babylonjs/scene";
  42947. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42949. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42950. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42951. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42952. /**
  42953. * States of the webXR experience
  42954. */
  42955. export enum WebXRState {
  42956. /**
  42957. * Transitioning to being in XR mode
  42958. */
  42959. ENTERING_XR = 0,
  42960. /**
  42961. * Transitioning to non XR mode
  42962. */
  42963. EXITING_XR = 1,
  42964. /**
  42965. * In XR mode and presenting
  42966. */
  42967. IN_XR = 2,
  42968. /**
  42969. * Not entered XR mode
  42970. */
  42971. NOT_IN_XR = 3
  42972. }
  42973. /**
  42974. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42975. * @see https://doc.babylonjs.com/how_to/webxr
  42976. */
  42977. export class WebXRExperienceHelper implements IDisposable {
  42978. private scene;
  42979. /**
  42980. * 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
  42981. */
  42982. container: AbstractMesh;
  42983. /**
  42984. * Camera used to render xr content
  42985. */
  42986. camera: WebXRCamera;
  42987. /**
  42988. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  42989. */
  42990. state: WebXRState;
  42991. private _setState;
  42992. private static _TmpVector;
  42993. /**
  42994. * Fires when the state of the experience helper has changed
  42995. */
  42996. onStateChangedObservable: Observable<WebXRState>;
  42997. /** Session manager used to keep track of xr session */
  42998. sessionManager: WebXRSessionManager;
  42999. private _nonVRCamera;
  43000. private _originalSceneAutoClear;
  43001. private _supported;
  43002. /**
  43003. * Creates the experience helper
  43004. * @param scene the scene to attach the experience helper to
  43005. * @returns a promise for the experience helper
  43006. */
  43007. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43008. /**
  43009. * Creates a WebXRExperienceHelper
  43010. * @param scene The scene the helper should be created in
  43011. */
  43012. private constructor();
  43013. /**
  43014. * Exits XR mode and returns the scene to its original state
  43015. * @returns promise that resolves after xr mode has exited
  43016. */
  43017. exitXRAsync(): Promise<unknown>;
  43018. /**
  43019. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43020. * @param sessionCreationOptions options for the XR session
  43021. * @param referenceSpaceType frame of reference of the XR session
  43022. * @param outputCanvas the output canvas that will be used to enter XR mode
  43023. * @returns promise that resolves after xr mode has entered
  43024. */
  43025. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43026. /**
  43027. * Updates the global position of the camera by moving the camera's container
  43028. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43029. * @param position The desired global position of the camera
  43030. */
  43031. setPositionOfCameraUsingContainer(position: Vector3): void;
  43032. /**
  43033. * Rotates the xr camera by rotating the camera's container around the camera's position
  43034. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43035. * @param rotation the desired quaternion rotation to apply to the camera
  43036. */
  43037. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43038. /**
  43039. * Disposes of the experience helper
  43040. */
  43041. dispose(): void;
  43042. }
  43043. }
  43044. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43045. import { Nullable } from "babylonjs/types";
  43046. import { Observable } from "babylonjs/Misc/observable";
  43047. import { IDisposable, Scene } from "babylonjs/scene";
  43048. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43049. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43050. /**
  43051. * Button which can be used to enter a different mode of XR
  43052. */
  43053. export class WebXREnterExitUIButton {
  43054. /** button element */
  43055. element: HTMLElement;
  43056. /** XR initialization options for the button */
  43057. sessionMode: XRSessionMode;
  43058. /** Reference space type */
  43059. referenceSpaceType: XRReferenceSpaceType;
  43060. /**
  43061. * Creates a WebXREnterExitUIButton
  43062. * @param element button element
  43063. * @param sessionMode XR initialization session mode
  43064. * @param referenceSpaceType the type of reference space to be used
  43065. */
  43066. constructor(
  43067. /** button element */
  43068. element: HTMLElement,
  43069. /** XR initialization options for the button */
  43070. sessionMode: XRSessionMode,
  43071. /** Reference space type */
  43072. referenceSpaceType: XRReferenceSpaceType);
  43073. /**
  43074. * Overwritable function which can be used to update the button's visuals when the state changes
  43075. * @param activeButton the current active button in the UI
  43076. */
  43077. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43078. }
  43079. /**
  43080. * Options to create the webXR UI
  43081. */
  43082. export class WebXREnterExitUIOptions {
  43083. /**
  43084. * Context to enter xr with
  43085. */
  43086. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43087. /**
  43088. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43089. */
  43090. customButtons?: Array<WebXREnterExitUIButton>;
  43091. }
  43092. /**
  43093. * UI to allow the user to enter/exit XR mode
  43094. */
  43095. export class WebXREnterExitUI implements IDisposable {
  43096. private scene;
  43097. private _overlay;
  43098. private _buttons;
  43099. private _activeButton;
  43100. /**
  43101. * Fired every time the active button is changed.
  43102. *
  43103. * When xr is entered via a button that launches xr that button will be the callback parameter
  43104. *
  43105. * When exiting xr the callback parameter will be null)
  43106. */
  43107. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43108. /**
  43109. * Creates UI to allow the user to enter/exit XR mode
  43110. * @param scene the scene to add the ui to
  43111. * @param helper the xr experience helper to enter/exit xr with
  43112. * @param options options to configure the UI
  43113. * @returns the created ui
  43114. */
  43115. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43116. private constructor();
  43117. private _updateButtons;
  43118. /**
  43119. * Disposes of the object
  43120. */
  43121. dispose(): void;
  43122. }
  43123. }
  43124. declare module "babylonjs/Cameras/XR/webXRController" {
  43125. import { Nullable } from "babylonjs/types";
  43126. import { Observable } from "babylonjs/Misc/observable";
  43127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43128. import { Ray } from "babylonjs/Culling/ray";
  43129. import { Scene } from "babylonjs/scene";
  43130. /**
  43131. * Represents an XR input
  43132. */
  43133. export class WebXRController {
  43134. private scene;
  43135. /** The underlying input source for the controller */
  43136. inputSource: XRInputSource;
  43137. private parentContainer;
  43138. /**
  43139. * 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
  43140. */
  43141. grip?: AbstractMesh;
  43142. /**
  43143. * Pointer which can be used to select objects or attach a visible laser to
  43144. */
  43145. pointer: AbstractMesh;
  43146. /**
  43147. * Event that fires when the controller is removed/disposed
  43148. */
  43149. onDisposeObservable: Observable<{}>;
  43150. private _tmpMatrix;
  43151. private _tmpQuaternion;
  43152. private _tmpVector;
  43153. /**
  43154. * Creates the controller
  43155. * @see https://doc.babylonjs.com/how_to/webxr
  43156. * @param scene the scene which the controller should be associated to
  43157. * @param inputSource the underlying input source for the controller
  43158. * @param parentContainer parent that the controller meshes should be children of
  43159. */
  43160. constructor(scene: Scene,
  43161. /** The underlying input source for the controller */
  43162. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43163. /**
  43164. * Updates the controller pose based on the given XRFrame
  43165. * @param xrFrame xr frame to update the pose with
  43166. * @param referenceSpace reference space to use
  43167. */
  43168. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43169. /**
  43170. * Gets a world space ray coming from the controller
  43171. * @param result the resulting ray
  43172. */
  43173. getWorldPointerRayToRef(result: Ray): void;
  43174. /**
  43175. * Disposes of the object
  43176. */
  43177. dispose(): void;
  43178. }
  43179. }
  43180. declare module "babylonjs/Cameras/XR/webXRInput" {
  43181. import { Observable } from "babylonjs/Misc/observable";
  43182. import { IDisposable } from "babylonjs/scene";
  43183. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43184. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43185. /**
  43186. * XR input used to track XR inputs such as controllers/rays
  43187. */
  43188. export class WebXRInput implements IDisposable {
  43189. /**
  43190. * Base experience the input listens to
  43191. */
  43192. baseExperience: WebXRExperienceHelper;
  43193. /**
  43194. * XR controllers being tracked
  43195. */
  43196. controllers: Array<WebXRController>;
  43197. private _frameObserver;
  43198. private _stateObserver;
  43199. /**
  43200. * Event when a controller has been connected/added
  43201. */
  43202. onControllerAddedObservable: Observable<WebXRController>;
  43203. /**
  43204. * Event when a controller has been removed/disconnected
  43205. */
  43206. onControllerRemovedObservable: Observable<WebXRController>;
  43207. /**
  43208. * Initializes the WebXRInput
  43209. * @param baseExperience experience helper which the input should be created for
  43210. */
  43211. constructor(
  43212. /**
  43213. * Base experience the input listens to
  43214. */
  43215. baseExperience: WebXRExperienceHelper);
  43216. private _onInputSourcesChange;
  43217. private _addAndRemoveControllers;
  43218. /**
  43219. * Disposes of the object
  43220. */
  43221. dispose(): void;
  43222. }
  43223. }
  43224. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43225. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43226. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43227. /**
  43228. * Enables teleportation
  43229. */
  43230. export class WebXRControllerTeleportation {
  43231. private _teleportationFillColor;
  43232. private _teleportationBorderColor;
  43233. private _tmpRay;
  43234. private _tmpVector;
  43235. /**
  43236. * Creates a WebXRControllerTeleportation
  43237. * @param input input manager to add teleportation to
  43238. * @param floorMeshes floormeshes which can be teleported to
  43239. */
  43240. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43241. }
  43242. }
  43243. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43244. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43245. /**
  43246. * Handles pointer input automatically for the pointer of XR controllers
  43247. */
  43248. export class WebXRControllerPointerSelection {
  43249. private static _idCounter;
  43250. private _tmpRay;
  43251. /**
  43252. * Creates a WebXRControllerPointerSelection
  43253. * @param input input manager to setup pointer selection
  43254. */
  43255. constructor(input: WebXRInput);
  43256. private _convertNormalToDirectionOfRay;
  43257. private _updatePointerDistance;
  43258. }
  43259. }
  43260. declare module "babylonjs/Loading/sceneLoader" {
  43261. import { Observable } from "babylonjs/Misc/observable";
  43262. import { Nullable } from "babylonjs/types";
  43263. import { Scene } from "babylonjs/scene";
  43264. import { Engine } from "babylonjs/Engines/engine";
  43265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43266. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43267. import { AssetContainer } from "babylonjs/assetContainer";
  43268. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43269. import { Skeleton } from "babylonjs/Bones/skeleton";
  43270. /**
  43271. * Class used to represent data loading progression
  43272. */
  43273. export class SceneLoaderProgressEvent {
  43274. /** defines if data length to load can be evaluated */
  43275. readonly lengthComputable: boolean;
  43276. /** defines the loaded data length */
  43277. readonly loaded: number;
  43278. /** defines the data length to load */
  43279. readonly total: number;
  43280. /**
  43281. * Create a new progress event
  43282. * @param lengthComputable defines if data length to load can be evaluated
  43283. * @param loaded defines the loaded data length
  43284. * @param total defines the data length to load
  43285. */
  43286. constructor(
  43287. /** defines if data length to load can be evaluated */
  43288. lengthComputable: boolean,
  43289. /** defines the loaded data length */
  43290. loaded: number,
  43291. /** defines the data length to load */
  43292. total: number);
  43293. /**
  43294. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43295. * @param event defines the source event
  43296. * @returns a new SceneLoaderProgressEvent
  43297. */
  43298. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43299. }
  43300. /**
  43301. * Interface used by SceneLoader plugins to define supported file extensions
  43302. */
  43303. export interface ISceneLoaderPluginExtensions {
  43304. /**
  43305. * Defines the list of supported extensions
  43306. */
  43307. [extension: string]: {
  43308. isBinary: boolean;
  43309. };
  43310. }
  43311. /**
  43312. * Interface used by SceneLoader plugin factory
  43313. */
  43314. export interface ISceneLoaderPluginFactory {
  43315. /**
  43316. * Defines the name of the factory
  43317. */
  43318. name: string;
  43319. /**
  43320. * Function called to create a new plugin
  43321. * @return the new plugin
  43322. */
  43323. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43324. /**
  43325. * Boolean indicating if the plugin can direct load specific data
  43326. */
  43327. canDirectLoad?: (data: string) => boolean;
  43328. }
  43329. /**
  43330. * Interface used to define a SceneLoader plugin
  43331. */
  43332. export interface ISceneLoaderPlugin {
  43333. /**
  43334. * The friendly name of this plugin.
  43335. */
  43336. name: string;
  43337. /**
  43338. * The file extensions supported by this plugin.
  43339. */
  43340. extensions: string | ISceneLoaderPluginExtensions;
  43341. /**
  43342. * Import meshes into a scene.
  43343. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43344. * @param scene The scene to import into
  43345. * @param data The data to import
  43346. * @param rootUrl The root url for scene and resources
  43347. * @param meshes The meshes array to import into
  43348. * @param particleSystems The particle systems array to import into
  43349. * @param skeletons The skeletons array to import into
  43350. * @param onError The callback when import fails
  43351. * @returns True if successful or false otherwise
  43352. */
  43353. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43354. /**
  43355. * Load into a scene.
  43356. * @param scene The scene to load into
  43357. * @param data The data to import
  43358. * @param rootUrl The root url for scene and resources
  43359. * @param onError The callback when import fails
  43360. * @returns true if successful or false otherwise
  43361. */
  43362. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43363. /**
  43364. * The callback that returns true if the data can be directly loaded.
  43365. */
  43366. canDirectLoad?: (data: string) => boolean;
  43367. /**
  43368. * The callback that allows custom handling of the root url based on the response url.
  43369. */
  43370. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43371. /**
  43372. * Load into an asset container.
  43373. * @param scene The scene to load into
  43374. * @param data The data to import
  43375. * @param rootUrl The root url for scene and resources
  43376. * @param onError The callback when import fails
  43377. * @returns The loaded asset container
  43378. */
  43379. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43380. }
  43381. /**
  43382. * Interface used to define an async SceneLoader plugin
  43383. */
  43384. export interface ISceneLoaderPluginAsync {
  43385. /**
  43386. * The friendly name of this plugin.
  43387. */
  43388. name: string;
  43389. /**
  43390. * The file extensions supported by this plugin.
  43391. */
  43392. extensions: string | ISceneLoaderPluginExtensions;
  43393. /**
  43394. * Import meshes into a scene.
  43395. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43396. * @param scene The scene to import into
  43397. * @param data The data to import
  43398. * @param rootUrl The root url for scene and resources
  43399. * @param onProgress The callback when the load progresses
  43400. * @param fileName Defines the name of the file to load
  43401. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43402. */
  43403. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43404. meshes: AbstractMesh[];
  43405. particleSystems: IParticleSystem[];
  43406. skeletons: Skeleton[];
  43407. animationGroups: AnimationGroup[];
  43408. }>;
  43409. /**
  43410. * Load into a scene.
  43411. * @param scene The scene to load into
  43412. * @param data The data to import
  43413. * @param rootUrl The root url for scene and resources
  43414. * @param onProgress The callback when the load progresses
  43415. * @param fileName Defines the name of the file to load
  43416. * @returns Nothing
  43417. */
  43418. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43419. /**
  43420. * The callback that returns true if the data can be directly loaded.
  43421. */
  43422. canDirectLoad?: (data: string) => boolean;
  43423. /**
  43424. * The callback that allows custom handling of the root url based on the response url.
  43425. */
  43426. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43427. /**
  43428. * Load into an asset container.
  43429. * @param scene The scene to load into
  43430. * @param data The data to import
  43431. * @param rootUrl The root url for scene and resources
  43432. * @param onProgress The callback when the load progresses
  43433. * @param fileName Defines the name of the file to load
  43434. * @returns The loaded asset container
  43435. */
  43436. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43437. }
  43438. /**
  43439. * Class used to load scene from various file formats using registered plugins
  43440. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43441. */
  43442. export class SceneLoader {
  43443. /**
  43444. * No logging while loading
  43445. */
  43446. static readonly NO_LOGGING: number;
  43447. /**
  43448. * Minimal logging while loading
  43449. */
  43450. static readonly MINIMAL_LOGGING: number;
  43451. /**
  43452. * Summary logging while loading
  43453. */
  43454. static readonly SUMMARY_LOGGING: number;
  43455. /**
  43456. * Detailled logging while loading
  43457. */
  43458. static readonly DETAILED_LOGGING: number;
  43459. /**
  43460. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43461. */
  43462. static ForceFullSceneLoadingForIncremental: boolean;
  43463. /**
  43464. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43465. */
  43466. static ShowLoadingScreen: boolean;
  43467. /**
  43468. * Defines the current logging level (while loading the scene)
  43469. * @ignorenaming
  43470. */
  43471. static loggingLevel: number;
  43472. /**
  43473. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43474. */
  43475. static CleanBoneMatrixWeights: boolean;
  43476. /**
  43477. * Event raised when a plugin is used to load a scene
  43478. */
  43479. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43480. private static _registeredPlugins;
  43481. private static _getDefaultPlugin;
  43482. private static _getPluginForExtension;
  43483. private static _getPluginForDirectLoad;
  43484. private static _getPluginForFilename;
  43485. private static _getDirectLoad;
  43486. private static _loadData;
  43487. private static _getFileInfo;
  43488. /**
  43489. * Gets a plugin that can load the given extension
  43490. * @param extension defines the extension to load
  43491. * @returns a plugin or null if none works
  43492. */
  43493. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43494. /**
  43495. * Gets a boolean indicating that the given extension can be loaded
  43496. * @param extension defines the extension to load
  43497. * @returns true if the extension is supported
  43498. */
  43499. static IsPluginForExtensionAvailable(extension: string): boolean;
  43500. /**
  43501. * Adds a new plugin to the list of registered plugins
  43502. * @param plugin defines the plugin to add
  43503. */
  43504. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43505. /**
  43506. * Import meshes into a scene
  43507. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43508. * @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)
  43509. * @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)
  43510. * @param scene the instance of BABYLON.Scene to append to
  43511. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43512. * @param onProgress a callback with a progress event for each file being loaded
  43513. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43514. * @param pluginExtension the extension used to determine the plugin
  43515. * @returns The loaded plugin
  43516. */
  43517. 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>;
  43518. /**
  43519. * Import meshes into a scene
  43520. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43521. * @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)
  43522. * @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)
  43523. * @param scene the instance of BABYLON.Scene to append to
  43524. * @param onProgress a callback with a progress event for each file being loaded
  43525. * @param pluginExtension the extension used to determine the plugin
  43526. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43527. */
  43528. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43529. meshes: AbstractMesh[];
  43530. particleSystems: IParticleSystem[];
  43531. skeletons: Skeleton[];
  43532. animationGroups: AnimationGroup[];
  43533. }>;
  43534. /**
  43535. * Load a scene
  43536. * @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)
  43537. * @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)
  43538. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43539. * @param onSuccess a callback with the scene when import succeeds
  43540. * @param onProgress a callback with a progress event for each file being loaded
  43541. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43542. * @param pluginExtension the extension used to determine the plugin
  43543. * @returns The loaded plugin
  43544. */
  43545. 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>;
  43546. /**
  43547. * Load a scene
  43548. * @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)
  43549. * @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)
  43550. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43551. * @param onProgress a callback with a progress event for each file being loaded
  43552. * @param pluginExtension the extension used to determine the plugin
  43553. * @returns The loaded scene
  43554. */
  43555. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43556. /**
  43557. * Append a scene
  43558. * @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)
  43559. * @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)
  43560. * @param scene is the instance of BABYLON.Scene to append to
  43561. * @param onSuccess a callback with the scene when import succeeds
  43562. * @param onProgress a callback with a progress event for each file being loaded
  43563. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43564. * @param pluginExtension the extension used to determine the plugin
  43565. * @returns The loaded plugin
  43566. */
  43567. 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>;
  43568. /**
  43569. * Append a scene
  43570. * @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)
  43571. * @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)
  43572. * @param scene is the instance of BABYLON.Scene to append to
  43573. * @param onProgress a callback with a progress event for each file being loaded
  43574. * @param pluginExtension the extension used to determine the plugin
  43575. * @returns The given scene
  43576. */
  43577. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43578. /**
  43579. * Load a scene into an asset container
  43580. * @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)
  43581. * @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)
  43582. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43583. * @param onSuccess a callback with the scene when import succeeds
  43584. * @param onProgress a callback with a progress event for each file being loaded
  43585. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43586. * @param pluginExtension the extension used to determine the plugin
  43587. * @returns The loaded plugin
  43588. */
  43589. 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>;
  43590. /**
  43591. * Load a scene into an asset container
  43592. * @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)
  43593. * @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)
  43594. * @param scene is the instance of Scene to append to
  43595. * @param onProgress a callback with a progress event for each file being loaded
  43596. * @param pluginExtension the extension used to determine the plugin
  43597. * @returns The loaded asset container
  43598. */
  43599. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43600. }
  43601. }
  43602. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43603. import { Scene } from "babylonjs/scene";
  43604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43605. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43606. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43607. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43608. /**
  43609. * Generic Controller
  43610. */
  43611. export class GenericController extends WebVRController {
  43612. /**
  43613. * Base Url for the controller model.
  43614. */
  43615. static readonly MODEL_BASE_URL: string;
  43616. /**
  43617. * File name for the controller model.
  43618. */
  43619. static readonly MODEL_FILENAME: string;
  43620. /**
  43621. * Creates a new GenericController from a gamepad
  43622. * @param vrGamepad the gamepad that the controller should be created from
  43623. */
  43624. constructor(vrGamepad: any);
  43625. /**
  43626. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43627. * @param scene scene in which to add meshes
  43628. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43629. */
  43630. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43631. /**
  43632. * Called once for each button that changed state since the last frame
  43633. * @param buttonIdx Which button index changed
  43634. * @param state New state of the button
  43635. * @param changes Which properties on the state changed since last frame
  43636. */
  43637. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43638. }
  43639. }
  43640. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43641. import { Observable } from "babylonjs/Misc/observable";
  43642. import { Scene } from "babylonjs/scene";
  43643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43644. import { Ray } from "babylonjs/Culling/ray";
  43645. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43646. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43647. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43648. /**
  43649. * Defines the WindowsMotionController object that the state of the windows motion controller
  43650. */
  43651. export class WindowsMotionController extends WebVRController {
  43652. /**
  43653. * The base url used to load the left and right controller models
  43654. */
  43655. static MODEL_BASE_URL: string;
  43656. /**
  43657. * The name of the left controller model file
  43658. */
  43659. static MODEL_LEFT_FILENAME: string;
  43660. /**
  43661. * The name of the right controller model file
  43662. */
  43663. static MODEL_RIGHT_FILENAME: string;
  43664. /**
  43665. * The controller name prefix for this controller type
  43666. */
  43667. static readonly GAMEPAD_ID_PREFIX: string;
  43668. /**
  43669. * The controller id pattern for this controller type
  43670. */
  43671. private static readonly GAMEPAD_ID_PATTERN;
  43672. private _loadedMeshInfo;
  43673. private readonly _mapping;
  43674. /**
  43675. * Fired when the trackpad on this controller is clicked
  43676. */
  43677. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43678. /**
  43679. * Fired when the trackpad on this controller is modified
  43680. */
  43681. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43682. /**
  43683. * The current x and y values of this controller's trackpad
  43684. */
  43685. trackpad: StickValues;
  43686. /**
  43687. * Creates a new WindowsMotionController from a gamepad
  43688. * @param vrGamepad the gamepad that the controller should be created from
  43689. */
  43690. constructor(vrGamepad: any);
  43691. /**
  43692. * Fired when the trigger on this controller is modified
  43693. */
  43694. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43695. /**
  43696. * Fired when the menu button on this controller is modified
  43697. */
  43698. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43699. /**
  43700. * Fired when the grip button on this controller is modified
  43701. */
  43702. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43703. /**
  43704. * Fired when the thumbstick button on this controller is modified
  43705. */
  43706. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43707. /**
  43708. * Fired when the touchpad button on this controller is modified
  43709. */
  43710. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43711. /**
  43712. * Fired when the touchpad values on this controller are modified
  43713. */
  43714. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43715. private _updateTrackpad;
  43716. /**
  43717. * Called once per frame by the engine.
  43718. */
  43719. update(): void;
  43720. /**
  43721. * Called once for each button that changed state since the last frame
  43722. * @param buttonIdx Which button index changed
  43723. * @param state New state of the button
  43724. * @param changes Which properties on the state changed since last frame
  43725. */
  43726. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43727. /**
  43728. * Moves the buttons on the controller mesh based on their current state
  43729. * @param buttonName the name of the button to move
  43730. * @param buttonValue the value of the button which determines the buttons new position
  43731. */
  43732. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43733. /**
  43734. * Moves the axis on the controller mesh based on its current state
  43735. * @param axis the index of the axis
  43736. * @param axisValue the value of the axis which determines the meshes new position
  43737. * @hidden
  43738. */
  43739. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43740. /**
  43741. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43742. * @param scene scene in which to add meshes
  43743. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43744. */
  43745. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43746. /**
  43747. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43748. * can be transformed by button presses and axes values, based on this._mapping.
  43749. *
  43750. * @param scene scene in which the meshes exist
  43751. * @param meshes list of meshes that make up the controller model to process
  43752. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43753. */
  43754. private processModel;
  43755. private createMeshInfo;
  43756. /**
  43757. * Gets the ray of the controller in the direction the controller is pointing
  43758. * @param length the length the resulting ray should be
  43759. * @returns a ray in the direction the controller is pointing
  43760. */
  43761. getForwardRay(length?: number): Ray;
  43762. /**
  43763. * Disposes of the controller
  43764. */
  43765. dispose(): void;
  43766. }
  43767. }
  43768. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43769. import { Observable } from "babylonjs/Misc/observable";
  43770. import { Scene } from "babylonjs/scene";
  43771. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43772. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43773. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43774. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43775. /**
  43776. * Oculus Touch Controller
  43777. */
  43778. export class OculusTouchController extends WebVRController {
  43779. /**
  43780. * Base Url for the controller model.
  43781. */
  43782. static MODEL_BASE_URL: string;
  43783. /**
  43784. * File name for the left controller model.
  43785. */
  43786. static MODEL_LEFT_FILENAME: string;
  43787. /**
  43788. * File name for the right controller model.
  43789. */
  43790. static MODEL_RIGHT_FILENAME: string;
  43791. /**
  43792. * Base Url for the Quest controller model.
  43793. */
  43794. static QUEST_MODEL_BASE_URL: string;
  43795. /**
  43796. * @hidden
  43797. * If the controllers are running on a device that needs the updated Quest controller models
  43798. */
  43799. static _IsQuest: boolean;
  43800. /**
  43801. * Fired when the secondary trigger on this controller is modified
  43802. */
  43803. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43804. /**
  43805. * Fired when the thumb rest on this controller is modified
  43806. */
  43807. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43808. /**
  43809. * Creates a new OculusTouchController from a gamepad
  43810. * @param vrGamepad the gamepad that the controller should be created from
  43811. */
  43812. constructor(vrGamepad: any);
  43813. /**
  43814. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43815. * @param scene scene in which to add meshes
  43816. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43817. */
  43818. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43819. /**
  43820. * Fired when the A button on this controller is modified
  43821. */
  43822. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43823. /**
  43824. * Fired when the B button on this controller is modified
  43825. */
  43826. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43827. /**
  43828. * Fired when the X button on this controller is modified
  43829. */
  43830. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43831. /**
  43832. * Fired when the Y button on this controller is modified
  43833. */
  43834. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43835. /**
  43836. * Called once for each button that changed state since the last frame
  43837. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43838. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43839. * 2) secondary trigger (same)
  43840. * 3) A (right) X (left), touch, pressed = value
  43841. * 4) B / Y
  43842. * 5) thumb rest
  43843. * @param buttonIdx Which button index changed
  43844. * @param state New state of the button
  43845. * @param changes Which properties on the state changed since last frame
  43846. */
  43847. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43848. }
  43849. }
  43850. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43851. import { Scene } from "babylonjs/scene";
  43852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43853. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43854. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43855. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43856. import { Observable } from "babylonjs/Misc/observable";
  43857. /**
  43858. * Vive Controller
  43859. */
  43860. export class ViveController extends WebVRController {
  43861. /**
  43862. * Base Url for the controller model.
  43863. */
  43864. static MODEL_BASE_URL: string;
  43865. /**
  43866. * File name for the controller model.
  43867. */
  43868. static MODEL_FILENAME: string;
  43869. /**
  43870. * Creates a new ViveController from a gamepad
  43871. * @param vrGamepad the gamepad that the controller should be created from
  43872. */
  43873. constructor(vrGamepad: any);
  43874. /**
  43875. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43876. * @param scene scene in which to add meshes
  43877. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43878. */
  43879. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43880. /**
  43881. * Fired when the left button on this controller is modified
  43882. */
  43883. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43884. /**
  43885. * Fired when the right button on this controller is modified
  43886. */
  43887. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43888. /**
  43889. * Fired when the menu button on this controller is modified
  43890. */
  43891. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43892. /**
  43893. * Called once for each button that changed state since the last frame
  43894. * Vive mapping:
  43895. * 0: touchpad
  43896. * 1: trigger
  43897. * 2: left AND right buttons
  43898. * 3: menu button
  43899. * @param buttonIdx Which button index changed
  43900. * @param state New state of the button
  43901. * @param changes Which properties on the state changed since last frame
  43902. */
  43903. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43904. }
  43905. }
  43906. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43907. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43908. /**
  43909. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43910. */
  43911. export class WebXRControllerModelLoader {
  43912. /**
  43913. * Creates the WebXRControllerModelLoader
  43914. * @param input xr input that creates the controllers
  43915. */
  43916. constructor(input: WebXRInput);
  43917. }
  43918. }
  43919. declare module "babylonjs/Cameras/XR/index" {
  43920. export * from "babylonjs/Cameras/XR/webXRCamera";
  43921. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43922. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43923. export * from "babylonjs/Cameras/XR/webXRInput";
  43924. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43925. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43926. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43927. export * from "babylonjs/Cameras/XR/webXRController";
  43928. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43929. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43930. }
  43931. declare module "babylonjs/Cameras/RigModes/index" {
  43932. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43933. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43934. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43935. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43936. }
  43937. declare module "babylonjs/Cameras/index" {
  43938. export * from "babylonjs/Cameras/Inputs/index";
  43939. export * from "babylonjs/Cameras/cameraInputsManager";
  43940. export * from "babylonjs/Cameras/camera";
  43941. export * from "babylonjs/Cameras/targetCamera";
  43942. export * from "babylonjs/Cameras/freeCamera";
  43943. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43944. export * from "babylonjs/Cameras/touchCamera";
  43945. export * from "babylonjs/Cameras/arcRotateCamera";
  43946. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43947. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43948. export * from "babylonjs/Cameras/flyCamera";
  43949. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43950. export * from "babylonjs/Cameras/followCamera";
  43951. export * from "babylonjs/Cameras/followCameraInputsManager";
  43952. export * from "babylonjs/Cameras/gamepadCamera";
  43953. export * from "babylonjs/Cameras/Stereoscopic/index";
  43954. export * from "babylonjs/Cameras/universalCamera";
  43955. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43956. export * from "babylonjs/Cameras/VR/index";
  43957. export * from "babylonjs/Cameras/XR/index";
  43958. export * from "babylonjs/Cameras/RigModes/index";
  43959. }
  43960. declare module "babylonjs/Collisions/index" {
  43961. export * from "babylonjs/Collisions/collider";
  43962. export * from "babylonjs/Collisions/collisionCoordinator";
  43963. export * from "babylonjs/Collisions/pickingInfo";
  43964. export * from "babylonjs/Collisions/intersectionInfo";
  43965. export * from "babylonjs/Collisions/meshCollisionData";
  43966. }
  43967. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43968. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43969. import { Vector3 } from "babylonjs/Maths/math.vector";
  43970. import { Ray } from "babylonjs/Culling/ray";
  43971. import { Plane } from "babylonjs/Maths/math.plane";
  43972. /**
  43973. * Contains an array of blocks representing the octree
  43974. */
  43975. export interface IOctreeContainer<T> {
  43976. /**
  43977. * Blocks within the octree
  43978. */
  43979. blocks: Array<OctreeBlock<T>>;
  43980. }
  43981. /**
  43982. * Class used to store a cell in an octree
  43983. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  43984. */
  43985. export class OctreeBlock<T> {
  43986. /**
  43987. * Gets the content of the current block
  43988. */
  43989. entries: T[];
  43990. /**
  43991. * Gets the list of block children
  43992. */
  43993. blocks: Array<OctreeBlock<T>>;
  43994. private _depth;
  43995. private _maxDepth;
  43996. private _capacity;
  43997. private _minPoint;
  43998. private _maxPoint;
  43999. private _boundingVectors;
  44000. private _creationFunc;
  44001. /**
  44002. * Creates a new block
  44003. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44004. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44005. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44006. * @param depth defines the current depth of this block in the octree
  44007. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44008. * @param creationFunc defines a callback to call when an element is added to the block
  44009. */
  44010. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44011. /**
  44012. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44013. */
  44014. readonly capacity: number;
  44015. /**
  44016. * Gets the minimum vector (in world space) of the block's bounding box
  44017. */
  44018. readonly minPoint: Vector3;
  44019. /**
  44020. * Gets the maximum vector (in world space) of the block's bounding box
  44021. */
  44022. readonly maxPoint: Vector3;
  44023. /**
  44024. * Add a new element to this block
  44025. * @param entry defines the element to add
  44026. */
  44027. addEntry(entry: T): void;
  44028. /**
  44029. * Remove an element from this block
  44030. * @param entry defines the element to remove
  44031. */
  44032. removeEntry(entry: T): void;
  44033. /**
  44034. * Add an array of elements to this block
  44035. * @param entries defines the array of elements to add
  44036. */
  44037. addEntries(entries: T[]): void;
  44038. /**
  44039. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44040. * @param frustumPlanes defines the frustum planes to test
  44041. * @param selection defines the array to store current content if selection is positive
  44042. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44043. */
  44044. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44045. /**
  44046. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44047. * @param sphereCenter defines the bounding sphere center
  44048. * @param sphereRadius defines the bounding sphere radius
  44049. * @param selection defines the array to store current content if selection is positive
  44050. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44051. */
  44052. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44053. /**
  44054. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44055. * @param ray defines the ray to test with
  44056. * @param selection defines the array to store current content if selection is positive
  44057. */
  44058. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44059. /**
  44060. * Subdivide the content into child blocks (this block will then be empty)
  44061. */
  44062. createInnerBlocks(): void;
  44063. /**
  44064. * @hidden
  44065. */
  44066. 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;
  44067. }
  44068. }
  44069. declare module "babylonjs/Culling/Octrees/octree" {
  44070. import { SmartArray } from "babylonjs/Misc/smartArray";
  44071. import { Vector3 } from "babylonjs/Maths/math.vector";
  44072. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44074. import { Ray } from "babylonjs/Culling/ray";
  44075. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44076. import { Plane } from "babylonjs/Maths/math.plane";
  44077. /**
  44078. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44079. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44080. */
  44081. export class Octree<T> {
  44082. /** 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.) */
  44083. maxDepth: number;
  44084. /**
  44085. * Blocks within the octree containing objects
  44086. */
  44087. blocks: Array<OctreeBlock<T>>;
  44088. /**
  44089. * Content stored in the octree
  44090. */
  44091. dynamicContent: T[];
  44092. private _maxBlockCapacity;
  44093. private _selectionContent;
  44094. private _creationFunc;
  44095. /**
  44096. * Creates a octree
  44097. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44098. * @param creationFunc function to be used to instatiate the octree
  44099. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44100. * @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.)
  44101. */
  44102. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44103. /** 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.) */
  44104. maxDepth?: number);
  44105. /**
  44106. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44107. * @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);
  44108. * @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);
  44109. * @param entries meshes to be added to the octree blocks
  44110. */
  44111. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44112. /**
  44113. * Adds a mesh to the octree
  44114. * @param entry Mesh to add to the octree
  44115. */
  44116. addMesh(entry: T): void;
  44117. /**
  44118. * Remove an element from the octree
  44119. * @param entry defines the element to remove
  44120. */
  44121. removeMesh(entry: T): void;
  44122. /**
  44123. * Selects an array of meshes within the frustum
  44124. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44125. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44126. * @returns array of meshes within the frustum
  44127. */
  44128. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44129. /**
  44130. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44131. * @param sphereCenter defines the bounding sphere center
  44132. * @param sphereRadius defines the bounding sphere radius
  44133. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44134. * @returns an array of objects that intersect the sphere
  44135. */
  44136. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44137. /**
  44138. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44139. * @param ray defines the ray to test with
  44140. * @returns array of intersected objects
  44141. */
  44142. intersectsRay(ray: Ray): SmartArray<T>;
  44143. /**
  44144. * Adds a mesh into the octree block if it intersects the block
  44145. */
  44146. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44147. /**
  44148. * Adds a submesh into the octree block if it intersects the block
  44149. */
  44150. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44151. }
  44152. }
  44153. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44154. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44155. import { Scene } from "babylonjs/scene";
  44156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44157. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44158. import { Ray } from "babylonjs/Culling/ray";
  44159. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44160. import { Collider } from "babylonjs/Collisions/collider";
  44161. module "babylonjs/scene" {
  44162. interface Scene {
  44163. /**
  44164. * @hidden
  44165. * Backing Filed
  44166. */
  44167. _selectionOctree: Octree<AbstractMesh>;
  44168. /**
  44169. * Gets the octree used to boost mesh selection (picking)
  44170. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44171. */
  44172. selectionOctree: Octree<AbstractMesh>;
  44173. /**
  44174. * Creates or updates the octree used to boost selection (picking)
  44175. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44176. * @param maxCapacity defines the maximum capacity per leaf
  44177. * @param maxDepth defines the maximum depth of the octree
  44178. * @returns an octree of AbstractMesh
  44179. */
  44180. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44181. }
  44182. }
  44183. module "babylonjs/Meshes/abstractMesh" {
  44184. interface AbstractMesh {
  44185. /**
  44186. * @hidden
  44187. * Backing Field
  44188. */
  44189. _submeshesOctree: Octree<SubMesh>;
  44190. /**
  44191. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44192. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44193. * @param maxCapacity defines the maximum size of each block (64 by default)
  44194. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44195. * @returns the new octree
  44196. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44198. */
  44199. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44200. }
  44201. }
  44202. /**
  44203. * Defines the octree scene component responsible to manage any octrees
  44204. * in a given scene.
  44205. */
  44206. export class OctreeSceneComponent {
  44207. /**
  44208. * The component name help to identify the component in the list of scene components.
  44209. */
  44210. readonly name: string;
  44211. /**
  44212. * The scene the component belongs to.
  44213. */
  44214. scene: Scene;
  44215. /**
  44216. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44217. */
  44218. readonly checksIsEnabled: boolean;
  44219. /**
  44220. * Creates a new instance of the component for the given scene
  44221. * @param scene Defines the scene to register the component in
  44222. */
  44223. constructor(scene: Scene);
  44224. /**
  44225. * Registers the component in a given scene
  44226. */
  44227. register(): void;
  44228. /**
  44229. * Return the list of active meshes
  44230. * @returns the list of active meshes
  44231. */
  44232. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44233. /**
  44234. * Return the list of active sub meshes
  44235. * @param mesh The mesh to get the candidates sub meshes from
  44236. * @returns the list of active sub meshes
  44237. */
  44238. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44239. private _tempRay;
  44240. /**
  44241. * Return the list of sub meshes intersecting with a given local ray
  44242. * @param mesh defines the mesh to find the submesh for
  44243. * @param localRay defines the ray in local space
  44244. * @returns the list of intersecting sub meshes
  44245. */
  44246. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44247. /**
  44248. * Return the list of sub meshes colliding with a collider
  44249. * @param mesh defines the mesh to find the submesh for
  44250. * @param collider defines the collider to evaluate the collision against
  44251. * @returns the list of colliding sub meshes
  44252. */
  44253. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44254. /**
  44255. * Rebuilds the elements related to this component in case of
  44256. * context lost for instance.
  44257. */
  44258. rebuild(): void;
  44259. /**
  44260. * Disposes the component and the associated ressources.
  44261. */
  44262. dispose(): void;
  44263. }
  44264. }
  44265. declare module "babylonjs/Culling/Octrees/index" {
  44266. export * from "babylonjs/Culling/Octrees/octree";
  44267. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44268. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44269. }
  44270. declare module "babylonjs/Culling/index" {
  44271. export * from "babylonjs/Culling/boundingBox";
  44272. export * from "babylonjs/Culling/boundingInfo";
  44273. export * from "babylonjs/Culling/boundingSphere";
  44274. export * from "babylonjs/Culling/Octrees/index";
  44275. export * from "babylonjs/Culling/ray";
  44276. }
  44277. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44278. import { IDisposable, Scene } from "babylonjs/scene";
  44279. import { Nullable } from "babylonjs/types";
  44280. import { Observable } from "babylonjs/Misc/observable";
  44281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44282. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44283. import { Camera } from "babylonjs/Cameras/camera";
  44284. /**
  44285. * Renders a layer on top of an existing scene
  44286. */
  44287. export class UtilityLayerRenderer implements IDisposable {
  44288. /** the original scene that will be rendered on top of */
  44289. originalScene: Scene;
  44290. private _pointerCaptures;
  44291. private _lastPointerEvents;
  44292. private static _DefaultUtilityLayer;
  44293. private static _DefaultKeepDepthUtilityLayer;
  44294. private _sharedGizmoLight;
  44295. private _renderCamera;
  44296. /**
  44297. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44298. * @returns the camera that is used when rendering the utility layer
  44299. */
  44300. getRenderCamera(): Nullable<Camera>;
  44301. /**
  44302. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44303. * @param cam the camera that should be used when rendering the utility layer
  44304. */
  44305. setRenderCamera(cam: Nullable<Camera>): void;
  44306. /**
  44307. * @hidden
  44308. * Light which used by gizmos to get light shading
  44309. */
  44310. _getSharedGizmoLight(): HemisphericLight;
  44311. /**
  44312. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44313. */
  44314. pickUtilitySceneFirst: boolean;
  44315. /**
  44316. * 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)
  44317. */
  44318. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44319. /**
  44320. * 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)
  44321. */
  44322. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44323. /**
  44324. * The scene that is rendered on top of the original scene
  44325. */
  44326. utilityLayerScene: Scene;
  44327. /**
  44328. * If the utility layer should automatically be rendered on top of existing scene
  44329. */
  44330. shouldRender: boolean;
  44331. /**
  44332. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44333. */
  44334. onlyCheckPointerDownEvents: boolean;
  44335. /**
  44336. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44337. */
  44338. processAllEvents: boolean;
  44339. /**
  44340. * Observable raised when the pointer move from the utility layer scene to the main scene
  44341. */
  44342. onPointerOutObservable: Observable<number>;
  44343. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44344. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44345. private _afterRenderObserver;
  44346. private _sceneDisposeObserver;
  44347. private _originalPointerObserver;
  44348. /**
  44349. * Instantiates a UtilityLayerRenderer
  44350. * @param originalScene the original scene that will be rendered on top of
  44351. * @param handleEvents boolean indicating if the utility layer should handle events
  44352. */
  44353. constructor(
  44354. /** the original scene that will be rendered on top of */
  44355. originalScene: Scene, handleEvents?: boolean);
  44356. private _notifyObservers;
  44357. /**
  44358. * Renders the utility layers scene on top of the original scene
  44359. */
  44360. render(): void;
  44361. /**
  44362. * Disposes of the renderer
  44363. */
  44364. dispose(): void;
  44365. private _updateCamera;
  44366. }
  44367. }
  44368. declare module "babylonjs/Gizmos/gizmo" {
  44369. import { Nullable } from "babylonjs/types";
  44370. import { IDisposable } from "babylonjs/scene";
  44371. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44372. import { Mesh } from "babylonjs/Meshes/mesh";
  44373. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44374. /**
  44375. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44376. */
  44377. export class Gizmo implements IDisposable {
  44378. /** The utility layer the gizmo will be added to */
  44379. gizmoLayer: UtilityLayerRenderer;
  44380. /**
  44381. * The root mesh of the gizmo
  44382. */
  44383. _rootMesh: Mesh;
  44384. private _attachedMesh;
  44385. /**
  44386. * Ratio for the scale of the gizmo (Default: 1)
  44387. */
  44388. scaleRatio: number;
  44389. /**
  44390. * If a custom mesh has been set (Default: false)
  44391. */
  44392. protected _customMeshSet: boolean;
  44393. /**
  44394. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44395. * * When set, interactions will be enabled
  44396. */
  44397. attachedMesh: Nullable<AbstractMesh>;
  44398. /**
  44399. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44400. * @param mesh The mesh to replace the default mesh of the gizmo
  44401. */
  44402. setCustomMesh(mesh: Mesh): void;
  44403. /**
  44404. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44405. */
  44406. updateGizmoRotationToMatchAttachedMesh: boolean;
  44407. /**
  44408. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44409. */
  44410. updateGizmoPositionToMatchAttachedMesh: boolean;
  44411. /**
  44412. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44413. */
  44414. updateScale: boolean;
  44415. protected _interactionsEnabled: boolean;
  44416. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44417. private _beforeRenderObserver;
  44418. private _tempVector;
  44419. /**
  44420. * Creates a gizmo
  44421. * @param gizmoLayer The utility layer the gizmo will be added to
  44422. */
  44423. constructor(
  44424. /** The utility layer the gizmo will be added to */
  44425. gizmoLayer?: UtilityLayerRenderer);
  44426. /**
  44427. * Updates the gizmo to match the attached mesh's position/rotation
  44428. */
  44429. protected _update(): void;
  44430. /**
  44431. * Disposes of the gizmo
  44432. */
  44433. dispose(): void;
  44434. }
  44435. }
  44436. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44437. import { Observable } from "babylonjs/Misc/observable";
  44438. import { Nullable } from "babylonjs/types";
  44439. import { Vector3 } from "babylonjs/Maths/math.vector";
  44440. import { Color3 } from "babylonjs/Maths/math.color";
  44441. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44442. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44443. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44444. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44445. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44446. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44447. import { Scene } from "babylonjs/scene";
  44448. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44449. /**
  44450. * Single plane drag gizmo
  44451. */
  44452. export class PlaneDragGizmo extends Gizmo {
  44453. /**
  44454. * Drag behavior responsible for the gizmos dragging interactions
  44455. */
  44456. dragBehavior: PointerDragBehavior;
  44457. private _pointerObserver;
  44458. /**
  44459. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44460. */
  44461. snapDistance: number;
  44462. /**
  44463. * Event that fires each time the gizmo snaps to a new location.
  44464. * * snapDistance is the the change in distance
  44465. */
  44466. onSnapObservable: Observable<{
  44467. snapDistance: number;
  44468. }>;
  44469. private _plane;
  44470. private _coloredMaterial;
  44471. private _hoverMaterial;
  44472. private _isEnabled;
  44473. private _parent;
  44474. /** @hidden */
  44475. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44476. /** @hidden */
  44477. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44478. /**
  44479. * Creates a PlaneDragGizmo
  44480. * @param gizmoLayer The utility layer the gizmo will be added to
  44481. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44482. * @param color The color of the gizmo
  44483. */
  44484. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44485. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44486. /**
  44487. * If the gizmo is enabled
  44488. */
  44489. isEnabled: boolean;
  44490. /**
  44491. * Disposes of the gizmo
  44492. */
  44493. dispose(): void;
  44494. }
  44495. }
  44496. declare module "babylonjs/Gizmos/positionGizmo" {
  44497. import { Observable } from "babylonjs/Misc/observable";
  44498. import { Nullable } from "babylonjs/types";
  44499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44500. import { Mesh } from "babylonjs/Meshes/mesh";
  44501. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44502. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44503. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44504. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44505. /**
  44506. * Gizmo that enables dragging a mesh along 3 axis
  44507. */
  44508. export class PositionGizmo extends Gizmo {
  44509. /**
  44510. * Internal gizmo used for interactions on the x axis
  44511. */
  44512. xGizmo: AxisDragGizmo;
  44513. /**
  44514. * Internal gizmo used for interactions on the y axis
  44515. */
  44516. yGizmo: AxisDragGizmo;
  44517. /**
  44518. * Internal gizmo used for interactions on the z axis
  44519. */
  44520. zGizmo: AxisDragGizmo;
  44521. /**
  44522. * Internal gizmo used for interactions on the yz plane
  44523. */
  44524. xPlaneGizmo: PlaneDragGizmo;
  44525. /**
  44526. * Internal gizmo used for interactions on the xz plane
  44527. */
  44528. yPlaneGizmo: PlaneDragGizmo;
  44529. /**
  44530. * Internal gizmo used for interactions on the xy plane
  44531. */
  44532. zPlaneGizmo: PlaneDragGizmo;
  44533. /**
  44534. * private variables
  44535. */
  44536. private _meshAttached;
  44537. private _updateGizmoRotationToMatchAttachedMesh;
  44538. private _snapDistance;
  44539. private _scaleRatio;
  44540. /** Fires an event when any of it's sub gizmos are dragged */
  44541. onDragStartObservable: Observable<unknown>;
  44542. /** Fires an event when any of it's sub gizmos are released from dragging */
  44543. onDragEndObservable: Observable<unknown>;
  44544. /**
  44545. * If set to true, planar drag is enabled
  44546. */
  44547. private _planarGizmoEnabled;
  44548. attachedMesh: Nullable<AbstractMesh>;
  44549. /**
  44550. * Creates a PositionGizmo
  44551. * @param gizmoLayer The utility layer the gizmo will be added to
  44552. */
  44553. constructor(gizmoLayer?: UtilityLayerRenderer);
  44554. /**
  44555. * If the planar drag gizmo is enabled
  44556. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44557. */
  44558. planarGizmoEnabled: boolean;
  44559. updateGizmoRotationToMatchAttachedMesh: boolean;
  44560. /**
  44561. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44562. */
  44563. snapDistance: number;
  44564. /**
  44565. * Ratio for the scale of the gizmo (Default: 1)
  44566. */
  44567. scaleRatio: number;
  44568. /**
  44569. * Disposes of the gizmo
  44570. */
  44571. dispose(): void;
  44572. /**
  44573. * CustomMeshes are not supported by this gizmo
  44574. * @param mesh The mesh to replace the default mesh of the gizmo
  44575. */
  44576. setCustomMesh(mesh: Mesh): void;
  44577. }
  44578. }
  44579. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44580. import { Observable } from "babylonjs/Misc/observable";
  44581. import { Nullable } from "babylonjs/types";
  44582. import { Vector3 } from "babylonjs/Maths/math.vector";
  44583. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44584. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44585. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44586. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44587. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44588. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44589. import { Scene } from "babylonjs/scene";
  44590. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44591. import { Color3 } from "babylonjs/Maths/math.color";
  44592. /**
  44593. * Single axis drag gizmo
  44594. */
  44595. export class AxisDragGizmo extends Gizmo {
  44596. /**
  44597. * Drag behavior responsible for the gizmos dragging interactions
  44598. */
  44599. dragBehavior: PointerDragBehavior;
  44600. private _pointerObserver;
  44601. /**
  44602. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44603. */
  44604. snapDistance: number;
  44605. /**
  44606. * Event that fires each time the gizmo snaps to a new location.
  44607. * * snapDistance is the the change in distance
  44608. */
  44609. onSnapObservable: Observable<{
  44610. snapDistance: number;
  44611. }>;
  44612. private _isEnabled;
  44613. private _parent;
  44614. private _arrow;
  44615. private _coloredMaterial;
  44616. private _hoverMaterial;
  44617. /** @hidden */
  44618. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44619. /** @hidden */
  44620. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44621. /**
  44622. * Creates an AxisDragGizmo
  44623. * @param gizmoLayer The utility layer the gizmo will be added to
  44624. * @param dragAxis The axis which the gizmo will be able to drag on
  44625. * @param color The color of the gizmo
  44626. */
  44627. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44628. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44629. /**
  44630. * If the gizmo is enabled
  44631. */
  44632. isEnabled: boolean;
  44633. /**
  44634. * Disposes of the gizmo
  44635. */
  44636. dispose(): void;
  44637. }
  44638. }
  44639. declare module "babylonjs/Debug/axesViewer" {
  44640. import { Vector3 } from "babylonjs/Maths/math.vector";
  44641. import { Nullable } from "babylonjs/types";
  44642. import { Scene } from "babylonjs/scene";
  44643. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44644. /**
  44645. * The Axes viewer will show 3 axes in a specific point in space
  44646. */
  44647. export class AxesViewer {
  44648. private _xAxis;
  44649. private _yAxis;
  44650. private _zAxis;
  44651. private _scaleLinesFactor;
  44652. private _instanced;
  44653. /**
  44654. * Gets the hosting scene
  44655. */
  44656. scene: Scene;
  44657. /**
  44658. * Gets or sets a number used to scale line length
  44659. */
  44660. scaleLines: number;
  44661. /** Gets the node hierarchy used to render x-axis */
  44662. readonly xAxis: TransformNode;
  44663. /** Gets the node hierarchy used to render y-axis */
  44664. readonly yAxis: TransformNode;
  44665. /** Gets the node hierarchy used to render z-axis */
  44666. readonly zAxis: TransformNode;
  44667. /**
  44668. * Creates a new AxesViewer
  44669. * @param scene defines the hosting scene
  44670. * @param scaleLines defines a number used to scale line length (1 by default)
  44671. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44672. * @param xAxis defines the node hierarchy used to render the x-axis
  44673. * @param yAxis defines the node hierarchy used to render the y-axis
  44674. * @param zAxis defines the node hierarchy used to render the z-axis
  44675. */
  44676. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44677. /**
  44678. * Force the viewer to update
  44679. * @param position defines the position of the viewer
  44680. * @param xaxis defines the x axis of the viewer
  44681. * @param yaxis defines the y axis of the viewer
  44682. * @param zaxis defines the z axis of the viewer
  44683. */
  44684. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44685. /**
  44686. * Creates an instance of this axes viewer.
  44687. * @returns a new axes viewer with instanced meshes
  44688. */
  44689. createInstance(): AxesViewer;
  44690. /** Releases resources */
  44691. dispose(): void;
  44692. private static _SetRenderingGroupId;
  44693. }
  44694. }
  44695. declare module "babylonjs/Debug/boneAxesViewer" {
  44696. import { Nullable } from "babylonjs/types";
  44697. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44698. import { Vector3 } from "babylonjs/Maths/math.vector";
  44699. import { Mesh } from "babylonjs/Meshes/mesh";
  44700. import { Bone } from "babylonjs/Bones/bone";
  44701. import { Scene } from "babylonjs/scene";
  44702. /**
  44703. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44704. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44705. */
  44706. export class BoneAxesViewer extends AxesViewer {
  44707. /**
  44708. * Gets or sets the target mesh where to display the axes viewer
  44709. */
  44710. mesh: Nullable<Mesh>;
  44711. /**
  44712. * Gets or sets the target bone where to display the axes viewer
  44713. */
  44714. bone: Nullable<Bone>;
  44715. /** Gets current position */
  44716. pos: Vector3;
  44717. /** Gets direction of X axis */
  44718. xaxis: Vector3;
  44719. /** Gets direction of Y axis */
  44720. yaxis: Vector3;
  44721. /** Gets direction of Z axis */
  44722. zaxis: Vector3;
  44723. /**
  44724. * Creates a new BoneAxesViewer
  44725. * @param scene defines the hosting scene
  44726. * @param bone defines the target bone
  44727. * @param mesh defines the target mesh
  44728. * @param scaleLines defines a scaling factor for line length (1 by default)
  44729. */
  44730. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44731. /**
  44732. * Force the viewer to update
  44733. */
  44734. update(): void;
  44735. /** Releases resources */
  44736. dispose(): void;
  44737. }
  44738. }
  44739. declare module "babylonjs/Debug/debugLayer" {
  44740. import { Scene } from "babylonjs/scene";
  44741. /**
  44742. * Interface used to define scene explorer extensibility option
  44743. */
  44744. export interface IExplorerExtensibilityOption {
  44745. /**
  44746. * Define the option label
  44747. */
  44748. label: string;
  44749. /**
  44750. * Defines the action to execute on click
  44751. */
  44752. action: (entity: any) => void;
  44753. }
  44754. /**
  44755. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44756. */
  44757. export interface IExplorerExtensibilityGroup {
  44758. /**
  44759. * Defines a predicate to test if a given type mut be extended
  44760. */
  44761. predicate: (entity: any) => boolean;
  44762. /**
  44763. * Gets the list of options added to a type
  44764. */
  44765. entries: IExplorerExtensibilityOption[];
  44766. }
  44767. /**
  44768. * Interface used to define the options to use to create the Inspector
  44769. */
  44770. export interface IInspectorOptions {
  44771. /**
  44772. * Display in overlay mode (default: false)
  44773. */
  44774. overlay?: boolean;
  44775. /**
  44776. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44777. */
  44778. globalRoot?: HTMLElement;
  44779. /**
  44780. * Display the Scene explorer
  44781. */
  44782. showExplorer?: boolean;
  44783. /**
  44784. * Display the property inspector
  44785. */
  44786. showInspector?: boolean;
  44787. /**
  44788. * Display in embed mode (both panes on the right)
  44789. */
  44790. embedMode?: boolean;
  44791. /**
  44792. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44793. */
  44794. handleResize?: boolean;
  44795. /**
  44796. * Allow the panes to popup (default: true)
  44797. */
  44798. enablePopup?: boolean;
  44799. /**
  44800. * Allow the panes to be closed by users (default: true)
  44801. */
  44802. enableClose?: boolean;
  44803. /**
  44804. * Optional list of extensibility entries
  44805. */
  44806. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44807. /**
  44808. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44809. */
  44810. inspectorURL?: string;
  44811. }
  44812. module "babylonjs/scene" {
  44813. interface Scene {
  44814. /**
  44815. * @hidden
  44816. * Backing field
  44817. */
  44818. _debugLayer: DebugLayer;
  44819. /**
  44820. * Gets the debug layer (aka Inspector) associated with the scene
  44821. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44822. */
  44823. debugLayer: DebugLayer;
  44824. }
  44825. }
  44826. /**
  44827. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44828. * what is happening in your scene
  44829. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44830. */
  44831. export class DebugLayer {
  44832. /**
  44833. * Define the url to get the inspector script from.
  44834. * By default it uses the babylonjs CDN.
  44835. * @ignoreNaming
  44836. */
  44837. static InspectorURL: string;
  44838. private _scene;
  44839. private BJSINSPECTOR;
  44840. private _onPropertyChangedObservable?;
  44841. /**
  44842. * Observable triggered when a property is changed through the inspector.
  44843. */
  44844. readonly onPropertyChangedObservable: any;
  44845. /**
  44846. * Instantiates a new debug layer.
  44847. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44848. * what is happening in your scene
  44849. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44850. * @param scene Defines the scene to inspect
  44851. */
  44852. constructor(scene: Scene);
  44853. /** Creates the inspector window. */
  44854. private _createInspector;
  44855. /**
  44856. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44857. * @param entity defines the entity to select
  44858. * @param lineContainerTitle defines the specific block to highlight
  44859. */
  44860. select(entity: any, lineContainerTitle?: string): void;
  44861. /** Get the inspector from bundle or global */
  44862. private _getGlobalInspector;
  44863. /**
  44864. * Get if the inspector is visible or not.
  44865. * @returns true if visible otherwise, false
  44866. */
  44867. isVisible(): boolean;
  44868. /**
  44869. * Hide the inspector and close its window.
  44870. */
  44871. hide(): void;
  44872. /**
  44873. * Launch the debugLayer.
  44874. * @param config Define the configuration of the inspector
  44875. * @return a promise fulfilled when the debug layer is visible
  44876. */
  44877. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44878. }
  44879. }
  44880. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44881. import { Nullable } from "babylonjs/types";
  44882. import { Scene } from "babylonjs/scene";
  44883. import { Vector4 } from "babylonjs/Maths/math.vector";
  44884. import { Color4 } from "babylonjs/Maths/math.color";
  44885. import { Mesh } from "babylonjs/Meshes/mesh";
  44886. /**
  44887. * Class containing static functions to help procedurally build meshes
  44888. */
  44889. export class BoxBuilder {
  44890. /**
  44891. * Creates a box mesh
  44892. * * The parameter `size` sets the size (float) of each box side (default 1)
  44893. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44894. * * 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)
  44895. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44896. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44897. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44899. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44900. * @param name defines the name of the mesh
  44901. * @param options defines the options used to create the mesh
  44902. * @param scene defines the hosting scene
  44903. * @returns the box mesh
  44904. */
  44905. static CreateBox(name: string, options: {
  44906. size?: number;
  44907. width?: number;
  44908. height?: number;
  44909. depth?: number;
  44910. faceUV?: Vector4[];
  44911. faceColors?: Color4[];
  44912. sideOrientation?: number;
  44913. frontUVs?: Vector4;
  44914. backUVs?: Vector4;
  44915. wrap?: boolean;
  44916. topBaseAt?: number;
  44917. bottomBaseAt?: number;
  44918. updatable?: boolean;
  44919. }, scene?: Nullable<Scene>): Mesh;
  44920. }
  44921. }
  44922. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44923. import { Vector4 } from "babylonjs/Maths/math.vector";
  44924. import { Mesh } from "babylonjs/Meshes/mesh";
  44925. import { Scene } from "babylonjs/scene";
  44926. import { Nullable } from "babylonjs/types";
  44927. /**
  44928. * Class containing static functions to help procedurally build meshes
  44929. */
  44930. export class SphereBuilder {
  44931. /**
  44932. * Creates a sphere mesh
  44933. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44934. * * 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`)
  44935. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44936. * * 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
  44937. * * 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)
  44938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44941. * @param name defines the name of the mesh
  44942. * @param options defines the options used to create the mesh
  44943. * @param scene defines the hosting scene
  44944. * @returns the sphere mesh
  44945. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44946. */
  44947. static CreateSphere(name: string, options: {
  44948. segments?: number;
  44949. diameter?: number;
  44950. diameterX?: number;
  44951. diameterY?: number;
  44952. diameterZ?: number;
  44953. arc?: number;
  44954. slice?: number;
  44955. sideOrientation?: number;
  44956. frontUVs?: Vector4;
  44957. backUVs?: Vector4;
  44958. updatable?: boolean;
  44959. }, scene?: Nullable<Scene>): Mesh;
  44960. }
  44961. }
  44962. declare module "babylonjs/Debug/physicsViewer" {
  44963. import { Nullable } from "babylonjs/types";
  44964. import { Scene } from "babylonjs/scene";
  44965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44966. import { Mesh } from "babylonjs/Meshes/mesh";
  44967. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44968. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44969. /**
  44970. * Used to show the physics impostor around the specific mesh
  44971. */
  44972. export class PhysicsViewer {
  44973. /** @hidden */
  44974. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44975. /** @hidden */
  44976. protected _meshes: Array<Nullable<AbstractMesh>>;
  44977. /** @hidden */
  44978. protected _scene: Nullable<Scene>;
  44979. /** @hidden */
  44980. protected _numMeshes: number;
  44981. /** @hidden */
  44982. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44983. private _renderFunction;
  44984. private _utilityLayer;
  44985. private _debugBoxMesh;
  44986. private _debugSphereMesh;
  44987. private _debugCylinderMesh;
  44988. private _debugMaterial;
  44989. private _debugMeshMeshes;
  44990. /**
  44991. * Creates a new PhysicsViewer
  44992. * @param scene defines the hosting scene
  44993. */
  44994. constructor(scene: Scene);
  44995. /** @hidden */
  44996. protected _updateDebugMeshes(): void;
  44997. /**
  44998. * Renders a specified physic impostor
  44999. * @param impostor defines the impostor to render
  45000. * @param targetMesh defines the mesh represented by the impostor
  45001. * @returns the new debug mesh used to render the impostor
  45002. */
  45003. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45004. /**
  45005. * Hides a specified physic impostor
  45006. * @param impostor defines the impostor to hide
  45007. */
  45008. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45009. private _getDebugMaterial;
  45010. private _getDebugBoxMesh;
  45011. private _getDebugSphereMesh;
  45012. private _getDebugCylinderMesh;
  45013. private _getDebugMeshMesh;
  45014. private _getDebugMesh;
  45015. /** Releases all resources */
  45016. dispose(): void;
  45017. }
  45018. }
  45019. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45020. import { Vector3 } from "babylonjs/Maths/math.vector";
  45021. import { Color4 } from "babylonjs/Maths/math.color";
  45022. import { Nullable } from "babylonjs/types";
  45023. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45024. import { Scene } from "babylonjs/scene";
  45025. /**
  45026. * Class containing static functions to help procedurally build meshes
  45027. */
  45028. export class LinesBuilder {
  45029. /**
  45030. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45031. * * 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
  45032. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45033. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45034. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45035. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45036. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45037. * * 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
  45038. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45040. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45041. * @param name defines the name of the new line system
  45042. * @param options defines the options used to create the line system
  45043. * @param scene defines the hosting scene
  45044. * @returns a new line system mesh
  45045. */
  45046. static CreateLineSystem(name: string, options: {
  45047. lines: Vector3[][];
  45048. updatable?: boolean;
  45049. instance?: Nullable<LinesMesh>;
  45050. colors?: Nullable<Color4[][]>;
  45051. useVertexAlpha?: boolean;
  45052. }, scene: Nullable<Scene>): LinesMesh;
  45053. /**
  45054. * Creates a line mesh
  45055. * 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
  45056. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45057. * * The parameter `points` is an array successive Vector3
  45058. * * 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
  45059. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45060. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45061. * * When updating an instance, remember that only point positions can change, not the number of points
  45062. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45063. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45064. * @param name defines the name of the new line system
  45065. * @param options defines the options used to create the line system
  45066. * @param scene defines the hosting scene
  45067. * @returns a new line mesh
  45068. */
  45069. static CreateLines(name: string, options: {
  45070. points: Vector3[];
  45071. updatable?: boolean;
  45072. instance?: Nullable<LinesMesh>;
  45073. colors?: Color4[];
  45074. useVertexAlpha?: boolean;
  45075. }, scene?: Nullable<Scene>): LinesMesh;
  45076. /**
  45077. * Creates a dashed line mesh
  45078. * * 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
  45079. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45080. * * The parameter `points` is an array successive Vector3
  45081. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45082. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45083. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45084. * * 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
  45085. * * When updating an instance, remember that only point positions can change, not the number of points
  45086. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45087. * @param name defines the name of the mesh
  45088. * @param options defines the options used to create the mesh
  45089. * @param scene defines the hosting scene
  45090. * @returns the dashed line mesh
  45091. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45092. */
  45093. static CreateDashedLines(name: string, options: {
  45094. points: Vector3[];
  45095. dashSize?: number;
  45096. gapSize?: number;
  45097. dashNb?: number;
  45098. updatable?: boolean;
  45099. instance?: LinesMesh;
  45100. }, scene?: Nullable<Scene>): LinesMesh;
  45101. }
  45102. }
  45103. declare module "babylonjs/Debug/rayHelper" {
  45104. import { Nullable } from "babylonjs/types";
  45105. import { Ray } from "babylonjs/Culling/ray";
  45106. import { Vector3 } from "babylonjs/Maths/math.vector";
  45107. import { Color3 } from "babylonjs/Maths/math.color";
  45108. import { Scene } from "babylonjs/scene";
  45109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45110. import "babylonjs/Meshes/Builders/linesBuilder";
  45111. /**
  45112. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45113. * in order to better appreciate the issue one might have.
  45114. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45115. */
  45116. export class RayHelper {
  45117. /**
  45118. * Defines the ray we are currently tryin to visualize.
  45119. */
  45120. ray: Nullable<Ray>;
  45121. private _renderPoints;
  45122. private _renderLine;
  45123. private _renderFunction;
  45124. private _scene;
  45125. private _updateToMeshFunction;
  45126. private _attachedToMesh;
  45127. private _meshSpaceDirection;
  45128. private _meshSpaceOrigin;
  45129. /**
  45130. * Helper function to create a colored helper in a scene in one line.
  45131. * @param ray Defines the ray we are currently tryin to visualize
  45132. * @param scene Defines the scene the ray is used in
  45133. * @param color Defines the color we want to see the ray in
  45134. * @returns The newly created ray helper.
  45135. */
  45136. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45137. /**
  45138. * Instantiate a new ray helper.
  45139. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45140. * in order to better appreciate the issue one might have.
  45141. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45142. * @param ray Defines the ray we are currently tryin to visualize
  45143. */
  45144. constructor(ray: Ray);
  45145. /**
  45146. * Shows the ray we are willing to debug.
  45147. * @param scene Defines the scene the ray needs to be rendered in
  45148. * @param color Defines the color the ray needs to be rendered in
  45149. */
  45150. show(scene: Scene, color?: Color3): void;
  45151. /**
  45152. * Hides the ray we are debugging.
  45153. */
  45154. hide(): void;
  45155. private _render;
  45156. /**
  45157. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45158. * @param mesh Defines the mesh we want the helper attached to
  45159. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45160. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45161. * @param length Defines the length of the ray
  45162. */
  45163. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45164. /**
  45165. * Detach the ray helper from the mesh it has previously been attached to.
  45166. */
  45167. detachFromMesh(): void;
  45168. private _updateToMesh;
  45169. /**
  45170. * Dispose the helper and release its associated resources.
  45171. */
  45172. dispose(): void;
  45173. }
  45174. }
  45175. declare module "babylonjs/Debug/skeletonViewer" {
  45176. import { Color3 } from "babylonjs/Maths/math.color";
  45177. import { Scene } from "babylonjs/scene";
  45178. import { Nullable } from "babylonjs/types";
  45179. import { Skeleton } from "babylonjs/Bones/skeleton";
  45180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45181. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45182. /**
  45183. * Class used to render a debug view of a given skeleton
  45184. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45185. */
  45186. export class SkeletonViewer {
  45187. /** defines the skeleton to render */
  45188. skeleton: Skeleton;
  45189. /** defines the mesh attached to the skeleton */
  45190. mesh: AbstractMesh;
  45191. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45192. autoUpdateBonesMatrices: boolean;
  45193. /** defines the rendering group id to use with the viewer */
  45194. renderingGroupId: number;
  45195. /** Gets or sets the color used to render the skeleton */
  45196. color: Color3;
  45197. private _scene;
  45198. private _debugLines;
  45199. private _debugMesh;
  45200. private _isEnabled;
  45201. private _renderFunction;
  45202. private _utilityLayer;
  45203. /**
  45204. * Returns the mesh used to render the bones
  45205. */
  45206. readonly debugMesh: Nullable<LinesMesh>;
  45207. /**
  45208. * Creates a new SkeletonViewer
  45209. * @param skeleton defines the skeleton to render
  45210. * @param mesh defines the mesh attached to the skeleton
  45211. * @param scene defines the hosting scene
  45212. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45213. * @param renderingGroupId defines the rendering group id to use with the viewer
  45214. */
  45215. constructor(
  45216. /** defines the skeleton to render */
  45217. skeleton: Skeleton,
  45218. /** defines the mesh attached to the skeleton */
  45219. mesh: AbstractMesh, scene: Scene,
  45220. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45221. autoUpdateBonesMatrices?: boolean,
  45222. /** defines the rendering group id to use with the viewer */
  45223. renderingGroupId?: number);
  45224. /** Gets or sets a boolean indicating if the viewer is enabled */
  45225. isEnabled: boolean;
  45226. private _getBonePosition;
  45227. private _getLinesForBonesWithLength;
  45228. private _getLinesForBonesNoLength;
  45229. /** Update the viewer to sync with current skeleton state */
  45230. update(): void;
  45231. /** Release associated resources */
  45232. dispose(): void;
  45233. }
  45234. }
  45235. declare module "babylonjs/Debug/index" {
  45236. export * from "babylonjs/Debug/axesViewer";
  45237. export * from "babylonjs/Debug/boneAxesViewer";
  45238. export * from "babylonjs/Debug/debugLayer";
  45239. export * from "babylonjs/Debug/physicsViewer";
  45240. export * from "babylonjs/Debug/rayHelper";
  45241. export * from "babylonjs/Debug/skeletonViewer";
  45242. }
  45243. declare module "babylonjs/Engines/nullEngine" {
  45244. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45245. import { Scene } from "babylonjs/scene";
  45246. import { Engine } from "babylonjs/Engines/engine";
  45247. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45248. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45249. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45250. import { Effect } from "babylonjs/Materials/effect";
  45251. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45252. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45253. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45254. /**
  45255. * Options to create the null engine
  45256. */
  45257. export class NullEngineOptions {
  45258. /**
  45259. * Render width (Default: 512)
  45260. */
  45261. renderWidth: number;
  45262. /**
  45263. * Render height (Default: 256)
  45264. */
  45265. renderHeight: number;
  45266. /**
  45267. * Texture size (Default: 512)
  45268. */
  45269. textureSize: number;
  45270. /**
  45271. * If delta time between frames should be constant
  45272. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45273. */
  45274. deterministicLockstep: boolean;
  45275. /**
  45276. * Maximum about of steps between frames (Default: 4)
  45277. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45278. */
  45279. lockstepMaxSteps: number;
  45280. }
  45281. /**
  45282. * The null engine class provides support for headless version of babylon.js.
  45283. * This can be used in server side scenario or for testing purposes
  45284. */
  45285. export class NullEngine extends Engine {
  45286. private _options;
  45287. /**
  45288. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45289. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45290. * @returns true if engine is in deterministic lock step mode
  45291. */
  45292. isDeterministicLockStep(): boolean;
  45293. /**
  45294. * Gets the max steps when engine is running in deterministic lock step
  45295. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45296. * @returns the max steps
  45297. */
  45298. getLockstepMaxSteps(): number;
  45299. /**
  45300. * Gets the current hardware scaling level.
  45301. * By default the hardware scaling level is computed from the window device ratio.
  45302. * 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.
  45303. * @returns a number indicating the current hardware scaling level
  45304. */
  45305. getHardwareScalingLevel(): number;
  45306. constructor(options?: NullEngineOptions);
  45307. /**
  45308. * Creates a vertex buffer
  45309. * @param vertices the data for the vertex buffer
  45310. * @returns the new WebGL static buffer
  45311. */
  45312. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45313. /**
  45314. * Creates a new index buffer
  45315. * @param indices defines the content of the index buffer
  45316. * @param updatable defines if the index buffer must be updatable
  45317. * @returns a new webGL buffer
  45318. */
  45319. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45320. /**
  45321. * Clear the current render buffer or the current render target (if any is set up)
  45322. * @param color defines the color to use
  45323. * @param backBuffer defines if the back buffer must be cleared
  45324. * @param depth defines if the depth buffer must be cleared
  45325. * @param stencil defines if the stencil buffer must be cleared
  45326. */
  45327. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45328. /**
  45329. * Gets the current render width
  45330. * @param useScreen defines if screen size must be used (or the current render target if any)
  45331. * @returns a number defining the current render width
  45332. */
  45333. getRenderWidth(useScreen?: boolean): number;
  45334. /**
  45335. * Gets the current render height
  45336. * @param useScreen defines if screen size must be used (or the current render target if any)
  45337. * @returns a number defining the current render height
  45338. */
  45339. getRenderHeight(useScreen?: boolean): number;
  45340. /**
  45341. * Set the WebGL's viewport
  45342. * @param viewport defines the viewport element to be used
  45343. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45344. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45345. */
  45346. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45347. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45348. /**
  45349. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45350. * @param pipelineContext defines the pipeline context to use
  45351. * @param uniformsNames defines the list of uniform names
  45352. * @returns an array of webGL uniform locations
  45353. */
  45354. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45355. /**
  45356. * Gets the lsit of active attributes for a given webGL program
  45357. * @param pipelineContext defines the pipeline context to use
  45358. * @param attributesNames defines the list of attribute names to get
  45359. * @returns an array of indices indicating the offset of each attribute
  45360. */
  45361. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45362. /**
  45363. * Binds an effect to the webGL context
  45364. * @param effect defines the effect to bind
  45365. */
  45366. bindSamplers(effect: Effect): void;
  45367. /**
  45368. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45369. * @param effect defines the effect to activate
  45370. */
  45371. enableEffect(effect: Effect): void;
  45372. /**
  45373. * Set various states to the webGL context
  45374. * @param culling defines backface culling state
  45375. * @param zOffset defines the value to apply to zOffset (0 by default)
  45376. * @param force defines if states must be applied even if cache is up to date
  45377. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45378. */
  45379. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45380. /**
  45381. * Set the value of an uniform to an array of int32
  45382. * @param uniform defines the webGL uniform location where to store the value
  45383. * @param array defines the array of int32 to store
  45384. */
  45385. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45386. /**
  45387. * Set the value of an uniform to an array of int32 (stored as vec2)
  45388. * @param uniform defines the webGL uniform location where to store the value
  45389. * @param array defines the array of int32 to store
  45390. */
  45391. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45392. /**
  45393. * Set the value of an uniform to an array of int32 (stored as vec3)
  45394. * @param uniform defines the webGL uniform location where to store the value
  45395. * @param array defines the array of int32 to store
  45396. */
  45397. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45398. /**
  45399. * Set the value of an uniform to an array of int32 (stored as vec4)
  45400. * @param uniform defines the webGL uniform location where to store the value
  45401. * @param array defines the array of int32 to store
  45402. */
  45403. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45404. /**
  45405. * Set the value of an uniform to an array of float32
  45406. * @param uniform defines the webGL uniform location where to store the value
  45407. * @param array defines the array of float32 to store
  45408. */
  45409. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45410. /**
  45411. * Set the value of an uniform to an array of float32 (stored as vec2)
  45412. * @param uniform defines the webGL uniform location where to store the value
  45413. * @param array defines the array of float32 to store
  45414. */
  45415. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45416. /**
  45417. * Set the value of an uniform to an array of float32 (stored as vec3)
  45418. * @param uniform defines the webGL uniform location where to store the value
  45419. * @param array defines the array of float32 to store
  45420. */
  45421. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45422. /**
  45423. * Set the value of an uniform to an array of float32 (stored as vec4)
  45424. * @param uniform defines the webGL uniform location where to store the value
  45425. * @param array defines the array of float32 to store
  45426. */
  45427. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45428. /**
  45429. * Set the value of an uniform to an array of number
  45430. * @param uniform defines the webGL uniform location where to store the value
  45431. * @param array defines the array of number to store
  45432. */
  45433. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45434. /**
  45435. * Set the value of an uniform to an array of number (stored as vec2)
  45436. * @param uniform defines the webGL uniform location where to store the value
  45437. * @param array defines the array of number to store
  45438. */
  45439. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45440. /**
  45441. * Set the value of an uniform to an array of number (stored as vec3)
  45442. * @param uniform defines the webGL uniform location where to store the value
  45443. * @param array defines the array of number to store
  45444. */
  45445. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45446. /**
  45447. * Set the value of an uniform to an array of number (stored as vec4)
  45448. * @param uniform defines the webGL uniform location where to store the value
  45449. * @param array defines the array of number to store
  45450. */
  45451. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45452. /**
  45453. * Set the value of an uniform to an array of float32 (stored as matrices)
  45454. * @param uniform defines the webGL uniform location where to store the value
  45455. * @param matrices defines the array of float32 to store
  45456. */
  45457. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45458. /**
  45459. * Set the value of an uniform to a matrix (3x3)
  45460. * @param uniform defines the webGL uniform location where to store the value
  45461. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45462. */
  45463. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45464. /**
  45465. * Set the value of an uniform to a matrix (2x2)
  45466. * @param uniform defines the webGL uniform location where to store the value
  45467. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45468. */
  45469. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45470. /**
  45471. * Set the value of an uniform to a number (float)
  45472. * @param uniform defines the webGL uniform location where to store the value
  45473. * @param value defines the float number to store
  45474. */
  45475. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45476. /**
  45477. * Set the value of an uniform to a vec2
  45478. * @param uniform defines the webGL uniform location where to store the value
  45479. * @param x defines the 1st component of the value
  45480. * @param y defines the 2nd component of the value
  45481. */
  45482. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45483. /**
  45484. * Set the value of an uniform to a vec3
  45485. * @param uniform defines the webGL uniform location where to store the value
  45486. * @param x defines the 1st component of the value
  45487. * @param y defines the 2nd component of the value
  45488. * @param z defines the 3rd component of the value
  45489. */
  45490. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45491. /**
  45492. * Set the value of an uniform to a boolean
  45493. * @param uniform defines the webGL uniform location where to store the value
  45494. * @param bool defines the boolean to store
  45495. */
  45496. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45497. /**
  45498. * Set the value of an uniform to a vec4
  45499. * @param uniform defines the webGL uniform location where to store the value
  45500. * @param x defines the 1st component of the value
  45501. * @param y defines the 2nd component of the value
  45502. * @param z defines the 3rd component of the value
  45503. * @param w defines the 4th component of the value
  45504. */
  45505. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45506. /**
  45507. * Sets the current alpha mode
  45508. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45511. */
  45512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45513. /**
  45514. * Bind webGl buffers directly to the webGL context
  45515. * @param vertexBuffers defines the vertex buffer to bind
  45516. * @param indexBuffer defines the index buffer to bind
  45517. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45518. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45519. * @param effect defines the effect associated with the vertex buffer
  45520. */
  45521. bindBuffers(vertexBuffers: {
  45522. [key: string]: VertexBuffer;
  45523. }, indexBuffer: DataBuffer, effect: Effect): void;
  45524. /**
  45525. * Force the entire cache to be cleared
  45526. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45527. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45528. */
  45529. wipeCaches(bruteForce?: boolean): void;
  45530. /**
  45531. * Send a draw order
  45532. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45533. * @param indexStart defines the starting index
  45534. * @param indexCount defines the number of index to draw
  45535. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45536. */
  45537. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45538. /**
  45539. * Draw a list of indexed primitives
  45540. * @param fillMode defines the primitive to use
  45541. * @param indexStart defines the starting index
  45542. * @param indexCount defines the number of index to draw
  45543. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45544. */
  45545. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45546. /**
  45547. * Draw a list of unindexed primitives
  45548. * @param fillMode defines the primitive to use
  45549. * @param verticesStart defines the index of first vertex to draw
  45550. * @param verticesCount defines the count of vertices to draw
  45551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45552. */
  45553. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45554. /** @hidden */
  45555. _createTexture(): WebGLTexture;
  45556. /** @hidden */
  45557. _releaseTexture(texture: InternalTexture): void;
  45558. /**
  45559. * Usually called from Texture.ts.
  45560. * Passed information to create a WebGLTexture
  45561. * @param urlArg defines a value which contains one of the following:
  45562. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45563. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45564. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45565. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45566. * @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)
  45567. * @param scene needed for loading to the correct scene
  45568. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45569. * @param onLoad optional callback to be called upon successful completion
  45570. * @param onError optional callback to be called upon failure
  45571. * @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
  45572. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45573. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45574. * @param forcedExtension defines the extension to use to pick the right loader
  45575. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45576. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45577. */
  45578. 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;
  45579. /**
  45580. * Creates a new render target texture
  45581. * @param size defines the size of the texture
  45582. * @param options defines the options used to create the texture
  45583. * @returns a new render target texture stored in an InternalTexture
  45584. */
  45585. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45586. /**
  45587. * Update the sampling mode of a given texture
  45588. * @param samplingMode defines the required sampling mode
  45589. * @param texture defines the texture to update
  45590. */
  45591. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45592. /**
  45593. * Binds the frame buffer to the specified texture.
  45594. * @param texture The texture to render to or null for the default canvas
  45595. * @param faceIndex The face of the texture to render to in case of cube texture
  45596. * @param requiredWidth The width of the target to render to
  45597. * @param requiredHeight The height of the target to render to
  45598. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45599. * @param depthStencilTexture The depth stencil texture to use to render
  45600. * @param lodLevel defines le lod level to bind to the frame buffer
  45601. */
  45602. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45603. /**
  45604. * Unbind the current render target texture from the webGL context
  45605. * @param texture defines the render target texture to unbind
  45606. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45607. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45608. */
  45609. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45610. /**
  45611. * Creates a dynamic vertex buffer
  45612. * @param vertices the data for the dynamic vertex buffer
  45613. * @returns the new WebGL dynamic buffer
  45614. */
  45615. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45616. /**
  45617. * Update the content of a dynamic texture
  45618. * @param texture defines the texture to update
  45619. * @param canvas defines the canvas containing the source
  45620. * @param invertY defines if data must be stored with Y axis inverted
  45621. * @param premulAlpha defines if alpha is stored as premultiplied
  45622. * @param format defines the format of the data
  45623. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45624. */
  45625. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45626. /**
  45627. * Gets a boolean indicating if all created effects are ready
  45628. * @returns true if all effects are ready
  45629. */
  45630. areAllEffectsReady(): boolean;
  45631. /**
  45632. * @hidden
  45633. * Get the current error code of the webGL context
  45634. * @returns the error code
  45635. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45636. */
  45637. getError(): number;
  45638. /** @hidden */
  45639. _getUnpackAlignement(): number;
  45640. /** @hidden */
  45641. _unpackFlipY(value: boolean): void;
  45642. /**
  45643. * Update a dynamic index buffer
  45644. * @param indexBuffer defines the target index buffer
  45645. * @param indices defines the data to update
  45646. * @param offset defines the offset in the target index buffer where update should start
  45647. */
  45648. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45649. /**
  45650. * Updates a dynamic vertex buffer.
  45651. * @param vertexBuffer the vertex buffer to update
  45652. * @param vertices the data used to update the vertex buffer
  45653. * @param byteOffset the byte offset of the data (optional)
  45654. * @param byteLength the byte length of the data (optional)
  45655. */
  45656. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45657. /** @hidden */
  45658. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45659. /** @hidden */
  45660. _bindTexture(channel: number, texture: InternalTexture): void;
  45661. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45662. /**
  45663. * 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
  45664. */
  45665. releaseEffects(): void;
  45666. displayLoadingUI(): void;
  45667. hideLoadingUI(): void;
  45668. /** @hidden */
  45669. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45670. /** @hidden */
  45671. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45672. /** @hidden */
  45673. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45674. /** @hidden */
  45675. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45676. }
  45677. }
  45678. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45679. import { Nullable, int } from "babylonjs/types";
  45680. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45681. /** @hidden */
  45682. export class _OcclusionDataStorage {
  45683. /** @hidden */
  45684. occlusionInternalRetryCounter: number;
  45685. /** @hidden */
  45686. isOcclusionQueryInProgress: boolean;
  45687. /** @hidden */
  45688. isOccluded: boolean;
  45689. /** @hidden */
  45690. occlusionRetryCount: number;
  45691. /** @hidden */
  45692. occlusionType: number;
  45693. /** @hidden */
  45694. occlusionQueryAlgorithmType: number;
  45695. }
  45696. module "babylonjs/Engines/engine" {
  45697. interface Engine {
  45698. /**
  45699. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45700. * @return the new query
  45701. */
  45702. createQuery(): WebGLQuery;
  45703. /**
  45704. * Delete and release a webGL query
  45705. * @param query defines the query to delete
  45706. * @return the current engine
  45707. */
  45708. deleteQuery(query: WebGLQuery): Engine;
  45709. /**
  45710. * Check if a given query has resolved and got its value
  45711. * @param query defines the query to check
  45712. * @returns true if the query got its value
  45713. */
  45714. isQueryResultAvailable(query: WebGLQuery): boolean;
  45715. /**
  45716. * Gets the value of a given query
  45717. * @param query defines the query to check
  45718. * @returns the value of the query
  45719. */
  45720. getQueryResult(query: WebGLQuery): number;
  45721. /**
  45722. * Initiates an occlusion query
  45723. * @param algorithmType defines the algorithm to use
  45724. * @param query defines the query to use
  45725. * @returns the current engine
  45726. * @see http://doc.babylonjs.com/features/occlusionquery
  45727. */
  45728. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45729. /**
  45730. * Ends an occlusion query
  45731. * @see http://doc.babylonjs.com/features/occlusionquery
  45732. * @param algorithmType defines the algorithm to use
  45733. * @returns the current engine
  45734. */
  45735. endOcclusionQuery(algorithmType: number): Engine;
  45736. /**
  45737. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45738. * Please note that only one query can be issued at a time
  45739. * @returns a time token used to track the time span
  45740. */
  45741. startTimeQuery(): Nullable<_TimeToken>;
  45742. /**
  45743. * Ends a time query
  45744. * @param token defines the token used to measure the time span
  45745. * @returns the time spent (in ns)
  45746. */
  45747. endTimeQuery(token: _TimeToken): int;
  45748. /** @hidden */
  45749. _currentNonTimestampToken: Nullable<_TimeToken>;
  45750. /** @hidden */
  45751. _createTimeQuery(): WebGLQuery;
  45752. /** @hidden */
  45753. _deleteTimeQuery(query: WebGLQuery): void;
  45754. /** @hidden */
  45755. _getGlAlgorithmType(algorithmType: number): number;
  45756. /** @hidden */
  45757. _getTimeQueryResult(query: WebGLQuery): any;
  45758. /** @hidden */
  45759. _getTimeQueryAvailability(query: WebGLQuery): any;
  45760. }
  45761. }
  45762. module "babylonjs/Meshes/abstractMesh" {
  45763. interface AbstractMesh {
  45764. /**
  45765. * Backing filed
  45766. * @hidden
  45767. */
  45768. __occlusionDataStorage: _OcclusionDataStorage;
  45769. /**
  45770. * Access property
  45771. * @hidden
  45772. */
  45773. _occlusionDataStorage: _OcclusionDataStorage;
  45774. /**
  45775. * 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.
  45776. * The default value is -1 which means don't break the query and wait till the result
  45777. * @see http://doc.babylonjs.com/features/occlusionquery
  45778. */
  45779. occlusionRetryCount: number;
  45780. /**
  45781. * 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:
  45782. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45783. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45784. * * 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.
  45785. * @see http://doc.babylonjs.com/features/occlusionquery
  45786. */
  45787. occlusionType: number;
  45788. /**
  45789. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45790. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45791. * * 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.
  45792. * @see http://doc.babylonjs.com/features/occlusionquery
  45793. */
  45794. occlusionQueryAlgorithmType: number;
  45795. /**
  45796. * 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
  45797. * @see http://doc.babylonjs.com/features/occlusionquery
  45798. */
  45799. isOccluded: boolean;
  45800. /**
  45801. * Flag to check the progress status of the query
  45802. * @see http://doc.babylonjs.com/features/occlusionquery
  45803. */
  45804. isOcclusionQueryInProgress: boolean;
  45805. }
  45806. }
  45807. }
  45808. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45809. import { Nullable } from "babylonjs/types";
  45810. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45811. /** @hidden */
  45812. export var _forceTransformFeedbackToBundle: boolean;
  45813. module "babylonjs/Engines/engine" {
  45814. interface Engine {
  45815. /**
  45816. * Creates a webGL transform feedback object
  45817. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45818. * @returns the webGL transform feedback object
  45819. */
  45820. createTransformFeedback(): WebGLTransformFeedback;
  45821. /**
  45822. * Delete a webGL transform feedback object
  45823. * @param value defines the webGL transform feedback object to delete
  45824. */
  45825. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45826. /**
  45827. * Bind a webGL transform feedback object to the webgl context
  45828. * @param value defines the webGL transform feedback object to bind
  45829. */
  45830. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45831. /**
  45832. * Begins a transform feedback operation
  45833. * @param usePoints defines if points or triangles must be used
  45834. */
  45835. beginTransformFeedback(usePoints: boolean): void;
  45836. /**
  45837. * Ends a transform feedback operation
  45838. */
  45839. endTransformFeedback(): void;
  45840. /**
  45841. * Specify the varyings to use with transform feedback
  45842. * @param program defines the associated webGL program
  45843. * @param value defines the list of strings representing the varying names
  45844. */
  45845. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45846. /**
  45847. * Bind a webGL buffer for a transform feedback operation
  45848. * @param value defines the webGL buffer to bind
  45849. */
  45850. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45851. }
  45852. }
  45853. }
  45854. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45855. import { Scene } from "babylonjs/scene";
  45856. import { Engine } from "babylonjs/Engines/engine";
  45857. import { Texture } from "babylonjs/Materials/Textures/texture";
  45858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45859. import "babylonjs/Engines/Extensions/engine.multiRender";
  45860. /**
  45861. * Creation options of the multi render target texture.
  45862. */
  45863. export interface IMultiRenderTargetOptions {
  45864. /**
  45865. * Define if the texture needs to create mip maps after render.
  45866. */
  45867. generateMipMaps?: boolean;
  45868. /**
  45869. * Define the types of all the draw buffers we want to create
  45870. */
  45871. types?: number[];
  45872. /**
  45873. * Define the sampling modes of all the draw buffers we want to create
  45874. */
  45875. samplingModes?: number[];
  45876. /**
  45877. * Define if a depth buffer is required
  45878. */
  45879. generateDepthBuffer?: boolean;
  45880. /**
  45881. * Define if a stencil buffer is required
  45882. */
  45883. generateStencilBuffer?: boolean;
  45884. /**
  45885. * Define if a depth texture is required instead of a depth buffer
  45886. */
  45887. generateDepthTexture?: boolean;
  45888. /**
  45889. * Define the number of desired draw buffers
  45890. */
  45891. textureCount?: number;
  45892. /**
  45893. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45894. */
  45895. doNotChangeAspectRatio?: boolean;
  45896. /**
  45897. * Define the default type of the buffers we are creating
  45898. */
  45899. defaultType?: number;
  45900. }
  45901. /**
  45902. * A multi render target, like a render target provides the ability to render to a texture.
  45903. * Unlike the render target, it can render to several draw buffers in one draw.
  45904. * This is specially interesting in deferred rendering or for any effects requiring more than
  45905. * just one color from a single pass.
  45906. */
  45907. export class MultiRenderTarget extends RenderTargetTexture {
  45908. private _internalTextures;
  45909. private _textures;
  45910. private _multiRenderTargetOptions;
  45911. /**
  45912. * Get if draw buffers are currently supported by the used hardware and browser.
  45913. */
  45914. readonly isSupported: boolean;
  45915. /**
  45916. * Get the list of textures generated by the multi render target.
  45917. */
  45918. readonly textures: Texture[];
  45919. /**
  45920. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45921. */
  45922. readonly depthTexture: Texture;
  45923. /**
  45924. * Set the wrapping mode on U of all the textures we are rendering to.
  45925. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45926. */
  45927. wrapU: number;
  45928. /**
  45929. * Set the wrapping mode on V of all the textures we are rendering to.
  45930. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45931. */
  45932. wrapV: number;
  45933. /**
  45934. * Instantiate a new multi render target texture.
  45935. * A multi render target, like a render target provides the ability to render to a texture.
  45936. * Unlike the render target, it can render to several draw buffers in one draw.
  45937. * This is specially interesting in deferred rendering or for any effects requiring more than
  45938. * just one color from a single pass.
  45939. * @param name Define the name of the texture
  45940. * @param size Define the size of the buffers to render to
  45941. * @param count Define the number of target we are rendering into
  45942. * @param scene Define the scene the texture belongs to
  45943. * @param options Define the options used to create the multi render target
  45944. */
  45945. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45946. /** @hidden */
  45947. _rebuild(): void;
  45948. private _createInternalTextures;
  45949. private _createTextures;
  45950. /**
  45951. * Define the number of samples used if MSAA is enabled.
  45952. */
  45953. samples: number;
  45954. /**
  45955. * Resize all the textures in the multi render target.
  45956. * Be carrefull as it will recreate all the data in the new texture.
  45957. * @param size Define the new size
  45958. */
  45959. resize(size: any): void;
  45960. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45961. /**
  45962. * Dispose the render targets and their associated resources
  45963. */
  45964. dispose(): void;
  45965. /**
  45966. * Release all the underlying texture used as draw buffers.
  45967. */
  45968. releaseInternalTextures(): void;
  45969. }
  45970. }
  45971. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45972. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45973. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45974. import { Nullable } from "babylonjs/types";
  45975. module "babylonjs/Engines/thinEngine" {
  45976. interface ThinEngine {
  45977. /**
  45978. * Unbind a list of render target textures from the webGL context
  45979. * This is used only when drawBuffer extension or webGL2 are active
  45980. * @param textures defines the render target textures to unbind
  45981. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45982. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45983. */
  45984. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  45985. /**
  45986. * Create a multi render target texture
  45987. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  45988. * @param size defines the size of the texture
  45989. * @param options defines the creation options
  45990. * @returns the cube texture as an InternalTexture
  45991. */
  45992. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  45993. /**
  45994. * Update the sample count for a given multiple render target texture
  45995. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  45996. * @param textures defines the textures to update
  45997. * @param samples defines the sample count to set
  45998. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  45999. */
  46000. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46001. }
  46002. }
  46003. }
  46004. declare module "babylonjs/Engines/Extensions/index" {
  46005. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46006. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46007. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46008. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46009. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46010. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46011. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46012. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46013. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46014. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46015. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46016. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46017. }
  46018. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46019. import { Nullable } from "babylonjs/types";
  46020. /**
  46021. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46022. */
  46023. export interface CubeMapInfo {
  46024. /**
  46025. * The pixel array for the front face.
  46026. * This is stored in format, left to right, up to down format.
  46027. */
  46028. front: Nullable<ArrayBufferView>;
  46029. /**
  46030. * The pixel array for the back face.
  46031. * This is stored in format, left to right, up to down format.
  46032. */
  46033. back: Nullable<ArrayBufferView>;
  46034. /**
  46035. * The pixel array for the left face.
  46036. * This is stored in format, left to right, up to down format.
  46037. */
  46038. left: Nullable<ArrayBufferView>;
  46039. /**
  46040. * The pixel array for the right face.
  46041. * This is stored in format, left to right, up to down format.
  46042. */
  46043. right: Nullable<ArrayBufferView>;
  46044. /**
  46045. * The pixel array for the up face.
  46046. * This is stored in format, left to right, up to down format.
  46047. */
  46048. up: Nullable<ArrayBufferView>;
  46049. /**
  46050. * The pixel array for the down face.
  46051. * This is stored in format, left to right, up to down format.
  46052. */
  46053. down: Nullable<ArrayBufferView>;
  46054. /**
  46055. * The size of the cubemap stored.
  46056. *
  46057. * Each faces will be size * size pixels.
  46058. */
  46059. size: number;
  46060. /**
  46061. * The format of the texture.
  46062. *
  46063. * RGBA, RGB.
  46064. */
  46065. format: number;
  46066. /**
  46067. * The type of the texture data.
  46068. *
  46069. * UNSIGNED_INT, FLOAT.
  46070. */
  46071. type: number;
  46072. /**
  46073. * Specifies whether the texture is in gamma space.
  46074. */
  46075. gammaSpace: boolean;
  46076. }
  46077. /**
  46078. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46079. */
  46080. export class PanoramaToCubeMapTools {
  46081. private static FACE_FRONT;
  46082. private static FACE_BACK;
  46083. private static FACE_RIGHT;
  46084. private static FACE_LEFT;
  46085. private static FACE_DOWN;
  46086. private static FACE_UP;
  46087. /**
  46088. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46089. *
  46090. * @param float32Array The source data.
  46091. * @param inputWidth The width of the input panorama.
  46092. * @param inputHeight The height of the input panorama.
  46093. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46094. * @return The cubemap data
  46095. */
  46096. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46097. private static CreateCubemapTexture;
  46098. private static CalcProjectionSpherical;
  46099. }
  46100. }
  46101. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46102. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46104. import { Nullable } from "babylonjs/types";
  46105. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46106. /**
  46107. * Helper class dealing with the extraction of spherical polynomial dataArray
  46108. * from a cube map.
  46109. */
  46110. export class CubeMapToSphericalPolynomialTools {
  46111. private static FileFaces;
  46112. /**
  46113. * Converts a texture to the according Spherical Polynomial data.
  46114. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46115. *
  46116. * @param texture The texture to extract the information from.
  46117. * @return The Spherical Polynomial data.
  46118. */
  46119. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46120. /**
  46121. * Converts a cubemap to the according Spherical Polynomial data.
  46122. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46123. *
  46124. * @param cubeInfo The Cube map to extract the information from.
  46125. * @return The Spherical Polynomial data.
  46126. */
  46127. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46128. }
  46129. }
  46130. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46131. import { Nullable } from "babylonjs/types";
  46132. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46133. module "babylonjs/Materials/Textures/baseTexture" {
  46134. interface BaseTexture {
  46135. /**
  46136. * Get the polynomial representation of the texture data.
  46137. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46138. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46139. */
  46140. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46141. }
  46142. }
  46143. }
  46144. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46145. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46146. /** @hidden */
  46147. export var rgbdEncodePixelShader: {
  46148. name: string;
  46149. shader: string;
  46150. };
  46151. }
  46152. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46153. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46154. /** @hidden */
  46155. export var rgbdDecodePixelShader: {
  46156. name: string;
  46157. shader: string;
  46158. };
  46159. }
  46160. declare module "babylonjs/Misc/environmentTextureTools" {
  46161. import { Nullable } from "babylonjs/types";
  46162. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46163. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46164. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46165. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46166. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46167. import "babylonjs/Shaders/rgbdEncode.fragment";
  46168. import "babylonjs/Shaders/rgbdDecode.fragment";
  46169. /**
  46170. * Raw texture data and descriptor sufficient for WebGL texture upload
  46171. */
  46172. export interface EnvironmentTextureInfo {
  46173. /**
  46174. * Version of the environment map
  46175. */
  46176. version: number;
  46177. /**
  46178. * Width of image
  46179. */
  46180. width: number;
  46181. /**
  46182. * Irradiance information stored in the file.
  46183. */
  46184. irradiance: any;
  46185. /**
  46186. * Specular information stored in the file.
  46187. */
  46188. specular: any;
  46189. }
  46190. /**
  46191. * Defines One Image in the file. It requires only the position in the file
  46192. * as well as the length.
  46193. */
  46194. interface BufferImageData {
  46195. /**
  46196. * Length of the image data.
  46197. */
  46198. length: number;
  46199. /**
  46200. * Position of the data from the null terminator delimiting the end of the JSON.
  46201. */
  46202. position: number;
  46203. }
  46204. /**
  46205. * Defines the specular data enclosed in the file.
  46206. * This corresponds to the version 1 of the data.
  46207. */
  46208. export interface EnvironmentTextureSpecularInfoV1 {
  46209. /**
  46210. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46211. */
  46212. specularDataPosition?: number;
  46213. /**
  46214. * This contains all the images data needed to reconstruct the cubemap.
  46215. */
  46216. mipmaps: Array<BufferImageData>;
  46217. /**
  46218. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46219. */
  46220. lodGenerationScale: number;
  46221. }
  46222. /**
  46223. * Sets of helpers addressing the serialization and deserialization of environment texture
  46224. * stored in a BabylonJS env file.
  46225. * Those files are usually stored as .env files.
  46226. */
  46227. export class EnvironmentTextureTools {
  46228. /**
  46229. * Magic number identifying the env file.
  46230. */
  46231. private static _MagicBytes;
  46232. /**
  46233. * Gets the environment info from an env file.
  46234. * @param data The array buffer containing the .env bytes.
  46235. * @returns the environment file info (the json header) if successfully parsed.
  46236. */
  46237. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46238. /**
  46239. * Creates an environment texture from a loaded cube texture.
  46240. * @param texture defines the cube texture to convert in env file
  46241. * @return a promise containing the environment data if succesfull.
  46242. */
  46243. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46244. /**
  46245. * Creates a JSON representation of the spherical data.
  46246. * @param texture defines the texture containing the polynomials
  46247. * @return the JSON representation of the spherical info
  46248. */
  46249. private static _CreateEnvTextureIrradiance;
  46250. /**
  46251. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46252. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46253. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46254. * @return the views described by info providing access to the underlying buffer
  46255. */
  46256. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46257. /**
  46258. * Uploads the texture info contained in the env file to the GPU.
  46259. * @param texture defines the internal texture to upload to
  46260. * @param arrayBuffer defines the buffer cotaining the data to load
  46261. * @param info defines the texture info retrieved through the GetEnvInfo method
  46262. * @returns a promise
  46263. */
  46264. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46265. /**
  46266. * Uploads the levels of image data to the GPU.
  46267. * @param texture defines the internal texture to upload to
  46268. * @param imageData defines the array buffer views of image data [mipmap][face]
  46269. * @returns a promise
  46270. */
  46271. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46272. /**
  46273. * Uploads spherical polynomials information to the texture.
  46274. * @param texture defines the texture we are trying to upload the information to
  46275. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46276. */
  46277. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46278. /** @hidden */
  46279. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46280. }
  46281. }
  46282. declare module "babylonjs/Maths/math.vertexFormat" {
  46283. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46284. /**
  46285. * Contains position and normal vectors for a vertex
  46286. */
  46287. export class PositionNormalVertex {
  46288. /** the position of the vertex (defaut: 0,0,0) */
  46289. position: Vector3;
  46290. /** the normal of the vertex (defaut: 0,1,0) */
  46291. normal: Vector3;
  46292. /**
  46293. * Creates a PositionNormalVertex
  46294. * @param position the position of the vertex (defaut: 0,0,0)
  46295. * @param normal the normal of the vertex (defaut: 0,1,0)
  46296. */
  46297. constructor(
  46298. /** the position of the vertex (defaut: 0,0,0) */
  46299. position?: Vector3,
  46300. /** the normal of the vertex (defaut: 0,1,0) */
  46301. normal?: Vector3);
  46302. /**
  46303. * Clones the PositionNormalVertex
  46304. * @returns the cloned PositionNormalVertex
  46305. */
  46306. clone(): PositionNormalVertex;
  46307. }
  46308. /**
  46309. * Contains position, normal and uv vectors for a vertex
  46310. */
  46311. export class PositionNormalTextureVertex {
  46312. /** the position of the vertex (defaut: 0,0,0) */
  46313. position: Vector3;
  46314. /** the normal of the vertex (defaut: 0,1,0) */
  46315. normal: Vector3;
  46316. /** the uv of the vertex (default: 0,0) */
  46317. uv: Vector2;
  46318. /**
  46319. * Creates a PositionNormalTextureVertex
  46320. * @param position the position of the vertex (defaut: 0,0,0)
  46321. * @param normal the normal of the vertex (defaut: 0,1,0)
  46322. * @param uv the uv of the vertex (default: 0,0)
  46323. */
  46324. constructor(
  46325. /** the position of the vertex (defaut: 0,0,0) */
  46326. position?: Vector3,
  46327. /** the normal of the vertex (defaut: 0,1,0) */
  46328. normal?: Vector3,
  46329. /** the uv of the vertex (default: 0,0) */
  46330. uv?: Vector2);
  46331. /**
  46332. * Clones the PositionNormalTextureVertex
  46333. * @returns the cloned PositionNormalTextureVertex
  46334. */
  46335. clone(): PositionNormalTextureVertex;
  46336. }
  46337. }
  46338. declare module "babylonjs/Maths/math" {
  46339. export * from "babylonjs/Maths/math.axis";
  46340. export * from "babylonjs/Maths/math.color";
  46341. export * from "babylonjs/Maths/math.constants";
  46342. export * from "babylonjs/Maths/math.frustum";
  46343. export * from "babylonjs/Maths/math.path";
  46344. export * from "babylonjs/Maths/math.plane";
  46345. export * from "babylonjs/Maths/math.size";
  46346. export * from "babylonjs/Maths/math.vector";
  46347. export * from "babylonjs/Maths/math.vertexFormat";
  46348. export * from "babylonjs/Maths/math.viewport";
  46349. }
  46350. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46351. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46352. /** @hidden */
  46353. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46354. private _genericAttributeLocation;
  46355. private _varyingLocationCount;
  46356. private _varyingLocationMap;
  46357. private _replacements;
  46358. private _textureCount;
  46359. private _uniforms;
  46360. lineProcessor(line: string): string;
  46361. attributeProcessor(attribute: string): string;
  46362. varyingProcessor(varying: string, isFragment: boolean): string;
  46363. uniformProcessor(uniform: string): string;
  46364. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46365. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46366. }
  46367. }
  46368. declare module "babylonjs/Engines/nativeEngine" {
  46369. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46370. import { Engine } from "babylonjs/Engines/engine";
  46371. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46372. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46373. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46374. import { Effect } from "babylonjs/Materials/effect";
  46375. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46376. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46377. import { Scene } from "babylonjs/scene";
  46378. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46379. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46380. /**
  46381. * Container for accessors for natively-stored mesh data buffers.
  46382. */
  46383. class NativeDataBuffer extends DataBuffer {
  46384. /**
  46385. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46386. */
  46387. nativeIndexBuffer?: any;
  46388. /**
  46389. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46390. */
  46391. nativeVertexBuffer?: any;
  46392. }
  46393. /** @hidden */
  46394. export class NativeEngine extends Engine {
  46395. private readonly _native;
  46396. getHardwareScalingLevel(): number;
  46397. constructor();
  46398. /**
  46399. * Can be used to override the current requestAnimationFrame requester.
  46400. * @hidden
  46401. */
  46402. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46403. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46404. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46405. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46406. recordVertexArrayObject(vertexBuffers: {
  46407. [key: string]: VertexBuffer;
  46408. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46409. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46410. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46411. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46412. /**
  46413. * Draw a list of indexed primitives
  46414. * @param fillMode defines the primitive to use
  46415. * @param indexStart defines the starting index
  46416. * @param indexCount defines the number of index to draw
  46417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46418. */
  46419. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46420. /**
  46421. * Draw a list of unindexed primitives
  46422. * @param fillMode defines the primitive to use
  46423. * @param verticesStart defines the index of first vertex to draw
  46424. * @param verticesCount defines the count of vertices to draw
  46425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46426. */
  46427. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46428. createPipelineContext(): IPipelineContext;
  46429. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46430. /** @hidden */
  46431. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46432. /** @hidden */
  46433. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46434. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46435. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46436. protected _setProgram(program: WebGLProgram): void;
  46437. _releaseEffect(effect: Effect): void;
  46438. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46439. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46440. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46441. bindSamplers(effect: Effect): void;
  46442. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46443. getRenderWidth(useScreen?: boolean): number;
  46444. getRenderHeight(useScreen?: boolean): number;
  46445. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46447. /**
  46448. * Set the z offset to apply to current rendering
  46449. * @param value defines the offset to apply
  46450. */
  46451. setZOffset(value: number): void;
  46452. /**
  46453. * Gets the current value of the zOffset
  46454. * @returns the current zOffset state
  46455. */
  46456. getZOffset(): number;
  46457. /**
  46458. * Enable or disable depth buffering
  46459. * @param enable defines the state to set
  46460. */
  46461. setDepthBuffer(enable: boolean): void;
  46462. /**
  46463. * Gets a boolean indicating if depth writing is enabled
  46464. * @returns the current depth writing state
  46465. */
  46466. getDepthWrite(): boolean;
  46467. /**
  46468. * Enable or disable depth writing
  46469. * @param enable defines the state to set
  46470. */
  46471. setDepthWrite(enable: boolean): void;
  46472. /**
  46473. * Enable or disable color writing
  46474. * @param enable defines the state to set
  46475. */
  46476. setColorWrite(enable: boolean): void;
  46477. /**
  46478. * Gets a boolean indicating if color writing is enabled
  46479. * @returns the current color writing state
  46480. */
  46481. getColorWrite(): boolean;
  46482. /**
  46483. * Sets alpha constants used by some alpha blending modes
  46484. * @param r defines the red component
  46485. * @param g defines the green component
  46486. * @param b defines the blue component
  46487. * @param a defines the alpha component
  46488. */
  46489. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46490. /**
  46491. * Sets the current alpha mode
  46492. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46493. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46494. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46495. */
  46496. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46497. /**
  46498. * Gets the current alpha mode
  46499. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46500. * @returns the current alpha mode
  46501. */
  46502. getAlphaMode(): number;
  46503. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46504. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46505. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46506. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46507. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46508. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46509. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46510. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46511. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46512. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46513. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46514. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46515. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46516. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46517. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46518. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46519. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46520. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46521. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46522. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46523. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46524. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46525. wipeCaches(bruteForce?: boolean): void;
  46526. _createTexture(): WebGLTexture;
  46527. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46528. /**
  46529. * Usually called from BABYLON.Texture.ts.
  46530. * Passed information to create a WebGLTexture
  46531. * @param urlArg defines a value which contains one of the following:
  46532. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46533. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46534. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46535. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46536. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46537. * @param scene needed for loading to the correct scene
  46538. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46539. * @param onLoad optional callback to be called upon successful completion
  46540. * @param onError optional callback to be called upon failure
  46541. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46542. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46543. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46544. * @param forcedExtension defines the extension to use to pick the right loader
  46545. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46546. */
  46547. 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;
  46548. /**
  46549. * Creates a cube texture
  46550. * @param rootUrl defines the url where the files to load is located
  46551. * @param scene defines the current scene
  46552. * @param files defines the list of files to load (1 per face)
  46553. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46554. * @param onLoad defines an optional callback raised when the texture is loaded
  46555. * @param onError defines an optional callback raised if there is an issue to load the texture
  46556. * @param format defines the format of the data
  46557. * @param forcedExtension defines the extension to use to pick the right loader
  46558. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46559. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46560. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46561. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46562. * @returns the cube texture as an InternalTexture
  46563. */
  46564. 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;
  46565. private _getSamplingFilter;
  46566. private static _GetNativeTextureFormat;
  46567. createRenderTargetTexture(size: number | {
  46568. width: number;
  46569. height: number;
  46570. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46571. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46572. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46573. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46574. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46575. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46576. /**
  46577. * Updates a dynamic vertex buffer.
  46578. * @param vertexBuffer the vertex buffer to update
  46579. * @param data the data used to update the vertex buffer
  46580. * @param byteOffset the byte offset of the data (optional)
  46581. * @param byteLength the byte length of the data (optional)
  46582. */
  46583. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46584. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46585. private _updateAnisotropicLevel;
  46586. private _getAddressMode;
  46587. /** @hidden */
  46588. _bindTexture(channel: number, texture: InternalTexture): void;
  46589. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46590. releaseEffects(): void;
  46591. /** @hidden */
  46592. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46593. /** @hidden */
  46594. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46595. /** @hidden */
  46596. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46597. /** @hidden */
  46598. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46599. }
  46600. }
  46601. declare module "babylonjs/Engines/index" {
  46602. export * from "babylonjs/Engines/constants";
  46603. export * from "babylonjs/Engines/engineCapabilities";
  46604. export * from "babylonjs/Engines/instancingAttributeInfo";
  46605. export * from "babylonjs/Engines/thinEngine";
  46606. export * from "babylonjs/Engines/engine";
  46607. export * from "babylonjs/Engines/engineStore";
  46608. export * from "babylonjs/Engines/nullEngine";
  46609. export * from "babylonjs/Engines/Extensions/index";
  46610. export * from "babylonjs/Engines/IPipelineContext";
  46611. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46612. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46613. export * from "babylonjs/Engines/nativeEngine";
  46614. }
  46615. declare module "babylonjs/Events/clipboardEvents" {
  46616. /**
  46617. * Gather the list of clipboard event types as constants.
  46618. */
  46619. export class ClipboardEventTypes {
  46620. /**
  46621. * The clipboard event is fired when a copy command is active (pressed).
  46622. */
  46623. static readonly COPY: number;
  46624. /**
  46625. * The clipboard event is fired when a cut command is active (pressed).
  46626. */
  46627. static readonly CUT: number;
  46628. /**
  46629. * The clipboard event is fired when a paste command is active (pressed).
  46630. */
  46631. static readonly PASTE: number;
  46632. }
  46633. /**
  46634. * This class is used to store clipboard related info for the onClipboardObservable event.
  46635. */
  46636. export class ClipboardInfo {
  46637. /**
  46638. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46639. */
  46640. type: number;
  46641. /**
  46642. * Defines the related dom event
  46643. */
  46644. event: ClipboardEvent;
  46645. /**
  46646. *Creates an instance of ClipboardInfo.
  46647. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46648. * @param event Defines the related dom event
  46649. */
  46650. constructor(
  46651. /**
  46652. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46653. */
  46654. type: number,
  46655. /**
  46656. * Defines the related dom event
  46657. */
  46658. event: ClipboardEvent);
  46659. /**
  46660. * Get the clipboard event's type from the keycode.
  46661. * @param keyCode Defines the keyCode for the current keyboard event.
  46662. * @return {number}
  46663. */
  46664. static GetTypeFromCharacter(keyCode: number): number;
  46665. }
  46666. }
  46667. declare module "babylonjs/Events/index" {
  46668. export * from "babylonjs/Events/keyboardEvents";
  46669. export * from "babylonjs/Events/pointerEvents";
  46670. export * from "babylonjs/Events/clipboardEvents";
  46671. }
  46672. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46673. import { Scene } from "babylonjs/scene";
  46674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46675. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46676. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46677. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46678. /**
  46679. * Google Daydream controller
  46680. */
  46681. export class DaydreamController extends WebVRController {
  46682. /**
  46683. * Base Url for the controller model.
  46684. */
  46685. static MODEL_BASE_URL: string;
  46686. /**
  46687. * File name for the controller model.
  46688. */
  46689. static MODEL_FILENAME: string;
  46690. /**
  46691. * Gamepad Id prefix used to identify Daydream Controller.
  46692. */
  46693. static readonly GAMEPAD_ID_PREFIX: string;
  46694. /**
  46695. * Creates a new DaydreamController from a gamepad
  46696. * @param vrGamepad the gamepad that the controller should be created from
  46697. */
  46698. constructor(vrGamepad: any);
  46699. /**
  46700. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46701. * @param scene scene in which to add meshes
  46702. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46703. */
  46704. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46705. /**
  46706. * Called once for each button that changed state since the last frame
  46707. * @param buttonIdx Which button index changed
  46708. * @param state New state of the button
  46709. * @param changes Which properties on the state changed since last frame
  46710. */
  46711. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46712. }
  46713. }
  46714. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46715. import { Scene } from "babylonjs/scene";
  46716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46717. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46718. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46719. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46720. /**
  46721. * Gear VR Controller
  46722. */
  46723. export class GearVRController extends WebVRController {
  46724. /**
  46725. * Base Url for the controller model.
  46726. */
  46727. static MODEL_BASE_URL: string;
  46728. /**
  46729. * File name for the controller model.
  46730. */
  46731. static MODEL_FILENAME: string;
  46732. /**
  46733. * Gamepad Id prefix used to identify this controller.
  46734. */
  46735. static readonly GAMEPAD_ID_PREFIX: string;
  46736. private readonly _buttonIndexToObservableNameMap;
  46737. /**
  46738. * Creates a new GearVRController from a gamepad
  46739. * @param vrGamepad the gamepad that the controller should be created from
  46740. */
  46741. constructor(vrGamepad: any);
  46742. /**
  46743. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46744. * @param scene scene in which to add meshes
  46745. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46746. */
  46747. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46748. /**
  46749. * Called once for each button that changed state since the last frame
  46750. * @param buttonIdx Which button index changed
  46751. * @param state New state of the button
  46752. * @param changes Which properties on the state changed since last frame
  46753. */
  46754. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46755. }
  46756. }
  46757. declare module "babylonjs/Gamepads/Controllers/index" {
  46758. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46759. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46760. export * from "babylonjs/Gamepads/Controllers/genericController";
  46761. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46762. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46763. export * from "babylonjs/Gamepads/Controllers/viveController";
  46764. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46765. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46766. }
  46767. declare module "babylonjs/Gamepads/index" {
  46768. export * from "babylonjs/Gamepads/Controllers/index";
  46769. export * from "babylonjs/Gamepads/gamepad";
  46770. export * from "babylonjs/Gamepads/gamepadManager";
  46771. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46772. export * from "babylonjs/Gamepads/xboxGamepad";
  46773. export * from "babylonjs/Gamepads/dualShockGamepad";
  46774. }
  46775. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46776. import { Scene } from "babylonjs/scene";
  46777. import { Vector4 } from "babylonjs/Maths/math.vector";
  46778. import { Color4 } from "babylonjs/Maths/math.color";
  46779. import { Mesh } from "babylonjs/Meshes/mesh";
  46780. import { Nullable } from "babylonjs/types";
  46781. /**
  46782. * Class containing static functions to help procedurally build meshes
  46783. */
  46784. export class PolyhedronBuilder {
  46785. /**
  46786. * Creates a polyhedron mesh
  46787. * * 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
  46788. * * The parameter `size` (positive float, default 1) sets the polygon size
  46789. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46790. * * 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`
  46791. * * 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
  46792. * * 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)`)
  46793. * * 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
  46794. * * 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
  46795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46798. * @param name defines the name of the mesh
  46799. * @param options defines the options used to create the mesh
  46800. * @param scene defines the hosting scene
  46801. * @returns the polyhedron mesh
  46802. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46803. */
  46804. static CreatePolyhedron(name: string, options: {
  46805. type?: number;
  46806. size?: number;
  46807. sizeX?: number;
  46808. sizeY?: number;
  46809. sizeZ?: number;
  46810. custom?: any;
  46811. faceUV?: Vector4[];
  46812. faceColors?: Color4[];
  46813. flat?: boolean;
  46814. updatable?: boolean;
  46815. sideOrientation?: number;
  46816. frontUVs?: Vector4;
  46817. backUVs?: Vector4;
  46818. }, scene?: Nullable<Scene>): Mesh;
  46819. }
  46820. }
  46821. declare module "babylonjs/Gizmos/scaleGizmo" {
  46822. import { Observable } from "babylonjs/Misc/observable";
  46823. import { Nullable } from "babylonjs/types";
  46824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46825. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46826. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46827. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46828. /**
  46829. * Gizmo that enables scaling a mesh along 3 axis
  46830. */
  46831. export class ScaleGizmo extends Gizmo {
  46832. /**
  46833. * Internal gizmo used for interactions on the x axis
  46834. */
  46835. xGizmo: AxisScaleGizmo;
  46836. /**
  46837. * Internal gizmo used for interactions on the y axis
  46838. */
  46839. yGizmo: AxisScaleGizmo;
  46840. /**
  46841. * Internal gizmo used for interactions on the z axis
  46842. */
  46843. zGizmo: AxisScaleGizmo;
  46844. /**
  46845. * Internal gizmo used to scale all axis equally
  46846. */
  46847. uniformScaleGizmo: AxisScaleGizmo;
  46848. private _meshAttached;
  46849. private _updateGizmoRotationToMatchAttachedMesh;
  46850. private _snapDistance;
  46851. private _scaleRatio;
  46852. private _uniformScalingMesh;
  46853. private _octahedron;
  46854. /** Fires an event when any of it's sub gizmos are dragged */
  46855. onDragStartObservable: Observable<unknown>;
  46856. /** Fires an event when any of it's sub gizmos are released from dragging */
  46857. onDragEndObservable: Observable<unknown>;
  46858. attachedMesh: Nullable<AbstractMesh>;
  46859. /**
  46860. * Creates a ScaleGizmo
  46861. * @param gizmoLayer The utility layer the gizmo will be added to
  46862. */
  46863. constructor(gizmoLayer?: UtilityLayerRenderer);
  46864. updateGizmoRotationToMatchAttachedMesh: boolean;
  46865. /**
  46866. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46867. */
  46868. snapDistance: number;
  46869. /**
  46870. * Ratio for the scale of the gizmo (Default: 1)
  46871. */
  46872. scaleRatio: number;
  46873. /**
  46874. * Disposes of the gizmo
  46875. */
  46876. dispose(): void;
  46877. }
  46878. }
  46879. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46880. import { Observable } from "babylonjs/Misc/observable";
  46881. import { Nullable } from "babylonjs/types";
  46882. import { Vector3 } from "babylonjs/Maths/math.vector";
  46883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46884. import { Mesh } from "babylonjs/Meshes/mesh";
  46885. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46886. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46887. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46888. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46889. import { Color3 } from "babylonjs/Maths/math.color";
  46890. /**
  46891. * Single axis scale gizmo
  46892. */
  46893. export class AxisScaleGizmo extends Gizmo {
  46894. /**
  46895. * Drag behavior responsible for the gizmos dragging interactions
  46896. */
  46897. dragBehavior: PointerDragBehavior;
  46898. private _pointerObserver;
  46899. /**
  46900. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46901. */
  46902. snapDistance: number;
  46903. /**
  46904. * Event that fires each time the gizmo snaps to a new location.
  46905. * * snapDistance is the the change in distance
  46906. */
  46907. onSnapObservable: Observable<{
  46908. snapDistance: number;
  46909. }>;
  46910. /**
  46911. * If the scaling operation should be done on all axis (default: false)
  46912. */
  46913. uniformScaling: boolean;
  46914. private _isEnabled;
  46915. private _parent;
  46916. private _arrow;
  46917. private _coloredMaterial;
  46918. private _hoverMaterial;
  46919. /**
  46920. * Creates an AxisScaleGizmo
  46921. * @param gizmoLayer The utility layer the gizmo will be added to
  46922. * @param dragAxis The axis which the gizmo will be able to scale on
  46923. * @param color The color of the gizmo
  46924. */
  46925. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46926. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46927. /**
  46928. * If the gizmo is enabled
  46929. */
  46930. isEnabled: boolean;
  46931. /**
  46932. * Disposes of the gizmo
  46933. */
  46934. dispose(): void;
  46935. /**
  46936. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46937. * @param mesh The mesh to replace the default mesh of the gizmo
  46938. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46939. */
  46940. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46941. }
  46942. }
  46943. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46944. import { Observable } from "babylonjs/Misc/observable";
  46945. import { Nullable } from "babylonjs/types";
  46946. import { Vector3 } from "babylonjs/Maths/math.vector";
  46947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46948. import { Mesh } from "babylonjs/Meshes/mesh";
  46949. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46950. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46951. import { Color3 } from "babylonjs/Maths/math.color";
  46952. import "babylonjs/Meshes/Builders/boxBuilder";
  46953. /**
  46954. * Bounding box gizmo
  46955. */
  46956. export class BoundingBoxGizmo extends Gizmo {
  46957. private _lineBoundingBox;
  46958. private _rotateSpheresParent;
  46959. private _scaleBoxesParent;
  46960. private _boundingDimensions;
  46961. private _renderObserver;
  46962. private _pointerObserver;
  46963. private _scaleDragSpeed;
  46964. private _tmpQuaternion;
  46965. private _tmpVector;
  46966. private _tmpRotationMatrix;
  46967. /**
  46968. * 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)
  46969. */
  46970. ignoreChildren: boolean;
  46971. /**
  46972. * 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)
  46973. */
  46974. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46975. /**
  46976. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46977. */
  46978. rotationSphereSize: number;
  46979. /**
  46980. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46981. */
  46982. scaleBoxSize: number;
  46983. /**
  46984. * 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)
  46985. */
  46986. fixedDragMeshScreenSize: boolean;
  46987. /**
  46988. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46989. */
  46990. fixedDragMeshScreenSizeDistanceFactor: number;
  46991. /**
  46992. * Fired when a rotation sphere or scale box is dragged
  46993. */
  46994. onDragStartObservable: Observable<{}>;
  46995. /**
  46996. * Fired when a scale box is dragged
  46997. */
  46998. onScaleBoxDragObservable: Observable<{}>;
  46999. /**
  47000. * Fired when a scale box drag is ended
  47001. */
  47002. onScaleBoxDragEndObservable: Observable<{}>;
  47003. /**
  47004. * Fired when a rotation sphere is dragged
  47005. */
  47006. onRotationSphereDragObservable: Observable<{}>;
  47007. /**
  47008. * Fired when a rotation sphere drag is ended
  47009. */
  47010. onRotationSphereDragEndObservable: Observable<{}>;
  47011. /**
  47012. * 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)
  47013. */
  47014. scalePivot: Nullable<Vector3>;
  47015. /**
  47016. * Mesh used as a pivot to rotate the attached mesh
  47017. */
  47018. private _anchorMesh;
  47019. private _existingMeshScale;
  47020. private _dragMesh;
  47021. private pointerDragBehavior;
  47022. private coloredMaterial;
  47023. private hoverColoredMaterial;
  47024. /**
  47025. * Sets the color of the bounding box gizmo
  47026. * @param color the color to set
  47027. */
  47028. setColor(color: Color3): void;
  47029. /**
  47030. * Creates an BoundingBoxGizmo
  47031. * @param gizmoLayer The utility layer the gizmo will be added to
  47032. * @param color The color of the gizmo
  47033. */
  47034. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47036. private _selectNode;
  47037. /**
  47038. * Updates the bounding box information for the Gizmo
  47039. */
  47040. updateBoundingBox(): void;
  47041. private _updateRotationSpheres;
  47042. private _updateScaleBoxes;
  47043. /**
  47044. * Enables rotation on the specified axis and disables rotation on the others
  47045. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47046. */
  47047. setEnabledRotationAxis(axis: string): void;
  47048. /**
  47049. * Enables/disables scaling
  47050. * @param enable if scaling should be enabled
  47051. */
  47052. setEnabledScaling(enable: boolean): void;
  47053. private _updateDummy;
  47054. /**
  47055. * Enables a pointer drag behavior on the bounding box of the gizmo
  47056. */
  47057. enableDragBehavior(): void;
  47058. /**
  47059. * Disposes of the gizmo
  47060. */
  47061. dispose(): void;
  47062. /**
  47063. * 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)
  47064. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47065. * @returns the bounding box mesh with the passed in mesh as a child
  47066. */
  47067. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47068. /**
  47069. * CustomMeshes are not supported by this gizmo
  47070. * @param mesh The mesh to replace the default mesh of the gizmo
  47071. */
  47072. setCustomMesh(mesh: Mesh): void;
  47073. }
  47074. }
  47075. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47076. import { Observable } from "babylonjs/Misc/observable";
  47077. import { Nullable } from "babylonjs/types";
  47078. import { Vector3 } from "babylonjs/Maths/math.vector";
  47079. import { Color3 } from "babylonjs/Maths/math.color";
  47080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47081. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47082. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47083. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47084. import "babylonjs/Meshes/Builders/linesBuilder";
  47085. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47086. /**
  47087. * Single plane rotation gizmo
  47088. */
  47089. export class PlaneRotationGizmo extends Gizmo {
  47090. /**
  47091. * Drag behavior responsible for the gizmos dragging interactions
  47092. */
  47093. dragBehavior: PointerDragBehavior;
  47094. private _pointerObserver;
  47095. /**
  47096. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47097. */
  47098. snapDistance: number;
  47099. /**
  47100. * Event that fires each time the gizmo snaps to a new location.
  47101. * * snapDistance is the the change in distance
  47102. */
  47103. onSnapObservable: Observable<{
  47104. snapDistance: number;
  47105. }>;
  47106. private _isEnabled;
  47107. private _parent;
  47108. /**
  47109. * Creates a PlaneRotationGizmo
  47110. * @param gizmoLayer The utility layer the gizmo will be added to
  47111. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47112. * @param color The color of the gizmo
  47113. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47114. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47115. */
  47116. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47117. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47118. /**
  47119. * If the gizmo is enabled
  47120. */
  47121. isEnabled: boolean;
  47122. /**
  47123. * Disposes of the gizmo
  47124. */
  47125. dispose(): void;
  47126. }
  47127. }
  47128. declare module "babylonjs/Gizmos/rotationGizmo" {
  47129. import { Observable } from "babylonjs/Misc/observable";
  47130. import { Nullable } from "babylonjs/types";
  47131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47132. import { Mesh } from "babylonjs/Meshes/mesh";
  47133. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47134. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47135. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47136. /**
  47137. * Gizmo that enables rotating a mesh along 3 axis
  47138. */
  47139. export class RotationGizmo extends Gizmo {
  47140. /**
  47141. * Internal gizmo used for interactions on the x axis
  47142. */
  47143. xGizmo: PlaneRotationGizmo;
  47144. /**
  47145. * Internal gizmo used for interactions on the y axis
  47146. */
  47147. yGizmo: PlaneRotationGizmo;
  47148. /**
  47149. * Internal gizmo used for interactions on the z axis
  47150. */
  47151. zGizmo: PlaneRotationGizmo;
  47152. /** Fires an event when any of it's sub gizmos are dragged */
  47153. onDragStartObservable: Observable<unknown>;
  47154. /** Fires an event when any of it's sub gizmos are released from dragging */
  47155. onDragEndObservable: Observable<unknown>;
  47156. private _meshAttached;
  47157. attachedMesh: Nullable<AbstractMesh>;
  47158. /**
  47159. * Creates a RotationGizmo
  47160. * @param gizmoLayer The utility layer the gizmo will be added to
  47161. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47162. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47163. */
  47164. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47165. updateGizmoRotationToMatchAttachedMesh: boolean;
  47166. /**
  47167. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47168. */
  47169. snapDistance: number;
  47170. /**
  47171. * Ratio for the scale of the gizmo (Default: 1)
  47172. */
  47173. scaleRatio: number;
  47174. /**
  47175. * Disposes of the gizmo
  47176. */
  47177. dispose(): void;
  47178. /**
  47179. * CustomMeshes are not supported by this gizmo
  47180. * @param mesh The mesh to replace the default mesh of the gizmo
  47181. */
  47182. setCustomMesh(mesh: Mesh): void;
  47183. }
  47184. }
  47185. declare module "babylonjs/Gizmos/gizmoManager" {
  47186. import { Observable } from "babylonjs/Misc/observable";
  47187. import { Nullable } from "babylonjs/types";
  47188. import { Scene, IDisposable } from "babylonjs/scene";
  47189. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47190. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47191. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47192. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47193. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47194. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47195. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47196. /**
  47197. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47198. */
  47199. export class GizmoManager implements IDisposable {
  47200. private scene;
  47201. /**
  47202. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47203. */
  47204. gizmos: {
  47205. positionGizmo: Nullable<PositionGizmo>;
  47206. rotationGizmo: Nullable<RotationGizmo>;
  47207. scaleGizmo: Nullable<ScaleGizmo>;
  47208. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47209. };
  47210. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47211. clearGizmoOnEmptyPointerEvent: boolean;
  47212. /** Fires an event when the manager is attached to a mesh */
  47213. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47214. private _gizmosEnabled;
  47215. private _pointerObserver;
  47216. private _attachedMesh;
  47217. private _boundingBoxColor;
  47218. private _defaultUtilityLayer;
  47219. private _defaultKeepDepthUtilityLayer;
  47220. /**
  47221. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47222. */
  47223. boundingBoxDragBehavior: SixDofDragBehavior;
  47224. /**
  47225. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47226. */
  47227. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47228. /**
  47229. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47230. */
  47231. usePointerToAttachGizmos: boolean;
  47232. /**
  47233. * Utility layer that the bounding box gizmo belongs to
  47234. */
  47235. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47236. /**
  47237. * Utility layer that all gizmos besides bounding box belong to
  47238. */
  47239. readonly utilityLayer: UtilityLayerRenderer;
  47240. /**
  47241. * Instatiates a gizmo manager
  47242. * @param scene the scene to overlay the gizmos on top of
  47243. */
  47244. constructor(scene: Scene);
  47245. /**
  47246. * Attaches a set of gizmos to the specified mesh
  47247. * @param mesh The mesh the gizmo's should be attached to
  47248. */
  47249. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47250. /**
  47251. * If the position gizmo is enabled
  47252. */
  47253. positionGizmoEnabled: boolean;
  47254. /**
  47255. * If the rotation gizmo is enabled
  47256. */
  47257. rotationGizmoEnabled: boolean;
  47258. /**
  47259. * If the scale gizmo is enabled
  47260. */
  47261. scaleGizmoEnabled: boolean;
  47262. /**
  47263. * If the boundingBox gizmo is enabled
  47264. */
  47265. boundingBoxGizmoEnabled: boolean;
  47266. /**
  47267. * Disposes of the gizmo manager
  47268. */
  47269. dispose(): void;
  47270. }
  47271. }
  47272. declare module "babylonjs/Lights/directionalLight" {
  47273. import { Camera } from "babylonjs/Cameras/camera";
  47274. import { Scene } from "babylonjs/scene";
  47275. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47277. import { Light } from "babylonjs/Lights/light";
  47278. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47279. import { Effect } from "babylonjs/Materials/effect";
  47280. /**
  47281. * A directional light is defined by a direction (what a surprise!).
  47282. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47283. * 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.
  47284. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47285. */
  47286. export class DirectionalLight extends ShadowLight {
  47287. private _shadowFrustumSize;
  47288. /**
  47289. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47290. */
  47291. /**
  47292. * Specifies a fix frustum size for the shadow generation.
  47293. */
  47294. shadowFrustumSize: number;
  47295. private _shadowOrthoScale;
  47296. /**
  47297. * Gets the shadow projection scale against the optimal computed one.
  47298. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47299. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47300. */
  47301. /**
  47302. * Sets the shadow projection scale against the optimal computed one.
  47303. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47304. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47305. */
  47306. shadowOrthoScale: number;
  47307. /**
  47308. * Automatically compute the projection matrix to best fit (including all the casters)
  47309. * on each frame.
  47310. */
  47311. autoUpdateExtends: boolean;
  47312. private _orthoLeft;
  47313. private _orthoRight;
  47314. private _orthoTop;
  47315. private _orthoBottom;
  47316. /**
  47317. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47318. * The directional light is emitted from everywhere in the given direction.
  47319. * It can cast shadows.
  47320. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47321. * @param name The friendly name of the light
  47322. * @param direction The direction of the light
  47323. * @param scene The scene the light belongs to
  47324. */
  47325. constructor(name: string, direction: Vector3, scene: Scene);
  47326. /**
  47327. * Returns the string "DirectionalLight".
  47328. * @return The class name
  47329. */
  47330. getClassName(): string;
  47331. /**
  47332. * Returns the integer 1.
  47333. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47334. */
  47335. getTypeID(): number;
  47336. /**
  47337. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47338. * Returns the DirectionalLight Shadow projection matrix.
  47339. */
  47340. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47341. /**
  47342. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47343. * Returns the DirectionalLight Shadow projection matrix.
  47344. */
  47345. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47346. /**
  47347. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47348. * Returns the DirectionalLight Shadow projection matrix.
  47349. */
  47350. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47351. protected _buildUniformLayout(): void;
  47352. /**
  47353. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47354. * @param effect The effect to update
  47355. * @param lightIndex The index of the light in the effect to update
  47356. * @returns The directional light
  47357. */
  47358. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47359. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47360. /**
  47361. * Gets the minZ used for shadow according to both the scene and the light.
  47362. *
  47363. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47364. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47365. * @param activeCamera The camera we are returning the min for
  47366. * @returns the depth min z
  47367. */
  47368. getDepthMinZ(activeCamera: Camera): number;
  47369. /**
  47370. * Gets the maxZ used for shadow according to both the scene and the light.
  47371. *
  47372. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47373. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47374. * @param activeCamera The camera we are returning the max for
  47375. * @returns the depth max z
  47376. */
  47377. getDepthMaxZ(activeCamera: Camera): number;
  47378. /**
  47379. * Prepares the list of defines specific to the light type.
  47380. * @param defines the list of defines
  47381. * @param lightIndex defines the index of the light for the effect
  47382. */
  47383. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47384. }
  47385. }
  47386. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47387. import { Mesh } from "babylonjs/Meshes/mesh";
  47388. /**
  47389. * Class containing static functions to help procedurally build meshes
  47390. */
  47391. export class HemisphereBuilder {
  47392. /**
  47393. * Creates a hemisphere mesh
  47394. * @param name defines the name of the mesh
  47395. * @param options defines the options used to create the mesh
  47396. * @param scene defines the hosting scene
  47397. * @returns the hemisphere mesh
  47398. */
  47399. static CreateHemisphere(name: string, options: {
  47400. segments?: number;
  47401. diameter?: number;
  47402. sideOrientation?: number;
  47403. }, scene: any): Mesh;
  47404. }
  47405. }
  47406. declare module "babylonjs/Lights/spotLight" {
  47407. import { Nullable } from "babylonjs/types";
  47408. import { Scene } from "babylonjs/scene";
  47409. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47411. import { Effect } from "babylonjs/Materials/effect";
  47412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47413. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47414. /**
  47415. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47416. * These values define a cone of light starting from the position, emitting toward the direction.
  47417. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47418. * and the exponent defines the speed of the decay of the light with distance (reach).
  47419. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47420. */
  47421. export class SpotLight extends ShadowLight {
  47422. private _angle;
  47423. private _innerAngle;
  47424. private _cosHalfAngle;
  47425. private _lightAngleScale;
  47426. private _lightAngleOffset;
  47427. /**
  47428. * Gets the cone angle of the spot light in Radians.
  47429. */
  47430. /**
  47431. * Sets the cone angle of the spot light in Radians.
  47432. */
  47433. angle: number;
  47434. /**
  47435. * Only used in gltf falloff mode, this defines the angle where
  47436. * the directional falloff will start before cutting at angle which could be seen
  47437. * as outer angle.
  47438. */
  47439. /**
  47440. * Only used in gltf falloff mode, this defines the angle where
  47441. * the directional falloff will start before cutting at angle which could be seen
  47442. * as outer angle.
  47443. */
  47444. innerAngle: number;
  47445. private _shadowAngleScale;
  47446. /**
  47447. * Allows scaling the angle of the light for shadow generation only.
  47448. */
  47449. /**
  47450. * Allows scaling the angle of the light for shadow generation only.
  47451. */
  47452. shadowAngleScale: number;
  47453. /**
  47454. * The light decay speed with the distance from the emission spot.
  47455. */
  47456. exponent: number;
  47457. private _projectionTextureMatrix;
  47458. /**
  47459. * Allows reading the projecton texture
  47460. */
  47461. readonly projectionTextureMatrix: Matrix;
  47462. protected _projectionTextureLightNear: number;
  47463. /**
  47464. * Gets the near clip of the Spotlight for texture projection.
  47465. */
  47466. /**
  47467. * Sets the near clip of the Spotlight for texture projection.
  47468. */
  47469. projectionTextureLightNear: number;
  47470. protected _projectionTextureLightFar: number;
  47471. /**
  47472. * Gets the far clip of the Spotlight for texture projection.
  47473. */
  47474. /**
  47475. * Sets the far clip of the Spotlight for texture projection.
  47476. */
  47477. projectionTextureLightFar: number;
  47478. protected _projectionTextureUpDirection: Vector3;
  47479. /**
  47480. * Gets the Up vector of the Spotlight for texture projection.
  47481. */
  47482. /**
  47483. * Sets the Up vector of the Spotlight for texture projection.
  47484. */
  47485. projectionTextureUpDirection: Vector3;
  47486. private _projectionTexture;
  47487. /**
  47488. * Gets the projection texture of the light.
  47489. */
  47490. /**
  47491. * Sets the projection texture of the light.
  47492. */
  47493. projectionTexture: Nullable<BaseTexture>;
  47494. private _projectionTextureViewLightDirty;
  47495. private _projectionTextureProjectionLightDirty;
  47496. private _projectionTextureDirty;
  47497. private _projectionTextureViewTargetVector;
  47498. private _projectionTextureViewLightMatrix;
  47499. private _projectionTextureProjectionLightMatrix;
  47500. private _projectionTextureScalingMatrix;
  47501. /**
  47502. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47503. * It can cast shadows.
  47504. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47505. * @param name The light friendly name
  47506. * @param position The position of the spot light in the scene
  47507. * @param direction The direction of the light in the scene
  47508. * @param angle The cone angle of the light in Radians
  47509. * @param exponent The light decay speed with the distance from the emission spot
  47510. * @param scene The scene the lights belongs to
  47511. */
  47512. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47513. /**
  47514. * Returns the string "SpotLight".
  47515. * @returns the class name
  47516. */
  47517. getClassName(): string;
  47518. /**
  47519. * Returns the integer 2.
  47520. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47521. */
  47522. getTypeID(): number;
  47523. /**
  47524. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47525. */
  47526. protected _setDirection(value: Vector3): void;
  47527. /**
  47528. * Overrides the position setter to recompute the projection texture view light Matrix.
  47529. */
  47530. protected _setPosition(value: Vector3): void;
  47531. /**
  47532. * 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.
  47533. * Returns the SpotLight.
  47534. */
  47535. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47536. protected _computeProjectionTextureViewLightMatrix(): void;
  47537. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47538. /**
  47539. * Main function for light texture projection matrix computing.
  47540. */
  47541. protected _computeProjectionTextureMatrix(): void;
  47542. protected _buildUniformLayout(): void;
  47543. private _computeAngleValues;
  47544. /**
  47545. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47546. * @param effect The effect to update
  47547. * @param lightIndex The index of the light in the effect to update
  47548. * @returns The spot light
  47549. */
  47550. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47551. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47552. /**
  47553. * Disposes the light and the associated resources.
  47554. */
  47555. dispose(): void;
  47556. /**
  47557. * Prepares the list of defines specific to the light type.
  47558. * @param defines the list of defines
  47559. * @param lightIndex defines the index of the light for the effect
  47560. */
  47561. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47562. }
  47563. }
  47564. declare module "babylonjs/Gizmos/lightGizmo" {
  47565. import { Nullable } from "babylonjs/types";
  47566. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47567. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47568. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47569. import { Light } from "babylonjs/Lights/light";
  47570. /**
  47571. * Gizmo that enables viewing a light
  47572. */
  47573. export class LightGizmo extends Gizmo {
  47574. private _lightMesh;
  47575. private _material;
  47576. private cachedPosition;
  47577. private cachedForward;
  47578. /**
  47579. * Creates a LightGizmo
  47580. * @param gizmoLayer The utility layer the gizmo will be added to
  47581. */
  47582. constructor(gizmoLayer?: UtilityLayerRenderer);
  47583. private _light;
  47584. /**
  47585. * The light that the gizmo is attached to
  47586. */
  47587. light: Nullable<Light>;
  47588. /**
  47589. * Gets the material used to render the light gizmo
  47590. */
  47591. readonly material: StandardMaterial;
  47592. /**
  47593. * @hidden
  47594. * Updates the gizmo to match the attached mesh's position/rotation
  47595. */
  47596. protected _update(): void;
  47597. private static _Scale;
  47598. /**
  47599. * Creates the lines for a light mesh
  47600. */
  47601. private static _createLightLines;
  47602. /**
  47603. * Disposes of the light gizmo
  47604. */
  47605. dispose(): void;
  47606. private static _CreateHemisphericLightMesh;
  47607. private static _CreatePointLightMesh;
  47608. private static _CreateSpotLightMesh;
  47609. private static _CreateDirectionalLightMesh;
  47610. }
  47611. }
  47612. declare module "babylonjs/Gizmos/index" {
  47613. export * from "babylonjs/Gizmos/axisDragGizmo";
  47614. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47615. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47616. export * from "babylonjs/Gizmos/gizmo";
  47617. export * from "babylonjs/Gizmos/gizmoManager";
  47618. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47619. export * from "babylonjs/Gizmos/positionGizmo";
  47620. export * from "babylonjs/Gizmos/rotationGizmo";
  47621. export * from "babylonjs/Gizmos/scaleGizmo";
  47622. export * from "babylonjs/Gizmos/lightGizmo";
  47623. export * from "babylonjs/Gizmos/planeDragGizmo";
  47624. }
  47625. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47626. /** @hidden */
  47627. export var backgroundFragmentDeclaration: {
  47628. name: string;
  47629. shader: string;
  47630. };
  47631. }
  47632. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47633. /** @hidden */
  47634. export var backgroundUboDeclaration: {
  47635. name: string;
  47636. shader: string;
  47637. };
  47638. }
  47639. declare module "babylonjs/Shaders/background.fragment" {
  47640. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47641. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47642. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47643. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47644. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47645. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47646. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47647. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47648. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47649. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47650. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47651. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47652. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47653. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47654. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47655. /** @hidden */
  47656. export var backgroundPixelShader: {
  47657. name: string;
  47658. shader: string;
  47659. };
  47660. }
  47661. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47662. /** @hidden */
  47663. export var backgroundVertexDeclaration: {
  47664. name: string;
  47665. shader: string;
  47666. };
  47667. }
  47668. declare module "babylonjs/Shaders/background.vertex" {
  47669. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47670. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47672. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47673. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47674. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47675. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47676. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47677. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47678. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47679. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47680. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47681. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47682. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47683. /** @hidden */
  47684. export var backgroundVertexShader: {
  47685. name: string;
  47686. shader: string;
  47687. };
  47688. }
  47689. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47690. import { Nullable, int, float } from "babylonjs/types";
  47691. import { Scene } from "babylonjs/scene";
  47692. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47693. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47695. import { Mesh } from "babylonjs/Meshes/mesh";
  47696. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47697. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47698. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47699. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47700. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47701. import { Color3 } from "babylonjs/Maths/math.color";
  47702. import "babylonjs/Shaders/background.fragment";
  47703. import "babylonjs/Shaders/background.vertex";
  47704. /**
  47705. * Background material used to create an efficient environement around your scene.
  47706. */
  47707. export class BackgroundMaterial extends PushMaterial {
  47708. /**
  47709. * Standard reflectance value at parallel view angle.
  47710. */
  47711. static StandardReflectance0: number;
  47712. /**
  47713. * Standard reflectance value at grazing angle.
  47714. */
  47715. static StandardReflectance90: number;
  47716. protected _primaryColor: Color3;
  47717. /**
  47718. * Key light Color (multiply against the environement texture)
  47719. */
  47720. primaryColor: Color3;
  47721. protected __perceptualColor: Nullable<Color3>;
  47722. /**
  47723. * Experimental Internal Use Only.
  47724. *
  47725. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47726. * This acts as a helper to set the primary color to a more "human friendly" value.
  47727. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47728. * output color as close as possible from the chosen value.
  47729. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47730. * part of lighting setup.)
  47731. */
  47732. _perceptualColor: Nullable<Color3>;
  47733. protected _primaryColorShadowLevel: float;
  47734. /**
  47735. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47736. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47737. */
  47738. primaryColorShadowLevel: float;
  47739. protected _primaryColorHighlightLevel: float;
  47740. /**
  47741. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47742. * The primary color is used at the level chosen to define what the white area would look.
  47743. */
  47744. primaryColorHighlightLevel: float;
  47745. protected _reflectionTexture: Nullable<BaseTexture>;
  47746. /**
  47747. * Reflection Texture used in the material.
  47748. * Should be author in a specific way for the best result (refer to the documentation).
  47749. */
  47750. reflectionTexture: Nullable<BaseTexture>;
  47751. protected _reflectionBlur: float;
  47752. /**
  47753. * Reflection Texture level of blur.
  47754. *
  47755. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47756. * texture twice.
  47757. */
  47758. reflectionBlur: float;
  47759. protected _diffuseTexture: Nullable<BaseTexture>;
  47760. /**
  47761. * Diffuse Texture used in the material.
  47762. * Should be author in a specific way for the best result (refer to the documentation).
  47763. */
  47764. diffuseTexture: Nullable<BaseTexture>;
  47765. protected _shadowLights: Nullable<IShadowLight[]>;
  47766. /**
  47767. * Specify the list of lights casting shadow on the material.
  47768. * All scene shadow lights will be included if null.
  47769. */
  47770. shadowLights: Nullable<IShadowLight[]>;
  47771. protected _shadowLevel: float;
  47772. /**
  47773. * Helps adjusting the shadow to a softer level if required.
  47774. * 0 means black shadows and 1 means no shadows.
  47775. */
  47776. shadowLevel: float;
  47777. protected _sceneCenter: Vector3;
  47778. /**
  47779. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47780. * It is usually zero but might be interesting to modify according to your setup.
  47781. */
  47782. sceneCenter: Vector3;
  47783. protected _opacityFresnel: boolean;
  47784. /**
  47785. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47786. * This helps ensuring a nice transition when the camera goes under the ground.
  47787. */
  47788. opacityFresnel: boolean;
  47789. protected _reflectionFresnel: boolean;
  47790. /**
  47791. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47792. * This helps adding a mirror texture on the ground.
  47793. */
  47794. reflectionFresnel: boolean;
  47795. protected _reflectionFalloffDistance: number;
  47796. /**
  47797. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47798. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47799. */
  47800. reflectionFalloffDistance: number;
  47801. protected _reflectionAmount: number;
  47802. /**
  47803. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47804. */
  47805. reflectionAmount: number;
  47806. protected _reflectionReflectance0: number;
  47807. /**
  47808. * This specifies the weight of the reflection at grazing angle.
  47809. */
  47810. reflectionReflectance0: number;
  47811. protected _reflectionReflectance90: number;
  47812. /**
  47813. * This specifies the weight of the reflection at a perpendicular point of view.
  47814. */
  47815. reflectionReflectance90: number;
  47816. /**
  47817. * Sets the reflection reflectance fresnel values according to the default standard
  47818. * empirically know to work well :-)
  47819. */
  47820. reflectionStandardFresnelWeight: number;
  47821. protected _useRGBColor: boolean;
  47822. /**
  47823. * Helps to directly use the maps channels instead of their level.
  47824. */
  47825. useRGBColor: boolean;
  47826. protected _enableNoise: boolean;
  47827. /**
  47828. * This helps reducing the banding effect that could occur on the background.
  47829. */
  47830. enableNoise: boolean;
  47831. /**
  47832. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47833. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47834. * Recommended to be keep at 1.0 except for special cases.
  47835. */
  47836. fovMultiplier: number;
  47837. private _fovMultiplier;
  47838. /**
  47839. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47840. */
  47841. useEquirectangularFOV: boolean;
  47842. private _maxSimultaneousLights;
  47843. /**
  47844. * Number of Simultaneous lights allowed on the material.
  47845. */
  47846. maxSimultaneousLights: int;
  47847. /**
  47848. * Default configuration related to image processing available in the Background Material.
  47849. */
  47850. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47851. /**
  47852. * Keep track of the image processing observer to allow dispose and replace.
  47853. */
  47854. private _imageProcessingObserver;
  47855. /**
  47856. * Attaches a new image processing configuration to the PBR Material.
  47857. * @param configuration (if null the scene configuration will be use)
  47858. */
  47859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47860. /**
  47861. * Gets the image processing configuration used either in this material.
  47862. */
  47863. /**
  47864. * Sets the Default image processing configuration used either in the this material.
  47865. *
  47866. * If sets to null, the scene one is in use.
  47867. */
  47868. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47869. /**
  47870. * Gets wether the color curves effect is enabled.
  47871. */
  47872. /**
  47873. * Sets wether the color curves effect is enabled.
  47874. */
  47875. cameraColorCurvesEnabled: boolean;
  47876. /**
  47877. * Gets wether the color grading effect is enabled.
  47878. */
  47879. /**
  47880. * Gets wether the color grading effect is enabled.
  47881. */
  47882. cameraColorGradingEnabled: boolean;
  47883. /**
  47884. * Gets wether tonemapping is enabled or not.
  47885. */
  47886. /**
  47887. * Sets wether tonemapping is enabled or not
  47888. */
  47889. cameraToneMappingEnabled: boolean;
  47890. /**
  47891. * The camera exposure used on this material.
  47892. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47893. * This corresponds to a photographic exposure.
  47894. */
  47895. /**
  47896. * The camera exposure used on this material.
  47897. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47898. * This corresponds to a photographic exposure.
  47899. */
  47900. cameraExposure: float;
  47901. /**
  47902. * Gets The camera contrast used on this material.
  47903. */
  47904. /**
  47905. * Sets The camera contrast used on this material.
  47906. */
  47907. cameraContrast: float;
  47908. /**
  47909. * Gets the Color Grading 2D Lookup Texture.
  47910. */
  47911. /**
  47912. * Sets the Color Grading 2D Lookup Texture.
  47913. */
  47914. cameraColorGradingTexture: Nullable<BaseTexture>;
  47915. /**
  47916. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47917. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47918. * 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;
  47919. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47920. */
  47921. /**
  47922. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47923. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47924. * 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;
  47925. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47926. */
  47927. cameraColorCurves: Nullable<ColorCurves>;
  47928. /**
  47929. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47930. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47931. */
  47932. switchToBGR: boolean;
  47933. private _renderTargets;
  47934. private _reflectionControls;
  47935. private _white;
  47936. private _primaryShadowColor;
  47937. private _primaryHighlightColor;
  47938. /**
  47939. * Instantiates a Background Material in the given scene
  47940. * @param name The friendly name of the material
  47941. * @param scene The scene to add the material to
  47942. */
  47943. constructor(name: string, scene: Scene);
  47944. /**
  47945. * Gets a boolean indicating that current material needs to register RTT
  47946. */
  47947. readonly hasRenderTargetTextures: boolean;
  47948. /**
  47949. * The entire material has been created in order to prevent overdraw.
  47950. * @returns false
  47951. */
  47952. needAlphaTesting(): boolean;
  47953. /**
  47954. * The entire material has been created in order to prevent overdraw.
  47955. * @returns true if blending is enable
  47956. */
  47957. needAlphaBlending(): boolean;
  47958. /**
  47959. * Checks wether the material is ready to be rendered for a given mesh.
  47960. * @param mesh The mesh to render
  47961. * @param subMesh The submesh to check against
  47962. * @param useInstances Specify wether or not the material is used with instances
  47963. * @returns true if all the dependencies are ready (Textures, Effects...)
  47964. */
  47965. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47966. /**
  47967. * Compute the primary color according to the chosen perceptual color.
  47968. */
  47969. private _computePrimaryColorFromPerceptualColor;
  47970. /**
  47971. * Compute the highlights and shadow colors according to their chosen levels.
  47972. */
  47973. private _computePrimaryColors;
  47974. /**
  47975. * Build the uniform buffer used in the material.
  47976. */
  47977. buildUniformLayout(): void;
  47978. /**
  47979. * Unbind the material.
  47980. */
  47981. unbind(): void;
  47982. /**
  47983. * Bind only the world matrix to the material.
  47984. * @param world The world matrix to bind.
  47985. */
  47986. bindOnlyWorldMatrix(world: Matrix): void;
  47987. /**
  47988. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47989. * @param world The world matrix to bind.
  47990. * @param subMesh The submesh to bind for.
  47991. */
  47992. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47993. /**
  47994. * Checks to see if a texture is used in the material.
  47995. * @param texture - Base texture to use.
  47996. * @returns - Boolean specifying if a texture is used in the material.
  47997. */
  47998. hasTexture(texture: BaseTexture): boolean;
  47999. /**
  48000. * Dispose the material.
  48001. * @param forceDisposeEffect Force disposal of the associated effect.
  48002. * @param forceDisposeTextures Force disposal of the associated textures.
  48003. */
  48004. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48005. /**
  48006. * Clones the material.
  48007. * @param name The cloned name.
  48008. * @returns The cloned material.
  48009. */
  48010. clone(name: string): BackgroundMaterial;
  48011. /**
  48012. * Serializes the current material to its JSON representation.
  48013. * @returns The JSON representation.
  48014. */
  48015. serialize(): any;
  48016. /**
  48017. * Gets the class name of the material
  48018. * @returns "BackgroundMaterial"
  48019. */
  48020. getClassName(): string;
  48021. /**
  48022. * Parse a JSON input to create back a background material.
  48023. * @param source The JSON data to parse
  48024. * @param scene The scene to create the parsed material in
  48025. * @param rootUrl The root url of the assets the material depends upon
  48026. * @returns the instantiated BackgroundMaterial.
  48027. */
  48028. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48029. }
  48030. }
  48031. declare module "babylonjs/Helpers/environmentHelper" {
  48032. import { Observable } from "babylonjs/Misc/observable";
  48033. import { Nullable } from "babylonjs/types";
  48034. import { Scene } from "babylonjs/scene";
  48035. import { Vector3 } from "babylonjs/Maths/math.vector";
  48036. import { Color3 } from "babylonjs/Maths/math.color";
  48037. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48038. import { Mesh } from "babylonjs/Meshes/mesh";
  48039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48040. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48041. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48042. import "babylonjs/Meshes/Builders/planeBuilder";
  48043. import "babylonjs/Meshes/Builders/boxBuilder";
  48044. /**
  48045. * Represents the different options available during the creation of
  48046. * a Environment helper.
  48047. *
  48048. * This can control the default ground, skybox and image processing setup of your scene.
  48049. */
  48050. export interface IEnvironmentHelperOptions {
  48051. /**
  48052. * Specifies wether or not to create a ground.
  48053. * True by default.
  48054. */
  48055. createGround: boolean;
  48056. /**
  48057. * Specifies the ground size.
  48058. * 15 by default.
  48059. */
  48060. groundSize: number;
  48061. /**
  48062. * The texture used on the ground for the main color.
  48063. * Comes from the BabylonJS CDN by default.
  48064. *
  48065. * Remarks: Can be either a texture or a url.
  48066. */
  48067. groundTexture: string | BaseTexture;
  48068. /**
  48069. * The color mixed in the ground texture by default.
  48070. * BabylonJS clearColor by default.
  48071. */
  48072. groundColor: Color3;
  48073. /**
  48074. * Specifies the ground opacity.
  48075. * 1 by default.
  48076. */
  48077. groundOpacity: number;
  48078. /**
  48079. * Enables the ground to receive shadows.
  48080. * True by default.
  48081. */
  48082. enableGroundShadow: boolean;
  48083. /**
  48084. * Helps preventing the shadow to be fully black on the ground.
  48085. * 0.5 by default.
  48086. */
  48087. groundShadowLevel: number;
  48088. /**
  48089. * Creates a mirror texture attach to the ground.
  48090. * false by default.
  48091. */
  48092. enableGroundMirror: boolean;
  48093. /**
  48094. * Specifies the ground mirror size ratio.
  48095. * 0.3 by default as the default kernel is 64.
  48096. */
  48097. groundMirrorSizeRatio: number;
  48098. /**
  48099. * Specifies the ground mirror blur kernel size.
  48100. * 64 by default.
  48101. */
  48102. groundMirrorBlurKernel: number;
  48103. /**
  48104. * Specifies the ground mirror visibility amount.
  48105. * 1 by default
  48106. */
  48107. groundMirrorAmount: number;
  48108. /**
  48109. * Specifies the ground mirror reflectance weight.
  48110. * This uses the standard weight of the background material to setup the fresnel effect
  48111. * of the mirror.
  48112. * 1 by default.
  48113. */
  48114. groundMirrorFresnelWeight: number;
  48115. /**
  48116. * Specifies the ground mirror Falloff distance.
  48117. * This can helps reducing the size of the reflection.
  48118. * 0 by Default.
  48119. */
  48120. groundMirrorFallOffDistance: number;
  48121. /**
  48122. * Specifies the ground mirror texture type.
  48123. * Unsigned Int by Default.
  48124. */
  48125. groundMirrorTextureType: number;
  48126. /**
  48127. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48128. * the shown objects.
  48129. */
  48130. groundYBias: number;
  48131. /**
  48132. * Specifies wether or not to create a skybox.
  48133. * True by default.
  48134. */
  48135. createSkybox: boolean;
  48136. /**
  48137. * Specifies the skybox size.
  48138. * 20 by default.
  48139. */
  48140. skyboxSize: number;
  48141. /**
  48142. * The texture used on the skybox for the main color.
  48143. * Comes from the BabylonJS CDN by default.
  48144. *
  48145. * Remarks: Can be either a texture or a url.
  48146. */
  48147. skyboxTexture: string | BaseTexture;
  48148. /**
  48149. * The color mixed in the skybox texture by default.
  48150. * BabylonJS clearColor by default.
  48151. */
  48152. skyboxColor: Color3;
  48153. /**
  48154. * The background rotation around the Y axis of the scene.
  48155. * This helps aligning the key lights of your scene with the background.
  48156. * 0 by default.
  48157. */
  48158. backgroundYRotation: number;
  48159. /**
  48160. * Compute automatically the size of the elements to best fit with the scene.
  48161. */
  48162. sizeAuto: boolean;
  48163. /**
  48164. * Default position of the rootMesh if autoSize is not true.
  48165. */
  48166. rootPosition: Vector3;
  48167. /**
  48168. * Sets up the image processing in the scene.
  48169. * true by default.
  48170. */
  48171. setupImageProcessing: boolean;
  48172. /**
  48173. * The texture used as your environment texture in the scene.
  48174. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48175. *
  48176. * Remarks: Can be either a texture or a url.
  48177. */
  48178. environmentTexture: string | BaseTexture;
  48179. /**
  48180. * The value of the exposure to apply to the scene.
  48181. * 0.6 by default if setupImageProcessing is true.
  48182. */
  48183. cameraExposure: number;
  48184. /**
  48185. * The value of the contrast to apply to the scene.
  48186. * 1.6 by default if setupImageProcessing is true.
  48187. */
  48188. cameraContrast: number;
  48189. /**
  48190. * Specifies wether or not tonemapping should be enabled in the scene.
  48191. * true by default if setupImageProcessing is true.
  48192. */
  48193. toneMappingEnabled: boolean;
  48194. }
  48195. /**
  48196. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48197. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48198. * It also helps with the default setup of your imageProcessing configuration.
  48199. */
  48200. export class EnvironmentHelper {
  48201. /**
  48202. * Default ground texture URL.
  48203. */
  48204. private static _groundTextureCDNUrl;
  48205. /**
  48206. * Default skybox texture URL.
  48207. */
  48208. private static _skyboxTextureCDNUrl;
  48209. /**
  48210. * Default environment texture URL.
  48211. */
  48212. private static _environmentTextureCDNUrl;
  48213. /**
  48214. * Creates the default options for the helper.
  48215. */
  48216. private static _getDefaultOptions;
  48217. private _rootMesh;
  48218. /**
  48219. * Gets the root mesh created by the helper.
  48220. */
  48221. readonly rootMesh: Mesh;
  48222. private _skybox;
  48223. /**
  48224. * Gets the skybox created by the helper.
  48225. */
  48226. readonly skybox: Nullable<Mesh>;
  48227. private _skyboxTexture;
  48228. /**
  48229. * Gets the skybox texture created by the helper.
  48230. */
  48231. readonly skyboxTexture: Nullable<BaseTexture>;
  48232. private _skyboxMaterial;
  48233. /**
  48234. * Gets the skybox material created by the helper.
  48235. */
  48236. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48237. private _ground;
  48238. /**
  48239. * Gets the ground mesh created by the helper.
  48240. */
  48241. readonly ground: Nullable<Mesh>;
  48242. private _groundTexture;
  48243. /**
  48244. * Gets the ground texture created by the helper.
  48245. */
  48246. readonly groundTexture: Nullable<BaseTexture>;
  48247. private _groundMirror;
  48248. /**
  48249. * Gets the ground mirror created by the helper.
  48250. */
  48251. readonly groundMirror: Nullable<MirrorTexture>;
  48252. /**
  48253. * Gets the ground mirror render list to helps pushing the meshes
  48254. * you wish in the ground reflection.
  48255. */
  48256. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48257. private _groundMaterial;
  48258. /**
  48259. * Gets the ground material created by the helper.
  48260. */
  48261. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48262. /**
  48263. * Stores the creation options.
  48264. */
  48265. private readonly _scene;
  48266. private _options;
  48267. /**
  48268. * This observable will be notified with any error during the creation of the environment,
  48269. * mainly texture creation errors.
  48270. */
  48271. onErrorObservable: Observable<{
  48272. message?: string;
  48273. exception?: any;
  48274. }>;
  48275. /**
  48276. * constructor
  48277. * @param options Defines the options we want to customize the helper
  48278. * @param scene The scene to add the material to
  48279. */
  48280. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48281. /**
  48282. * Updates the background according to the new options
  48283. * @param options
  48284. */
  48285. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48286. /**
  48287. * Sets the primary color of all the available elements.
  48288. * @param color the main color to affect to the ground and the background
  48289. */
  48290. setMainColor(color: Color3): void;
  48291. /**
  48292. * Setup the image processing according to the specified options.
  48293. */
  48294. private _setupImageProcessing;
  48295. /**
  48296. * Setup the environment texture according to the specified options.
  48297. */
  48298. private _setupEnvironmentTexture;
  48299. /**
  48300. * Setup the background according to the specified options.
  48301. */
  48302. private _setupBackground;
  48303. /**
  48304. * Get the scene sizes according to the setup.
  48305. */
  48306. private _getSceneSize;
  48307. /**
  48308. * Setup the ground according to the specified options.
  48309. */
  48310. private _setupGround;
  48311. /**
  48312. * Setup the ground material according to the specified options.
  48313. */
  48314. private _setupGroundMaterial;
  48315. /**
  48316. * Setup the ground diffuse texture according to the specified options.
  48317. */
  48318. private _setupGroundDiffuseTexture;
  48319. /**
  48320. * Setup the ground mirror texture according to the specified options.
  48321. */
  48322. private _setupGroundMirrorTexture;
  48323. /**
  48324. * Setup the ground to receive the mirror texture.
  48325. */
  48326. private _setupMirrorInGroundMaterial;
  48327. /**
  48328. * Setup the skybox according to the specified options.
  48329. */
  48330. private _setupSkybox;
  48331. /**
  48332. * Setup the skybox material according to the specified options.
  48333. */
  48334. private _setupSkyboxMaterial;
  48335. /**
  48336. * Setup the skybox reflection texture according to the specified options.
  48337. */
  48338. private _setupSkyboxReflectionTexture;
  48339. private _errorHandler;
  48340. /**
  48341. * Dispose all the elements created by the Helper.
  48342. */
  48343. dispose(): void;
  48344. }
  48345. }
  48346. declare module "babylonjs/Helpers/photoDome" {
  48347. import { Observable } from "babylonjs/Misc/observable";
  48348. import { Nullable } from "babylonjs/types";
  48349. import { Scene } from "babylonjs/scene";
  48350. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48351. import { Mesh } from "babylonjs/Meshes/mesh";
  48352. import { Texture } from "babylonjs/Materials/Textures/texture";
  48353. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48354. import "babylonjs/Meshes/Builders/sphereBuilder";
  48355. /**
  48356. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48357. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48358. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48359. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48360. */
  48361. export class PhotoDome extends TransformNode {
  48362. /**
  48363. * Define the image as a Monoscopic panoramic 360 image.
  48364. */
  48365. static readonly MODE_MONOSCOPIC: number;
  48366. /**
  48367. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48368. */
  48369. static readonly MODE_TOPBOTTOM: number;
  48370. /**
  48371. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48372. */
  48373. static readonly MODE_SIDEBYSIDE: number;
  48374. private _useDirectMapping;
  48375. /**
  48376. * The texture being displayed on the sphere
  48377. */
  48378. protected _photoTexture: Texture;
  48379. /**
  48380. * Gets or sets the texture being displayed on the sphere
  48381. */
  48382. photoTexture: Texture;
  48383. /**
  48384. * Observable raised when an error occured while loading the 360 image
  48385. */
  48386. onLoadErrorObservable: Observable<string>;
  48387. /**
  48388. * The skybox material
  48389. */
  48390. protected _material: BackgroundMaterial;
  48391. /**
  48392. * The surface used for the skybox
  48393. */
  48394. protected _mesh: Mesh;
  48395. /**
  48396. * Gets the mesh used for the skybox.
  48397. */
  48398. readonly mesh: Mesh;
  48399. /**
  48400. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48401. * Also see the options.resolution property.
  48402. */
  48403. fovMultiplier: number;
  48404. private _imageMode;
  48405. /**
  48406. * Gets or set the current video mode for the video. It can be:
  48407. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48408. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48409. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48410. */
  48411. imageMode: number;
  48412. /**
  48413. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48414. * @param name Element's name, child elements will append suffixes for their own names.
  48415. * @param urlsOfPhoto defines the url of the photo to display
  48416. * @param options defines an object containing optional or exposed sub element properties
  48417. * @param onError defines a callback called when an error occured while loading the texture
  48418. */
  48419. constructor(name: string, urlOfPhoto: string, options: {
  48420. resolution?: number;
  48421. size?: number;
  48422. useDirectMapping?: boolean;
  48423. faceForward?: boolean;
  48424. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48425. private _onBeforeCameraRenderObserver;
  48426. private _changeImageMode;
  48427. /**
  48428. * Releases resources associated with this node.
  48429. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48430. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48431. */
  48432. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48433. }
  48434. }
  48435. declare module "babylonjs/Misc/rgbdTextureTools" {
  48436. import "babylonjs/Shaders/rgbdDecode.fragment";
  48437. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48438. import { Texture } from "babylonjs/Materials/Textures/texture";
  48439. /**
  48440. * Class used to host RGBD texture specific utilities
  48441. */
  48442. export class RGBDTextureTools {
  48443. /**
  48444. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48445. * @param texture the texture to expand.
  48446. */
  48447. static ExpandRGBDTexture(texture: Texture): void;
  48448. }
  48449. }
  48450. declare module "babylonjs/Misc/brdfTextureTools" {
  48451. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48452. import { Scene } from "babylonjs/scene";
  48453. /**
  48454. * Class used to host texture specific utilities
  48455. */
  48456. export class BRDFTextureTools {
  48457. /**
  48458. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48459. * @param scene defines the hosting scene
  48460. * @returns the environment BRDF texture
  48461. */
  48462. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48463. private static _environmentBRDFBase64Texture;
  48464. }
  48465. }
  48466. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48467. import { Nullable } from "babylonjs/types";
  48468. import { Color3 } from "babylonjs/Maths/math.color";
  48469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48470. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48472. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48473. import { Engine } from "babylonjs/Engines/engine";
  48474. import { Scene } from "babylonjs/scene";
  48475. /**
  48476. * @hidden
  48477. */
  48478. export interface IMaterialClearCoatDefines {
  48479. CLEARCOAT: boolean;
  48480. CLEARCOAT_DEFAULTIOR: boolean;
  48481. CLEARCOAT_TEXTURE: boolean;
  48482. CLEARCOAT_TEXTUREDIRECTUV: number;
  48483. CLEARCOAT_BUMP: boolean;
  48484. CLEARCOAT_BUMPDIRECTUV: number;
  48485. CLEARCOAT_TINT: boolean;
  48486. CLEARCOAT_TINT_TEXTURE: boolean;
  48487. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48488. /** @hidden */
  48489. _areTexturesDirty: boolean;
  48490. }
  48491. /**
  48492. * Define the code related to the clear coat parameters of the pbr material.
  48493. */
  48494. export class PBRClearCoatConfiguration {
  48495. /**
  48496. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48497. * The default fits with a polyurethane material.
  48498. */
  48499. private static readonly _DefaultIndexOfRefraction;
  48500. private _isEnabled;
  48501. /**
  48502. * Defines if the clear coat is enabled in the material.
  48503. */
  48504. isEnabled: boolean;
  48505. /**
  48506. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48507. */
  48508. intensity: number;
  48509. /**
  48510. * Defines the clear coat layer roughness.
  48511. */
  48512. roughness: number;
  48513. private _indexOfRefraction;
  48514. /**
  48515. * Defines the index of refraction of the clear coat.
  48516. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48517. * The default fits with a polyurethane material.
  48518. * Changing the default value is more performance intensive.
  48519. */
  48520. indexOfRefraction: number;
  48521. private _texture;
  48522. /**
  48523. * Stores the clear coat values in a texture.
  48524. */
  48525. texture: Nullable<BaseTexture>;
  48526. private _bumpTexture;
  48527. /**
  48528. * Define the clear coat specific bump texture.
  48529. */
  48530. bumpTexture: Nullable<BaseTexture>;
  48531. private _isTintEnabled;
  48532. /**
  48533. * Defines if the clear coat tint is enabled in the material.
  48534. */
  48535. isTintEnabled: boolean;
  48536. /**
  48537. * Defines the clear coat tint of the material.
  48538. * This is only use if tint is enabled
  48539. */
  48540. tintColor: Color3;
  48541. /**
  48542. * Defines the distance at which the tint color should be found in the
  48543. * clear coat media.
  48544. * This is only use if tint is enabled
  48545. */
  48546. tintColorAtDistance: number;
  48547. /**
  48548. * Defines the clear coat layer thickness.
  48549. * This is only use if tint is enabled
  48550. */
  48551. tintThickness: number;
  48552. private _tintTexture;
  48553. /**
  48554. * Stores the clear tint values in a texture.
  48555. * rgb is tint
  48556. * a is a thickness factor
  48557. */
  48558. tintTexture: Nullable<BaseTexture>;
  48559. /** @hidden */
  48560. private _internalMarkAllSubMeshesAsTexturesDirty;
  48561. /** @hidden */
  48562. _markAllSubMeshesAsTexturesDirty(): void;
  48563. /**
  48564. * Instantiate a new istance of clear coat configuration.
  48565. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48566. */
  48567. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48568. /**
  48569. * Gets wehter the submesh is ready to be used or not.
  48570. * @param defines the list of "defines" to update.
  48571. * @param scene defines the scene the material belongs to.
  48572. * @param engine defines the engine the material belongs to.
  48573. * @param disableBumpMap defines wether the material disables bump or not.
  48574. * @returns - boolean indicating that the submesh is ready or not.
  48575. */
  48576. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48577. /**
  48578. * Checks to see if a texture is used in the material.
  48579. * @param defines the list of "defines" to update.
  48580. * @param scene defines the scene to the material belongs to.
  48581. */
  48582. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48583. /**
  48584. * Binds the material data.
  48585. * @param uniformBuffer defines the Uniform buffer to fill in.
  48586. * @param scene defines the scene the material belongs to.
  48587. * @param engine defines the engine the material belongs to.
  48588. * @param disableBumpMap defines wether the material disables bump or not.
  48589. * @param isFrozen defines wether the material is frozen or not.
  48590. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48591. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48592. */
  48593. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48594. /**
  48595. * Checks to see if a texture is used in the material.
  48596. * @param texture - Base texture to use.
  48597. * @returns - Boolean specifying if a texture is used in the material.
  48598. */
  48599. hasTexture(texture: BaseTexture): boolean;
  48600. /**
  48601. * Returns an array of the actively used textures.
  48602. * @param activeTextures Array of BaseTextures
  48603. */
  48604. getActiveTextures(activeTextures: BaseTexture[]): void;
  48605. /**
  48606. * Returns the animatable textures.
  48607. * @param animatables Array of animatable textures.
  48608. */
  48609. getAnimatables(animatables: IAnimatable[]): void;
  48610. /**
  48611. * Disposes the resources of the material.
  48612. * @param forceDisposeTextures - Forces the disposal of all textures.
  48613. */
  48614. dispose(forceDisposeTextures?: boolean): void;
  48615. /**
  48616. * Get the current class name of the texture useful for serialization or dynamic coding.
  48617. * @returns "PBRClearCoatConfiguration"
  48618. */
  48619. getClassName(): string;
  48620. /**
  48621. * Add fallbacks to the effect fallbacks list.
  48622. * @param defines defines the Base texture to use.
  48623. * @param fallbacks defines the current fallback list.
  48624. * @param currentRank defines the current fallback rank.
  48625. * @returns the new fallback rank.
  48626. */
  48627. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48628. /**
  48629. * Add the required uniforms to the current list.
  48630. * @param uniforms defines the current uniform list.
  48631. */
  48632. static AddUniforms(uniforms: string[]): void;
  48633. /**
  48634. * Add the required samplers to the current list.
  48635. * @param samplers defines the current sampler list.
  48636. */
  48637. static AddSamplers(samplers: string[]): void;
  48638. /**
  48639. * Add the required uniforms to the current buffer.
  48640. * @param uniformBuffer defines the current uniform buffer.
  48641. */
  48642. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48643. /**
  48644. * Makes a duplicate of the current configuration into another one.
  48645. * @param clearCoatConfiguration define the config where to copy the info
  48646. */
  48647. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48648. /**
  48649. * Serializes this clear coat configuration.
  48650. * @returns - An object with the serialized config.
  48651. */
  48652. serialize(): any;
  48653. /**
  48654. * Parses a anisotropy Configuration from a serialized object.
  48655. * @param source - Serialized object.
  48656. * @param scene Defines the scene we are parsing for
  48657. * @param rootUrl Defines the rootUrl to load from
  48658. */
  48659. parse(source: any, scene: Scene, rootUrl: string): void;
  48660. }
  48661. }
  48662. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48663. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48665. import { Vector2 } from "babylonjs/Maths/math.vector";
  48666. import { Scene } from "babylonjs/scene";
  48667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48668. import { Nullable } from "babylonjs/types";
  48669. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48670. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48671. /**
  48672. * @hidden
  48673. */
  48674. export interface IMaterialAnisotropicDefines {
  48675. ANISOTROPIC: boolean;
  48676. ANISOTROPIC_TEXTURE: boolean;
  48677. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48678. MAINUV1: boolean;
  48679. _areTexturesDirty: boolean;
  48680. _needUVs: boolean;
  48681. }
  48682. /**
  48683. * Define the code related to the anisotropic parameters of the pbr material.
  48684. */
  48685. export class PBRAnisotropicConfiguration {
  48686. private _isEnabled;
  48687. /**
  48688. * Defines if the anisotropy is enabled in the material.
  48689. */
  48690. isEnabled: boolean;
  48691. /**
  48692. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48693. */
  48694. intensity: number;
  48695. /**
  48696. * Defines if the effect is along the tangents, bitangents or in between.
  48697. * By default, the effect is "strectching" the highlights along the tangents.
  48698. */
  48699. direction: Vector2;
  48700. private _texture;
  48701. /**
  48702. * Stores the anisotropy values in a texture.
  48703. * rg is direction (like normal from -1 to 1)
  48704. * b is a intensity
  48705. */
  48706. texture: Nullable<BaseTexture>;
  48707. /** @hidden */
  48708. private _internalMarkAllSubMeshesAsTexturesDirty;
  48709. /** @hidden */
  48710. _markAllSubMeshesAsTexturesDirty(): void;
  48711. /**
  48712. * Instantiate a new istance of anisotropy configuration.
  48713. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48714. */
  48715. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48716. /**
  48717. * Specifies that the submesh is ready to be used.
  48718. * @param defines the list of "defines" to update.
  48719. * @param scene defines the scene the material belongs to.
  48720. * @returns - boolean indicating that the submesh is ready or not.
  48721. */
  48722. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48723. /**
  48724. * Checks to see if a texture is used in the material.
  48725. * @param defines the list of "defines" to update.
  48726. * @param mesh the mesh we are preparing the defines for.
  48727. * @param scene defines the scene the material belongs to.
  48728. */
  48729. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48730. /**
  48731. * Binds the material data.
  48732. * @param uniformBuffer defines the Uniform buffer to fill in.
  48733. * @param scene defines the scene the material belongs to.
  48734. * @param isFrozen defines wether the material is frozen or not.
  48735. */
  48736. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48737. /**
  48738. * Checks to see if a texture is used in the material.
  48739. * @param texture - Base texture to use.
  48740. * @returns - Boolean specifying if a texture is used in the material.
  48741. */
  48742. hasTexture(texture: BaseTexture): boolean;
  48743. /**
  48744. * Returns an array of the actively used textures.
  48745. * @param activeTextures Array of BaseTextures
  48746. */
  48747. getActiveTextures(activeTextures: BaseTexture[]): void;
  48748. /**
  48749. * Returns the animatable textures.
  48750. * @param animatables Array of animatable textures.
  48751. */
  48752. getAnimatables(animatables: IAnimatable[]): void;
  48753. /**
  48754. * Disposes the resources of the material.
  48755. * @param forceDisposeTextures - Forces the disposal of all textures.
  48756. */
  48757. dispose(forceDisposeTextures?: boolean): void;
  48758. /**
  48759. * Get the current class name of the texture useful for serialization or dynamic coding.
  48760. * @returns "PBRAnisotropicConfiguration"
  48761. */
  48762. getClassName(): string;
  48763. /**
  48764. * Add fallbacks to the effect fallbacks list.
  48765. * @param defines defines the Base texture to use.
  48766. * @param fallbacks defines the current fallback list.
  48767. * @param currentRank defines the current fallback rank.
  48768. * @returns the new fallback rank.
  48769. */
  48770. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48771. /**
  48772. * Add the required uniforms to the current list.
  48773. * @param uniforms defines the current uniform list.
  48774. */
  48775. static AddUniforms(uniforms: string[]): void;
  48776. /**
  48777. * Add the required uniforms to the current buffer.
  48778. * @param uniformBuffer defines the current uniform buffer.
  48779. */
  48780. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48781. /**
  48782. * Add the required samplers to the current list.
  48783. * @param samplers defines the current sampler list.
  48784. */
  48785. static AddSamplers(samplers: string[]): void;
  48786. /**
  48787. * Makes a duplicate of the current configuration into another one.
  48788. * @param anisotropicConfiguration define the config where to copy the info
  48789. */
  48790. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48791. /**
  48792. * Serializes this anisotropy configuration.
  48793. * @returns - An object with the serialized config.
  48794. */
  48795. serialize(): any;
  48796. /**
  48797. * Parses a anisotropy Configuration from a serialized object.
  48798. * @param source - Serialized object.
  48799. * @param scene Defines the scene we are parsing for
  48800. * @param rootUrl Defines the rootUrl to load from
  48801. */
  48802. parse(source: any, scene: Scene, rootUrl: string): void;
  48803. }
  48804. }
  48805. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48806. import { Scene } from "babylonjs/scene";
  48807. /**
  48808. * @hidden
  48809. */
  48810. export interface IMaterialBRDFDefines {
  48811. BRDF_V_HEIGHT_CORRELATED: boolean;
  48812. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48813. SPHERICAL_HARMONICS: boolean;
  48814. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48815. /** @hidden */
  48816. _areMiscDirty: boolean;
  48817. }
  48818. /**
  48819. * Define the code related to the BRDF parameters of the pbr material.
  48820. */
  48821. export class PBRBRDFConfiguration {
  48822. /**
  48823. * Default value used for the energy conservation.
  48824. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48825. */
  48826. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48827. /**
  48828. * Default value used for the Smith Visibility Height Correlated mode.
  48829. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48830. */
  48831. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48832. /**
  48833. * Default value used for the IBL diffuse part.
  48834. * This can help switching back to the polynomials mode globally which is a tiny bit
  48835. * less GPU intensive at the drawback of a lower quality.
  48836. */
  48837. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48838. /**
  48839. * Default value used for activating energy conservation for the specular workflow.
  48840. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48841. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48842. */
  48843. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48844. private _useEnergyConservation;
  48845. /**
  48846. * Defines if the material uses energy conservation.
  48847. */
  48848. useEnergyConservation: boolean;
  48849. private _useSmithVisibilityHeightCorrelated;
  48850. /**
  48851. * LEGACY Mode set to false
  48852. * Defines if the material uses height smith correlated visibility term.
  48853. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48854. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48855. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48856. * Not relying on height correlated will also disable energy conservation.
  48857. */
  48858. useSmithVisibilityHeightCorrelated: boolean;
  48859. private _useSphericalHarmonics;
  48860. /**
  48861. * LEGACY Mode set to false
  48862. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48863. * diffuse part of the IBL.
  48864. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48865. * to the ground truth.
  48866. */
  48867. useSphericalHarmonics: boolean;
  48868. private _useSpecularGlossinessInputEnergyConservation;
  48869. /**
  48870. * Defines if the material uses energy conservation, when the specular workflow is active.
  48871. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48872. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48873. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48874. */
  48875. useSpecularGlossinessInputEnergyConservation: boolean;
  48876. /** @hidden */
  48877. private _internalMarkAllSubMeshesAsMiscDirty;
  48878. /** @hidden */
  48879. _markAllSubMeshesAsMiscDirty(): void;
  48880. /**
  48881. * Instantiate a new istance of clear coat configuration.
  48882. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48883. */
  48884. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48885. /**
  48886. * Checks to see if a texture is used in the material.
  48887. * @param defines the list of "defines" to update.
  48888. */
  48889. prepareDefines(defines: IMaterialBRDFDefines): void;
  48890. /**
  48891. * Get the current class name of the texture useful for serialization or dynamic coding.
  48892. * @returns "PBRClearCoatConfiguration"
  48893. */
  48894. getClassName(): string;
  48895. /**
  48896. * Makes a duplicate of the current configuration into another one.
  48897. * @param brdfConfiguration define the config where to copy the info
  48898. */
  48899. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48900. /**
  48901. * Serializes this BRDF configuration.
  48902. * @returns - An object with the serialized config.
  48903. */
  48904. serialize(): any;
  48905. /**
  48906. * Parses a anisotropy Configuration from a serialized object.
  48907. * @param source - Serialized object.
  48908. * @param scene Defines the scene we are parsing for
  48909. * @param rootUrl Defines the rootUrl to load from
  48910. */
  48911. parse(source: any, scene: Scene, rootUrl: string): void;
  48912. }
  48913. }
  48914. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48915. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48916. import { Color3 } from "babylonjs/Maths/math.color";
  48917. import { Scene } from "babylonjs/scene";
  48918. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48919. import { Nullable } from "babylonjs/types";
  48920. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48921. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48922. /**
  48923. * @hidden
  48924. */
  48925. export interface IMaterialSheenDefines {
  48926. SHEEN: boolean;
  48927. SHEEN_TEXTURE: boolean;
  48928. SHEEN_TEXTUREDIRECTUV: number;
  48929. SHEEN_LINKWITHALBEDO: boolean;
  48930. /** @hidden */
  48931. _areTexturesDirty: boolean;
  48932. }
  48933. /**
  48934. * Define the code related to the Sheen parameters of the pbr material.
  48935. */
  48936. export class PBRSheenConfiguration {
  48937. private _isEnabled;
  48938. /**
  48939. * Defines if the material uses sheen.
  48940. */
  48941. isEnabled: boolean;
  48942. private _linkSheenWithAlbedo;
  48943. /**
  48944. * Defines if the sheen is linked to the sheen color.
  48945. */
  48946. linkSheenWithAlbedo: boolean;
  48947. /**
  48948. * Defines the sheen intensity.
  48949. */
  48950. intensity: number;
  48951. /**
  48952. * Defines the sheen color.
  48953. */
  48954. color: Color3;
  48955. private _texture;
  48956. /**
  48957. * Stores the sheen tint values in a texture.
  48958. * rgb is tint
  48959. * a is a intensity
  48960. */
  48961. texture: Nullable<BaseTexture>;
  48962. /** @hidden */
  48963. private _internalMarkAllSubMeshesAsTexturesDirty;
  48964. /** @hidden */
  48965. _markAllSubMeshesAsTexturesDirty(): void;
  48966. /**
  48967. * Instantiate a new istance of clear coat configuration.
  48968. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48969. */
  48970. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48971. /**
  48972. * Specifies that the submesh is ready to be used.
  48973. * @param defines the list of "defines" to update.
  48974. * @param scene defines the scene the material belongs to.
  48975. * @returns - boolean indicating that the submesh is ready or not.
  48976. */
  48977. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48978. /**
  48979. * Checks to see if a texture is used in the material.
  48980. * @param defines the list of "defines" to update.
  48981. * @param scene defines the scene the material belongs to.
  48982. */
  48983. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48984. /**
  48985. * Binds the material data.
  48986. * @param uniformBuffer defines the Uniform buffer to fill in.
  48987. * @param scene defines the scene the material belongs to.
  48988. * @param isFrozen defines wether the material is frozen or not.
  48989. */
  48990. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48991. /**
  48992. * Checks to see if a texture is used in the material.
  48993. * @param texture - Base texture to use.
  48994. * @returns - Boolean specifying if a texture is used in the material.
  48995. */
  48996. hasTexture(texture: BaseTexture): boolean;
  48997. /**
  48998. * Returns an array of the actively used textures.
  48999. * @param activeTextures Array of BaseTextures
  49000. */
  49001. getActiveTextures(activeTextures: BaseTexture[]): void;
  49002. /**
  49003. * Returns the animatable textures.
  49004. * @param animatables Array of animatable textures.
  49005. */
  49006. getAnimatables(animatables: IAnimatable[]): void;
  49007. /**
  49008. * Disposes the resources of the material.
  49009. * @param forceDisposeTextures - Forces the disposal of all textures.
  49010. */
  49011. dispose(forceDisposeTextures?: boolean): void;
  49012. /**
  49013. * Get the current class name of the texture useful for serialization or dynamic coding.
  49014. * @returns "PBRSheenConfiguration"
  49015. */
  49016. getClassName(): string;
  49017. /**
  49018. * Add fallbacks to the effect fallbacks list.
  49019. * @param defines defines the Base texture to use.
  49020. * @param fallbacks defines the current fallback list.
  49021. * @param currentRank defines the current fallback rank.
  49022. * @returns the new fallback rank.
  49023. */
  49024. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49025. /**
  49026. * Add the required uniforms to the current list.
  49027. * @param uniforms defines the current uniform list.
  49028. */
  49029. static AddUniforms(uniforms: string[]): void;
  49030. /**
  49031. * Add the required uniforms to the current buffer.
  49032. * @param uniformBuffer defines the current uniform buffer.
  49033. */
  49034. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49035. /**
  49036. * Add the required samplers to the current list.
  49037. * @param samplers defines the current sampler list.
  49038. */
  49039. static AddSamplers(samplers: string[]): void;
  49040. /**
  49041. * Makes a duplicate of the current configuration into another one.
  49042. * @param sheenConfiguration define the config where to copy the info
  49043. */
  49044. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49045. /**
  49046. * Serializes this BRDF configuration.
  49047. * @returns - An object with the serialized config.
  49048. */
  49049. serialize(): any;
  49050. /**
  49051. * Parses a anisotropy Configuration from a serialized object.
  49052. * @param source - Serialized object.
  49053. * @param scene Defines the scene we are parsing for
  49054. * @param rootUrl Defines the rootUrl to load from
  49055. */
  49056. parse(source: any, scene: Scene, rootUrl: string): void;
  49057. }
  49058. }
  49059. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49060. import { Nullable } from "babylonjs/types";
  49061. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49062. import { Color3 } from "babylonjs/Maths/math.color";
  49063. import { SmartArray } from "babylonjs/Misc/smartArray";
  49064. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49065. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49066. import { Effect } from "babylonjs/Materials/effect";
  49067. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49068. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49069. import { Engine } from "babylonjs/Engines/engine";
  49070. import { Scene } from "babylonjs/scene";
  49071. /**
  49072. * @hidden
  49073. */
  49074. export interface IMaterialSubSurfaceDefines {
  49075. SUBSURFACE: boolean;
  49076. SS_REFRACTION: boolean;
  49077. SS_TRANSLUCENCY: boolean;
  49078. SS_SCATERRING: boolean;
  49079. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49080. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49081. SS_REFRACTIONMAP_3D: boolean;
  49082. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49083. SS_LODINREFRACTIONALPHA: boolean;
  49084. SS_GAMMAREFRACTION: boolean;
  49085. SS_RGBDREFRACTION: boolean;
  49086. SS_LINEARSPECULARREFRACTION: boolean;
  49087. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49088. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49089. /** @hidden */
  49090. _areTexturesDirty: boolean;
  49091. }
  49092. /**
  49093. * Define the code related to the sub surface parameters of the pbr material.
  49094. */
  49095. export class PBRSubSurfaceConfiguration {
  49096. private _isRefractionEnabled;
  49097. /**
  49098. * Defines if the refraction is enabled in the material.
  49099. */
  49100. isRefractionEnabled: boolean;
  49101. private _isTranslucencyEnabled;
  49102. /**
  49103. * Defines if the translucency is enabled in the material.
  49104. */
  49105. isTranslucencyEnabled: boolean;
  49106. private _isScatteringEnabled;
  49107. /**
  49108. * Defines the refraction intensity of the material.
  49109. * The refraction when enabled replaces the Diffuse part of the material.
  49110. * The intensity helps transitionning between diffuse and refraction.
  49111. */
  49112. refractionIntensity: number;
  49113. /**
  49114. * Defines the translucency intensity of the material.
  49115. * When translucency has been enabled, this defines how much of the "translucency"
  49116. * is addded to the diffuse part of the material.
  49117. */
  49118. translucencyIntensity: number;
  49119. /**
  49120. * Defines the scattering intensity of the material.
  49121. * When scattering has been enabled, this defines how much of the "scattered light"
  49122. * is addded to the diffuse part of the material.
  49123. */
  49124. scatteringIntensity: number;
  49125. private _thicknessTexture;
  49126. /**
  49127. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49128. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49129. * 0 would mean minimumThickness
  49130. * 1 would mean maximumThickness
  49131. * The other channels might be use as a mask to vary the different effects intensity.
  49132. */
  49133. thicknessTexture: Nullable<BaseTexture>;
  49134. private _refractionTexture;
  49135. /**
  49136. * Defines the texture to use for refraction.
  49137. */
  49138. refractionTexture: Nullable<BaseTexture>;
  49139. private _indexOfRefraction;
  49140. /**
  49141. * Defines the index of refraction used in the material.
  49142. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49143. */
  49144. indexOfRefraction: number;
  49145. private _invertRefractionY;
  49146. /**
  49147. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49148. */
  49149. invertRefractionY: boolean;
  49150. private _linkRefractionWithTransparency;
  49151. /**
  49152. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49153. * Materials half opaque for instance using refraction could benefit from this control.
  49154. */
  49155. linkRefractionWithTransparency: boolean;
  49156. /**
  49157. * Defines the minimum thickness stored in the thickness map.
  49158. * If no thickness map is defined, this value will be used to simulate thickness.
  49159. */
  49160. minimumThickness: number;
  49161. /**
  49162. * Defines the maximum thickness stored in the thickness map.
  49163. */
  49164. maximumThickness: number;
  49165. /**
  49166. * Defines the volume tint of the material.
  49167. * This is used for both translucency and scattering.
  49168. */
  49169. tintColor: Color3;
  49170. /**
  49171. * Defines the distance at which the tint color should be found in the media.
  49172. * This is used for refraction only.
  49173. */
  49174. tintColorAtDistance: number;
  49175. /**
  49176. * Defines how far each channel transmit through the media.
  49177. * It is defined as a color to simplify it selection.
  49178. */
  49179. diffusionDistance: Color3;
  49180. private _useMaskFromThicknessTexture;
  49181. /**
  49182. * Stores the intensity of the different subsurface effects in the thickness texture.
  49183. * * the green channel is the translucency intensity.
  49184. * * the blue channel is the scattering intensity.
  49185. * * the alpha channel is the refraction intensity.
  49186. */
  49187. useMaskFromThicknessTexture: boolean;
  49188. /** @hidden */
  49189. private _internalMarkAllSubMeshesAsTexturesDirty;
  49190. /** @hidden */
  49191. _markAllSubMeshesAsTexturesDirty(): void;
  49192. /**
  49193. * Instantiate a new istance of sub surface configuration.
  49194. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49195. */
  49196. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49197. /**
  49198. * Gets wehter the submesh is ready to be used or not.
  49199. * @param defines the list of "defines" to update.
  49200. * @param scene defines the scene the material belongs to.
  49201. * @returns - boolean indicating that the submesh is ready or not.
  49202. */
  49203. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49204. /**
  49205. * Checks to see if a texture is used in the material.
  49206. * @param defines the list of "defines" to update.
  49207. * @param scene defines the scene to the material belongs to.
  49208. */
  49209. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49210. /**
  49211. * Binds the material data.
  49212. * @param uniformBuffer defines the Uniform buffer to fill in.
  49213. * @param scene defines the scene the material belongs to.
  49214. * @param engine defines the engine the material belongs to.
  49215. * @param isFrozen defines wether the material is frozen or not.
  49216. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49217. */
  49218. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49219. /**
  49220. * Unbinds the material from the mesh.
  49221. * @param activeEffect defines the effect that should be unbound from.
  49222. * @returns true if unbound, otherwise false
  49223. */
  49224. unbind(activeEffect: Effect): boolean;
  49225. /**
  49226. * Returns the texture used for refraction or null if none is used.
  49227. * @param scene defines the scene the material belongs to.
  49228. * @returns - Refraction texture if present. If no refraction texture and refraction
  49229. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49230. */
  49231. private _getRefractionTexture;
  49232. /**
  49233. * Returns true if alpha blending should be disabled.
  49234. */
  49235. readonly disableAlphaBlending: boolean;
  49236. /**
  49237. * Fills the list of render target textures.
  49238. * @param renderTargets the list of render targets to update
  49239. */
  49240. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49241. /**
  49242. * Checks to see if a texture is used in the material.
  49243. * @param texture - Base texture to use.
  49244. * @returns - Boolean specifying if a texture is used in the material.
  49245. */
  49246. hasTexture(texture: BaseTexture): boolean;
  49247. /**
  49248. * Gets a boolean indicating that current material needs to register RTT
  49249. * @returns true if this uses a render target otherwise false.
  49250. */
  49251. hasRenderTargetTextures(): boolean;
  49252. /**
  49253. * Returns an array of the actively used textures.
  49254. * @param activeTextures Array of BaseTextures
  49255. */
  49256. getActiveTextures(activeTextures: BaseTexture[]): void;
  49257. /**
  49258. * Returns the animatable textures.
  49259. * @param animatables Array of animatable textures.
  49260. */
  49261. getAnimatables(animatables: IAnimatable[]): void;
  49262. /**
  49263. * Disposes the resources of the material.
  49264. * @param forceDisposeTextures - Forces the disposal of all textures.
  49265. */
  49266. dispose(forceDisposeTextures?: boolean): void;
  49267. /**
  49268. * Get the current class name of the texture useful for serialization or dynamic coding.
  49269. * @returns "PBRSubSurfaceConfiguration"
  49270. */
  49271. getClassName(): string;
  49272. /**
  49273. * Add fallbacks to the effect fallbacks list.
  49274. * @param defines defines the Base texture to use.
  49275. * @param fallbacks defines the current fallback list.
  49276. * @param currentRank defines the current fallback rank.
  49277. * @returns the new fallback rank.
  49278. */
  49279. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49280. /**
  49281. * Add the required uniforms to the current list.
  49282. * @param uniforms defines the current uniform list.
  49283. */
  49284. static AddUniforms(uniforms: string[]): void;
  49285. /**
  49286. * Add the required samplers to the current list.
  49287. * @param samplers defines the current sampler list.
  49288. */
  49289. static AddSamplers(samplers: string[]): void;
  49290. /**
  49291. * Add the required uniforms to the current buffer.
  49292. * @param uniformBuffer defines the current uniform buffer.
  49293. */
  49294. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49295. /**
  49296. * Makes a duplicate of the current configuration into another one.
  49297. * @param configuration define the config where to copy the info
  49298. */
  49299. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49300. /**
  49301. * Serializes this Sub Surface configuration.
  49302. * @returns - An object with the serialized config.
  49303. */
  49304. serialize(): any;
  49305. /**
  49306. * Parses a anisotropy Configuration from a serialized object.
  49307. * @param source - Serialized object.
  49308. * @param scene Defines the scene we are parsing for
  49309. * @param rootUrl Defines the rootUrl to load from
  49310. */
  49311. parse(source: any, scene: Scene, rootUrl: string): void;
  49312. }
  49313. }
  49314. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49315. /** @hidden */
  49316. export var pbrFragmentDeclaration: {
  49317. name: string;
  49318. shader: string;
  49319. };
  49320. }
  49321. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49322. /** @hidden */
  49323. export var pbrUboDeclaration: {
  49324. name: string;
  49325. shader: string;
  49326. };
  49327. }
  49328. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49329. /** @hidden */
  49330. export var pbrFragmentExtraDeclaration: {
  49331. name: string;
  49332. shader: string;
  49333. };
  49334. }
  49335. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49336. /** @hidden */
  49337. export var pbrFragmentSamplersDeclaration: {
  49338. name: string;
  49339. shader: string;
  49340. };
  49341. }
  49342. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49343. /** @hidden */
  49344. export var pbrHelperFunctions: {
  49345. name: string;
  49346. shader: string;
  49347. };
  49348. }
  49349. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49350. /** @hidden */
  49351. export var harmonicsFunctions: {
  49352. name: string;
  49353. shader: string;
  49354. };
  49355. }
  49356. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49357. /** @hidden */
  49358. export var pbrDirectLightingSetupFunctions: {
  49359. name: string;
  49360. shader: string;
  49361. };
  49362. }
  49363. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49364. /** @hidden */
  49365. export var pbrDirectLightingFalloffFunctions: {
  49366. name: string;
  49367. shader: string;
  49368. };
  49369. }
  49370. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49371. /** @hidden */
  49372. export var pbrBRDFFunctions: {
  49373. name: string;
  49374. shader: string;
  49375. };
  49376. }
  49377. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49378. /** @hidden */
  49379. export var pbrDirectLightingFunctions: {
  49380. name: string;
  49381. shader: string;
  49382. };
  49383. }
  49384. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49385. /** @hidden */
  49386. export var pbrIBLFunctions: {
  49387. name: string;
  49388. shader: string;
  49389. };
  49390. }
  49391. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49392. /** @hidden */
  49393. export var pbrDebug: {
  49394. name: string;
  49395. shader: string;
  49396. };
  49397. }
  49398. declare module "babylonjs/Shaders/pbr.fragment" {
  49399. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49400. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49401. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49402. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49403. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49404. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49405. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49406. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49407. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49408. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49409. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49410. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49411. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49413. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49414. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49415. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49416. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49417. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49418. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49419. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49420. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49421. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49422. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49423. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49424. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49425. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49426. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49427. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49428. /** @hidden */
  49429. export var pbrPixelShader: {
  49430. name: string;
  49431. shader: string;
  49432. };
  49433. }
  49434. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49435. /** @hidden */
  49436. export var pbrVertexDeclaration: {
  49437. name: string;
  49438. shader: string;
  49439. };
  49440. }
  49441. declare module "babylonjs/Shaders/pbr.vertex" {
  49442. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49443. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49444. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49446. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49447. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49448. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49449. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49450. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49451. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49452. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49453. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49454. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49455. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49456. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49457. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49459. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49460. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49461. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49462. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49463. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49464. /** @hidden */
  49465. export var pbrVertexShader: {
  49466. name: string;
  49467. shader: string;
  49468. };
  49469. }
  49470. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49471. import { Nullable } from "babylonjs/types";
  49472. import { Scene } from "babylonjs/scene";
  49473. import { Matrix } from "babylonjs/Maths/math.vector";
  49474. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49475. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49476. import { Mesh } from "babylonjs/Meshes/mesh";
  49477. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49478. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49479. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49480. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49481. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49482. import { Color3 } from "babylonjs/Maths/math.color";
  49483. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49484. import { Material } from "babylonjs/Materials/material";
  49485. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49486. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49487. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49488. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49489. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49490. import "babylonjs/Shaders/pbr.fragment";
  49491. import "babylonjs/Shaders/pbr.vertex";
  49492. /**
  49493. * Manages the defines for the PBR Material.
  49494. * @hidden
  49495. */
  49496. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49497. PBR: boolean;
  49498. MAINUV1: boolean;
  49499. MAINUV2: boolean;
  49500. UV1: boolean;
  49501. UV2: boolean;
  49502. ALBEDO: boolean;
  49503. ALBEDODIRECTUV: number;
  49504. VERTEXCOLOR: boolean;
  49505. AMBIENT: boolean;
  49506. AMBIENTDIRECTUV: number;
  49507. AMBIENTINGRAYSCALE: boolean;
  49508. OPACITY: boolean;
  49509. VERTEXALPHA: boolean;
  49510. OPACITYDIRECTUV: number;
  49511. OPACITYRGB: boolean;
  49512. ALPHATEST: boolean;
  49513. DEPTHPREPASS: boolean;
  49514. ALPHABLEND: boolean;
  49515. ALPHAFROMALBEDO: boolean;
  49516. ALPHATESTVALUE: string;
  49517. SPECULAROVERALPHA: boolean;
  49518. RADIANCEOVERALPHA: boolean;
  49519. ALPHAFRESNEL: boolean;
  49520. LINEARALPHAFRESNEL: boolean;
  49521. PREMULTIPLYALPHA: boolean;
  49522. EMISSIVE: boolean;
  49523. EMISSIVEDIRECTUV: number;
  49524. REFLECTIVITY: boolean;
  49525. REFLECTIVITYDIRECTUV: number;
  49526. SPECULARTERM: boolean;
  49527. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49528. MICROSURFACEAUTOMATIC: boolean;
  49529. LODBASEDMICROSFURACE: boolean;
  49530. MICROSURFACEMAP: boolean;
  49531. MICROSURFACEMAPDIRECTUV: number;
  49532. METALLICWORKFLOW: boolean;
  49533. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49534. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49535. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49536. AOSTOREINMETALMAPRED: boolean;
  49537. ENVIRONMENTBRDF: boolean;
  49538. ENVIRONMENTBRDF_RGBD: boolean;
  49539. NORMAL: boolean;
  49540. TANGENT: boolean;
  49541. BUMP: boolean;
  49542. BUMPDIRECTUV: number;
  49543. OBJECTSPACE_NORMALMAP: boolean;
  49544. PARALLAX: boolean;
  49545. PARALLAXOCCLUSION: boolean;
  49546. NORMALXYSCALE: boolean;
  49547. LIGHTMAP: boolean;
  49548. LIGHTMAPDIRECTUV: number;
  49549. USELIGHTMAPASSHADOWMAP: boolean;
  49550. GAMMALIGHTMAP: boolean;
  49551. RGBDLIGHTMAP: boolean;
  49552. REFLECTION: boolean;
  49553. REFLECTIONMAP_3D: boolean;
  49554. REFLECTIONMAP_SPHERICAL: boolean;
  49555. REFLECTIONMAP_PLANAR: boolean;
  49556. REFLECTIONMAP_CUBIC: boolean;
  49557. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49558. REFLECTIONMAP_PROJECTION: boolean;
  49559. REFLECTIONMAP_SKYBOX: boolean;
  49560. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49561. REFLECTIONMAP_EXPLICIT: boolean;
  49562. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49563. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49564. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49565. INVERTCUBICMAP: boolean;
  49566. USESPHERICALFROMREFLECTIONMAP: boolean;
  49567. USEIRRADIANCEMAP: boolean;
  49568. SPHERICAL_HARMONICS: boolean;
  49569. USESPHERICALINVERTEX: boolean;
  49570. REFLECTIONMAP_OPPOSITEZ: boolean;
  49571. LODINREFLECTIONALPHA: boolean;
  49572. GAMMAREFLECTION: boolean;
  49573. RGBDREFLECTION: boolean;
  49574. LINEARSPECULARREFLECTION: boolean;
  49575. RADIANCEOCCLUSION: boolean;
  49576. HORIZONOCCLUSION: boolean;
  49577. INSTANCES: boolean;
  49578. NUM_BONE_INFLUENCERS: number;
  49579. BonesPerMesh: number;
  49580. BONETEXTURE: boolean;
  49581. NONUNIFORMSCALING: boolean;
  49582. MORPHTARGETS: boolean;
  49583. MORPHTARGETS_NORMAL: boolean;
  49584. MORPHTARGETS_TANGENT: boolean;
  49585. MORPHTARGETS_UV: boolean;
  49586. NUM_MORPH_INFLUENCERS: number;
  49587. IMAGEPROCESSING: boolean;
  49588. VIGNETTE: boolean;
  49589. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49590. VIGNETTEBLENDMODEOPAQUE: boolean;
  49591. TONEMAPPING: boolean;
  49592. TONEMAPPING_ACES: boolean;
  49593. CONTRAST: boolean;
  49594. COLORCURVES: boolean;
  49595. COLORGRADING: boolean;
  49596. COLORGRADING3D: boolean;
  49597. SAMPLER3DGREENDEPTH: boolean;
  49598. SAMPLER3DBGRMAP: boolean;
  49599. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49600. EXPOSURE: boolean;
  49601. MULTIVIEW: boolean;
  49602. USEPHYSICALLIGHTFALLOFF: boolean;
  49603. USEGLTFLIGHTFALLOFF: boolean;
  49604. TWOSIDEDLIGHTING: boolean;
  49605. SHADOWFLOAT: boolean;
  49606. CLIPPLANE: boolean;
  49607. CLIPPLANE2: boolean;
  49608. CLIPPLANE3: boolean;
  49609. CLIPPLANE4: boolean;
  49610. POINTSIZE: boolean;
  49611. FOG: boolean;
  49612. LOGARITHMICDEPTH: boolean;
  49613. FORCENORMALFORWARD: boolean;
  49614. SPECULARAA: boolean;
  49615. CLEARCOAT: boolean;
  49616. CLEARCOAT_DEFAULTIOR: boolean;
  49617. CLEARCOAT_TEXTURE: boolean;
  49618. CLEARCOAT_TEXTUREDIRECTUV: number;
  49619. CLEARCOAT_BUMP: boolean;
  49620. CLEARCOAT_BUMPDIRECTUV: number;
  49621. CLEARCOAT_TINT: boolean;
  49622. CLEARCOAT_TINT_TEXTURE: boolean;
  49623. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49624. ANISOTROPIC: boolean;
  49625. ANISOTROPIC_TEXTURE: boolean;
  49626. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49627. BRDF_V_HEIGHT_CORRELATED: boolean;
  49628. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49629. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49630. SHEEN: boolean;
  49631. SHEEN_TEXTURE: boolean;
  49632. SHEEN_TEXTUREDIRECTUV: number;
  49633. SHEEN_LINKWITHALBEDO: boolean;
  49634. SUBSURFACE: boolean;
  49635. SS_REFRACTION: boolean;
  49636. SS_TRANSLUCENCY: boolean;
  49637. SS_SCATERRING: boolean;
  49638. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49639. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49640. SS_REFRACTIONMAP_3D: boolean;
  49641. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49642. SS_LODINREFRACTIONALPHA: boolean;
  49643. SS_GAMMAREFRACTION: boolean;
  49644. SS_RGBDREFRACTION: boolean;
  49645. SS_LINEARSPECULARREFRACTION: boolean;
  49646. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49647. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49648. UNLIT: boolean;
  49649. DEBUGMODE: number;
  49650. /**
  49651. * Initializes the PBR Material defines.
  49652. */
  49653. constructor();
  49654. /**
  49655. * Resets the PBR Material defines.
  49656. */
  49657. reset(): void;
  49658. }
  49659. /**
  49660. * The Physically based material base class of BJS.
  49661. *
  49662. * This offers the main features of a standard PBR material.
  49663. * For more information, please refer to the documentation :
  49664. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49665. */
  49666. export abstract class PBRBaseMaterial extends PushMaterial {
  49667. /**
  49668. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49669. */
  49670. static readonly PBRMATERIAL_OPAQUE: number;
  49671. /**
  49672. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49673. */
  49674. static readonly PBRMATERIAL_ALPHATEST: number;
  49675. /**
  49676. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49677. */
  49678. static readonly PBRMATERIAL_ALPHABLEND: number;
  49679. /**
  49680. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49681. * They are also discarded below the alpha cutoff threshold to improve performances.
  49682. */
  49683. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49684. /**
  49685. * Defines the default value of how much AO map is occluding the analytical lights
  49686. * (point spot...).
  49687. */
  49688. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49689. /**
  49690. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49691. */
  49692. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49693. /**
  49694. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49695. * to enhance interoperability with other engines.
  49696. */
  49697. static readonly LIGHTFALLOFF_GLTF: number;
  49698. /**
  49699. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49700. * to enhance interoperability with other materials.
  49701. */
  49702. static readonly LIGHTFALLOFF_STANDARD: number;
  49703. /**
  49704. * Intensity of the direct lights e.g. the four lights available in your scene.
  49705. * This impacts both the direct diffuse and specular highlights.
  49706. */
  49707. protected _directIntensity: number;
  49708. /**
  49709. * Intensity of the emissive part of the material.
  49710. * This helps controlling the emissive effect without modifying the emissive color.
  49711. */
  49712. protected _emissiveIntensity: number;
  49713. /**
  49714. * Intensity of the environment e.g. how much the environment will light the object
  49715. * either through harmonics for rough material or through the refelction for shiny ones.
  49716. */
  49717. protected _environmentIntensity: number;
  49718. /**
  49719. * This is a special control allowing the reduction of the specular highlights coming from the
  49720. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49721. */
  49722. protected _specularIntensity: number;
  49723. /**
  49724. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49725. */
  49726. private _lightingInfos;
  49727. /**
  49728. * Debug Control allowing disabling the bump map on this material.
  49729. */
  49730. protected _disableBumpMap: boolean;
  49731. /**
  49732. * AKA Diffuse Texture in standard nomenclature.
  49733. */
  49734. protected _albedoTexture: Nullable<BaseTexture>;
  49735. /**
  49736. * AKA Occlusion Texture in other nomenclature.
  49737. */
  49738. protected _ambientTexture: Nullable<BaseTexture>;
  49739. /**
  49740. * AKA Occlusion Texture Intensity in other nomenclature.
  49741. */
  49742. protected _ambientTextureStrength: number;
  49743. /**
  49744. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49745. * 1 means it completely occludes it
  49746. * 0 mean it has no impact
  49747. */
  49748. protected _ambientTextureImpactOnAnalyticalLights: number;
  49749. /**
  49750. * Stores the alpha values in a texture.
  49751. */
  49752. protected _opacityTexture: Nullable<BaseTexture>;
  49753. /**
  49754. * Stores the reflection values in a texture.
  49755. */
  49756. protected _reflectionTexture: Nullable<BaseTexture>;
  49757. /**
  49758. * Stores the emissive values in a texture.
  49759. */
  49760. protected _emissiveTexture: Nullable<BaseTexture>;
  49761. /**
  49762. * AKA Specular texture in other nomenclature.
  49763. */
  49764. protected _reflectivityTexture: Nullable<BaseTexture>;
  49765. /**
  49766. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49767. */
  49768. protected _metallicTexture: Nullable<BaseTexture>;
  49769. /**
  49770. * Specifies the metallic scalar of the metallic/roughness workflow.
  49771. * Can also be used to scale the metalness values of the metallic texture.
  49772. */
  49773. protected _metallic: Nullable<number>;
  49774. /**
  49775. * Specifies the roughness scalar of the metallic/roughness workflow.
  49776. * Can also be used to scale the roughness values of the metallic texture.
  49777. */
  49778. protected _roughness: Nullable<number>;
  49779. /**
  49780. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49781. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49782. */
  49783. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49784. /**
  49785. * Stores surface normal data used to displace a mesh in a texture.
  49786. */
  49787. protected _bumpTexture: Nullable<BaseTexture>;
  49788. /**
  49789. * Stores the pre-calculated light information of a mesh in a texture.
  49790. */
  49791. protected _lightmapTexture: Nullable<BaseTexture>;
  49792. /**
  49793. * The color of a material in ambient lighting.
  49794. */
  49795. protected _ambientColor: Color3;
  49796. /**
  49797. * AKA Diffuse Color in other nomenclature.
  49798. */
  49799. protected _albedoColor: Color3;
  49800. /**
  49801. * AKA Specular Color in other nomenclature.
  49802. */
  49803. protected _reflectivityColor: Color3;
  49804. /**
  49805. * The color applied when light is reflected from a material.
  49806. */
  49807. protected _reflectionColor: Color3;
  49808. /**
  49809. * The color applied when light is emitted from a material.
  49810. */
  49811. protected _emissiveColor: Color3;
  49812. /**
  49813. * AKA Glossiness in other nomenclature.
  49814. */
  49815. protected _microSurface: number;
  49816. /**
  49817. * Specifies that the material will use the light map as a show map.
  49818. */
  49819. protected _useLightmapAsShadowmap: boolean;
  49820. /**
  49821. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49822. * makes the reflect vector face the model (under horizon).
  49823. */
  49824. protected _useHorizonOcclusion: boolean;
  49825. /**
  49826. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49827. * too much the area relying on ambient texture to define their ambient occlusion.
  49828. */
  49829. protected _useRadianceOcclusion: boolean;
  49830. /**
  49831. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49832. */
  49833. protected _useAlphaFromAlbedoTexture: boolean;
  49834. /**
  49835. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49836. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49837. */
  49838. protected _useSpecularOverAlpha: boolean;
  49839. /**
  49840. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49841. */
  49842. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49843. /**
  49844. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49845. */
  49846. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49847. /**
  49848. * Specifies if the metallic texture contains the roughness information in its green channel.
  49849. */
  49850. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49851. /**
  49852. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49853. */
  49854. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49855. /**
  49856. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49857. */
  49858. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49859. /**
  49860. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49861. */
  49862. protected _useAmbientInGrayScale: boolean;
  49863. /**
  49864. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49865. * The material will try to infer what glossiness each pixel should be.
  49866. */
  49867. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49868. /**
  49869. * Defines the falloff type used in this material.
  49870. * It by default is Physical.
  49871. */
  49872. protected _lightFalloff: number;
  49873. /**
  49874. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49875. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49876. */
  49877. protected _useRadianceOverAlpha: boolean;
  49878. /**
  49879. * Allows using an object space normal map (instead of tangent space).
  49880. */
  49881. protected _useObjectSpaceNormalMap: boolean;
  49882. /**
  49883. * Allows using the bump map in parallax mode.
  49884. */
  49885. protected _useParallax: boolean;
  49886. /**
  49887. * Allows using the bump map in parallax occlusion mode.
  49888. */
  49889. protected _useParallaxOcclusion: boolean;
  49890. /**
  49891. * Controls the scale bias of the parallax mode.
  49892. */
  49893. protected _parallaxScaleBias: number;
  49894. /**
  49895. * If sets to true, disables all the lights affecting the material.
  49896. */
  49897. protected _disableLighting: boolean;
  49898. /**
  49899. * Number of Simultaneous lights allowed on the material.
  49900. */
  49901. protected _maxSimultaneousLights: number;
  49902. /**
  49903. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49904. */
  49905. protected _invertNormalMapX: boolean;
  49906. /**
  49907. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49908. */
  49909. protected _invertNormalMapY: boolean;
  49910. /**
  49911. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49912. */
  49913. protected _twoSidedLighting: boolean;
  49914. /**
  49915. * Defines the alpha limits in alpha test mode.
  49916. */
  49917. protected _alphaCutOff: number;
  49918. /**
  49919. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49920. */
  49921. protected _forceAlphaTest: boolean;
  49922. /**
  49923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49924. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49925. */
  49926. protected _useAlphaFresnel: boolean;
  49927. /**
  49928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49929. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49930. */
  49931. protected _useLinearAlphaFresnel: boolean;
  49932. /**
  49933. * The transparency mode of the material.
  49934. */
  49935. protected _transparencyMode: Nullable<number>;
  49936. /**
  49937. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49938. * from cos thetav and roughness:
  49939. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49940. */
  49941. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49942. /**
  49943. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49944. */
  49945. protected _forceIrradianceInFragment: boolean;
  49946. /**
  49947. * Force normal to face away from face.
  49948. */
  49949. protected _forceNormalForward: boolean;
  49950. /**
  49951. * Enables specular anti aliasing in the PBR shader.
  49952. * It will both interacts on the Geometry for analytical and IBL lighting.
  49953. * It also prefilter the roughness map based on the bump values.
  49954. */
  49955. protected _enableSpecularAntiAliasing: boolean;
  49956. /**
  49957. * Default configuration related to image processing available in the PBR Material.
  49958. */
  49959. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49960. /**
  49961. * Keep track of the image processing observer to allow dispose and replace.
  49962. */
  49963. private _imageProcessingObserver;
  49964. /**
  49965. * Attaches a new image processing configuration to the PBR Material.
  49966. * @param configuration
  49967. */
  49968. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49969. /**
  49970. * Stores the available render targets.
  49971. */
  49972. private _renderTargets;
  49973. /**
  49974. * Sets the global ambient color for the material used in lighting calculations.
  49975. */
  49976. private _globalAmbientColor;
  49977. /**
  49978. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49979. */
  49980. private _useLogarithmicDepth;
  49981. /**
  49982. * If set to true, no lighting calculations will be applied.
  49983. */
  49984. private _unlit;
  49985. private _debugMode;
  49986. /**
  49987. * @hidden
  49988. * This is reserved for the inspector.
  49989. * Defines the material debug mode.
  49990. * It helps seeing only some components of the material while troubleshooting.
  49991. */
  49992. debugMode: number;
  49993. /**
  49994. * @hidden
  49995. * This is reserved for the inspector.
  49996. * Specify from where on screen the debug mode should start.
  49997. * The value goes from -1 (full screen) to 1 (not visible)
  49998. * It helps with side by side comparison against the final render
  49999. * This defaults to -1
  50000. */
  50001. private debugLimit;
  50002. /**
  50003. * @hidden
  50004. * This is reserved for the inspector.
  50005. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50006. * You can use the factor to better multiply the final value.
  50007. */
  50008. private debugFactor;
  50009. /**
  50010. * Defines the clear coat layer parameters for the material.
  50011. */
  50012. readonly clearCoat: PBRClearCoatConfiguration;
  50013. /**
  50014. * Defines the anisotropic parameters for the material.
  50015. */
  50016. readonly anisotropy: PBRAnisotropicConfiguration;
  50017. /**
  50018. * Defines the BRDF parameters for the material.
  50019. */
  50020. readonly brdf: PBRBRDFConfiguration;
  50021. /**
  50022. * Defines the Sheen parameters for the material.
  50023. */
  50024. readonly sheen: PBRSheenConfiguration;
  50025. /**
  50026. * Defines the SubSurface parameters for the material.
  50027. */
  50028. readonly subSurface: PBRSubSurfaceConfiguration;
  50029. /**
  50030. * Custom callback helping to override the default shader used in the material.
  50031. */
  50032. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50033. protected _rebuildInParallel: boolean;
  50034. /**
  50035. * Instantiates a new PBRMaterial instance.
  50036. *
  50037. * @param name The material name
  50038. * @param scene The scene the material will be use in.
  50039. */
  50040. constructor(name: string, scene: Scene);
  50041. /**
  50042. * Gets a boolean indicating that current material needs to register RTT
  50043. */
  50044. readonly hasRenderTargetTextures: boolean;
  50045. /**
  50046. * Gets the name of the material class.
  50047. */
  50048. getClassName(): string;
  50049. /**
  50050. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50051. */
  50052. /**
  50053. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50054. */
  50055. useLogarithmicDepth: boolean;
  50056. /**
  50057. * Gets the current transparency mode.
  50058. */
  50059. /**
  50060. * Sets the transparency mode of the material.
  50061. *
  50062. * | Value | Type | Description |
  50063. * | ----- | ----------------------------------- | ----------- |
  50064. * | 0 | OPAQUE | |
  50065. * | 1 | ALPHATEST | |
  50066. * | 2 | ALPHABLEND | |
  50067. * | 3 | ALPHATESTANDBLEND | |
  50068. *
  50069. */
  50070. transparencyMode: Nullable<number>;
  50071. /**
  50072. * Returns true if alpha blending should be disabled.
  50073. */
  50074. private readonly _disableAlphaBlending;
  50075. /**
  50076. * Specifies whether or not this material should be rendered in alpha blend mode.
  50077. */
  50078. needAlphaBlending(): boolean;
  50079. /**
  50080. * Specifies if the mesh will require alpha blending.
  50081. * @param mesh - BJS mesh.
  50082. */
  50083. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50084. /**
  50085. * Specifies whether or not this material should be rendered in alpha test mode.
  50086. */
  50087. needAlphaTesting(): boolean;
  50088. /**
  50089. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50090. */
  50091. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50092. /**
  50093. * Gets the texture used for the alpha test.
  50094. */
  50095. getAlphaTestTexture(): Nullable<BaseTexture>;
  50096. /**
  50097. * Specifies that the submesh is ready to be used.
  50098. * @param mesh - BJS mesh.
  50099. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50100. * @param useInstances - Specifies that instances should be used.
  50101. * @returns - boolean indicating that the submesh is ready or not.
  50102. */
  50103. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50104. /**
  50105. * Specifies if the material uses metallic roughness workflow.
  50106. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50107. */
  50108. isMetallicWorkflow(): boolean;
  50109. private _prepareEffect;
  50110. private _prepareDefines;
  50111. /**
  50112. * Force shader compilation
  50113. */
  50114. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50115. clipPlane: boolean;
  50116. }>): void;
  50117. /**
  50118. * Initializes the uniform buffer layout for the shader.
  50119. */
  50120. buildUniformLayout(): void;
  50121. /**
  50122. * Unbinds the material from the mesh
  50123. */
  50124. unbind(): void;
  50125. /**
  50126. * Binds the submesh data.
  50127. * @param world - The world matrix.
  50128. * @param mesh - The BJS mesh.
  50129. * @param subMesh - A submesh of the BJS mesh.
  50130. */
  50131. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50132. /**
  50133. * Returns the animatable textures.
  50134. * @returns - Array of animatable textures.
  50135. */
  50136. getAnimatables(): IAnimatable[];
  50137. /**
  50138. * Returns the texture used for reflections.
  50139. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50140. */
  50141. private _getReflectionTexture;
  50142. /**
  50143. * Returns an array of the actively used textures.
  50144. * @returns - Array of BaseTextures
  50145. */
  50146. getActiveTextures(): BaseTexture[];
  50147. /**
  50148. * Checks to see if a texture is used in the material.
  50149. * @param texture - Base texture to use.
  50150. * @returns - Boolean specifying if a texture is used in the material.
  50151. */
  50152. hasTexture(texture: BaseTexture): boolean;
  50153. /**
  50154. * Disposes the resources of the material.
  50155. * @param forceDisposeEffect - Forces the disposal of effects.
  50156. * @param forceDisposeTextures - Forces the disposal of all textures.
  50157. */
  50158. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50159. }
  50160. }
  50161. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50162. import { Nullable } from "babylonjs/types";
  50163. import { Scene } from "babylonjs/scene";
  50164. import { Color3 } from "babylonjs/Maths/math.color";
  50165. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50166. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50167. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50168. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50169. /**
  50170. * The Physically based material of BJS.
  50171. *
  50172. * This offers the main features of a standard PBR material.
  50173. * For more information, please refer to the documentation :
  50174. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50175. */
  50176. export class PBRMaterial extends PBRBaseMaterial {
  50177. /**
  50178. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50179. */
  50180. static readonly PBRMATERIAL_OPAQUE: number;
  50181. /**
  50182. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50183. */
  50184. static readonly PBRMATERIAL_ALPHATEST: number;
  50185. /**
  50186. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50187. */
  50188. static readonly PBRMATERIAL_ALPHABLEND: number;
  50189. /**
  50190. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50191. * They are also discarded below the alpha cutoff threshold to improve performances.
  50192. */
  50193. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50194. /**
  50195. * Defines the default value of how much AO map is occluding the analytical lights
  50196. * (point spot...).
  50197. */
  50198. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50199. /**
  50200. * Intensity of the direct lights e.g. the four lights available in your scene.
  50201. * This impacts both the direct diffuse and specular highlights.
  50202. */
  50203. directIntensity: number;
  50204. /**
  50205. * Intensity of the emissive part of the material.
  50206. * This helps controlling the emissive effect without modifying the emissive color.
  50207. */
  50208. emissiveIntensity: number;
  50209. /**
  50210. * Intensity of the environment e.g. how much the environment will light the object
  50211. * either through harmonics for rough material or through the refelction for shiny ones.
  50212. */
  50213. environmentIntensity: number;
  50214. /**
  50215. * This is a special control allowing the reduction of the specular highlights coming from the
  50216. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50217. */
  50218. specularIntensity: number;
  50219. /**
  50220. * Debug Control allowing disabling the bump map on this material.
  50221. */
  50222. disableBumpMap: boolean;
  50223. /**
  50224. * AKA Diffuse Texture in standard nomenclature.
  50225. */
  50226. albedoTexture: BaseTexture;
  50227. /**
  50228. * AKA Occlusion Texture in other nomenclature.
  50229. */
  50230. ambientTexture: BaseTexture;
  50231. /**
  50232. * AKA Occlusion Texture Intensity in other nomenclature.
  50233. */
  50234. ambientTextureStrength: number;
  50235. /**
  50236. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50237. * 1 means it completely occludes it
  50238. * 0 mean it has no impact
  50239. */
  50240. ambientTextureImpactOnAnalyticalLights: number;
  50241. /**
  50242. * Stores the alpha values in a texture.
  50243. */
  50244. opacityTexture: BaseTexture;
  50245. /**
  50246. * Stores the reflection values in a texture.
  50247. */
  50248. reflectionTexture: Nullable<BaseTexture>;
  50249. /**
  50250. * Stores the emissive values in a texture.
  50251. */
  50252. emissiveTexture: BaseTexture;
  50253. /**
  50254. * AKA Specular texture in other nomenclature.
  50255. */
  50256. reflectivityTexture: BaseTexture;
  50257. /**
  50258. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50259. */
  50260. metallicTexture: BaseTexture;
  50261. /**
  50262. * Specifies the metallic scalar of the metallic/roughness workflow.
  50263. * Can also be used to scale the metalness values of the metallic texture.
  50264. */
  50265. metallic: Nullable<number>;
  50266. /**
  50267. * Specifies the roughness scalar of the metallic/roughness workflow.
  50268. * Can also be used to scale the roughness values of the metallic texture.
  50269. */
  50270. roughness: Nullable<number>;
  50271. /**
  50272. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50273. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50274. */
  50275. microSurfaceTexture: BaseTexture;
  50276. /**
  50277. * Stores surface normal data used to displace a mesh in a texture.
  50278. */
  50279. bumpTexture: BaseTexture;
  50280. /**
  50281. * Stores the pre-calculated light information of a mesh in a texture.
  50282. */
  50283. lightmapTexture: BaseTexture;
  50284. /**
  50285. * Stores the refracted light information in a texture.
  50286. */
  50287. refractionTexture: Nullable<BaseTexture>;
  50288. /**
  50289. * The color of a material in ambient lighting.
  50290. */
  50291. ambientColor: Color3;
  50292. /**
  50293. * AKA Diffuse Color in other nomenclature.
  50294. */
  50295. albedoColor: Color3;
  50296. /**
  50297. * AKA Specular Color in other nomenclature.
  50298. */
  50299. reflectivityColor: Color3;
  50300. /**
  50301. * The color reflected from the material.
  50302. */
  50303. reflectionColor: Color3;
  50304. /**
  50305. * The color emitted from the material.
  50306. */
  50307. emissiveColor: Color3;
  50308. /**
  50309. * AKA Glossiness in other nomenclature.
  50310. */
  50311. microSurface: number;
  50312. /**
  50313. * source material index of refraction (IOR)' / 'destination material IOR.
  50314. */
  50315. indexOfRefraction: number;
  50316. /**
  50317. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50318. */
  50319. invertRefractionY: boolean;
  50320. /**
  50321. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50322. * Materials half opaque for instance using refraction could benefit from this control.
  50323. */
  50324. linkRefractionWithTransparency: boolean;
  50325. /**
  50326. * If true, the light map contains occlusion information instead of lighting info.
  50327. */
  50328. useLightmapAsShadowmap: boolean;
  50329. /**
  50330. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50331. */
  50332. useAlphaFromAlbedoTexture: boolean;
  50333. /**
  50334. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50335. */
  50336. forceAlphaTest: boolean;
  50337. /**
  50338. * Defines the alpha limits in alpha test mode.
  50339. */
  50340. alphaCutOff: number;
  50341. /**
  50342. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50343. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50344. */
  50345. useSpecularOverAlpha: boolean;
  50346. /**
  50347. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50348. */
  50349. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50350. /**
  50351. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50352. */
  50353. useRoughnessFromMetallicTextureAlpha: boolean;
  50354. /**
  50355. * Specifies if the metallic texture contains the roughness information in its green channel.
  50356. */
  50357. useRoughnessFromMetallicTextureGreen: boolean;
  50358. /**
  50359. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50360. */
  50361. useMetallnessFromMetallicTextureBlue: boolean;
  50362. /**
  50363. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50364. */
  50365. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50366. /**
  50367. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50368. */
  50369. useAmbientInGrayScale: boolean;
  50370. /**
  50371. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50372. * The material will try to infer what glossiness each pixel should be.
  50373. */
  50374. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50375. /**
  50376. * BJS is using an harcoded light falloff based on a manually sets up range.
  50377. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50378. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50379. */
  50380. /**
  50381. * BJS is using an harcoded light falloff based on a manually sets up range.
  50382. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50383. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50384. */
  50385. usePhysicalLightFalloff: boolean;
  50386. /**
  50387. * In order to support the falloff compatibility with gltf, a special mode has been added
  50388. * to reproduce the gltf light falloff.
  50389. */
  50390. /**
  50391. * In order to support the falloff compatibility with gltf, a special mode has been added
  50392. * to reproduce the gltf light falloff.
  50393. */
  50394. useGLTFLightFalloff: boolean;
  50395. /**
  50396. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50397. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50398. */
  50399. useRadianceOverAlpha: boolean;
  50400. /**
  50401. * Allows using an object space normal map (instead of tangent space).
  50402. */
  50403. useObjectSpaceNormalMap: boolean;
  50404. /**
  50405. * Allows using the bump map in parallax mode.
  50406. */
  50407. useParallax: boolean;
  50408. /**
  50409. * Allows using the bump map in parallax occlusion mode.
  50410. */
  50411. useParallaxOcclusion: boolean;
  50412. /**
  50413. * Controls the scale bias of the parallax mode.
  50414. */
  50415. parallaxScaleBias: number;
  50416. /**
  50417. * If sets to true, disables all the lights affecting the material.
  50418. */
  50419. disableLighting: boolean;
  50420. /**
  50421. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50422. */
  50423. forceIrradianceInFragment: boolean;
  50424. /**
  50425. * Number of Simultaneous lights allowed on the material.
  50426. */
  50427. maxSimultaneousLights: number;
  50428. /**
  50429. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50430. */
  50431. invertNormalMapX: boolean;
  50432. /**
  50433. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50434. */
  50435. invertNormalMapY: boolean;
  50436. /**
  50437. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50438. */
  50439. twoSidedLighting: boolean;
  50440. /**
  50441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50442. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50443. */
  50444. useAlphaFresnel: boolean;
  50445. /**
  50446. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50447. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50448. */
  50449. useLinearAlphaFresnel: boolean;
  50450. /**
  50451. * Let user defines the brdf lookup texture used for IBL.
  50452. * A default 8bit version is embedded but you could point at :
  50453. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50454. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50455. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50456. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50457. */
  50458. environmentBRDFTexture: Nullable<BaseTexture>;
  50459. /**
  50460. * Force normal to face away from face.
  50461. */
  50462. forceNormalForward: boolean;
  50463. /**
  50464. * Enables specular anti aliasing in the PBR shader.
  50465. * It will both interacts on the Geometry for analytical and IBL lighting.
  50466. * It also prefilter the roughness map based on the bump values.
  50467. */
  50468. enableSpecularAntiAliasing: boolean;
  50469. /**
  50470. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50471. * makes the reflect vector face the model (under horizon).
  50472. */
  50473. useHorizonOcclusion: boolean;
  50474. /**
  50475. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50476. * too much the area relying on ambient texture to define their ambient occlusion.
  50477. */
  50478. useRadianceOcclusion: boolean;
  50479. /**
  50480. * If set to true, no lighting calculations will be applied.
  50481. */
  50482. unlit: boolean;
  50483. /**
  50484. * Gets the image processing configuration used either in this material.
  50485. */
  50486. /**
  50487. * Sets the Default image processing configuration used either in the this material.
  50488. *
  50489. * If sets to null, the scene one is in use.
  50490. */
  50491. imageProcessingConfiguration: ImageProcessingConfiguration;
  50492. /**
  50493. * Gets wether the color curves effect is enabled.
  50494. */
  50495. /**
  50496. * Sets wether the color curves effect is enabled.
  50497. */
  50498. cameraColorCurvesEnabled: boolean;
  50499. /**
  50500. * Gets wether the color grading effect is enabled.
  50501. */
  50502. /**
  50503. * Gets wether the color grading effect is enabled.
  50504. */
  50505. cameraColorGradingEnabled: boolean;
  50506. /**
  50507. * Gets wether tonemapping is enabled or not.
  50508. */
  50509. /**
  50510. * Sets wether tonemapping is enabled or not
  50511. */
  50512. cameraToneMappingEnabled: boolean;
  50513. /**
  50514. * The camera exposure used on this material.
  50515. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50516. * This corresponds to a photographic exposure.
  50517. */
  50518. /**
  50519. * The camera exposure used on this material.
  50520. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50521. * This corresponds to a photographic exposure.
  50522. */
  50523. cameraExposure: number;
  50524. /**
  50525. * Gets The camera contrast used on this material.
  50526. */
  50527. /**
  50528. * Sets The camera contrast used on this material.
  50529. */
  50530. cameraContrast: number;
  50531. /**
  50532. * Gets the Color Grading 2D Lookup Texture.
  50533. */
  50534. /**
  50535. * Sets the Color Grading 2D Lookup Texture.
  50536. */
  50537. cameraColorGradingTexture: Nullable<BaseTexture>;
  50538. /**
  50539. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50540. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50541. * 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;
  50542. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50543. */
  50544. /**
  50545. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50546. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50547. * 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;
  50548. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50549. */
  50550. cameraColorCurves: Nullable<ColorCurves>;
  50551. /**
  50552. * Instantiates a new PBRMaterial instance.
  50553. *
  50554. * @param name The material name
  50555. * @param scene The scene the material will be use in.
  50556. */
  50557. constructor(name: string, scene: Scene);
  50558. /**
  50559. * Returns the name of this material class.
  50560. */
  50561. getClassName(): string;
  50562. /**
  50563. * Makes a duplicate of the current material.
  50564. * @param name - name to use for the new material.
  50565. */
  50566. clone(name: string): PBRMaterial;
  50567. /**
  50568. * Serializes this PBR Material.
  50569. * @returns - An object with the serialized material.
  50570. */
  50571. serialize(): any;
  50572. /**
  50573. * Parses a PBR Material from a serialized object.
  50574. * @param source - Serialized object.
  50575. * @param scene - BJS scene instance.
  50576. * @param rootUrl - url for the scene object
  50577. * @returns - PBRMaterial
  50578. */
  50579. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50580. }
  50581. }
  50582. declare module "babylonjs/Misc/dds" {
  50583. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50584. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50585. import { Nullable } from "babylonjs/types";
  50586. import { Scene } from "babylonjs/scene";
  50587. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50588. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50589. /**
  50590. * Direct draw surface info
  50591. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50592. */
  50593. export interface DDSInfo {
  50594. /**
  50595. * Width of the texture
  50596. */
  50597. width: number;
  50598. /**
  50599. * Width of the texture
  50600. */
  50601. height: number;
  50602. /**
  50603. * Number of Mipmaps for the texture
  50604. * @see https://en.wikipedia.org/wiki/Mipmap
  50605. */
  50606. mipmapCount: number;
  50607. /**
  50608. * If the textures format is a known fourCC format
  50609. * @see https://www.fourcc.org/
  50610. */
  50611. isFourCC: boolean;
  50612. /**
  50613. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50614. */
  50615. isRGB: boolean;
  50616. /**
  50617. * If the texture is a lumincance format
  50618. */
  50619. isLuminance: boolean;
  50620. /**
  50621. * If this is a cube texture
  50622. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50623. */
  50624. isCube: boolean;
  50625. /**
  50626. * If the texture is a compressed format eg. FOURCC_DXT1
  50627. */
  50628. isCompressed: boolean;
  50629. /**
  50630. * The dxgiFormat of the texture
  50631. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50632. */
  50633. dxgiFormat: number;
  50634. /**
  50635. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50636. */
  50637. textureType: number;
  50638. /**
  50639. * Sphericle polynomial created for the dds texture
  50640. */
  50641. sphericalPolynomial?: SphericalPolynomial;
  50642. }
  50643. /**
  50644. * Class used to provide DDS decompression tools
  50645. */
  50646. export class DDSTools {
  50647. /**
  50648. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50649. */
  50650. static StoreLODInAlphaChannel: boolean;
  50651. /**
  50652. * Gets DDS information from an array buffer
  50653. * @param arrayBuffer defines the array buffer to read data from
  50654. * @returns the DDS information
  50655. */
  50656. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50657. private static _FloatView;
  50658. private static _Int32View;
  50659. private static _ToHalfFloat;
  50660. private static _FromHalfFloat;
  50661. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50662. private static _GetHalfFloatRGBAArrayBuffer;
  50663. private static _GetFloatRGBAArrayBuffer;
  50664. private static _GetFloatAsUIntRGBAArrayBuffer;
  50665. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50666. private static _GetRGBAArrayBuffer;
  50667. private static _ExtractLongWordOrder;
  50668. private static _GetRGBArrayBuffer;
  50669. private static _GetLuminanceArrayBuffer;
  50670. /**
  50671. * Uploads DDS Levels to a Babylon Texture
  50672. * @hidden
  50673. */
  50674. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50675. }
  50676. module "babylonjs/Engines/thinEngine" {
  50677. interface ThinEngine {
  50678. /**
  50679. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50680. * @param rootUrl defines the url where the file to load is located
  50681. * @param scene defines the current scene
  50682. * @param lodScale defines scale to apply to the mip map selection
  50683. * @param lodOffset defines offset to apply to the mip map selection
  50684. * @param onLoad defines an optional callback raised when the texture is loaded
  50685. * @param onError defines an optional callback raised if there is an issue to load the texture
  50686. * @param format defines the format of the data
  50687. * @param forcedExtension defines the extension to use to pick the right loader
  50688. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50689. * @returns the cube texture as an InternalTexture
  50690. */
  50691. 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;
  50692. }
  50693. }
  50694. }
  50695. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50696. import { Nullable } from "babylonjs/types";
  50697. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50698. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50699. /**
  50700. * Implementation of the DDS Texture Loader.
  50701. * @hidden
  50702. */
  50703. export class _DDSTextureLoader implements IInternalTextureLoader {
  50704. /**
  50705. * Defines wether the loader supports cascade loading the different faces.
  50706. */
  50707. readonly supportCascades: boolean;
  50708. /**
  50709. * This returns if the loader support the current file information.
  50710. * @param extension defines the file extension of the file being loaded
  50711. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50712. * @param fallback defines the fallback internal texture if any
  50713. * @param isBase64 defines whether the texture is encoded as a base64
  50714. * @param isBuffer defines whether the texture data are stored as a buffer
  50715. * @returns true if the loader can load the specified file
  50716. */
  50717. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50718. /**
  50719. * Transform the url before loading if required.
  50720. * @param rootUrl the url of the texture
  50721. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50722. * @returns the transformed texture
  50723. */
  50724. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50725. /**
  50726. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50727. * @param rootUrl the url of the texture
  50728. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50729. * @returns the fallback texture
  50730. */
  50731. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50732. /**
  50733. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50734. * @param data contains the texture data
  50735. * @param texture defines the BabylonJS internal texture
  50736. * @param createPolynomials will be true if polynomials have been requested
  50737. * @param onLoad defines the callback to trigger once the texture is ready
  50738. * @param onError defines the callback to trigger in case of error
  50739. */
  50740. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50741. /**
  50742. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50743. * @param data contains the texture data
  50744. * @param texture defines the BabylonJS internal texture
  50745. * @param callback defines the method to call once ready to upload
  50746. */
  50747. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50748. }
  50749. }
  50750. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50751. import { Nullable } from "babylonjs/types";
  50752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50753. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50754. /**
  50755. * Implementation of the ENV Texture Loader.
  50756. * @hidden
  50757. */
  50758. export class _ENVTextureLoader implements IInternalTextureLoader {
  50759. /**
  50760. * Defines wether the loader supports cascade loading the different faces.
  50761. */
  50762. readonly supportCascades: boolean;
  50763. /**
  50764. * This returns if the loader support the current file information.
  50765. * @param extension defines the file extension of the file being loaded
  50766. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50767. * @param fallback defines the fallback internal texture if any
  50768. * @param isBase64 defines whether the texture is encoded as a base64
  50769. * @param isBuffer defines whether the texture data are stored as a buffer
  50770. * @returns true if the loader can load the specified file
  50771. */
  50772. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50773. /**
  50774. * Transform the url before loading if required.
  50775. * @param rootUrl the url of the texture
  50776. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50777. * @returns the transformed texture
  50778. */
  50779. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50780. /**
  50781. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50782. * @param rootUrl the url of the texture
  50783. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50784. * @returns the fallback texture
  50785. */
  50786. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50787. /**
  50788. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50789. * @param data contains the texture data
  50790. * @param texture defines the BabylonJS internal texture
  50791. * @param createPolynomials will be true if polynomials have been requested
  50792. * @param onLoad defines the callback to trigger once the texture is ready
  50793. * @param onError defines the callback to trigger in case of error
  50794. */
  50795. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50796. /**
  50797. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50798. * @param data contains the texture data
  50799. * @param texture defines the BabylonJS internal texture
  50800. * @param callback defines the method to call once ready to upload
  50801. */
  50802. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50803. }
  50804. }
  50805. declare module "babylonjs/Misc/khronosTextureContainer" {
  50806. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50807. /**
  50808. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50809. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50810. */
  50811. export class KhronosTextureContainer {
  50812. /** contents of the KTX container file */
  50813. arrayBuffer: any;
  50814. private static HEADER_LEN;
  50815. private static COMPRESSED_2D;
  50816. private static COMPRESSED_3D;
  50817. private static TEX_2D;
  50818. private static TEX_3D;
  50819. /**
  50820. * Gets the openGL type
  50821. */
  50822. glType: number;
  50823. /**
  50824. * Gets the openGL type size
  50825. */
  50826. glTypeSize: number;
  50827. /**
  50828. * Gets the openGL format
  50829. */
  50830. glFormat: number;
  50831. /**
  50832. * Gets the openGL internal format
  50833. */
  50834. glInternalFormat: number;
  50835. /**
  50836. * Gets the base internal format
  50837. */
  50838. glBaseInternalFormat: number;
  50839. /**
  50840. * Gets image width in pixel
  50841. */
  50842. pixelWidth: number;
  50843. /**
  50844. * Gets image height in pixel
  50845. */
  50846. pixelHeight: number;
  50847. /**
  50848. * Gets image depth in pixels
  50849. */
  50850. pixelDepth: number;
  50851. /**
  50852. * Gets the number of array elements
  50853. */
  50854. numberOfArrayElements: number;
  50855. /**
  50856. * Gets the number of faces
  50857. */
  50858. numberOfFaces: number;
  50859. /**
  50860. * Gets the number of mipmap levels
  50861. */
  50862. numberOfMipmapLevels: number;
  50863. /**
  50864. * Gets the bytes of key value data
  50865. */
  50866. bytesOfKeyValueData: number;
  50867. /**
  50868. * Gets the load type
  50869. */
  50870. loadType: number;
  50871. /**
  50872. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50873. */
  50874. isInvalid: boolean;
  50875. /**
  50876. * Creates a new KhronosTextureContainer
  50877. * @param arrayBuffer contents of the KTX container file
  50878. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50879. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50880. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50881. */
  50882. constructor(
  50883. /** contents of the KTX container file */
  50884. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50885. /**
  50886. * Uploads KTX content to a Babylon Texture.
  50887. * It is assumed that the texture has already been created & is currently bound
  50888. * @hidden
  50889. */
  50890. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50891. private _upload2DCompressedLevels;
  50892. }
  50893. }
  50894. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50895. import { Nullable } from "babylonjs/types";
  50896. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50897. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50898. /**
  50899. * Implementation of the KTX Texture Loader.
  50900. * @hidden
  50901. */
  50902. export class _KTXTextureLoader implements IInternalTextureLoader {
  50903. /**
  50904. * Defines wether the loader supports cascade loading the different faces.
  50905. */
  50906. readonly supportCascades: boolean;
  50907. /**
  50908. * This returns if the loader support the current file information.
  50909. * @param extension defines the file extension of the file being loaded
  50910. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50911. * @param fallback defines the fallback internal texture if any
  50912. * @param isBase64 defines whether the texture is encoded as a base64
  50913. * @param isBuffer defines whether the texture data are stored as a buffer
  50914. * @returns true if the loader can load the specified file
  50915. */
  50916. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50917. /**
  50918. * Transform the url before loading if required.
  50919. * @param rootUrl the url of the texture
  50920. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50921. * @returns the transformed texture
  50922. */
  50923. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50924. /**
  50925. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50926. * @param rootUrl the url of the texture
  50927. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50928. * @returns the fallback texture
  50929. */
  50930. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50931. /**
  50932. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50933. * @param data contains the texture data
  50934. * @param texture defines the BabylonJS internal texture
  50935. * @param createPolynomials will be true if polynomials have been requested
  50936. * @param onLoad defines the callback to trigger once the texture is ready
  50937. * @param onError defines the callback to trigger in case of error
  50938. */
  50939. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50940. /**
  50941. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50942. * @param data contains the texture data
  50943. * @param texture defines the BabylonJS internal texture
  50944. * @param callback defines the method to call once ready to upload
  50945. */
  50946. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50947. }
  50948. }
  50949. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50950. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50951. import { Scene } from "babylonjs/scene";
  50952. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50953. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50954. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50955. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50956. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50957. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50959. /**
  50960. * Options for the default xr helper
  50961. */
  50962. export class WebXRDefaultExperienceOptions {
  50963. /**
  50964. * Floor meshes that should be used for teleporting
  50965. */
  50966. floorMeshes: Array<AbstractMesh>;
  50967. }
  50968. /**
  50969. * Default experience which provides a similar setup to the previous webVRExperience
  50970. */
  50971. export class WebXRDefaultExperience {
  50972. /**
  50973. * Base experience
  50974. */
  50975. baseExperience: WebXRExperienceHelper;
  50976. /**
  50977. * Input experience extension
  50978. */
  50979. input: WebXRInput;
  50980. /**
  50981. * Loads the controller models
  50982. */
  50983. controllerModelLoader: WebXRControllerModelLoader;
  50984. /**
  50985. * Enables laser pointer and selection
  50986. */
  50987. pointerSelection: WebXRControllerPointerSelection;
  50988. /**
  50989. * Enables teleportation
  50990. */
  50991. teleportation: WebXRControllerTeleportation;
  50992. /**
  50993. * Enables ui for enetering/exiting xr
  50994. */
  50995. enterExitUI: WebXREnterExitUI;
  50996. /**
  50997. * Default output canvas xr should render to
  50998. */
  50999. outputCanvas: WebXRManagedOutputCanvas;
  51000. /**
  51001. * Creates the default xr experience
  51002. * @param scene scene
  51003. * @param options options for basic configuration
  51004. * @returns resulting WebXRDefaultExperience
  51005. */
  51006. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51007. private constructor();
  51008. /**
  51009. * DIsposes of the experience helper
  51010. */
  51011. dispose(): void;
  51012. }
  51013. }
  51014. declare module "babylonjs/Helpers/sceneHelpers" {
  51015. import { Nullable } from "babylonjs/types";
  51016. import { Mesh } from "babylonjs/Meshes/mesh";
  51017. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51018. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51019. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51020. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51021. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51022. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51023. import "babylonjs/Meshes/Builders/boxBuilder";
  51024. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51025. /** @hidden */
  51026. export var _forceSceneHelpersToBundle: boolean;
  51027. module "babylonjs/scene" {
  51028. interface Scene {
  51029. /**
  51030. * Creates a default light for the scene.
  51031. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51032. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51033. */
  51034. createDefaultLight(replace?: boolean): void;
  51035. /**
  51036. * Creates a default camera for the scene.
  51037. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51038. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51039. * @param replace has default false, when true replaces the active camera in the scene
  51040. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51041. */
  51042. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51043. /**
  51044. * Creates a default camera and a default light.
  51045. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51046. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51047. * @param replace has the default false, when true replaces the active camera/light in the scene
  51048. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51049. */
  51050. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51051. /**
  51052. * Creates a new sky box
  51053. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51054. * @param environmentTexture defines the texture to use as environment texture
  51055. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51056. * @param scale defines the overall scale of the skybox
  51057. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51058. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51059. * @returns a new mesh holding the sky box
  51060. */
  51061. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51062. /**
  51063. * Creates a new environment
  51064. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51065. * @param options defines the options you can use to configure the environment
  51066. * @returns the new EnvironmentHelper
  51067. */
  51068. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51069. /**
  51070. * Creates a new VREXperienceHelper
  51071. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51072. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51073. * @returns a new VREXperienceHelper
  51074. */
  51075. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51076. /**
  51077. * Creates a new WebXRDefaultExperience
  51078. * @see http://doc.babylonjs.com/how_to/webxr
  51079. * @param options experience options
  51080. * @returns a promise for a new WebXRDefaultExperience
  51081. */
  51082. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51083. }
  51084. }
  51085. }
  51086. declare module "babylonjs/Helpers/videoDome" {
  51087. import { Scene } from "babylonjs/scene";
  51088. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51089. import { Mesh } from "babylonjs/Meshes/mesh";
  51090. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51091. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51092. import "babylonjs/Meshes/Builders/sphereBuilder";
  51093. /**
  51094. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51095. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51096. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51097. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51098. */
  51099. export class VideoDome extends TransformNode {
  51100. /**
  51101. * Define the video source as a Monoscopic panoramic 360 video.
  51102. */
  51103. static readonly MODE_MONOSCOPIC: number;
  51104. /**
  51105. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51106. */
  51107. static readonly MODE_TOPBOTTOM: number;
  51108. /**
  51109. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51110. */
  51111. static readonly MODE_SIDEBYSIDE: number;
  51112. private _halfDome;
  51113. private _useDirectMapping;
  51114. /**
  51115. * The video texture being displayed on the sphere
  51116. */
  51117. protected _videoTexture: VideoTexture;
  51118. /**
  51119. * Gets the video texture being displayed on the sphere
  51120. */
  51121. readonly videoTexture: VideoTexture;
  51122. /**
  51123. * The skybox material
  51124. */
  51125. protected _material: BackgroundMaterial;
  51126. /**
  51127. * The surface used for the skybox
  51128. */
  51129. protected _mesh: Mesh;
  51130. /**
  51131. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51132. */
  51133. private _halfDomeMask;
  51134. /**
  51135. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51136. * Also see the options.resolution property.
  51137. */
  51138. fovMultiplier: number;
  51139. private _videoMode;
  51140. /**
  51141. * Gets or set the current video mode for the video. It can be:
  51142. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51143. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51144. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51145. */
  51146. videoMode: number;
  51147. /**
  51148. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51149. *
  51150. */
  51151. /**
  51152. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51153. */
  51154. halfDome: boolean;
  51155. /**
  51156. * Oberserver used in Stereoscopic VR Mode.
  51157. */
  51158. private _onBeforeCameraRenderObserver;
  51159. /**
  51160. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51161. * @param name Element's name, child elements will append suffixes for their own names.
  51162. * @param urlsOrVideo defines the url(s) or the video element to use
  51163. * @param options An object containing optional or exposed sub element properties
  51164. */
  51165. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51166. resolution?: number;
  51167. clickToPlay?: boolean;
  51168. autoPlay?: boolean;
  51169. loop?: boolean;
  51170. size?: number;
  51171. poster?: string;
  51172. faceForward?: boolean;
  51173. useDirectMapping?: boolean;
  51174. halfDomeMode?: boolean;
  51175. }, scene: Scene);
  51176. private _changeVideoMode;
  51177. /**
  51178. * Releases resources associated with this node.
  51179. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51180. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51181. */
  51182. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51183. }
  51184. }
  51185. declare module "babylonjs/Helpers/index" {
  51186. export * from "babylonjs/Helpers/environmentHelper";
  51187. export * from "babylonjs/Helpers/photoDome";
  51188. export * from "babylonjs/Helpers/sceneHelpers";
  51189. export * from "babylonjs/Helpers/videoDome";
  51190. }
  51191. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51192. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51193. import { IDisposable } from "babylonjs/scene";
  51194. import { Engine } from "babylonjs/Engines/engine";
  51195. /**
  51196. * This class can be used to get instrumentation data from a Babylon engine
  51197. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51198. */
  51199. export class EngineInstrumentation implements IDisposable {
  51200. /**
  51201. * Define the instrumented engine.
  51202. */
  51203. engine: Engine;
  51204. private _captureGPUFrameTime;
  51205. private _gpuFrameTimeToken;
  51206. private _gpuFrameTime;
  51207. private _captureShaderCompilationTime;
  51208. private _shaderCompilationTime;
  51209. private _onBeginFrameObserver;
  51210. private _onEndFrameObserver;
  51211. private _onBeforeShaderCompilationObserver;
  51212. private _onAfterShaderCompilationObserver;
  51213. /**
  51214. * Gets the perf counter used for GPU frame time
  51215. */
  51216. readonly gpuFrameTimeCounter: PerfCounter;
  51217. /**
  51218. * Gets the GPU frame time capture status
  51219. */
  51220. /**
  51221. * Enable or disable the GPU frame time capture
  51222. */
  51223. captureGPUFrameTime: boolean;
  51224. /**
  51225. * Gets the perf counter used for shader compilation time
  51226. */
  51227. readonly shaderCompilationTimeCounter: PerfCounter;
  51228. /**
  51229. * Gets the shader compilation time capture status
  51230. */
  51231. /**
  51232. * Enable or disable the shader compilation time capture
  51233. */
  51234. captureShaderCompilationTime: boolean;
  51235. /**
  51236. * Instantiates a new engine instrumentation.
  51237. * This class can be used to get instrumentation data from a Babylon engine
  51238. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51239. * @param engine Defines the engine to instrument
  51240. */
  51241. constructor(
  51242. /**
  51243. * Define the instrumented engine.
  51244. */
  51245. engine: Engine);
  51246. /**
  51247. * Dispose and release associated resources.
  51248. */
  51249. dispose(): void;
  51250. }
  51251. }
  51252. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51253. import { Scene, IDisposable } from "babylonjs/scene";
  51254. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51255. /**
  51256. * This class can be used to get instrumentation data from a Babylon engine
  51257. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51258. */
  51259. export class SceneInstrumentation implements IDisposable {
  51260. /**
  51261. * Defines the scene to instrument
  51262. */
  51263. scene: Scene;
  51264. private _captureActiveMeshesEvaluationTime;
  51265. private _activeMeshesEvaluationTime;
  51266. private _captureRenderTargetsRenderTime;
  51267. private _renderTargetsRenderTime;
  51268. private _captureFrameTime;
  51269. private _frameTime;
  51270. private _captureRenderTime;
  51271. private _renderTime;
  51272. private _captureInterFrameTime;
  51273. private _interFrameTime;
  51274. private _captureParticlesRenderTime;
  51275. private _particlesRenderTime;
  51276. private _captureSpritesRenderTime;
  51277. private _spritesRenderTime;
  51278. private _capturePhysicsTime;
  51279. private _physicsTime;
  51280. private _captureAnimationsTime;
  51281. private _animationsTime;
  51282. private _captureCameraRenderTime;
  51283. private _cameraRenderTime;
  51284. private _onBeforeActiveMeshesEvaluationObserver;
  51285. private _onAfterActiveMeshesEvaluationObserver;
  51286. private _onBeforeRenderTargetsRenderObserver;
  51287. private _onAfterRenderTargetsRenderObserver;
  51288. private _onAfterRenderObserver;
  51289. private _onBeforeDrawPhaseObserver;
  51290. private _onAfterDrawPhaseObserver;
  51291. private _onBeforeAnimationsObserver;
  51292. private _onBeforeParticlesRenderingObserver;
  51293. private _onAfterParticlesRenderingObserver;
  51294. private _onBeforeSpritesRenderingObserver;
  51295. private _onAfterSpritesRenderingObserver;
  51296. private _onBeforePhysicsObserver;
  51297. private _onAfterPhysicsObserver;
  51298. private _onAfterAnimationsObserver;
  51299. private _onBeforeCameraRenderObserver;
  51300. private _onAfterCameraRenderObserver;
  51301. /**
  51302. * Gets the perf counter used for active meshes evaluation time
  51303. */
  51304. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51305. /**
  51306. * Gets the active meshes evaluation time capture status
  51307. */
  51308. /**
  51309. * Enable or disable the active meshes evaluation time capture
  51310. */
  51311. captureActiveMeshesEvaluationTime: boolean;
  51312. /**
  51313. * Gets the perf counter used for render targets render time
  51314. */
  51315. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51316. /**
  51317. * Gets the render targets render time capture status
  51318. */
  51319. /**
  51320. * Enable or disable the render targets render time capture
  51321. */
  51322. captureRenderTargetsRenderTime: boolean;
  51323. /**
  51324. * Gets the perf counter used for particles render time
  51325. */
  51326. readonly particlesRenderTimeCounter: PerfCounter;
  51327. /**
  51328. * Gets the particles render time capture status
  51329. */
  51330. /**
  51331. * Enable or disable the particles render time capture
  51332. */
  51333. captureParticlesRenderTime: boolean;
  51334. /**
  51335. * Gets the perf counter used for sprites render time
  51336. */
  51337. readonly spritesRenderTimeCounter: PerfCounter;
  51338. /**
  51339. * Gets the sprites render time capture status
  51340. */
  51341. /**
  51342. * Enable or disable the sprites render time capture
  51343. */
  51344. captureSpritesRenderTime: boolean;
  51345. /**
  51346. * Gets the perf counter used for physics time
  51347. */
  51348. readonly physicsTimeCounter: PerfCounter;
  51349. /**
  51350. * Gets the physics time capture status
  51351. */
  51352. /**
  51353. * Enable or disable the physics time capture
  51354. */
  51355. capturePhysicsTime: boolean;
  51356. /**
  51357. * Gets the perf counter used for animations time
  51358. */
  51359. readonly animationsTimeCounter: PerfCounter;
  51360. /**
  51361. * Gets the animations time capture status
  51362. */
  51363. /**
  51364. * Enable or disable the animations time capture
  51365. */
  51366. captureAnimationsTime: boolean;
  51367. /**
  51368. * Gets the perf counter used for frame time capture
  51369. */
  51370. readonly frameTimeCounter: PerfCounter;
  51371. /**
  51372. * Gets the frame time capture status
  51373. */
  51374. /**
  51375. * Enable or disable the frame time capture
  51376. */
  51377. captureFrameTime: boolean;
  51378. /**
  51379. * Gets the perf counter used for inter-frames time capture
  51380. */
  51381. readonly interFrameTimeCounter: PerfCounter;
  51382. /**
  51383. * Gets the inter-frames time capture status
  51384. */
  51385. /**
  51386. * Enable or disable the inter-frames time capture
  51387. */
  51388. captureInterFrameTime: boolean;
  51389. /**
  51390. * Gets the perf counter used for render time capture
  51391. */
  51392. readonly renderTimeCounter: PerfCounter;
  51393. /**
  51394. * Gets the render time capture status
  51395. */
  51396. /**
  51397. * Enable or disable the render time capture
  51398. */
  51399. captureRenderTime: boolean;
  51400. /**
  51401. * Gets the perf counter used for camera render time capture
  51402. */
  51403. readonly cameraRenderTimeCounter: PerfCounter;
  51404. /**
  51405. * Gets the camera render time capture status
  51406. */
  51407. /**
  51408. * Enable or disable the camera render time capture
  51409. */
  51410. captureCameraRenderTime: boolean;
  51411. /**
  51412. * Gets the perf counter used for draw calls
  51413. */
  51414. readonly drawCallsCounter: PerfCounter;
  51415. /**
  51416. * Instantiates a new scene instrumentation.
  51417. * This class can be used to get instrumentation data from a Babylon engine
  51418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51419. * @param scene Defines the scene to instrument
  51420. */
  51421. constructor(
  51422. /**
  51423. * Defines the scene to instrument
  51424. */
  51425. scene: Scene);
  51426. /**
  51427. * Dispose and release associated resources.
  51428. */
  51429. dispose(): void;
  51430. }
  51431. }
  51432. declare module "babylonjs/Instrumentation/index" {
  51433. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51434. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51435. export * from "babylonjs/Instrumentation/timeToken";
  51436. }
  51437. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51438. /** @hidden */
  51439. export var glowMapGenerationPixelShader: {
  51440. name: string;
  51441. shader: string;
  51442. };
  51443. }
  51444. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51445. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51446. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51447. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51448. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51449. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51450. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51451. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51452. /** @hidden */
  51453. export var glowMapGenerationVertexShader: {
  51454. name: string;
  51455. shader: string;
  51456. };
  51457. }
  51458. declare module "babylonjs/Layers/effectLayer" {
  51459. import { Observable } from "babylonjs/Misc/observable";
  51460. import { Nullable } from "babylonjs/types";
  51461. import { Camera } from "babylonjs/Cameras/camera";
  51462. import { Scene } from "babylonjs/scene";
  51463. import { ISize } from "babylonjs/Maths/math.size";
  51464. import { Color4 } from "babylonjs/Maths/math.color";
  51465. import { Engine } from "babylonjs/Engines/engine";
  51466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51468. import { Mesh } from "babylonjs/Meshes/mesh";
  51469. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51470. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51471. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51472. import { Effect } from "babylonjs/Materials/effect";
  51473. import { Material } from "babylonjs/Materials/material";
  51474. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51475. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51476. /**
  51477. * Effect layer options. This helps customizing the behaviour
  51478. * of the effect layer.
  51479. */
  51480. export interface IEffectLayerOptions {
  51481. /**
  51482. * Multiplication factor apply to the canvas size to compute the render target size
  51483. * used to generated the objects (the smaller the faster).
  51484. */
  51485. mainTextureRatio: number;
  51486. /**
  51487. * Enforces a fixed size texture to ensure effect stability across devices.
  51488. */
  51489. mainTextureFixedSize?: number;
  51490. /**
  51491. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51492. */
  51493. alphaBlendingMode: number;
  51494. /**
  51495. * The camera attached to the layer.
  51496. */
  51497. camera: Nullable<Camera>;
  51498. /**
  51499. * The rendering group to draw the layer in.
  51500. */
  51501. renderingGroupId: number;
  51502. }
  51503. /**
  51504. * The effect layer Helps adding post process effect blended with the main pass.
  51505. *
  51506. * This can be for instance use to generate glow or higlight effects on the scene.
  51507. *
  51508. * The effect layer class can not be used directly and is intented to inherited from to be
  51509. * customized per effects.
  51510. */
  51511. export abstract class EffectLayer {
  51512. private _vertexBuffers;
  51513. private _indexBuffer;
  51514. private _cachedDefines;
  51515. private _effectLayerMapGenerationEffect;
  51516. private _effectLayerOptions;
  51517. private _mergeEffect;
  51518. protected _scene: Scene;
  51519. protected _engine: Engine;
  51520. protected _maxSize: number;
  51521. protected _mainTextureDesiredSize: ISize;
  51522. protected _mainTexture: RenderTargetTexture;
  51523. protected _shouldRender: boolean;
  51524. protected _postProcesses: PostProcess[];
  51525. protected _textures: BaseTexture[];
  51526. protected _emissiveTextureAndColor: {
  51527. texture: Nullable<BaseTexture>;
  51528. color: Color4;
  51529. };
  51530. /**
  51531. * The name of the layer
  51532. */
  51533. name: string;
  51534. /**
  51535. * The clear color of the texture used to generate the glow map.
  51536. */
  51537. neutralColor: Color4;
  51538. /**
  51539. * Specifies wether the highlight layer is enabled or not.
  51540. */
  51541. isEnabled: boolean;
  51542. /**
  51543. * Gets the camera attached to the layer.
  51544. */
  51545. readonly camera: Nullable<Camera>;
  51546. /**
  51547. * Gets the rendering group id the layer should render in.
  51548. */
  51549. renderingGroupId: number;
  51550. /**
  51551. * An event triggered when the effect layer has been disposed.
  51552. */
  51553. onDisposeObservable: Observable<EffectLayer>;
  51554. /**
  51555. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51556. */
  51557. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51558. /**
  51559. * An event triggered when the generated texture is being merged in the scene.
  51560. */
  51561. onBeforeComposeObservable: Observable<EffectLayer>;
  51562. /**
  51563. * An event triggered when the generated texture has been merged in the scene.
  51564. */
  51565. onAfterComposeObservable: Observable<EffectLayer>;
  51566. /**
  51567. * An event triggered when the efffect layer changes its size.
  51568. */
  51569. onSizeChangedObservable: Observable<EffectLayer>;
  51570. /** @hidden */
  51571. static _SceneComponentInitialization: (scene: Scene) => void;
  51572. /**
  51573. * Instantiates a new effect Layer and references it in the scene.
  51574. * @param name The name of the layer
  51575. * @param scene The scene to use the layer in
  51576. */
  51577. constructor(
  51578. /** The Friendly of the effect in the scene */
  51579. name: string, scene: Scene);
  51580. /**
  51581. * Get the effect name of the layer.
  51582. * @return The effect name
  51583. */
  51584. abstract getEffectName(): string;
  51585. /**
  51586. * Checks for the readiness of the element composing the layer.
  51587. * @param subMesh the mesh to check for
  51588. * @param useInstances specify wether or not to use instances to render the mesh
  51589. * @return true if ready otherwise, false
  51590. */
  51591. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51592. /**
  51593. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51594. * @returns true if the effect requires stencil during the main canvas render pass.
  51595. */
  51596. abstract needStencil(): boolean;
  51597. /**
  51598. * Create the merge effect. This is the shader use to blit the information back
  51599. * to the main canvas at the end of the scene rendering.
  51600. * @returns The effect containing the shader used to merge the effect on the main canvas
  51601. */
  51602. protected abstract _createMergeEffect(): Effect;
  51603. /**
  51604. * Creates the render target textures and post processes used in the effect layer.
  51605. */
  51606. protected abstract _createTextureAndPostProcesses(): void;
  51607. /**
  51608. * Implementation specific of rendering the generating effect on the main canvas.
  51609. * @param effect The effect used to render through
  51610. */
  51611. protected abstract _internalRender(effect: Effect): void;
  51612. /**
  51613. * Sets the required values for both the emissive texture and and the main color.
  51614. */
  51615. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51616. /**
  51617. * Free any resources and references associated to a mesh.
  51618. * Internal use
  51619. * @param mesh The mesh to free.
  51620. */
  51621. abstract _disposeMesh(mesh: Mesh): void;
  51622. /**
  51623. * Serializes this layer (Glow or Highlight for example)
  51624. * @returns a serialized layer object
  51625. */
  51626. abstract serialize?(): any;
  51627. /**
  51628. * Initializes the effect layer with the required options.
  51629. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51630. */
  51631. protected _init(options: Partial<IEffectLayerOptions>): void;
  51632. /**
  51633. * Generates the index buffer of the full screen quad blending to the main canvas.
  51634. */
  51635. private _generateIndexBuffer;
  51636. /**
  51637. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51638. */
  51639. private _generateVertexBuffer;
  51640. /**
  51641. * Sets the main texture desired size which is the closest power of two
  51642. * of the engine canvas size.
  51643. */
  51644. private _setMainTextureSize;
  51645. /**
  51646. * Creates the main texture for the effect layer.
  51647. */
  51648. protected _createMainTexture(): void;
  51649. /**
  51650. * Adds specific effects defines.
  51651. * @param defines The defines to add specifics to.
  51652. */
  51653. protected _addCustomEffectDefines(defines: string[]): void;
  51654. /**
  51655. * Checks for the readiness of the element composing the layer.
  51656. * @param subMesh the mesh to check for
  51657. * @param useInstances specify wether or not to use instances to render the mesh
  51658. * @param emissiveTexture the associated emissive texture used to generate the glow
  51659. * @return true if ready otherwise, false
  51660. */
  51661. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51662. /**
  51663. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51664. */
  51665. render(): void;
  51666. /**
  51667. * Determine if a given mesh will be used in the current effect.
  51668. * @param mesh mesh to test
  51669. * @returns true if the mesh will be used
  51670. */
  51671. hasMesh(mesh: AbstractMesh): boolean;
  51672. /**
  51673. * Returns true if the layer contains information to display, otherwise false.
  51674. * @returns true if the glow layer should be rendered
  51675. */
  51676. shouldRender(): boolean;
  51677. /**
  51678. * Returns true if the mesh should render, otherwise false.
  51679. * @param mesh The mesh to render
  51680. * @returns true if it should render otherwise false
  51681. */
  51682. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51683. /**
  51684. * Returns true if the mesh can be rendered, otherwise false.
  51685. * @param mesh The mesh to render
  51686. * @param material The material used on the mesh
  51687. * @returns true if it can be rendered otherwise false
  51688. */
  51689. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51690. /**
  51691. * Returns true if the mesh should render, otherwise false.
  51692. * @param mesh The mesh to render
  51693. * @returns true if it should render otherwise false
  51694. */
  51695. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51696. /**
  51697. * Renders the submesh passed in parameter to the generation map.
  51698. */
  51699. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51700. /**
  51701. * Rebuild the required buffers.
  51702. * @hidden Internal use only.
  51703. */
  51704. _rebuild(): void;
  51705. /**
  51706. * Dispose only the render target textures and post process.
  51707. */
  51708. private _disposeTextureAndPostProcesses;
  51709. /**
  51710. * Dispose the highlight layer and free resources.
  51711. */
  51712. dispose(): void;
  51713. /**
  51714. * Gets the class name of the effect layer
  51715. * @returns the string with the class name of the effect layer
  51716. */
  51717. getClassName(): string;
  51718. /**
  51719. * Creates an effect layer from parsed effect layer data
  51720. * @param parsedEffectLayer defines effect layer data
  51721. * @param scene defines the current scene
  51722. * @param rootUrl defines the root URL containing the effect layer information
  51723. * @returns a parsed effect Layer
  51724. */
  51725. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51726. }
  51727. }
  51728. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51729. import { Scene } from "babylonjs/scene";
  51730. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51731. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51732. import { AbstractScene } from "babylonjs/abstractScene";
  51733. module "babylonjs/abstractScene" {
  51734. interface AbstractScene {
  51735. /**
  51736. * The list of effect layers (highlights/glow) added to the scene
  51737. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51738. * @see http://doc.babylonjs.com/how_to/glow_layer
  51739. */
  51740. effectLayers: Array<EffectLayer>;
  51741. /**
  51742. * Removes the given effect layer from this scene.
  51743. * @param toRemove defines the effect layer to remove
  51744. * @returns the index of the removed effect layer
  51745. */
  51746. removeEffectLayer(toRemove: EffectLayer): number;
  51747. /**
  51748. * Adds the given effect layer to this scene
  51749. * @param newEffectLayer defines the effect layer to add
  51750. */
  51751. addEffectLayer(newEffectLayer: EffectLayer): void;
  51752. }
  51753. }
  51754. /**
  51755. * Defines the layer scene component responsible to manage any effect layers
  51756. * in a given scene.
  51757. */
  51758. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51759. /**
  51760. * The component name helpfull to identify the component in the list of scene components.
  51761. */
  51762. readonly name: string;
  51763. /**
  51764. * The scene the component belongs to.
  51765. */
  51766. scene: Scene;
  51767. private _engine;
  51768. private _renderEffects;
  51769. private _needStencil;
  51770. private _previousStencilState;
  51771. /**
  51772. * Creates a new instance of the component for the given scene
  51773. * @param scene Defines the scene to register the component in
  51774. */
  51775. constructor(scene: Scene);
  51776. /**
  51777. * Registers the component in a given scene
  51778. */
  51779. register(): void;
  51780. /**
  51781. * Rebuilds the elements related to this component in case of
  51782. * context lost for instance.
  51783. */
  51784. rebuild(): void;
  51785. /**
  51786. * Serializes the component data to the specified json object
  51787. * @param serializationObject The object to serialize to
  51788. */
  51789. serialize(serializationObject: any): void;
  51790. /**
  51791. * Adds all the elements from the container to the scene
  51792. * @param container the container holding the elements
  51793. */
  51794. addFromContainer(container: AbstractScene): void;
  51795. /**
  51796. * Removes all the elements in the container from the scene
  51797. * @param container contains the elements to remove
  51798. * @param dispose if the removed element should be disposed (default: false)
  51799. */
  51800. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51801. /**
  51802. * Disposes the component and the associated ressources.
  51803. */
  51804. dispose(): void;
  51805. private _isReadyForMesh;
  51806. private _renderMainTexture;
  51807. private _setStencil;
  51808. private _setStencilBack;
  51809. private _draw;
  51810. private _drawCamera;
  51811. private _drawRenderingGroup;
  51812. }
  51813. }
  51814. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51815. /** @hidden */
  51816. export var glowMapMergePixelShader: {
  51817. name: string;
  51818. shader: string;
  51819. };
  51820. }
  51821. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51822. /** @hidden */
  51823. export var glowMapMergeVertexShader: {
  51824. name: string;
  51825. shader: string;
  51826. };
  51827. }
  51828. declare module "babylonjs/Layers/glowLayer" {
  51829. import { Nullable } from "babylonjs/types";
  51830. import { Camera } from "babylonjs/Cameras/camera";
  51831. import { Scene } from "babylonjs/scene";
  51832. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51833. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51834. import { Mesh } from "babylonjs/Meshes/mesh";
  51835. import { Texture } from "babylonjs/Materials/Textures/texture";
  51836. import { Effect } from "babylonjs/Materials/effect";
  51837. import { Material } from "babylonjs/Materials/material";
  51838. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51839. import { Color4 } from "babylonjs/Maths/math.color";
  51840. import "babylonjs/Shaders/glowMapMerge.fragment";
  51841. import "babylonjs/Shaders/glowMapMerge.vertex";
  51842. import "babylonjs/Layers/effectLayerSceneComponent";
  51843. module "babylonjs/abstractScene" {
  51844. interface AbstractScene {
  51845. /**
  51846. * Return a the first highlight layer of the scene with a given name.
  51847. * @param name The name of the highlight layer to look for.
  51848. * @return The highlight layer if found otherwise null.
  51849. */
  51850. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51851. }
  51852. }
  51853. /**
  51854. * Glow layer options. This helps customizing the behaviour
  51855. * of the glow layer.
  51856. */
  51857. export interface IGlowLayerOptions {
  51858. /**
  51859. * Multiplication factor apply to the canvas size to compute the render target size
  51860. * used to generated the glowing objects (the smaller the faster).
  51861. */
  51862. mainTextureRatio: number;
  51863. /**
  51864. * Enforces a fixed size texture to ensure resize independant blur.
  51865. */
  51866. mainTextureFixedSize?: number;
  51867. /**
  51868. * How big is the kernel of the blur texture.
  51869. */
  51870. blurKernelSize: number;
  51871. /**
  51872. * The camera attached to the layer.
  51873. */
  51874. camera: Nullable<Camera>;
  51875. /**
  51876. * Enable MSAA by chosing the number of samples.
  51877. */
  51878. mainTextureSamples?: number;
  51879. /**
  51880. * The rendering group to draw the layer in.
  51881. */
  51882. renderingGroupId: number;
  51883. }
  51884. /**
  51885. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51886. *
  51887. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51888. * glowy meshes to your scene.
  51889. *
  51890. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51891. */
  51892. export class GlowLayer extends EffectLayer {
  51893. /**
  51894. * Effect Name of the layer.
  51895. */
  51896. static readonly EffectName: string;
  51897. /**
  51898. * The default blur kernel size used for the glow.
  51899. */
  51900. static DefaultBlurKernelSize: number;
  51901. /**
  51902. * The default texture size ratio used for the glow.
  51903. */
  51904. static DefaultTextureRatio: number;
  51905. /**
  51906. * Sets the kernel size of the blur.
  51907. */
  51908. /**
  51909. * Gets the kernel size of the blur.
  51910. */
  51911. blurKernelSize: number;
  51912. /**
  51913. * Sets the glow intensity.
  51914. */
  51915. /**
  51916. * Gets the glow intensity.
  51917. */
  51918. intensity: number;
  51919. private _options;
  51920. private _intensity;
  51921. private _horizontalBlurPostprocess1;
  51922. private _verticalBlurPostprocess1;
  51923. private _horizontalBlurPostprocess2;
  51924. private _verticalBlurPostprocess2;
  51925. private _blurTexture1;
  51926. private _blurTexture2;
  51927. private _postProcesses1;
  51928. private _postProcesses2;
  51929. private _includedOnlyMeshes;
  51930. private _excludedMeshes;
  51931. /**
  51932. * Callback used to let the user override the color selection on a per mesh basis
  51933. */
  51934. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51935. /**
  51936. * Callback used to let the user override the texture selection on a per mesh basis
  51937. */
  51938. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51939. /**
  51940. * Instantiates a new glow Layer and references it to the scene.
  51941. * @param name The name of the layer
  51942. * @param scene The scene to use the layer in
  51943. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51944. */
  51945. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51946. /**
  51947. * Get the effect name of the layer.
  51948. * @return The effect name
  51949. */
  51950. getEffectName(): string;
  51951. /**
  51952. * Create the merge effect. This is the shader use to blit the information back
  51953. * to the main canvas at the end of the scene rendering.
  51954. */
  51955. protected _createMergeEffect(): Effect;
  51956. /**
  51957. * Creates the render target textures and post processes used in the glow layer.
  51958. */
  51959. protected _createTextureAndPostProcesses(): void;
  51960. /**
  51961. * Checks for the readiness of the element composing the layer.
  51962. * @param subMesh the mesh to check for
  51963. * @param useInstances specify wether or not to use instances to render the mesh
  51964. * @param emissiveTexture the associated emissive texture used to generate the glow
  51965. * @return true if ready otherwise, false
  51966. */
  51967. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51968. /**
  51969. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51970. */
  51971. needStencil(): boolean;
  51972. /**
  51973. * Returns true if the mesh can be rendered, otherwise false.
  51974. * @param mesh The mesh to render
  51975. * @param material The material used on the mesh
  51976. * @returns true if it can be rendered otherwise false
  51977. */
  51978. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51979. /**
  51980. * Implementation specific of rendering the generating effect on the main canvas.
  51981. * @param effect The effect used to render through
  51982. */
  51983. protected _internalRender(effect: Effect): void;
  51984. /**
  51985. * Sets the required values for both the emissive texture and and the main color.
  51986. */
  51987. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51988. /**
  51989. * Returns true if the mesh should render, otherwise false.
  51990. * @param mesh The mesh to render
  51991. * @returns true if it should render otherwise false
  51992. */
  51993. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51994. /**
  51995. * Adds specific effects defines.
  51996. * @param defines The defines to add specifics to.
  51997. */
  51998. protected _addCustomEffectDefines(defines: string[]): void;
  51999. /**
  52000. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52001. * @param mesh The mesh to exclude from the glow layer
  52002. */
  52003. addExcludedMesh(mesh: Mesh): void;
  52004. /**
  52005. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52006. * @param mesh The mesh to remove
  52007. */
  52008. removeExcludedMesh(mesh: Mesh): void;
  52009. /**
  52010. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52011. * @param mesh The mesh to include in the glow layer
  52012. */
  52013. addIncludedOnlyMesh(mesh: Mesh): void;
  52014. /**
  52015. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52016. * @param mesh The mesh to remove
  52017. */
  52018. removeIncludedOnlyMesh(mesh: Mesh): void;
  52019. /**
  52020. * Determine if a given mesh will be used in the glow layer
  52021. * @param mesh The mesh to test
  52022. * @returns true if the mesh will be highlighted by the current glow layer
  52023. */
  52024. hasMesh(mesh: AbstractMesh): boolean;
  52025. /**
  52026. * Free any resources and references associated to a mesh.
  52027. * Internal use
  52028. * @param mesh The mesh to free.
  52029. * @hidden
  52030. */
  52031. _disposeMesh(mesh: Mesh): void;
  52032. /**
  52033. * Gets the class name of the effect layer
  52034. * @returns the string with the class name of the effect layer
  52035. */
  52036. getClassName(): string;
  52037. /**
  52038. * Serializes this glow layer
  52039. * @returns a serialized glow layer object
  52040. */
  52041. serialize(): any;
  52042. /**
  52043. * Creates a Glow Layer from parsed glow layer data
  52044. * @param parsedGlowLayer defines glow layer data
  52045. * @param scene defines the current scene
  52046. * @param rootUrl defines the root URL containing the glow layer information
  52047. * @returns a parsed Glow Layer
  52048. */
  52049. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52050. }
  52051. }
  52052. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52053. /** @hidden */
  52054. export var glowBlurPostProcessPixelShader: {
  52055. name: string;
  52056. shader: string;
  52057. };
  52058. }
  52059. declare module "babylonjs/Layers/highlightLayer" {
  52060. import { Observable } from "babylonjs/Misc/observable";
  52061. import { Nullable } from "babylonjs/types";
  52062. import { Camera } from "babylonjs/Cameras/camera";
  52063. import { Scene } from "babylonjs/scene";
  52064. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52066. import { Mesh } from "babylonjs/Meshes/mesh";
  52067. import { Effect } from "babylonjs/Materials/effect";
  52068. import { Material } from "babylonjs/Materials/material";
  52069. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52070. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52071. import "babylonjs/Shaders/glowMapMerge.fragment";
  52072. import "babylonjs/Shaders/glowMapMerge.vertex";
  52073. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52074. module "babylonjs/abstractScene" {
  52075. interface AbstractScene {
  52076. /**
  52077. * Return a the first highlight layer of the scene with a given name.
  52078. * @param name The name of the highlight layer to look for.
  52079. * @return The highlight layer if found otherwise null.
  52080. */
  52081. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52082. }
  52083. }
  52084. /**
  52085. * Highlight layer options. This helps customizing the behaviour
  52086. * of the highlight layer.
  52087. */
  52088. export interface IHighlightLayerOptions {
  52089. /**
  52090. * Multiplication factor apply to the canvas size to compute the render target size
  52091. * used to generated the glowing objects (the smaller the faster).
  52092. */
  52093. mainTextureRatio: number;
  52094. /**
  52095. * Enforces a fixed size texture to ensure resize independant blur.
  52096. */
  52097. mainTextureFixedSize?: number;
  52098. /**
  52099. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52100. * of the picture to blur (the smaller the faster).
  52101. */
  52102. blurTextureSizeRatio: number;
  52103. /**
  52104. * How big in texel of the blur texture is the vertical blur.
  52105. */
  52106. blurVerticalSize: number;
  52107. /**
  52108. * How big in texel of the blur texture is the horizontal blur.
  52109. */
  52110. blurHorizontalSize: number;
  52111. /**
  52112. * Alpha blending mode used to apply the blur. Default is combine.
  52113. */
  52114. alphaBlendingMode: number;
  52115. /**
  52116. * The camera attached to the layer.
  52117. */
  52118. camera: Nullable<Camera>;
  52119. /**
  52120. * Should we display highlight as a solid stroke?
  52121. */
  52122. isStroke?: boolean;
  52123. /**
  52124. * The rendering group to draw the layer in.
  52125. */
  52126. renderingGroupId: number;
  52127. }
  52128. /**
  52129. * The highlight layer Helps adding a glow effect around a mesh.
  52130. *
  52131. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52132. * glowy meshes to your scene.
  52133. *
  52134. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52135. */
  52136. export class HighlightLayer extends EffectLayer {
  52137. name: string;
  52138. /**
  52139. * Effect Name of the highlight layer.
  52140. */
  52141. static readonly EffectName: string;
  52142. /**
  52143. * The neutral color used during the preparation of the glow effect.
  52144. * This is black by default as the blend operation is a blend operation.
  52145. */
  52146. static NeutralColor: Color4;
  52147. /**
  52148. * Stencil value used for glowing meshes.
  52149. */
  52150. static GlowingMeshStencilReference: number;
  52151. /**
  52152. * Stencil value used for the other meshes in the scene.
  52153. */
  52154. static NormalMeshStencilReference: number;
  52155. /**
  52156. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52157. */
  52158. innerGlow: boolean;
  52159. /**
  52160. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52161. */
  52162. outerGlow: boolean;
  52163. /**
  52164. * Specifies the horizontal size of the blur.
  52165. */
  52166. /**
  52167. * Gets the horizontal size of the blur.
  52168. */
  52169. blurHorizontalSize: number;
  52170. /**
  52171. * Specifies the vertical size of the blur.
  52172. */
  52173. /**
  52174. * Gets the vertical size of the blur.
  52175. */
  52176. blurVerticalSize: number;
  52177. /**
  52178. * An event triggered when the highlight layer is being blurred.
  52179. */
  52180. onBeforeBlurObservable: Observable<HighlightLayer>;
  52181. /**
  52182. * An event triggered when the highlight layer has been blurred.
  52183. */
  52184. onAfterBlurObservable: Observable<HighlightLayer>;
  52185. private _instanceGlowingMeshStencilReference;
  52186. private _options;
  52187. private _downSamplePostprocess;
  52188. private _horizontalBlurPostprocess;
  52189. private _verticalBlurPostprocess;
  52190. private _blurTexture;
  52191. private _meshes;
  52192. private _excludedMeshes;
  52193. /**
  52194. * Instantiates a new highlight Layer and references it to the scene..
  52195. * @param name The name of the layer
  52196. * @param scene The scene to use the layer in
  52197. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52198. */
  52199. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52200. /**
  52201. * Get the effect name of the layer.
  52202. * @return The effect name
  52203. */
  52204. getEffectName(): string;
  52205. /**
  52206. * Create the merge effect. This is the shader use to blit the information back
  52207. * to the main canvas at the end of the scene rendering.
  52208. */
  52209. protected _createMergeEffect(): Effect;
  52210. /**
  52211. * Creates the render target textures and post processes used in the highlight layer.
  52212. */
  52213. protected _createTextureAndPostProcesses(): void;
  52214. /**
  52215. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52216. */
  52217. needStencil(): boolean;
  52218. /**
  52219. * Checks for the readiness of the element composing the layer.
  52220. * @param subMesh the mesh to check for
  52221. * @param useInstances specify wether or not to use instances to render the mesh
  52222. * @param emissiveTexture the associated emissive texture used to generate the glow
  52223. * @return true if ready otherwise, false
  52224. */
  52225. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52226. /**
  52227. * Implementation specific of rendering the generating effect on the main canvas.
  52228. * @param effect The effect used to render through
  52229. */
  52230. protected _internalRender(effect: Effect): void;
  52231. /**
  52232. * Returns true if the layer contains information to display, otherwise false.
  52233. */
  52234. shouldRender(): boolean;
  52235. /**
  52236. * Returns true if the mesh should render, otherwise false.
  52237. * @param mesh The mesh to render
  52238. * @returns true if it should render otherwise false
  52239. */
  52240. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52241. /**
  52242. * Sets the required values for both the emissive texture and and the main color.
  52243. */
  52244. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52245. /**
  52246. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52247. * @param mesh The mesh to exclude from the highlight layer
  52248. */
  52249. addExcludedMesh(mesh: Mesh): void;
  52250. /**
  52251. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52252. * @param mesh The mesh to highlight
  52253. */
  52254. removeExcludedMesh(mesh: Mesh): void;
  52255. /**
  52256. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52257. * @param mesh mesh to test
  52258. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52259. */
  52260. hasMesh(mesh: AbstractMesh): boolean;
  52261. /**
  52262. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52263. * @param mesh The mesh to highlight
  52264. * @param color The color of the highlight
  52265. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52266. */
  52267. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52268. /**
  52269. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52270. * @param mesh The mesh to highlight
  52271. */
  52272. removeMesh(mesh: Mesh): void;
  52273. /**
  52274. * Force the stencil to the normal expected value for none glowing parts
  52275. */
  52276. private _defaultStencilReference;
  52277. /**
  52278. * Free any resources and references associated to a mesh.
  52279. * Internal use
  52280. * @param mesh The mesh to free.
  52281. * @hidden
  52282. */
  52283. _disposeMesh(mesh: Mesh): void;
  52284. /**
  52285. * Dispose the highlight layer and free resources.
  52286. */
  52287. dispose(): void;
  52288. /**
  52289. * Gets the class name of the effect layer
  52290. * @returns the string with the class name of the effect layer
  52291. */
  52292. getClassName(): string;
  52293. /**
  52294. * Serializes this Highlight layer
  52295. * @returns a serialized Highlight layer object
  52296. */
  52297. serialize(): any;
  52298. /**
  52299. * Creates a Highlight layer from parsed Highlight layer data
  52300. * @param parsedHightlightLayer defines the Highlight layer data
  52301. * @param scene defines the current scene
  52302. * @param rootUrl defines the root URL containing the Highlight layer information
  52303. * @returns a parsed Highlight layer
  52304. */
  52305. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52306. }
  52307. }
  52308. declare module "babylonjs/Layers/layerSceneComponent" {
  52309. import { Scene } from "babylonjs/scene";
  52310. import { ISceneComponent } from "babylonjs/sceneComponent";
  52311. import { Layer } from "babylonjs/Layers/layer";
  52312. import { AbstractScene } from "babylonjs/abstractScene";
  52313. module "babylonjs/abstractScene" {
  52314. interface AbstractScene {
  52315. /**
  52316. * The list of layers (background and foreground) of the scene
  52317. */
  52318. layers: Array<Layer>;
  52319. }
  52320. }
  52321. /**
  52322. * Defines the layer scene component responsible to manage any layers
  52323. * in a given scene.
  52324. */
  52325. export class LayerSceneComponent implements ISceneComponent {
  52326. /**
  52327. * The component name helpfull to identify the component in the list of scene components.
  52328. */
  52329. readonly name: string;
  52330. /**
  52331. * The scene the component belongs to.
  52332. */
  52333. scene: Scene;
  52334. private _engine;
  52335. /**
  52336. * Creates a new instance of the component for the given scene
  52337. * @param scene Defines the scene to register the component in
  52338. */
  52339. constructor(scene: Scene);
  52340. /**
  52341. * Registers the component in a given scene
  52342. */
  52343. register(): void;
  52344. /**
  52345. * Rebuilds the elements related to this component in case of
  52346. * context lost for instance.
  52347. */
  52348. rebuild(): void;
  52349. /**
  52350. * Disposes the component and the associated ressources.
  52351. */
  52352. dispose(): void;
  52353. private _draw;
  52354. private _drawCameraPredicate;
  52355. private _drawCameraBackground;
  52356. private _drawCameraForeground;
  52357. private _drawRenderTargetPredicate;
  52358. private _drawRenderTargetBackground;
  52359. private _drawRenderTargetForeground;
  52360. /**
  52361. * Adds all the elements from the container to the scene
  52362. * @param container the container holding the elements
  52363. */
  52364. addFromContainer(container: AbstractScene): void;
  52365. /**
  52366. * Removes all the elements in the container from the scene
  52367. * @param container contains the elements to remove
  52368. * @param dispose if the removed element should be disposed (default: false)
  52369. */
  52370. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52371. }
  52372. }
  52373. declare module "babylonjs/Shaders/layer.fragment" {
  52374. /** @hidden */
  52375. export var layerPixelShader: {
  52376. name: string;
  52377. shader: string;
  52378. };
  52379. }
  52380. declare module "babylonjs/Shaders/layer.vertex" {
  52381. /** @hidden */
  52382. export var layerVertexShader: {
  52383. name: string;
  52384. shader: string;
  52385. };
  52386. }
  52387. declare module "babylonjs/Layers/layer" {
  52388. import { Observable } from "babylonjs/Misc/observable";
  52389. import { Nullable } from "babylonjs/types";
  52390. import { Scene } from "babylonjs/scene";
  52391. import { Vector2 } from "babylonjs/Maths/math.vector";
  52392. import { Color4 } from "babylonjs/Maths/math.color";
  52393. import { Texture } from "babylonjs/Materials/Textures/texture";
  52394. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52395. import "babylonjs/Shaders/layer.fragment";
  52396. import "babylonjs/Shaders/layer.vertex";
  52397. /**
  52398. * This represents a full screen 2d layer.
  52399. * This can be useful to display a picture in the background of your scene for instance.
  52400. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52401. */
  52402. export class Layer {
  52403. /**
  52404. * Define the name of the layer.
  52405. */
  52406. name: string;
  52407. /**
  52408. * Define the texture the layer should display.
  52409. */
  52410. texture: Nullable<Texture>;
  52411. /**
  52412. * Is the layer in background or foreground.
  52413. */
  52414. isBackground: boolean;
  52415. /**
  52416. * Define the color of the layer (instead of texture).
  52417. */
  52418. color: Color4;
  52419. /**
  52420. * Define the scale of the layer in order to zoom in out of the texture.
  52421. */
  52422. scale: Vector2;
  52423. /**
  52424. * Define an offset for the layer in order to shift the texture.
  52425. */
  52426. offset: Vector2;
  52427. /**
  52428. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52429. */
  52430. alphaBlendingMode: number;
  52431. /**
  52432. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52433. * Alpha test will not mix with the background color in case of transparency.
  52434. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52435. */
  52436. alphaTest: boolean;
  52437. /**
  52438. * Define a mask to restrict the layer to only some of the scene cameras.
  52439. */
  52440. layerMask: number;
  52441. /**
  52442. * Define the list of render target the layer is visible into.
  52443. */
  52444. renderTargetTextures: RenderTargetTexture[];
  52445. /**
  52446. * Define if the layer is only used in renderTarget or if it also
  52447. * renders in the main frame buffer of the canvas.
  52448. */
  52449. renderOnlyInRenderTargetTextures: boolean;
  52450. private _scene;
  52451. private _vertexBuffers;
  52452. private _indexBuffer;
  52453. private _effect;
  52454. private _alphaTestEffect;
  52455. /**
  52456. * An event triggered when the layer is disposed.
  52457. */
  52458. onDisposeObservable: Observable<Layer>;
  52459. private _onDisposeObserver;
  52460. /**
  52461. * Back compatibility with callback before the onDisposeObservable existed.
  52462. * The set callback will be triggered when the layer has been disposed.
  52463. */
  52464. onDispose: () => void;
  52465. /**
  52466. * An event triggered before rendering the scene
  52467. */
  52468. onBeforeRenderObservable: Observable<Layer>;
  52469. private _onBeforeRenderObserver;
  52470. /**
  52471. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52472. * The set callback will be triggered just before rendering the layer.
  52473. */
  52474. onBeforeRender: () => void;
  52475. /**
  52476. * An event triggered after rendering the scene
  52477. */
  52478. onAfterRenderObservable: Observable<Layer>;
  52479. private _onAfterRenderObserver;
  52480. /**
  52481. * Back compatibility with callback before the onAfterRenderObservable existed.
  52482. * The set callback will be triggered just after rendering the layer.
  52483. */
  52484. onAfterRender: () => void;
  52485. /**
  52486. * Instantiates a new layer.
  52487. * This represents a full screen 2d layer.
  52488. * This can be useful to display a picture in the background of your scene for instance.
  52489. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52490. * @param name Define the name of the layer in the scene
  52491. * @param imgUrl Define the url of the texture to display in the layer
  52492. * @param scene Define the scene the layer belongs to
  52493. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52494. * @param color Defines a color for the layer
  52495. */
  52496. constructor(
  52497. /**
  52498. * Define the name of the layer.
  52499. */
  52500. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52501. private _createIndexBuffer;
  52502. /** @hidden */
  52503. _rebuild(): void;
  52504. /**
  52505. * Renders the layer in the scene.
  52506. */
  52507. render(): void;
  52508. /**
  52509. * Disposes and releases the associated ressources.
  52510. */
  52511. dispose(): void;
  52512. }
  52513. }
  52514. declare module "babylonjs/Layers/index" {
  52515. export * from "babylonjs/Layers/effectLayer";
  52516. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52517. export * from "babylonjs/Layers/glowLayer";
  52518. export * from "babylonjs/Layers/highlightLayer";
  52519. export * from "babylonjs/Layers/layer";
  52520. export * from "babylonjs/Layers/layerSceneComponent";
  52521. }
  52522. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52523. /** @hidden */
  52524. export var lensFlarePixelShader: {
  52525. name: string;
  52526. shader: string;
  52527. };
  52528. }
  52529. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52530. /** @hidden */
  52531. export var lensFlareVertexShader: {
  52532. name: string;
  52533. shader: string;
  52534. };
  52535. }
  52536. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52537. import { Scene } from "babylonjs/scene";
  52538. import { Vector3 } from "babylonjs/Maths/math.vector";
  52539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52540. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52541. import "babylonjs/Shaders/lensFlare.fragment";
  52542. import "babylonjs/Shaders/lensFlare.vertex";
  52543. import { Viewport } from "babylonjs/Maths/math.viewport";
  52544. /**
  52545. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52546. * It is usually composed of several `lensFlare`.
  52547. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52548. */
  52549. export class LensFlareSystem {
  52550. /**
  52551. * Define the name of the lens flare system
  52552. */
  52553. name: string;
  52554. /**
  52555. * List of lens flares used in this system.
  52556. */
  52557. lensFlares: LensFlare[];
  52558. /**
  52559. * Define a limit from the border the lens flare can be visible.
  52560. */
  52561. borderLimit: number;
  52562. /**
  52563. * Define a viewport border we do not want to see the lens flare in.
  52564. */
  52565. viewportBorder: number;
  52566. /**
  52567. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52568. */
  52569. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52570. /**
  52571. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52572. */
  52573. layerMask: number;
  52574. /**
  52575. * Define the id of the lens flare system in the scene.
  52576. * (equal to name by default)
  52577. */
  52578. id: string;
  52579. private _scene;
  52580. private _emitter;
  52581. private _vertexBuffers;
  52582. private _indexBuffer;
  52583. private _effect;
  52584. private _positionX;
  52585. private _positionY;
  52586. private _isEnabled;
  52587. /** @hidden */
  52588. static _SceneComponentInitialization: (scene: Scene) => void;
  52589. /**
  52590. * Instantiates a lens flare system.
  52591. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52592. * It is usually composed of several `lensFlare`.
  52593. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52594. * @param name Define the name of the lens flare system in the scene
  52595. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52596. * @param scene Define the scene the lens flare system belongs to
  52597. */
  52598. constructor(
  52599. /**
  52600. * Define the name of the lens flare system
  52601. */
  52602. name: string, emitter: any, scene: Scene);
  52603. /**
  52604. * Define if the lens flare system is enabled.
  52605. */
  52606. isEnabled: boolean;
  52607. /**
  52608. * Get the scene the effects belongs to.
  52609. * @returns the scene holding the lens flare system
  52610. */
  52611. getScene(): Scene;
  52612. /**
  52613. * Get the emitter of the lens flare system.
  52614. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52615. * @returns the emitter of the lens flare system
  52616. */
  52617. getEmitter(): any;
  52618. /**
  52619. * Set the emitter of the lens flare system.
  52620. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52621. * @param newEmitter Define the new emitter of the system
  52622. */
  52623. setEmitter(newEmitter: any): void;
  52624. /**
  52625. * Get the lens flare system emitter position.
  52626. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52627. * @returns the position
  52628. */
  52629. getEmitterPosition(): Vector3;
  52630. /**
  52631. * @hidden
  52632. */
  52633. computeEffectivePosition(globalViewport: Viewport): boolean;
  52634. /** @hidden */
  52635. _isVisible(): boolean;
  52636. /**
  52637. * @hidden
  52638. */
  52639. render(): boolean;
  52640. /**
  52641. * Dispose and release the lens flare with its associated resources.
  52642. */
  52643. dispose(): void;
  52644. /**
  52645. * Parse a lens flare system from a JSON repressentation
  52646. * @param parsedLensFlareSystem Define the JSON to parse
  52647. * @param scene Define the scene the parsed system should be instantiated in
  52648. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52649. * @returns the parsed system
  52650. */
  52651. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52652. /**
  52653. * Serialize the current Lens Flare System into a JSON representation.
  52654. * @returns the serialized JSON
  52655. */
  52656. serialize(): any;
  52657. }
  52658. }
  52659. declare module "babylonjs/LensFlares/lensFlare" {
  52660. import { Nullable } from "babylonjs/types";
  52661. import { Color3 } from "babylonjs/Maths/math.color";
  52662. import { Texture } from "babylonjs/Materials/Textures/texture";
  52663. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52664. /**
  52665. * This represents one of the lens effect in a `lensFlareSystem`.
  52666. * It controls one of the indiviual texture used in the effect.
  52667. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52668. */
  52669. export class LensFlare {
  52670. /**
  52671. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52672. */
  52673. size: number;
  52674. /**
  52675. * 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.
  52676. */
  52677. position: number;
  52678. /**
  52679. * Define the lens color.
  52680. */
  52681. color: Color3;
  52682. /**
  52683. * Define the lens texture.
  52684. */
  52685. texture: Nullable<Texture>;
  52686. /**
  52687. * Define the alpha mode to render this particular lens.
  52688. */
  52689. alphaMode: number;
  52690. private _system;
  52691. /**
  52692. * Creates a new Lens Flare.
  52693. * This represents one of the lens effect in a `lensFlareSystem`.
  52694. * It controls one of the indiviual texture used in the effect.
  52695. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52696. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52697. * @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.
  52698. * @param color Define the lens color
  52699. * @param imgUrl Define the lens texture url
  52700. * @param system Define the `lensFlareSystem` this flare is part of
  52701. * @returns The newly created Lens Flare
  52702. */
  52703. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52704. /**
  52705. * Instantiates a new Lens Flare.
  52706. * This represents one of the lens effect in a `lensFlareSystem`.
  52707. * It controls one of the indiviual texture used in the effect.
  52708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52709. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52710. * @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.
  52711. * @param color Define the lens color
  52712. * @param imgUrl Define the lens texture url
  52713. * @param system Define the `lensFlareSystem` this flare is part of
  52714. */
  52715. constructor(
  52716. /**
  52717. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52718. */
  52719. size: number,
  52720. /**
  52721. * 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.
  52722. */
  52723. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52724. /**
  52725. * Dispose and release the lens flare with its associated resources.
  52726. */
  52727. dispose(): void;
  52728. }
  52729. }
  52730. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52731. import { Nullable } from "babylonjs/types";
  52732. import { Scene } from "babylonjs/scene";
  52733. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52734. import { AbstractScene } from "babylonjs/abstractScene";
  52735. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52736. module "babylonjs/abstractScene" {
  52737. interface AbstractScene {
  52738. /**
  52739. * The list of lens flare system added to the scene
  52740. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52741. */
  52742. lensFlareSystems: Array<LensFlareSystem>;
  52743. /**
  52744. * Removes the given lens flare system from this scene.
  52745. * @param toRemove The lens flare system to remove
  52746. * @returns The index of the removed lens flare system
  52747. */
  52748. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52749. /**
  52750. * Adds the given lens flare system to this scene
  52751. * @param newLensFlareSystem The lens flare system to add
  52752. */
  52753. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52754. /**
  52755. * Gets a lens flare system using its name
  52756. * @param name defines the name to look for
  52757. * @returns the lens flare system or null if not found
  52758. */
  52759. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52760. /**
  52761. * Gets a lens flare system using its id
  52762. * @param id defines the id to look for
  52763. * @returns the lens flare system or null if not found
  52764. */
  52765. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52766. }
  52767. }
  52768. /**
  52769. * Defines the lens flare scene component responsible to manage any lens flares
  52770. * in a given scene.
  52771. */
  52772. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52773. /**
  52774. * The component name helpfull to identify the component in the list of scene components.
  52775. */
  52776. readonly name: string;
  52777. /**
  52778. * The scene the component belongs to.
  52779. */
  52780. scene: Scene;
  52781. /**
  52782. * Creates a new instance of the component for the given scene
  52783. * @param scene Defines the scene to register the component in
  52784. */
  52785. constructor(scene: Scene);
  52786. /**
  52787. * Registers the component in a given scene
  52788. */
  52789. register(): void;
  52790. /**
  52791. * Rebuilds the elements related to this component in case of
  52792. * context lost for instance.
  52793. */
  52794. rebuild(): void;
  52795. /**
  52796. * Adds all the elements from the container to the scene
  52797. * @param container the container holding the elements
  52798. */
  52799. addFromContainer(container: AbstractScene): void;
  52800. /**
  52801. * Removes all the elements in the container from the scene
  52802. * @param container contains the elements to remove
  52803. * @param dispose if the removed element should be disposed (default: false)
  52804. */
  52805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52806. /**
  52807. * Serializes the component data to the specified json object
  52808. * @param serializationObject The object to serialize to
  52809. */
  52810. serialize(serializationObject: any): void;
  52811. /**
  52812. * Disposes the component and the associated ressources.
  52813. */
  52814. dispose(): void;
  52815. private _draw;
  52816. }
  52817. }
  52818. declare module "babylonjs/LensFlares/index" {
  52819. export * from "babylonjs/LensFlares/lensFlare";
  52820. export * from "babylonjs/LensFlares/lensFlareSystem";
  52821. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52822. }
  52823. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52824. import { Scene } from "babylonjs/scene";
  52825. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52826. import { AbstractScene } from "babylonjs/abstractScene";
  52827. /**
  52828. * Defines the shadow generator component responsible to manage any shadow generators
  52829. * in a given scene.
  52830. */
  52831. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52832. /**
  52833. * The component name helpfull to identify the component in the list of scene components.
  52834. */
  52835. readonly name: string;
  52836. /**
  52837. * The scene the component belongs to.
  52838. */
  52839. scene: Scene;
  52840. /**
  52841. * Creates a new instance of the component for the given scene
  52842. * @param scene Defines the scene to register the component in
  52843. */
  52844. constructor(scene: Scene);
  52845. /**
  52846. * Registers the component in a given scene
  52847. */
  52848. register(): void;
  52849. /**
  52850. * Rebuilds the elements related to this component in case of
  52851. * context lost for instance.
  52852. */
  52853. rebuild(): void;
  52854. /**
  52855. * Serializes the component data to the specified json object
  52856. * @param serializationObject The object to serialize to
  52857. */
  52858. serialize(serializationObject: any): void;
  52859. /**
  52860. * Adds all the elements from the container to the scene
  52861. * @param container the container holding the elements
  52862. */
  52863. addFromContainer(container: AbstractScene): void;
  52864. /**
  52865. * Removes all the elements in the container from the scene
  52866. * @param container contains the elements to remove
  52867. * @param dispose if the removed element should be disposed (default: false)
  52868. */
  52869. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52870. /**
  52871. * Rebuilds the elements related to this component in case of
  52872. * context lost for instance.
  52873. */
  52874. dispose(): void;
  52875. private _gatherRenderTargets;
  52876. }
  52877. }
  52878. declare module "babylonjs/Lights/Shadows/index" {
  52879. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52880. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52881. }
  52882. declare module "babylonjs/Lights/pointLight" {
  52883. import { Scene } from "babylonjs/scene";
  52884. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52886. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52887. import { Effect } from "babylonjs/Materials/effect";
  52888. /**
  52889. * A point light is a light defined by an unique point in world space.
  52890. * The light is emitted in every direction from this point.
  52891. * A good example of a point light is a standard light bulb.
  52892. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52893. */
  52894. export class PointLight extends ShadowLight {
  52895. private _shadowAngle;
  52896. /**
  52897. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52898. * This specifies what angle the shadow will use to be created.
  52899. *
  52900. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52901. */
  52902. /**
  52903. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52904. * This specifies what angle the shadow will use to be created.
  52905. *
  52906. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52907. */
  52908. shadowAngle: number;
  52909. /**
  52910. * Gets the direction if it has been set.
  52911. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52912. */
  52913. /**
  52914. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52915. */
  52916. direction: Vector3;
  52917. /**
  52918. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52919. * A PointLight emits the light in every direction.
  52920. * It can cast shadows.
  52921. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52922. * ```javascript
  52923. * var pointLight = new PointLight("pl", camera.position, scene);
  52924. * ```
  52925. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52926. * @param name The light friendly name
  52927. * @param position The position of the point light in the scene
  52928. * @param scene The scene the lights belongs to
  52929. */
  52930. constructor(name: string, position: Vector3, scene: Scene);
  52931. /**
  52932. * Returns the string "PointLight"
  52933. * @returns the class name
  52934. */
  52935. getClassName(): string;
  52936. /**
  52937. * Returns the integer 0.
  52938. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52939. */
  52940. getTypeID(): number;
  52941. /**
  52942. * Specifies wether or not the shadowmap should be a cube texture.
  52943. * @returns true if the shadowmap needs to be a cube texture.
  52944. */
  52945. needCube(): boolean;
  52946. /**
  52947. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52948. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52949. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52950. */
  52951. getShadowDirection(faceIndex?: number): Vector3;
  52952. /**
  52953. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52954. * - fov = PI / 2
  52955. * - aspect ratio : 1.0
  52956. * - z-near and far equal to the active camera minZ and maxZ.
  52957. * Returns the PointLight.
  52958. */
  52959. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52960. protected _buildUniformLayout(): void;
  52961. /**
  52962. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52963. * @param effect The effect to update
  52964. * @param lightIndex The index of the light in the effect to update
  52965. * @returns The point light
  52966. */
  52967. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52968. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52969. /**
  52970. * Prepares the list of defines specific to the light type.
  52971. * @param defines the list of defines
  52972. * @param lightIndex defines the index of the light for the effect
  52973. */
  52974. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52975. }
  52976. }
  52977. declare module "babylonjs/Lights/index" {
  52978. export * from "babylonjs/Lights/light";
  52979. export * from "babylonjs/Lights/shadowLight";
  52980. export * from "babylonjs/Lights/Shadows/index";
  52981. export * from "babylonjs/Lights/directionalLight";
  52982. export * from "babylonjs/Lights/hemisphericLight";
  52983. export * from "babylonjs/Lights/pointLight";
  52984. export * from "babylonjs/Lights/spotLight";
  52985. }
  52986. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52987. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52988. /**
  52989. * Header information of HDR texture files.
  52990. */
  52991. export interface HDRInfo {
  52992. /**
  52993. * The height of the texture in pixels.
  52994. */
  52995. height: number;
  52996. /**
  52997. * The width of the texture in pixels.
  52998. */
  52999. width: number;
  53000. /**
  53001. * The index of the beginning of the data in the binary file.
  53002. */
  53003. dataPosition: number;
  53004. }
  53005. /**
  53006. * This groups tools to convert HDR texture to native colors array.
  53007. */
  53008. export class HDRTools {
  53009. private static Ldexp;
  53010. private static Rgbe2float;
  53011. private static readStringLine;
  53012. /**
  53013. * Reads header information from an RGBE texture stored in a native array.
  53014. * More information on this format are available here:
  53015. * https://en.wikipedia.org/wiki/RGBE_image_format
  53016. *
  53017. * @param uint8array The binary file stored in native array.
  53018. * @return The header information.
  53019. */
  53020. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53021. /**
  53022. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53023. * This RGBE texture needs to store the information as a panorama.
  53024. *
  53025. * More information on this format are available here:
  53026. * https://en.wikipedia.org/wiki/RGBE_image_format
  53027. *
  53028. * @param buffer The binary file stored in an array buffer.
  53029. * @param size The expected size of the extracted cubemap.
  53030. * @return The Cube Map information.
  53031. */
  53032. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53033. /**
  53034. * Returns the pixels data extracted from an RGBE texture.
  53035. * This pixels will be stored left to right up to down in the R G B order in one array.
  53036. *
  53037. * More information on this format are available here:
  53038. * https://en.wikipedia.org/wiki/RGBE_image_format
  53039. *
  53040. * @param uint8array The binary file stored in an array buffer.
  53041. * @param hdrInfo The header information of the file.
  53042. * @return The pixels data in RGB right to left up to down order.
  53043. */
  53044. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53045. private static RGBE_ReadPixels_RLE;
  53046. }
  53047. }
  53048. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53049. import { Nullable } from "babylonjs/types";
  53050. import { Scene } from "babylonjs/scene";
  53051. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53052. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53053. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53054. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53055. /**
  53056. * This represents a texture coming from an HDR input.
  53057. *
  53058. * The only supported format is currently panorama picture stored in RGBE format.
  53059. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53060. */
  53061. export class HDRCubeTexture extends BaseTexture {
  53062. private static _facesMapping;
  53063. private _generateHarmonics;
  53064. private _noMipmap;
  53065. private _textureMatrix;
  53066. private _size;
  53067. private _onLoad;
  53068. private _onError;
  53069. /**
  53070. * The texture URL.
  53071. */
  53072. url: string;
  53073. /**
  53074. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53075. */
  53076. coordinatesMode: number;
  53077. protected _isBlocking: boolean;
  53078. /**
  53079. * Sets wether or not the texture is blocking during loading.
  53080. */
  53081. /**
  53082. * Gets wether or not the texture is blocking during loading.
  53083. */
  53084. isBlocking: boolean;
  53085. protected _rotationY: number;
  53086. /**
  53087. * Sets texture matrix rotation angle around Y axis in radians.
  53088. */
  53089. /**
  53090. * Gets texture matrix rotation angle around Y axis radians.
  53091. */
  53092. rotationY: number;
  53093. /**
  53094. * Gets or sets the center of the bounding box associated with the cube texture
  53095. * It must define where the camera used to render the texture was set
  53096. */
  53097. boundingBoxPosition: Vector3;
  53098. private _boundingBoxSize;
  53099. /**
  53100. * Gets or sets the size of the bounding box associated with the cube texture
  53101. * When defined, the cubemap will switch to local mode
  53102. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53103. * @example https://www.babylonjs-playground.com/#RNASML
  53104. */
  53105. boundingBoxSize: Vector3;
  53106. /**
  53107. * Instantiates an HDRTexture from the following parameters.
  53108. *
  53109. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53110. * @param scene The scene the texture will be used in
  53111. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53112. * @param noMipmap Forces to not generate the mipmap if true
  53113. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53114. * @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)
  53115. * @param reserved Reserved flag for internal use.
  53116. */
  53117. 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>);
  53118. /**
  53119. * Get the current class name of the texture useful for serialization or dynamic coding.
  53120. * @returns "HDRCubeTexture"
  53121. */
  53122. getClassName(): string;
  53123. /**
  53124. * Occurs when the file is raw .hdr file.
  53125. */
  53126. private loadTexture;
  53127. clone(): HDRCubeTexture;
  53128. delayLoad(): void;
  53129. /**
  53130. * Get the texture reflection matrix used to rotate/transform the reflection.
  53131. * @returns the reflection matrix
  53132. */
  53133. getReflectionTextureMatrix(): Matrix;
  53134. /**
  53135. * Set the texture reflection matrix used to rotate/transform the reflection.
  53136. * @param value Define the reflection matrix to set
  53137. */
  53138. setReflectionTextureMatrix(value: Matrix): void;
  53139. /**
  53140. * Parses a JSON representation of an HDR Texture in order to create the texture
  53141. * @param parsedTexture Define the JSON representation
  53142. * @param scene Define the scene the texture should be created in
  53143. * @param rootUrl Define the root url in case we need to load relative dependencies
  53144. * @returns the newly created texture after parsing
  53145. */
  53146. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53147. serialize(): any;
  53148. }
  53149. }
  53150. declare module "babylonjs/Physics/physicsEngine" {
  53151. import { Nullable } from "babylonjs/types";
  53152. import { Vector3 } from "babylonjs/Maths/math.vector";
  53153. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53154. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53155. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53156. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53157. /**
  53158. * Class used to control physics engine
  53159. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53160. */
  53161. export class PhysicsEngine implements IPhysicsEngine {
  53162. private _physicsPlugin;
  53163. /**
  53164. * Global value used to control the smallest number supported by the simulation
  53165. */
  53166. static Epsilon: number;
  53167. private _impostors;
  53168. private _joints;
  53169. /**
  53170. * Gets the gravity vector used by the simulation
  53171. */
  53172. gravity: Vector3;
  53173. /**
  53174. * Factory used to create the default physics plugin.
  53175. * @returns The default physics plugin
  53176. */
  53177. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53178. /**
  53179. * Creates a new Physics Engine
  53180. * @param gravity defines the gravity vector used by the simulation
  53181. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53182. */
  53183. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53184. /**
  53185. * Sets the gravity vector used by the simulation
  53186. * @param gravity defines the gravity vector to use
  53187. */
  53188. setGravity(gravity: Vector3): void;
  53189. /**
  53190. * Set the time step of the physics engine.
  53191. * Default is 1/60.
  53192. * To slow it down, enter 1/600 for example.
  53193. * To speed it up, 1/30
  53194. * @param newTimeStep defines the new timestep to apply to this world.
  53195. */
  53196. setTimeStep(newTimeStep?: number): void;
  53197. /**
  53198. * Get the time step of the physics engine.
  53199. * @returns the current time step
  53200. */
  53201. getTimeStep(): number;
  53202. /**
  53203. * Release all resources
  53204. */
  53205. dispose(): void;
  53206. /**
  53207. * Gets the name of the current physics plugin
  53208. * @returns the name of the plugin
  53209. */
  53210. getPhysicsPluginName(): string;
  53211. /**
  53212. * Adding a new impostor for the impostor tracking.
  53213. * This will be done by the impostor itself.
  53214. * @param impostor the impostor to add
  53215. */
  53216. addImpostor(impostor: PhysicsImpostor): void;
  53217. /**
  53218. * Remove an impostor from the engine.
  53219. * This impostor and its mesh will not longer be updated by the physics engine.
  53220. * @param impostor the impostor to remove
  53221. */
  53222. removeImpostor(impostor: PhysicsImpostor): void;
  53223. /**
  53224. * Add a joint to the physics engine
  53225. * @param mainImpostor defines the main impostor to which the joint is added.
  53226. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53227. * @param joint defines the joint that will connect both impostors.
  53228. */
  53229. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53230. /**
  53231. * Removes a joint from the simulation
  53232. * @param mainImpostor defines the impostor used with the joint
  53233. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53234. * @param joint defines the joint to remove
  53235. */
  53236. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53237. /**
  53238. * Called by the scene. No need to call it.
  53239. * @param delta defines the timespam between frames
  53240. */
  53241. _step(delta: number): void;
  53242. /**
  53243. * Gets the current plugin used to run the simulation
  53244. * @returns current plugin
  53245. */
  53246. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53247. /**
  53248. * Gets the list of physic impostors
  53249. * @returns an array of PhysicsImpostor
  53250. */
  53251. getImpostors(): Array<PhysicsImpostor>;
  53252. /**
  53253. * Gets the impostor for a physics enabled object
  53254. * @param object defines the object impersonated by the impostor
  53255. * @returns the PhysicsImpostor or null if not found
  53256. */
  53257. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53258. /**
  53259. * Gets the impostor for a physics body object
  53260. * @param body defines physics body used by the impostor
  53261. * @returns the PhysicsImpostor or null if not found
  53262. */
  53263. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53264. /**
  53265. * Does a raycast in the physics world
  53266. * @param from when should the ray start?
  53267. * @param to when should the ray end?
  53268. * @returns PhysicsRaycastResult
  53269. */
  53270. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53271. }
  53272. }
  53273. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53274. import { Nullable } from "babylonjs/types";
  53275. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53276. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53277. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53278. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53279. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53280. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53281. /** @hidden */
  53282. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53283. private _useDeltaForWorldStep;
  53284. world: any;
  53285. name: string;
  53286. private _physicsMaterials;
  53287. private _fixedTimeStep;
  53288. private _cannonRaycastResult;
  53289. private _raycastResult;
  53290. private _physicsBodysToRemoveAfterStep;
  53291. BJSCANNON: any;
  53292. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53293. setGravity(gravity: Vector3): void;
  53294. setTimeStep(timeStep: number): void;
  53295. getTimeStep(): number;
  53296. executeStep(delta: number): void;
  53297. private _removeMarkedPhysicsBodiesFromWorld;
  53298. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53299. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53300. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53301. private _processChildMeshes;
  53302. removePhysicsBody(impostor: PhysicsImpostor): void;
  53303. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53304. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53305. private _addMaterial;
  53306. private _checkWithEpsilon;
  53307. private _createShape;
  53308. private _createHeightmap;
  53309. private _minus90X;
  53310. private _plus90X;
  53311. private _tmpPosition;
  53312. private _tmpDeltaPosition;
  53313. private _tmpUnityRotation;
  53314. private _updatePhysicsBodyTransformation;
  53315. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53316. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53317. isSupported(): boolean;
  53318. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53319. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53320. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53321. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53322. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53323. getBodyMass(impostor: PhysicsImpostor): number;
  53324. getBodyFriction(impostor: PhysicsImpostor): number;
  53325. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53326. getBodyRestitution(impostor: PhysicsImpostor): number;
  53327. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53328. sleepBody(impostor: PhysicsImpostor): void;
  53329. wakeUpBody(impostor: PhysicsImpostor): void;
  53330. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53331. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53332. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53333. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53334. getRadius(impostor: PhysicsImpostor): number;
  53335. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53336. dispose(): void;
  53337. private _extendNamespace;
  53338. /**
  53339. * Does a raycast in the physics world
  53340. * @param from when should the ray start?
  53341. * @param to when should the ray end?
  53342. * @returns PhysicsRaycastResult
  53343. */
  53344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53345. }
  53346. }
  53347. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53348. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53349. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53350. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53352. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53353. import { Nullable } from "babylonjs/types";
  53354. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53355. /** @hidden */
  53356. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53357. world: any;
  53358. name: string;
  53359. BJSOIMO: any;
  53360. private _raycastResult;
  53361. constructor(iterations?: number, oimoInjection?: any);
  53362. setGravity(gravity: Vector3): void;
  53363. setTimeStep(timeStep: number): void;
  53364. getTimeStep(): number;
  53365. private _tmpImpostorsArray;
  53366. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53367. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53368. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53369. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53370. private _tmpPositionVector;
  53371. removePhysicsBody(impostor: PhysicsImpostor): void;
  53372. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53373. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53374. isSupported(): boolean;
  53375. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53376. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53377. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53378. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53379. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53380. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53381. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53382. getBodyMass(impostor: PhysicsImpostor): number;
  53383. getBodyFriction(impostor: PhysicsImpostor): number;
  53384. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53385. getBodyRestitution(impostor: PhysicsImpostor): number;
  53386. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53387. sleepBody(impostor: PhysicsImpostor): void;
  53388. wakeUpBody(impostor: PhysicsImpostor): void;
  53389. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53390. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53391. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53393. getRadius(impostor: PhysicsImpostor): number;
  53394. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53395. dispose(): void;
  53396. /**
  53397. * Does a raycast in the physics world
  53398. * @param from when should the ray start?
  53399. * @param to when should the ray end?
  53400. * @returns PhysicsRaycastResult
  53401. */
  53402. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53403. }
  53404. }
  53405. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53406. import { Nullable } from "babylonjs/types";
  53407. import { Scene } from "babylonjs/scene";
  53408. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53409. import { Color4 } from "babylonjs/Maths/math.color";
  53410. import { Mesh } from "babylonjs/Meshes/mesh";
  53411. /**
  53412. * Class containing static functions to help procedurally build meshes
  53413. */
  53414. export class RibbonBuilder {
  53415. /**
  53416. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53417. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53418. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53419. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53420. * * 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
  53421. * * 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
  53422. * * 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
  53423. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53424. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53425. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53426. * * 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
  53427. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53428. * * 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
  53429. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53431. * @param name defines the name of the mesh
  53432. * @param options defines the options used to create the mesh
  53433. * @param scene defines the hosting scene
  53434. * @returns the ribbon mesh
  53435. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53436. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53437. */
  53438. static CreateRibbon(name: string, options: {
  53439. pathArray: Vector3[][];
  53440. closeArray?: boolean;
  53441. closePath?: boolean;
  53442. offset?: number;
  53443. updatable?: boolean;
  53444. sideOrientation?: number;
  53445. frontUVs?: Vector4;
  53446. backUVs?: Vector4;
  53447. instance?: Mesh;
  53448. invertUV?: boolean;
  53449. uvs?: Vector2[];
  53450. colors?: Color4[];
  53451. }, scene?: Nullable<Scene>): Mesh;
  53452. }
  53453. }
  53454. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53455. import { Nullable } from "babylonjs/types";
  53456. import { Scene } from "babylonjs/scene";
  53457. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53458. import { Mesh } from "babylonjs/Meshes/mesh";
  53459. /**
  53460. * Class containing static functions to help procedurally build meshes
  53461. */
  53462. export class ShapeBuilder {
  53463. /**
  53464. * 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.
  53465. * * 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.
  53466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53467. * * 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.
  53468. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53469. * * 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
  53470. * * 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
  53471. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53472. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53473. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53474. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53475. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53476. * @param name defines the name of the mesh
  53477. * @param options defines the options used to create the mesh
  53478. * @param scene defines the hosting scene
  53479. * @returns the extruded shape mesh
  53480. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53482. */
  53483. static ExtrudeShape(name: string, options: {
  53484. shape: Vector3[];
  53485. path: Vector3[];
  53486. scale?: number;
  53487. rotation?: number;
  53488. cap?: number;
  53489. updatable?: boolean;
  53490. sideOrientation?: number;
  53491. frontUVs?: Vector4;
  53492. backUVs?: Vector4;
  53493. instance?: Mesh;
  53494. invertUV?: boolean;
  53495. }, scene?: Nullable<Scene>): Mesh;
  53496. /**
  53497. * Creates an custom extruded shape mesh.
  53498. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53499. * * 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.
  53500. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53501. * * 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
  53502. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53503. * * 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
  53504. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53505. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53506. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53507. * * 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
  53508. * * 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
  53509. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53510. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53511. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53512. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53514. * @param name defines the name of the mesh
  53515. * @param options defines the options used to create the mesh
  53516. * @param scene defines the hosting scene
  53517. * @returns the custom extruded shape mesh
  53518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53521. */
  53522. static ExtrudeShapeCustom(name: string, options: {
  53523. shape: Vector3[];
  53524. path: Vector3[];
  53525. scaleFunction?: any;
  53526. rotationFunction?: any;
  53527. ribbonCloseArray?: boolean;
  53528. ribbonClosePath?: boolean;
  53529. cap?: number;
  53530. updatable?: boolean;
  53531. sideOrientation?: number;
  53532. frontUVs?: Vector4;
  53533. backUVs?: Vector4;
  53534. instance?: Mesh;
  53535. invertUV?: boolean;
  53536. }, scene?: Nullable<Scene>): Mesh;
  53537. private static _ExtrudeShapeGeneric;
  53538. }
  53539. }
  53540. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53541. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53542. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53543. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53544. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53545. import { Nullable } from "babylonjs/types";
  53546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53547. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53548. /**
  53549. * AmmoJS Physics plugin
  53550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53551. * @see https://github.com/kripken/ammo.js/
  53552. */
  53553. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53554. private _useDeltaForWorldStep;
  53555. /**
  53556. * Reference to the Ammo library
  53557. */
  53558. bjsAMMO: any;
  53559. /**
  53560. * Created ammoJS world which physics bodies are added to
  53561. */
  53562. world: any;
  53563. /**
  53564. * Name of the plugin
  53565. */
  53566. name: string;
  53567. private _timeStep;
  53568. private _fixedTimeStep;
  53569. private _maxSteps;
  53570. private _tmpQuaternion;
  53571. private _tmpAmmoTransform;
  53572. private _tmpAmmoQuaternion;
  53573. private _tmpAmmoConcreteContactResultCallback;
  53574. private _collisionConfiguration;
  53575. private _dispatcher;
  53576. private _overlappingPairCache;
  53577. private _solver;
  53578. private _softBodySolver;
  53579. private _tmpAmmoVectorA;
  53580. private _tmpAmmoVectorB;
  53581. private _tmpAmmoVectorC;
  53582. private _tmpAmmoVectorD;
  53583. private _tmpContactCallbackResult;
  53584. private _tmpAmmoVectorRCA;
  53585. private _tmpAmmoVectorRCB;
  53586. private _raycastResult;
  53587. private static readonly DISABLE_COLLISION_FLAG;
  53588. private static readonly KINEMATIC_FLAG;
  53589. private static readonly DISABLE_DEACTIVATION_FLAG;
  53590. /**
  53591. * Initializes the ammoJS plugin
  53592. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53593. * @param ammoInjection can be used to inject your own ammo reference
  53594. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53595. */
  53596. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53597. /**
  53598. * Sets the gravity of the physics world (m/(s^2))
  53599. * @param gravity Gravity to set
  53600. */
  53601. setGravity(gravity: Vector3): void;
  53602. /**
  53603. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53604. * @param timeStep timestep to use in seconds
  53605. */
  53606. setTimeStep(timeStep: number): void;
  53607. /**
  53608. * 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)
  53609. * @param fixedTimeStep fixedTimeStep to use in seconds
  53610. */
  53611. setFixedTimeStep(fixedTimeStep: number): void;
  53612. /**
  53613. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53614. * @param maxSteps the maximum number of steps by the physics engine per frame
  53615. */
  53616. setMaxSteps(maxSteps: number): void;
  53617. /**
  53618. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53619. * @returns the current timestep in seconds
  53620. */
  53621. getTimeStep(): number;
  53622. private _isImpostorInContact;
  53623. private _isImpostorPairInContact;
  53624. private _stepSimulation;
  53625. /**
  53626. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53627. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53628. * After the step the babylon meshes are set to the position of the physics imposters
  53629. * @param delta amount of time to step forward
  53630. * @param impostors array of imposters to update before/after the step
  53631. */
  53632. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53633. /**
  53634. * Update babylon mesh to match physics world object
  53635. * @param impostor imposter to match
  53636. */
  53637. private _afterSoftStep;
  53638. /**
  53639. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53640. * @param impostor imposter to match
  53641. */
  53642. private _ropeStep;
  53643. /**
  53644. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53645. * @param impostor imposter to match
  53646. */
  53647. private _softbodyOrClothStep;
  53648. private _tmpVector;
  53649. private _tmpMatrix;
  53650. /**
  53651. * Applies an impulse on the imposter
  53652. * @param impostor imposter to apply impulse to
  53653. * @param force amount of force to be applied to the imposter
  53654. * @param contactPoint the location to apply the impulse on the imposter
  53655. */
  53656. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53657. /**
  53658. * Applies a force on the imposter
  53659. * @param impostor imposter to apply force
  53660. * @param force amount of force to be applied to the imposter
  53661. * @param contactPoint the location to apply the force on the imposter
  53662. */
  53663. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53664. /**
  53665. * Creates a physics body using the plugin
  53666. * @param impostor the imposter to create the physics body on
  53667. */
  53668. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53669. /**
  53670. * Removes the physics body from the imposter and disposes of the body's memory
  53671. * @param impostor imposter to remove the physics body from
  53672. */
  53673. removePhysicsBody(impostor: PhysicsImpostor): void;
  53674. /**
  53675. * Generates a joint
  53676. * @param impostorJoint the imposter joint to create the joint with
  53677. */
  53678. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53679. /**
  53680. * Removes a joint
  53681. * @param impostorJoint the imposter joint to remove the joint from
  53682. */
  53683. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53684. private _addMeshVerts;
  53685. /**
  53686. * Initialise the soft body vertices to match its object's (mesh) vertices
  53687. * Softbody vertices (nodes) are in world space and to match this
  53688. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53689. * @param impostor to create the softbody for
  53690. */
  53691. private _softVertexData;
  53692. /**
  53693. * Create an impostor's soft body
  53694. * @param impostor to create the softbody for
  53695. */
  53696. private _createSoftbody;
  53697. /**
  53698. * Create cloth for an impostor
  53699. * @param impostor to create the softbody for
  53700. */
  53701. private _createCloth;
  53702. /**
  53703. * Create rope for an impostor
  53704. * @param impostor to create the softbody for
  53705. */
  53706. private _createRope;
  53707. private _addHullVerts;
  53708. private _createShape;
  53709. /**
  53710. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53711. * @param impostor imposter containing the physics body and babylon object
  53712. */
  53713. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53714. /**
  53715. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53716. * @param impostor imposter containing the physics body and babylon object
  53717. * @param newPosition new position
  53718. * @param newRotation new rotation
  53719. */
  53720. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53721. /**
  53722. * If this plugin is supported
  53723. * @returns true if its supported
  53724. */
  53725. isSupported(): boolean;
  53726. /**
  53727. * Sets the linear velocity of the physics body
  53728. * @param impostor imposter to set the velocity on
  53729. * @param velocity velocity to set
  53730. */
  53731. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53732. /**
  53733. * Sets the angular velocity of the physics body
  53734. * @param impostor imposter to set the velocity on
  53735. * @param velocity velocity to set
  53736. */
  53737. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53738. /**
  53739. * gets the linear velocity
  53740. * @param impostor imposter to get linear velocity from
  53741. * @returns linear velocity
  53742. */
  53743. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53744. /**
  53745. * gets the angular velocity
  53746. * @param impostor imposter to get angular velocity from
  53747. * @returns angular velocity
  53748. */
  53749. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53750. /**
  53751. * Sets the mass of physics body
  53752. * @param impostor imposter to set the mass on
  53753. * @param mass mass to set
  53754. */
  53755. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53756. /**
  53757. * Gets the mass of the physics body
  53758. * @param impostor imposter to get the mass from
  53759. * @returns mass
  53760. */
  53761. getBodyMass(impostor: PhysicsImpostor): number;
  53762. /**
  53763. * Gets friction of the impostor
  53764. * @param impostor impostor to get friction from
  53765. * @returns friction value
  53766. */
  53767. getBodyFriction(impostor: PhysicsImpostor): number;
  53768. /**
  53769. * Sets friction of the impostor
  53770. * @param impostor impostor to set friction on
  53771. * @param friction friction value
  53772. */
  53773. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53774. /**
  53775. * Gets restitution of the impostor
  53776. * @param impostor impostor to get restitution from
  53777. * @returns restitution value
  53778. */
  53779. getBodyRestitution(impostor: PhysicsImpostor): number;
  53780. /**
  53781. * Sets resitution of the impostor
  53782. * @param impostor impostor to set resitution on
  53783. * @param restitution resitution value
  53784. */
  53785. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53786. /**
  53787. * Gets pressure inside the impostor
  53788. * @param impostor impostor to get pressure from
  53789. * @returns pressure value
  53790. */
  53791. getBodyPressure(impostor: PhysicsImpostor): number;
  53792. /**
  53793. * Sets pressure inside a soft body impostor
  53794. * Cloth and rope must remain 0 pressure
  53795. * @param impostor impostor to set pressure on
  53796. * @param pressure pressure value
  53797. */
  53798. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53799. /**
  53800. * Gets stiffness of the impostor
  53801. * @param impostor impostor to get stiffness from
  53802. * @returns pressure value
  53803. */
  53804. getBodyStiffness(impostor: PhysicsImpostor): number;
  53805. /**
  53806. * Sets stiffness of the impostor
  53807. * @param impostor impostor to set stiffness on
  53808. * @param stiffness stiffness value from 0 to 1
  53809. */
  53810. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53811. /**
  53812. * Gets velocityIterations of the impostor
  53813. * @param impostor impostor to get velocity iterations from
  53814. * @returns velocityIterations value
  53815. */
  53816. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53817. /**
  53818. * Sets velocityIterations of the impostor
  53819. * @param impostor impostor to set velocity iterations on
  53820. * @param velocityIterations velocityIterations value
  53821. */
  53822. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53823. /**
  53824. * Gets positionIterations of the impostor
  53825. * @param impostor impostor to get position iterations from
  53826. * @returns positionIterations value
  53827. */
  53828. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53829. /**
  53830. * Sets positionIterations of the impostor
  53831. * @param impostor impostor to set position on
  53832. * @param positionIterations positionIterations value
  53833. */
  53834. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53835. /**
  53836. * Append an anchor to a cloth object
  53837. * @param impostor is the cloth impostor to add anchor to
  53838. * @param otherImpostor is the rigid impostor to anchor to
  53839. * @param width ratio across width from 0 to 1
  53840. * @param height ratio up height from 0 to 1
  53841. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53842. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53843. */
  53844. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53845. /**
  53846. * Append an hook to a rope object
  53847. * @param impostor is the rope impostor to add hook to
  53848. * @param otherImpostor is the rigid impostor to hook to
  53849. * @param length ratio along the rope from 0 to 1
  53850. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53851. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53852. */
  53853. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53854. /**
  53855. * Sleeps the physics body and stops it from being active
  53856. * @param impostor impostor to sleep
  53857. */
  53858. sleepBody(impostor: PhysicsImpostor): void;
  53859. /**
  53860. * Activates the physics body
  53861. * @param impostor impostor to activate
  53862. */
  53863. wakeUpBody(impostor: PhysicsImpostor): void;
  53864. /**
  53865. * Updates the distance parameters of the joint
  53866. * @param joint joint to update
  53867. * @param maxDistance maximum distance of the joint
  53868. * @param minDistance minimum distance of the joint
  53869. */
  53870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53871. /**
  53872. * Sets a motor on the joint
  53873. * @param joint joint to set motor on
  53874. * @param speed speed of the motor
  53875. * @param maxForce maximum force of the motor
  53876. * @param motorIndex index of the motor
  53877. */
  53878. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53879. /**
  53880. * Sets the motors limit
  53881. * @param joint joint to set limit on
  53882. * @param upperLimit upper limit
  53883. * @param lowerLimit lower limit
  53884. */
  53885. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53886. /**
  53887. * Syncs the position and rotation of a mesh with the impostor
  53888. * @param mesh mesh to sync
  53889. * @param impostor impostor to update the mesh with
  53890. */
  53891. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53892. /**
  53893. * Gets the radius of the impostor
  53894. * @param impostor impostor to get radius from
  53895. * @returns the radius
  53896. */
  53897. getRadius(impostor: PhysicsImpostor): number;
  53898. /**
  53899. * Gets the box size of the impostor
  53900. * @param impostor impostor to get box size from
  53901. * @param result the resulting box size
  53902. */
  53903. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53904. /**
  53905. * Disposes of the impostor
  53906. */
  53907. dispose(): void;
  53908. /**
  53909. * Does a raycast in the physics world
  53910. * @param from when should the ray start?
  53911. * @param to when should the ray end?
  53912. * @returns PhysicsRaycastResult
  53913. */
  53914. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53915. }
  53916. }
  53917. declare module "babylonjs/Probes/reflectionProbe" {
  53918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53919. import { Vector3 } from "babylonjs/Maths/math.vector";
  53920. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53921. import { Nullable } from "babylonjs/types";
  53922. import { Scene } from "babylonjs/scene";
  53923. module "babylonjs/abstractScene" {
  53924. interface AbstractScene {
  53925. /**
  53926. * The list of reflection probes added to the scene
  53927. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53928. */
  53929. reflectionProbes: Array<ReflectionProbe>;
  53930. /**
  53931. * Removes the given reflection probe from this scene.
  53932. * @param toRemove The reflection probe to remove
  53933. * @returns The index of the removed reflection probe
  53934. */
  53935. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53936. /**
  53937. * Adds the given reflection probe to this scene.
  53938. * @param newReflectionProbe The reflection probe to add
  53939. */
  53940. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53941. }
  53942. }
  53943. /**
  53944. * Class used to generate realtime reflection / refraction cube textures
  53945. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53946. */
  53947. export class ReflectionProbe {
  53948. /** defines the name of the probe */
  53949. name: string;
  53950. private _scene;
  53951. private _renderTargetTexture;
  53952. private _projectionMatrix;
  53953. private _viewMatrix;
  53954. private _target;
  53955. private _add;
  53956. private _attachedMesh;
  53957. private _invertYAxis;
  53958. /** Gets or sets probe position (center of the cube map) */
  53959. position: Vector3;
  53960. /**
  53961. * Creates a new reflection probe
  53962. * @param name defines the name of the probe
  53963. * @param size defines the texture resolution (for each face)
  53964. * @param scene defines the hosting scene
  53965. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53966. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53967. */
  53968. constructor(
  53969. /** defines the name of the probe */
  53970. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53971. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53972. samples: number;
  53973. /** Gets or sets the refresh rate to use (on every frame by default) */
  53974. refreshRate: number;
  53975. /**
  53976. * Gets the hosting scene
  53977. * @returns a Scene
  53978. */
  53979. getScene(): Scene;
  53980. /** Gets the internal CubeTexture used to render to */
  53981. readonly cubeTexture: RenderTargetTexture;
  53982. /** Gets the list of meshes to render */
  53983. readonly renderList: Nullable<AbstractMesh[]>;
  53984. /**
  53985. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53986. * @param mesh defines the mesh to attach to
  53987. */
  53988. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53989. /**
  53990. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53991. * @param renderingGroupId The rendering group id corresponding to its index
  53992. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53993. */
  53994. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53995. /**
  53996. * Clean all associated resources
  53997. */
  53998. dispose(): void;
  53999. /**
  54000. * Converts the reflection probe information to a readable string for debug purpose.
  54001. * @param fullDetails Supports for multiple levels of logging within scene loading
  54002. * @returns the human readable reflection probe info
  54003. */
  54004. toString(fullDetails?: boolean): string;
  54005. /**
  54006. * Get the class name of the relfection probe.
  54007. * @returns "ReflectionProbe"
  54008. */
  54009. getClassName(): string;
  54010. /**
  54011. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54012. * @returns The JSON representation of the texture
  54013. */
  54014. serialize(): any;
  54015. /**
  54016. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54017. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54018. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54019. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54020. * @returns The parsed reflection probe if successful
  54021. */
  54022. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54023. }
  54024. }
  54025. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54026. /** @hidden */
  54027. export var _BabylonLoaderRegistered: boolean;
  54028. }
  54029. declare module "babylonjs/Loading/Plugins/index" {
  54030. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54031. }
  54032. declare module "babylonjs/Loading/index" {
  54033. export * from "babylonjs/Loading/loadingScreen";
  54034. export * from "babylonjs/Loading/Plugins/index";
  54035. export * from "babylonjs/Loading/sceneLoader";
  54036. export * from "babylonjs/Loading/sceneLoaderFlags";
  54037. }
  54038. declare module "babylonjs/Materials/Background/index" {
  54039. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54040. }
  54041. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54042. import { Scene } from "babylonjs/scene";
  54043. import { Color3 } from "babylonjs/Maths/math.color";
  54044. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54045. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54046. /**
  54047. * The Physically based simple base material of BJS.
  54048. *
  54049. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54050. * It is used as the base class for both the specGloss and metalRough conventions.
  54051. */
  54052. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54053. /**
  54054. * Number of Simultaneous lights allowed on the material.
  54055. */
  54056. maxSimultaneousLights: number;
  54057. /**
  54058. * If sets to true, disables all the lights affecting the material.
  54059. */
  54060. disableLighting: boolean;
  54061. /**
  54062. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54063. */
  54064. environmentTexture: BaseTexture;
  54065. /**
  54066. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54067. */
  54068. invertNormalMapX: boolean;
  54069. /**
  54070. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54071. */
  54072. invertNormalMapY: boolean;
  54073. /**
  54074. * Normal map used in the model.
  54075. */
  54076. normalTexture: BaseTexture;
  54077. /**
  54078. * Emissivie color used to self-illuminate the model.
  54079. */
  54080. emissiveColor: Color3;
  54081. /**
  54082. * Emissivie texture used to self-illuminate the model.
  54083. */
  54084. emissiveTexture: BaseTexture;
  54085. /**
  54086. * Occlusion Channel Strenght.
  54087. */
  54088. occlusionStrength: number;
  54089. /**
  54090. * Occlusion Texture of the material (adding extra occlusion effects).
  54091. */
  54092. occlusionTexture: BaseTexture;
  54093. /**
  54094. * Defines the alpha limits in alpha test mode.
  54095. */
  54096. alphaCutOff: number;
  54097. /**
  54098. * Gets the current double sided mode.
  54099. */
  54100. /**
  54101. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54102. */
  54103. doubleSided: boolean;
  54104. /**
  54105. * Stores the pre-calculated light information of a mesh in a texture.
  54106. */
  54107. lightmapTexture: BaseTexture;
  54108. /**
  54109. * If true, the light map contains occlusion information instead of lighting info.
  54110. */
  54111. useLightmapAsShadowmap: boolean;
  54112. /**
  54113. * Instantiates a new PBRMaterial instance.
  54114. *
  54115. * @param name The material name
  54116. * @param scene The scene the material will be use in.
  54117. */
  54118. constructor(name: string, scene: Scene);
  54119. getClassName(): string;
  54120. }
  54121. }
  54122. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54123. import { Scene } from "babylonjs/scene";
  54124. import { Color3 } from "babylonjs/Maths/math.color";
  54125. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54126. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54127. /**
  54128. * The PBR material of BJS following the metal roughness convention.
  54129. *
  54130. * This fits to the PBR convention in the GLTF definition:
  54131. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54132. */
  54133. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54134. /**
  54135. * The base color has two different interpretations depending on the value of metalness.
  54136. * When the material is a metal, the base color is the specific measured reflectance value
  54137. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54138. * of the material.
  54139. */
  54140. baseColor: Color3;
  54141. /**
  54142. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54143. * well as opacity information in the alpha channel.
  54144. */
  54145. baseTexture: BaseTexture;
  54146. /**
  54147. * Specifies the metallic scalar value of the material.
  54148. * Can also be used to scale the metalness values of the metallic texture.
  54149. */
  54150. metallic: number;
  54151. /**
  54152. * Specifies the roughness scalar value of the material.
  54153. * Can also be used to scale the roughness values of the metallic texture.
  54154. */
  54155. roughness: number;
  54156. /**
  54157. * Texture containing both the metallic value in the B channel and the
  54158. * roughness value in the G channel to keep better precision.
  54159. */
  54160. metallicRoughnessTexture: BaseTexture;
  54161. /**
  54162. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54163. *
  54164. * @param name The material name
  54165. * @param scene The scene the material will be use in.
  54166. */
  54167. constructor(name: string, scene: Scene);
  54168. /**
  54169. * Return the currrent class name of the material.
  54170. */
  54171. getClassName(): string;
  54172. /**
  54173. * Makes a duplicate of the current material.
  54174. * @param name - name to use for the new material.
  54175. */
  54176. clone(name: string): PBRMetallicRoughnessMaterial;
  54177. /**
  54178. * Serialize the material to a parsable JSON object.
  54179. */
  54180. serialize(): any;
  54181. /**
  54182. * Parses a JSON object correponding to the serialize function.
  54183. */
  54184. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54185. }
  54186. }
  54187. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54188. import { Scene } from "babylonjs/scene";
  54189. import { Color3 } from "babylonjs/Maths/math.color";
  54190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54191. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54192. /**
  54193. * The PBR material of BJS following the specular glossiness convention.
  54194. *
  54195. * This fits to the PBR convention in the GLTF definition:
  54196. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54197. */
  54198. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54199. /**
  54200. * Specifies the diffuse color of the material.
  54201. */
  54202. diffuseColor: Color3;
  54203. /**
  54204. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54205. * channel.
  54206. */
  54207. diffuseTexture: BaseTexture;
  54208. /**
  54209. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54210. */
  54211. specularColor: Color3;
  54212. /**
  54213. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54214. */
  54215. glossiness: number;
  54216. /**
  54217. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54218. */
  54219. specularGlossinessTexture: BaseTexture;
  54220. /**
  54221. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54222. *
  54223. * @param name The material name
  54224. * @param scene The scene the material will be use in.
  54225. */
  54226. constructor(name: string, scene: Scene);
  54227. /**
  54228. * Return the currrent class name of the material.
  54229. */
  54230. getClassName(): string;
  54231. /**
  54232. * Makes a duplicate of the current material.
  54233. * @param name - name to use for the new material.
  54234. */
  54235. clone(name: string): PBRSpecularGlossinessMaterial;
  54236. /**
  54237. * Serialize the material to a parsable JSON object.
  54238. */
  54239. serialize(): any;
  54240. /**
  54241. * Parses a JSON object correponding to the serialize function.
  54242. */
  54243. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54244. }
  54245. }
  54246. declare module "babylonjs/Materials/PBR/index" {
  54247. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54248. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54249. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54250. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54251. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54252. }
  54253. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54254. import { Nullable } from "babylonjs/types";
  54255. import { Scene } from "babylonjs/scene";
  54256. import { Matrix } from "babylonjs/Maths/math.vector";
  54257. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54258. /**
  54259. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54260. * It can help converting any input color in a desired output one. This can then be used to create effects
  54261. * from sepia, black and white to sixties or futuristic rendering...
  54262. *
  54263. * The only supported format is currently 3dl.
  54264. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54265. */
  54266. export class ColorGradingTexture extends BaseTexture {
  54267. /**
  54268. * The current texture matrix. (will always be identity in color grading texture)
  54269. */
  54270. private _textureMatrix;
  54271. /**
  54272. * The texture URL.
  54273. */
  54274. url: string;
  54275. /**
  54276. * Empty line regex stored for GC.
  54277. */
  54278. private static _noneEmptyLineRegex;
  54279. private _engine;
  54280. /**
  54281. * Instantiates a ColorGradingTexture from the following parameters.
  54282. *
  54283. * @param url The location of the color gradind data (currently only supporting 3dl)
  54284. * @param scene The scene the texture will be used in
  54285. */
  54286. constructor(url: string, scene: Scene);
  54287. /**
  54288. * Returns the texture matrix used in most of the material.
  54289. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54290. */
  54291. getTextureMatrix(): Matrix;
  54292. /**
  54293. * Occurs when the file being loaded is a .3dl LUT file.
  54294. */
  54295. private load3dlTexture;
  54296. /**
  54297. * Starts the loading process of the texture.
  54298. */
  54299. private loadTexture;
  54300. /**
  54301. * Clones the color gradind texture.
  54302. */
  54303. clone(): ColorGradingTexture;
  54304. /**
  54305. * Called during delayed load for textures.
  54306. */
  54307. delayLoad(): void;
  54308. /**
  54309. * Parses a color grading texture serialized by Babylon.
  54310. * @param parsedTexture The texture information being parsedTexture
  54311. * @param scene The scene to load the texture in
  54312. * @param rootUrl The root url of the data assets to load
  54313. * @return A color gradind texture
  54314. */
  54315. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54316. /**
  54317. * Serializes the LUT texture to json format.
  54318. */
  54319. serialize(): any;
  54320. }
  54321. }
  54322. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54323. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54324. import { Scene } from "babylonjs/scene";
  54325. import { Nullable } from "babylonjs/types";
  54326. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54327. /**
  54328. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54329. */
  54330. export class EquiRectangularCubeTexture extends BaseTexture {
  54331. /** The six faces of the cube. */
  54332. private static _FacesMapping;
  54333. private _noMipmap;
  54334. private _onLoad;
  54335. private _onError;
  54336. /** The size of the cubemap. */
  54337. private _size;
  54338. /** The buffer of the image. */
  54339. private _buffer;
  54340. /** The width of the input image. */
  54341. private _width;
  54342. /** The height of the input image. */
  54343. private _height;
  54344. /** The URL to the image. */
  54345. url: string;
  54346. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54347. coordinatesMode: number;
  54348. /**
  54349. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54350. * @param url The location of the image
  54351. * @param scene The scene the texture will be used in
  54352. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54353. * @param noMipmap Forces to not generate the mipmap if true
  54354. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54355. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54356. * @param onLoad — defines a callback called when texture is loaded
  54357. * @param onError — defines a callback called if there is an error
  54358. */
  54359. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54360. /**
  54361. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54362. */
  54363. private loadImage;
  54364. /**
  54365. * Convert the image buffer into a cubemap and create a CubeTexture.
  54366. */
  54367. private loadTexture;
  54368. /**
  54369. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54370. * @param buffer The ArrayBuffer that should be converted.
  54371. * @returns The buffer as Float32Array.
  54372. */
  54373. private getFloat32ArrayFromArrayBuffer;
  54374. /**
  54375. * Get the current class name of the texture useful for serialization or dynamic coding.
  54376. * @returns "EquiRectangularCubeTexture"
  54377. */
  54378. getClassName(): string;
  54379. /**
  54380. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54381. * @returns A clone of the current EquiRectangularCubeTexture.
  54382. */
  54383. clone(): EquiRectangularCubeTexture;
  54384. }
  54385. }
  54386. declare module "babylonjs/Misc/tga" {
  54387. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54388. /**
  54389. * Based on jsTGALoader - Javascript loader for TGA file
  54390. * By Vincent Thibault
  54391. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54392. */
  54393. export class TGATools {
  54394. private static _TYPE_INDEXED;
  54395. private static _TYPE_RGB;
  54396. private static _TYPE_GREY;
  54397. private static _TYPE_RLE_INDEXED;
  54398. private static _TYPE_RLE_RGB;
  54399. private static _TYPE_RLE_GREY;
  54400. private static _ORIGIN_MASK;
  54401. private static _ORIGIN_SHIFT;
  54402. private static _ORIGIN_BL;
  54403. private static _ORIGIN_BR;
  54404. private static _ORIGIN_UL;
  54405. private static _ORIGIN_UR;
  54406. /**
  54407. * Gets the header of a TGA file
  54408. * @param data defines the TGA data
  54409. * @returns the header
  54410. */
  54411. static GetTGAHeader(data: Uint8Array): any;
  54412. /**
  54413. * Uploads TGA content to a Babylon Texture
  54414. * @hidden
  54415. */
  54416. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54417. /** @hidden */
  54418. 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;
  54419. /** @hidden */
  54420. 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;
  54421. /** @hidden */
  54422. 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;
  54423. /** @hidden */
  54424. 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;
  54425. /** @hidden */
  54426. 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;
  54427. /** @hidden */
  54428. 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;
  54429. }
  54430. }
  54431. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54432. import { Nullable } from "babylonjs/types";
  54433. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54434. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54435. /**
  54436. * Implementation of the TGA Texture Loader.
  54437. * @hidden
  54438. */
  54439. export class _TGATextureLoader implements IInternalTextureLoader {
  54440. /**
  54441. * Defines wether the loader supports cascade loading the different faces.
  54442. */
  54443. readonly supportCascades: boolean;
  54444. /**
  54445. * This returns if the loader support the current file information.
  54446. * @param extension defines the file extension of the file being loaded
  54447. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54448. * @param fallback defines the fallback internal texture if any
  54449. * @param isBase64 defines whether the texture is encoded as a base64
  54450. * @param isBuffer defines whether the texture data are stored as a buffer
  54451. * @returns true if the loader can load the specified file
  54452. */
  54453. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54454. /**
  54455. * Transform the url before loading if required.
  54456. * @param rootUrl the url of the texture
  54457. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54458. * @returns the transformed texture
  54459. */
  54460. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54461. /**
  54462. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54463. * @param rootUrl the url of the texture
  54464. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54465. * @returns the fallback texture
  54466. */
  54467. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54468. /**
  54469. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54470. * @param data contains the texture data
  54471. * @param texture defines the BabylonJS internal texture
  54472. * @param createPolynomials will be true if polynomials have been requested
  54473. * @param onLoad defines the callback to trigger once the texture is ready
  54474. * @param onError defines the callback to trigger in case of error
  54475. */
  54476. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54477. /**
  54478. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54479. * @param data contains the texture data
  54480. * @param texture defines the BabylonJS internal texture
  54481. * @param callback defines the method to call once ready to upload
  54482. */
  54483. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54484. }
  54485. }
  54486. declare module "babylonjs/Misc/basis" {
  54487. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54488. /**
  54489. * Info about the .basis files
  54490. */
  54491. class BasisFileInfo {
  54492. /**
  54493. * If the file has alpha
  54494. */
  54495. hasAlpha: boolean;
  54496. /**
  54497. * Info about each image of the basis file
  54498. */
  54499. images: Array<{
  54500. levels: Array<{
  54501. width: number;
  54502. height: number;
  54503. transcodedPixels: ArrayBufferView;
  54504. }>;
  54505. }>;
  54506. }
  54507. /**
  54508. * Result of transcoding a basis file
  54509. */
  54510. class TranscodeResult {
  54511. /**
  54512. * Info about the .basis file
  54513. */
  54514. fileInfo: BasisFileInfo;
  54515. /**
  54516. * Format to use when loading the file
  54517. */
  54518. format: number;
  54519. }
  54520. /**
  54521. * Configuration options for the Basis transcoder
  54522. */
  54523. export class BasisTranscodeConfiguration {
  54524. /**
  54525. * Supported compression formats used to determine the supported output format of the transcoder
  54526. */
  54527. supportedCompressionFormats?: {
  54528. /**
  54529. * etc1 compression format
  54530. */
  54531. etc1?: boolean;
  54532. /**
  54533. * s3tc compression format
  54534. */
  54535. s3tc?: boolean;
  54536. /**
  54537. * pvrtc compression format
  54538. */
  54539. pvrtc?: boolean;
  54540. /**
  54541. * etc2 compression format
  54542. */
  54543. etc2?: boolean;
  54544. };
  54545. /**
  54546. * If mipmap levels should be loaded for transcoded images (Default: true)
  54547. */
  54548. loadMipmapLevels?: boolean;
  54549. /**
  54550. * Index of a single image to load (Default: all images)
  54551. */
  54552. loadSingleImage?: number;
  54553. }
  54554. /**
  54555. * Used to load .Basis files
  54556. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54557. */
  54558. export class BasisTools {
  54559. private static _IgnoreSupportedFormats;
  54560. /**
  54561. * URL to use when loading the basis transcoder
  54562. */
  54563. static JSModuleURL: string;
  54564. /**
  54565. * URL to use when loading the wasm module for the transcoder
  54566. */
  54567. static WasmModuleURL: string;
  54568. /**
  54569. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54570. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54571. * @returns internal format corresponding to the Basis format
  54572. */
  54573. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54574. private static _WorkerPromise;
  54575. private static _Worker;
  54576. private static _actionId;
  54577. private static _CreateWorkerAsync;
  54578. /**
  54579. * Transcodes a loaded image file to compressed pixel data
  54580. * @param imageData image data to transcode
  54581. * @param config configuration options for the transcoding
  54582. * @returns a promise resulting in the transcoded image
  54583. */
  54584. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54585. /**
  54586. * Loads a texture from the transcode result
  54587. * @param texture texture load to
  54588. * @param transcodeResult the result of transcoding the basis file to load from
  54589. */
  54590. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54591. }
  54592. }
  54593. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54594. import { Nullable } from "babylonjs/types";
  54595. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54596. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54597. /**
  54598. * Loader for .basis file format
  54599. */
  54600. export class _BasisTextureLoader implements IInternalTextureLoader {
  54601. /**
  54602. * Defines whether the loader supports cascade loading the different faces.
  54603. */
  54604. readonly supportCascades: boolean;
  54605. /**
  54606. * This returns if the loader support the current file information.
  54607. * @param extension defines the file extension of the file being loaded
  54608. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54609. * @param fallback defines the fallback internal texture if any
  54610. * @param isBase64 defines whether the texture is encoded as a base64
  54611. * @param isBuffer defines whether the texture data are stored as a buffer
  54612. * @returns true if the loader can load the specified file
  54613. */
  54614. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54615. /**
  54616. * Transform the url before loading if required.
  54617. * @param rootUrl the url of the texture
  54618. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54619. * @returns the transformed texture
  54620. */
  54621. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54622. /**
  54623. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54624. * @param rootUrl the url of the texture
  54625. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54626. * @returns the fallback texture
  54627. */
  54628. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54629. /**
  54630. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54631. * @param data contains the texture data
  54632. * @param texture defines the BabylonJS internal texture
  54633. * @param createPolynomials will be true if polynomials have been requested
  54634. * @param onLoad defines the callback to trigger once the texture is ready
  54635. * @param onError defines the callback to trigger in case of error
  54636. */
  54637. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54638. /**
  54639. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54640. * @param data contains the texture data
  54641. * @param texture defines the BabylonJS internal texture
  54642. * @param callback defines the method to call once ready to upload
  54643. */
  54644. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54645. }
  54646. }
  54647. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54648. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54649. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54650. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54651. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54652. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54653. }
  54654. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54655. import { Scene } from "babylonjs/scene";
  54656. import { Texture } from "babylonjs/Materials/Textures/texture";
  54657. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54658. /**
  54659. * 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.
  54660. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54661. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54662. */
  54663. export class CustomProceduralTexture extends ProceduralTexture {
  54664. private _animate;
  54665. private _time;
  54666. private _config;
  54667. private _texturePath;
  54668. /**
  54669. * Instantiates a new Custom Procedural Texture.
  54670. * 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.
  54671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54672. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54673. * @param name Define the name of the texture
  54674. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54675. * @param size Define the size of the texture to create
  54676. * @param scene Define the scene the texture belongs to
  54677. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54678. * @param generateMipMaps Define if the texture should creates mip maps or not
  54679. */
  54680. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54681. private _loadJson;
  54682. /**
  54683. * Is the texture ready to be used ? (rendered at least once)
  54684. * @returns true if ready, otherwise, false.
  54685. */
  54686. isReady(): boolean;
  54687. /**
  54688. * Render the texture to its associated render target.
  54689. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54690. */
  54691. render(useCameraPostProcess?: boolean): void;
  54692. /**
  54693. * Update the list of dependant textures samplers in the shader.
  54694. */
  54695. updateTextures(): void;
  54696. /**
  54697. * Update the uniform values of the procedural texture in the shader.
  54698. */
  54699. updateShaderUniforms(): void;
  54700. /**
  54701. * Define if the texture animates or not.
  54702. */
  54703. animate: boolean;
  54704. }
  54705. }
  54706. declare module "babylonjs/Shaders/noise.fragment" {
  54707. /** @hidden */
  54708. export var noisePixelShader: {
  54709. name: string;
  54710. shader: string;
  54711. };
  54712. }
  54713. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54714. import { Nullable } from "babylonjs/types";
  54715. import { Scene } from "babylonjs/scene";
  54716. import { Texture } from "babylonjs/Materials/Textures/texture";
  54717. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54718. import "babylonjs/Shaders/noise.fragment";
  54719. /**
  54720. * Class used to generate noise procedural textures
  54721. */
  54722. export class NoiseProceduralTexture extends ProceduralTexture {
  54723. private _time;
  54724. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54725. brightness: number;
  54726. /** Defines the number of octaves to process */
  54727. octaves: number;
  54728. /** Defines the level of persistence (0.8 by default) */
  54729. persistence: number;
  54730. /** Gets or sets animation speed factor (default is 1) */
  54731. animationSpeedFactor: number;
  54732. /**
  54733. * Creates a new NoiseProceduralTexture
  54734. * @param name defines the name fo the texture
  54735. * @param size defines the size of the texture (default is 256)
  54736. * @param scene defines the hosting scene
  54737. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54738. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54739. */
  54740. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54741. private _updateShaderUniforms;
  54742. protected _getDefines(): string;
  54743. /** Generate the current state of the procedural texture */
  54744. render(useCameraPostProcess?: boolean): void;
  54745. /**
  54746. * Serializes this noise procedural texture
  54747. * @returns a serialized noise procedural texture object
  54748. */
  54749. serialize(): any;
  54750. /**
  54751. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54752. * @param parsedTexture defines parsed texture data
  54753. * @param scene defines the current scene
  54754. * @param rootUrl defines the root URL containing noise procedural texture information
  54755. * @returns a parsed NoiseProceduralTexture
  54756. */
  54757. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54758. }
  54759. }
  54760. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54761. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54762. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54763. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54764. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54765. }
  54766. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54767. import { Nullable } from "babylonjs/types";
  54768. import { Scene } from "babylonjs/scene";
  54769. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54770. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54771. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54772. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54773. /**
  54774. * Raw cube texture where the raw buffers are passed in
  54775. */
  54776. export class RawCubeTexture extends CubeTexture {
  54777. /**
  54778. * Creates a cube texture where the raw buffers are passed in.
  54779. * @param scene defines the scene the texture is attached to
  54780. * @param data defines the array of data to use to create each face
  54781. * @param size defines the size of the textures
  54782. * @param format defines the format of the data
  54783. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54784. * @param generateMipMaps defines if the engine should generate the mip levels
  54785. * @param invertY defines if data must be stored with Y axis inverted
  54786. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54787. * @param compression defines the compression used (null by default)
  54788. */
  54789. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54790. /**
  54791. * Updates the raw cube texture.
  54792. * @param data defines the data to store
  54793. * @param format defines the data format
  54794. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54795. * @param invertY defines if data must be stored with Y axis inverted
  54796. * @param compression defines the compression used (null by default)
  54797. * @param level defines which level of the texture to update
  54798. */
  54799. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54800. /**
  54801. * Updates a raw cube texture with RGBD encoded data.
  54802. * @param data defines the array of data [mipmap][face] to use to create each face
  54803. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54804. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54805. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54806. * @returns a promsie that resolves when the operation is complete
  54807. */
  54808. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54809. /**
  54810. * Clones the raw cube texture.
  54811. * @return a new cube texture
  54812. */
  54813. clone(): CubeTexture;
  54814. /** @hidden */
  54815. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54816. }
  54817. }
  54818. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54819. import { Scene } from "babylonjs/scene";
  54820. import { Texture } from "babylonjs/Materials/Textures/texture";
  54821. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54822. /**
  54823. * Class used to store 3D textures containing user data
  54824. */
  54825. export class RawTexture3D extends Texture {
  54826. /** Gets or sets the texture format to use */
  54827. format: number;
  54828. private _engine;
  54829. /**
  54830. * Create a new RawTexture3D
  54831. * @param data defines the data of the texture
  54832. * @param width defines the width of the texture
  54833. * @param height defines the height of the texture
  54834. * @param depth defines the depth of the texture
  54835. * @param format defines the texture format to use
  54836. * @param scene defines the hosting scene
  54837. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54838. * @param invertY defines if texture must be stored with Y axis inverted
  54839. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54840. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54841. */
  54842. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54843. /** Gets or sets the texture format to use */
  54844. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54845. /**
  54846. * Update the texture with new data
  54847. * @param data defines the data to store in the texture
  54848. */
  54849. update(data: ArrayBufferView): void;
  54850. }
  54851. }
  54852. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54853. import { Scene } from "babylonjs/scene";
  54854. import { Plane } from "babylonjs/Maths/math.plane";
  54855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54856. /**
  54857. * Creates a refraction texture used by refraction channel of the standard material.
  54858. * It is like a mirror but to see through a material.
  54859. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54860. */
  54861. export class RefractionTexture extends RenderTargetTexture {
  54862. /**
  54863. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54864. * 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.
  54865. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54866. */
  54867. refractionPlane: Plane;
  54868. /**
  54869. * Define how deep under the surface we should see.
  54870. */
  54871. depth: number;
  54872. /**
  54873. * Creates a refraction texture used by refraction channel of the standard material.
  54874. * It is like a mirror but to see through a material.
  54875. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54876. * @param name Define the texture name
  54877. * @param size Define the size of the underlying texture
  54878. * @param scene Define the scene the refraction belongs to
  54879. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54880. */
  54881. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54882. /**
  54883. * Clone the refraction texture.
  54884. * @returns the cloned texture
  54885. */
  54886. clone(): RefractionTexture;
  54887. /**
  54888. * Serialize the texture to a JSON representation you could use in Parse later on
  54889. * @returns the serialized JSON representation
  54890. */
  54891. serialize(): any;
  54892. }
  54893. }
  54894. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54895. import { Nullable } from "babylonjs/types";
  54896. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54897. import { Matrix } from "babylonjs/Maths/math.vector";
  54898. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54899. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54900. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54901. import { Scene } from "babylonjs/scene";
  54902. /**
  54903. * Defines the options related to the creation of an HtmlElementTexture
  54904. */
  54905. export interface IHtmlElementTextureOptions {
  54906. /**
  54907. * Defines wether mip maps should be created or not.
  54908. */
  54909. generateMipMaps?: boolean;
  54910. /**
  54911. * Defines the sampling mode of the texture.
  54912. */
  54913. samplingMode?: number;
  54914. /**
  54915. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54916. */
  54917. engine: Nullable<ThinEngine>;
  54918. /**
  54919. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54920. */
  54921. scene: Nullable<Scene>;
  54922. }
  54923. /**
  54924. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54925. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54926. * is automatically managed.
  54927. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54928. * in your application.
  54929. *
  54930. * As the update is not automatic, you need to call them manually.
  54931. */
  54932. export class HtmlElementTexture extends BaseTexture {
  54933. /**
  54934. * The texture URL.
  54935. */
  54936. element: HTMLVideoElement | HTMLCanvasElement;
  54937. private static readonly DefaultOptions;
  54938. private _textureMatrix;
  54939. private _engine;
  54940. private _isVideo;
  54941. private _generateMipMaps;
  54942. private _samplingMode;
  54943. /**
  54944. * Instantiates a HtmlElementTexture from the following parameters.
  54945. *
  54946. * @param name Defines the name of the texture
  54947. * @param element Defines the video or canvas the texture is filled with
  54948. * @param options Defines the other none mandatory texture creation options
  54949. */
  54950. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54951. private _createInternalTexture;
  54952. /**
  54953. * Returns the texture matrix used in most of the material.
  54954. */
  54955. getTextureMatrix(): Matrix;
  54956. /**
  54957. * Updates the content of the texture.
  54958. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54959. */
  54960. update(invertY?: Nullable<boolean>): void;
  54961. }
  54962. }
  54963. declare module "babylonjs/Materials/Textures/index" {
  54964. export * from "babylonjs/Materials/Textures/baseTexture";
  54965. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54966. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54967. export * from "babylonjs/Materials/Textures/cubeTexture";
  54968. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54969. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54970. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54971. export * from "babylonjs/Materials/Textures/internalTexture";
  54972. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54973. export * from "babylonjs/Materials/Textures/Loaders/index";
  54974. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54975. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54976. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54977. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54978. export * from "babylonjs/Materials/Textures/rawTexture";
  54979. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54980. export * from "babylonjs/Materials/Textures/refractionTexture";
  54981. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54982. export * from "babylonjs/Materials/Textures/texture";
  54983. export * from "babylonjs/Materials/Textures/videoTexture";
  54984. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54985. }
  54986. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54987. /**
  54988. * Enum used to define the target of a block
  54989. */
  54990. export enum NodeMaterialBlockTargets {
  54991. /** Vertex shader */
  54992. Vertex = 1,
  54993. /** Fragment shader */
  54994. Fragment = 2,
  54995. /** Neutral */
  54996. Neutral = 4,
  54997. /** Vertex and Fragment */
  54998. VertexAndFragment = 3
  54999. }
  55000. }
  55001. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55002. /**
  55003. * Defines the kind of connection point for node based material
  55004. */
  55005. export enum NodeMaterialBlockConnectionPointTypes {
  55006. /** Float */
  55007. Float = 1,
  55008. /** Int */
  55009. Int = 2,
  55010. /** Vector2 */
  55011. Vector2 = 4,
  55012. /** Vector3 */
  55013. Vector3 = 8,
  55014. /** Vector4 */
  55015. Vector4 = 16,
  55016. /** Color3 */
  55017. Color3 = 32,
  55018. /** Color4 */
  55019. Color4 = 64,
  55020. /** Matrix */
  55021. Matrix = 128,
  55022. /** Detect type based on connection */
  55023. AutoDetect = 1024,
  55024. /** Output type that will be defined by input type */
  55025. BasedOnInput = 2048
  55026. }
  55027. }
  55028. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55029. /**
  55030. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55031. */
  55032. export enum NodeMaterialBlockConnectionPointMode {
  55033. /** Value is an uniform */
  55034. Uniform = 0,
  55035. /** Value is a mesh attribute */
  55036. Attribute = 1,
  55037. /** Value is a varying between vertex and fragment shaders */
  55038. Varying = 2,
  55039. /** Mode is undefined */
  55040. Undefined = 3
  55041. }
  55042. }
  55043. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55044. /**
  55045. * Enum used to define system values e.g. values automatically provided by the system
  55046. */
  55047. export enum NodeMaterialSystemValues {
  55048. /** World */
  55049. World = 1,
  55050. /** View */
  55051. View = 2,
  55052. /** Projection */
  55053. Projection = 3,
  55054. /** ViewProjection */
  55055. ViewProjection = 4,
  55056. /** WorldView */
  55057. WorldView = 5,
  55058. /** WorldViewProjection */
  55059. WorldViewProjection = 6,
  55060. /** CameraPosition */
  55061. CameraPosition = 7,
  55062. /** Fog Color */
  55063. FogColor = 8,
  55064. /** Delta time */
  55065. DeltaTime = 9
  55066. }
  55067. }
  55068. declare module "babylonjs/Materials/Node/Enums/index" {
  55069. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55070. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55071. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55072. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55073. }
  55074. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55075. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55076. /**
  55077. * Root class for all node material optimizers
  55078. */
  55079. export class NodeMaterialOptimizer {
  55080. /**
  55081. * Function used to optimize a NodeMaterial graph
  55082. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55083. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55084. */
  55085. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55086. }
  55087. }
  55088. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55089. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55090. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55091. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55092. import { Scene } from "babylonjs/scene";
  55093. /**
  55094. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55095. */
  55096. export class TransformBlock extends NodeMaterialBlock {
  55097. /**
  55098. * Defines the value to use to complement W value to transform it to a Vector4
  55099. */
  55100. complementW: number;
  55101. /**
  55102. * Defines the value to use to complement z value to transform it to a Vector4
  55103. */
  55104. complementZ: number;
  55105. /**
  55106. * Creates a new TransformBlock
  55107. * @param name defines the block name
  55108. */
  55109. constructor(name: string);
  55110. /**
  55111. * Gets the current class name
  55112. * @returns the class name
  55113. */
  55114. getClassName(): string;
  55115. /**
  55116. * Gets the vector input
  55117. */
  55118. readonly vector: NodeMaterialConnectionPoint;
  55119. /**
  55120. * Gets the output component
  55121. */
  55122. readonly output: NodeMaterialConnectionPoint;
  55123. /**
  55124. * Gets the matrix transform input
  55125. */
  55126. readonly transform: NodeMaterialConnectionPoint;
  55127. protected _buildBlock(state: NodeMaterialBuildState): this;
  55128. serialize(): any;
  55129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55130. protected _dumpPropertiesCode(): string;
  55131. }
  55132. }
  55133. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55137. /**
  55138. * Block used to output the vertex position
  55139. */
  55140. export class VertexOutputBlock extends NodeMaterialBlock {
  55141. /**
  55142. * Creates a new VertexOutputBlock
  55143. * @param name defines the block name
  55144. */
  55145. constructor(name: string);
  55146. /**
  55147. * Gets the current class name
  55148. * @returns the class name
  55149. */
  55150. getClassName(): string;
  55151. /**
  55152. * Gets the vector input component
  55153. */
  55154. readonly vector: NodeMaterialConnectionPoint;
  55155. protected _buildBlock(state: NodeMaterialBuildState): this;
  55156. }
  55157. }
  55158. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55159. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55160. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55161. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55162. /**
  55163. * Block used to output the final color
  55164. */
  55165. export class FragmentOutputBlock extends NodeMaterialBlock {
  55166. /**
  55167. * Create a new FragmentOutputBlock
  55168. * @param name defines the block name
  55169. */
  55170. constructor(name: string);
  55171. /**
  55172. * Gets the current class name
  55173. * @returns the class name
  55174. */
  55175. getClassName(): string;
  55176. /**
  55177. * Gets the rgba input component
  55178. */
  55179. readonly rgba: NodeMaterialConnectionPoint;
  55180. /**
  55181. * Gets the rgb input component
  55182. */
  55183. readonly rgb: NodeMaterialConnectionPoint;
  55184. /**
  55185. * Gets the a input component
  55186. */
  55187. readonly a: NodeMaterialConnectionPoint;
  55188. protected _buildBlock(state: NodeMaterialBuildState): this;
  55189. }
  55190. }
  55191. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55192. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55193. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55194. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55195. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55197. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55198. import { Effect } from "babylonjs/Materials/effect";
  55199. import { Mesh } from "babylonjs/Meshes/mesh";
  55200. import { Nullable } from "babylonjs/types";
  55201. import { Scene } from "babylonjs/scene";
  55202. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55203. /**
  55204. * Block used to read a reflection texture from a sampler
  55205. */
  55206. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55207. private _define3DName;
  55208. private _defineCubicName;
  55209. private _defineExplicitName;
  55210. private _defineProjectionName;
  55211. private _defineLocalCubicName;
  55212. private _defineSphericalName;
  55213. private _definePlanarName;
  55214. private _defineEquirectangularName;
  55215. private _defineMirroredEquirectangularFixedName;
  55216. private _defineEquirectangularFixedName;
  55217. private _defineSkyboxName;
  55218. private _cubeSamplerName;
  55219. private _2DSamplerName;
  55220. private _positionUVWName;
  55221. private _directionWName;
  55222. private _reflectionCoordsName;
  55223. private _reflection2DCoordsName;
  55224. private _reflectionColorName;
  55225. private _reflectionMatrixName;
  55226. /**
  55227. * Gets or sets the texture associated with the node
  55228. */
  55229. texture: Nullable<BaseTexture>;
  55230. /**
  55231. * Create a new TextureBlock
  55232. * @param name defines the block name
  55233. */
  55234. constructor(name: string);
  55235. /**
  55236. * Gets the current class name
  55237. * @returns the class name
  55238. */
  55239. getClassName(): string;
  55240. /**
  55241. * Gets the world position input component
  55242. */
  55243. readonly position: NodeMaterialConnectionPoint;
  55244. /**
  55245. * Gets the world position input component
  55246. */
  55247. readonly worldPosition: NodeMaterialConnectionPoint;
  55248. /**
  55249. * Gets the world normal input component
  55250. */
  55251. readonly worldNormal: NodeMaterialConnectionPoint;
  55252. /**
  55253. * Gets the world input component
  55254. */
  55255. readonly world: NodeMaterialConnectionPoint;
  55256. /**
  55257. * Gets the camera (or eye) position component
  55258. */
  55259. readonly cameraPosition: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the view input component
  55262. */
  55263. readonly view: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the rgb output component
  55266. */
  55267. readonly rgb: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the r output component
  55270. */
  55271. readonly r: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the g output component
  55274. */
  55275. readonly g: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the b output component
  55278. */
  55279. readonly b: NodeMaterialConnectionPoint;
  55280. autoConfigure(material: NodeMaterial): void;
  55281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55282. isReady(): boolean;
  55283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55284. private _injectVertexCode;
  55285. private _writeOutput;
  55286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55287. serialize(): any;
  55288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55289. }
  55290. }
  55291. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55292. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55293. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55294. import { Scene } from "babylonjs/scene";
  55295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55296. import { Matrix } from "babylonjs/Maths/math.vector";
  55297. import { Mesh } from "babylonjs/Meshes/mesh";
  55298. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55299. import { Observable } from "babylonjs/Misc/observable";
  55300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55301. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55302. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55303. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55304. import { Nullable } from "babylonjs/types";
  55305. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55306. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55307. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55308. /**
  55309. * Interface used to configure the node material editor
  55310. */
  55311. export interface INodeMaterialEditorOptions {
  55312. /** Define the URl to load node editor script */
  55313. editorURL?: string;
  55314. }
  55315. /** @hidden */
  55316. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55317. /** BONES */
  55318. NUM_BONE_INFLUENCERS: number;
  55319. BonesPerMesh: number;
  55320. BONETEXTURE: boolean;
  55321. /** MORPH TARGETS */
  55322. MORPHTARGETS: boolean;
  55323. MORPHTARGETS_NORMAL: boolean;
  55324. MORPHTARGETS_TANGENT: boolean;
  55325. MORPHTARGETS_UV: boolean;
  55326. NUM_MORPH_INFLUENCERS: number;
  55327. /** IMAGE PROCESSING */
  55328. IMAGEPROCESSING: boolean;
  55329. VIGNETTE: boolean;
  55330. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55331. VIGNETTEBLENDMODEOPAQUE: boolean;
  55332. TONEMAPPING: boolean;
  55333. TONEMAPPING_ACES: boolean;
  55334. CONTRAST: boolean;
  55335. EXPOSURE: boolean;
  55336. COLORCURVES: boolean;
  55337. COLORGRADING: boolean;
  55338. COLORGRADING3D: boolean;
  55339. SAMPLER3DGREENDEPTH: boolean;
  55340. SAMPLER3DBGRMAP: boolean;
  55341. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55342. /** MISC. */
  55343. BUMPDIRECTUV: number;
  55344. constructor();
  55345. setValue(name: string, value: boolean): void;
  55346. }
  55347. /**
  55348. * Class used to configure NodeMaterial
  55349. */
  55350. export interface INodeMaterialOptions {
  55351. /**
  55352. * Defines if blocks should emit comments
  55353. */
  55354. emitComments: boolean;
  55355. }
  55356. /**
  55357. * Class used to create a node based material built by assembling shader blocks
  55358. */
  55359. export class NodeMaterial extends PushMaterial {
  55360. private static _BuildIdGenerator;
  55361. private _options;
  55362. private _vertexCompilationState;
  55363. private _fragmentCompilationState;
  55364. private _sharedData;
  55365. private _buildId;
  55366. private _buildWasSuccessful;
  55367. private _cachedWorldViewMatrix;
  55368. private _cachedWorldViewProjectionMatrix;
  55369. private _optimizers;
  55370. private _animationFrame;
  55371. /** Define the URl to load node editor script */
  55372. static EditorURL: string;
  55373. private BJSNODEMATERIALEDITOR;
  55374. /** Get the inspector from bundle or global */
  55375. private _getGlobalNodeMaterialEditor;
  55376. /**
  55377. * 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)
  55378. */
  55379. ignoreAlpha: boolean;
  55380. /**
  55381. * Defines the maximum number of lights that can be used in the material
  55382. */
  55383. maxSimultaneousLights: number;
  55384. /**
  55385. * Observable raised when the material is built
  55386. */
  55387. onBuildObservable: Observable<NodeMaterial>;
  55388. /**
  55389. * Gets or sets the root nodes of the material vertex shader
  55390. */
  55391. _vertexOutputNodes: NodeMaterialBlock[];
  55392. /**
  55393. * Gets or sets the root nodes of the material fragment (pixel) shader
  55394. */
  55395. _fragmentOutputNodes: NodeMaterialBlock[];
  55396. /** Gets or sets options to control the node material overall behavior */
  55397. options: INodeMaterialOptions;
  55398. /**
  55399. * Default configuration related to image processing available in the standard Material.
  55400. */
  55401. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55402. /**
  55403. * Gets the image processing configuration used either in this material.
  55404. */
  55405. /**
  55406. * Sets the Default image processing configuration used either in the this material.
  55407. *
  55408. * If sets to null, the scene one is in use.
  55409. */
  55410. imageProcessingConfiguration: ImageProcessingConfiguration;
  55411. /**
  55412. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55413. */
  55414. attachedBlocks: NodeMaterialBlock[];
  55415. /**
  55416. * Create a new node based material
  55417. * @param name defines the material name
  55418. * @param scene defines the hosting scene
  55419. * @param options defines creation option
  55420. */
  55421. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55422. /**
  55423. * Gets the current class name of the material e.g. "NodeMaterial"
  55424. * @returns the class name
  55425. */
  55426. getClassName(): string;
  55427. /**
  55428. * Keep track of the image processing observer to allow dispose and replace.
  55429. */
  55430. private _imageProcessingObserver;
  55431. /**
  55432. * Attaches a new image processing configuration to the Standard Material.
  55433. * @param configuration
  55434. */
  55435. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55436. /**
  55437. * Get a block by its name
  55438. * @param name defines the name of the block to retrieve
  55439. * @returns the required block or null if not found
  55440. */
  55441. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55442. /**
  55443. * Get a block by its name
  55444. * @param predicate defines the predicate used to find the good candidate
  55445. * @returns the required block or null if not found
  55446. */
  55447. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55448. /**
  55449. * Get an input block by its name
  55450. * @param predicate defines the predicate used to find the good candidate
  55451. * @returns the required input block or null if not found
  55452. */
  55453. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55454. /**
  55455. * Gets the list of input blocks attached to this material
  55456. * @returns an array of InputBlocks
  55457. */
  55458. getInputBlocks(): InputBlock[];
  55459. /**
  55460. * Adds a new optimizer to the list of optimizers
  55461. * @param optimizer defines the optimizers to add
  55462. * @returns the current material
  55463. */
  55464. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55465. /**
  55466. * Remove an optimizer from the list of optimizers
  55467. * @param optimizer defines the optimizers to remove
  55468. * @returns the current material
  55469. */
  55470. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55471. /**
  55472. * Add a new block to the list of output nodes
  55473. * @param node defines the node to add
  55474. * @returns the current material
  55475. */
  55476. addOutputNode(node: NodeMaterialBlock): this;
  55477. /**
  55478. * Remove a block from the list of root nodes
  55479. * @param node defines the node to remove
  55480. * @returns the current material
  55481. */
  55482. removeOutputNode(node: NodeMaterialBlock): this;
  55483. private _addVertexOutputNode;
  55484. private _removeVertexOutputNode;
  55485. private _addFragmentOutputNode;
  55486. private _removeFragmentOutputNode;
  55487. /**
  55488. * Specifies if the material will require alpha blending
  55489. * @returns a boolean specifying if alpha blending is needed
  55490. */
  55491. needAlphaBlending(): boolean;
  55492. /**
  55493. * Specifies if this material should be rendered in alpha test mode
  55494. * @returns a boolean specifying if an alpha test is needed.
  55495. */
  55496. needAlphaTesting(): boolean;
  55497. private _initializeBlock;
  55498. private _resetDualBlocks;
  55499. /**
  55500. * Build the material and generates the inner effect
  55501. * @param verbose defines if the build should log activity
  55502. */
  55503. build(verbose?: boolean): void;
  55504. /**
  55505. * Runs an otpimization phase to try to improve the shader code
  55506. */
  55507. optimize(): void;
  55508. private _prepareDefinesForAttributes;
  55509. /**
  55510. * Get if the submesh is ready to be used and all its information available.
  55511. * Child classes can use it to update shaders
  55512. * @param mesh defines the mesh to check
  55513. * @param subMesh defines which submesh to check
  55514. * @param useInstances specifies that instances should be used
  55515. * @returns a boolean indicating that the submesh is ready or not
  55516. */
  55517. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55518. /**
  55519. * Get a string representing the shaders built by the current node graph
  55520. */
  55521. readonly compiledShaders: string;
  55522. /**
  55523. * Binds the world matrix to the material
  55524. * @param world defines the world transformation matrix
  55525. */
  55526. bindOnlyWorldMatrix(world: Matrix): void;
  55527. /**
  55528. * Binds the submesh to this material by preparing the effect and shader to draw
  55529. * @param world defines the world transformation matrix
  55530. * @param mesh defines the mesh containing the submesh
  55531. * @param subMesh defines the submesh to bind the material to
  55532. */
  55533. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55534. /**
  55535. * Gets the active textures from the material
  55536. * @returns an array of textures
  55537. */
  55538. getActiveTextures(): BaseTexture[];
  55539. /**
  55540. * Gets the list of texture blocks
  55541. * @returns an array of texture blocks
  55542. */
  55543. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55544. /**
  55545. * Specifies if the material uses a texture
  55546. * @param texture defines the texture to check against the material
  55547. * @returns a boolean specifying if the material uses the texture
  55548. */
  55549. hasTexture(texture: BaseTexture): boolean;
  55550. /**
  55551. * Disposes the material
  55552. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55553. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55554. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55555. */
  55556. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55557. /** Creates the node editor window. */
  55558. private _createNodeEditor;
  55559. /**
  55560. * Launch the node material editor
  55561. * @param config Define the configuration of the editor
  55562. * @return a promise fulfilled when the node editor is visible
  55563. */
  55564. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55565. /**
  55566. * Clear the current material
  55567. */
  55568. clear(): void;
  55569. /**
  55570. * Clear the current material and set it to a default state
  55571. */
  55572. setToDefault(): void;
  55573. /**
  55574. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55575. * @param url defines the url to load from
  55576. * @returns a promise that will fullfil when the material is fully loaded
  55577. */
  55578. loadAsync(url: string): Promise<unknown>;
  55579. private _gatherBlocks;
  55580. /**
  55581. * Generate a string containing the code declaration required to create an equivalent of this material
  55582. * @returns a string
  55583. */
  55584. generateCode(): string;
  55585. /**
  55586. * Serializes this material in a JSON representation
  55587. * @returns the serialized material object
  55588. */
  55589. serialize(): any;
  55590. private _restoreConnections;
  55591. /**
  55592. * Clear the current graph and load a new one from a serialization object
  55593. * @param source defines the JSON representation of the material
  55594. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55595. */
  55596. loadFromSerialization(source: any, rootUrl?: string): void;
  55597. /**
  55598. * Creates a node material from parsed material data
  55599. * @param source defines the JSON representation of the material
  55600. * @param scene defines the hosting scene
  55601. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55602. * @returns a new node material
  55603. */
  55604. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55605. /**
  55606. * Creates a new node material set to default basic configuration
  55607. * @param name defines the name of the material
  55608. * @param scene defines the hosting scene
  55609. * @returns a new NodeMaterial
  55610. */
  55611. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55612. }
  55613. }
  55614. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55615. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55616. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55617. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55620. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55621. import { Effect } from "babylonjs/Materials/effect";
  55622. import { Mesh } from "babylonjs/Meshes/mesh";
  55623. import { Nullable } from "babylonjs/types";
  55624. import { Texture } from "babylonjs/Materials/Textures/texture";
  55625. import { Scene } from "babylonjs/scene";
  55626. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55627. /**
  55628. * Block used to read a texture from a sampler
  55629. */
  55630. export class TextureBlock extends NodeMaterialBlock {
  55631. private _defineName;
  55632. private _linearDefineName;
  55633. private _samplerName;
  55634. private _transformedUVName;
  55635. private _textureTransformName;
  55636. private _textureInfoName;
  55637. private _mainUVName;
  55638. private _mainUVDefineName;
  55639. /**
  55640. * Gets or sets the texture associated with the node
  55641. */
  55642. texture: Nullable<Texture>;
  55643. /**
  55644. * Create a new TextureBlock
  55645. * @param name defines the block name
  55646. */
  55647. constructor(name: string);
  55648. /**
  55649. * Gets the current class name
  55650. * @returns the class name
  55651. */
  55652. getClassName(): string;
  55653. /**
  55654. * Gets the uv input component
  55655. */
  55656. readonly uv: NodeMaterialConnectionPoint;
  55657. /**
  55658. * Gets the rgba output component
  55659. */
  55660. readonly rgba: NodeMaterialConnectionPoint;
  55661. /**
  55662. * Gets the rgb output component
  55663. */
  55664. readonly rgb: NodeMaterialConnectionPoint;
  55665. /**
  55666. * Gets the r output component
  55667. */
  55668. readonly r: NodeMaterialConnectionPoint;
  55669. /**
  55670. * Gets the g output component
  55671. */
  55672. readonly g: NodeMaterialConnectionPoint;
  55673. /**
  55674. * Gets the b output component
  55675. */
  55676. readonly b: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the a output component
  55679. */
  55680. readonly a: NodeMaterialConnectionPoint;
  55681. readonly target: NodeMaterialBlockTargets;
  55682. autoConfigure(material: NodeMaterial): void;
  55683. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55685. isReady(): boolean;
  55686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55687. private readonly _isMixed;
  55688. private _injectVertexCode;
  55689. private _writeOutput;
  55690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55691. protected _dumpPropertiesCode(): string;
  55692. serialize(): any;
  55693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55694. }
  55695. }
  55696. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55697. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55699. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55700. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55701. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55702. import { Scene } from "babylonjs/scene";
  55703. /**
  55704. * Class used to store shared data between 2 NodeMaterialBuildState
  55705. */
  55706. export class NodeMaterialBuildStateSharedData {
  55707. /**
  55708. * Gets the list of emitted varyings
  55709. */
  55710. temps: string[];
  55711. /**
  55712. * Gets the list of emitted varyings
  55713. */
  55714. varyings: string[];
  55715. /**
  55716. * Gets the varying declaration string
  55717. */
  55718. varyingDeclaration: string;
  55719. /**
  55720. * Input blocks
  55721. */
  55722. inputBlocks: InputBlock[];
  55723. /**
  55724. * Input blocks
  55725. */
  55726. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55727. /**
  55728. * Bindable blocks (Blocks that need to set data to the effect)
  55729. */
  55730. bindableBlocks: NodeMaterialBlock[];
  55731. /**
  55732. * List of blocks that can provide a compilation fallback
  55733. */
  55734. blocksWithFallbacks: NodeMaterialBlock[];
  55735. /**
  55736. * List of blocks that can provide a define update
  55737. */
  55738. blocksWithDefines: NodeMaterialBlock[];
  55739. /**
  55740. * List of blocks that can provide a repeatable content
  55741. */
  55742. repeatableContentBlocks: NodeMaterialBlock[];
  55743. /**
  55744. * List of blocks that can provide a dynamic list of uniforms
  55745. */
  55746. dynamicUniformBlocks: NodeMaterialBlock[];
  55747. /**
  55748. * List of blocks that can block the isReady function for the material
  55749. */
  55750. blockingBlocks: NodeMaterialBlock[];
  55751. /**
  55752. * Gets the list of animated inputs
  55753. */
  55754. animatedInputs: InputBlock[];
  55755. /**
  55756. * Build Id used to avoid multiple recompilations
  55757. */
  55758. buildId: number;
  55759. /** List of emitted variables */
  55760. variableNames: {
  55761. [key: string]: number;
  55762. };
  55763. /** List of emitted defines */
  55764. defineNames: {
  55765. [key: string]: number;
  55766. };
  55767. /** Should emit comments? */
  55768. emitComments: boolean;
  55769. /** Emit build activity */
  55770. verbose: boolean;
  55771. /** Gets or sets the hosting scene */
  55772. scene: Scene;
  55773. /**
  55774. * Gets the compilation hints emitted at compilation time
  55775. */
  55776. hints: {
  55777. needWorldViewMatrix: boolean;
  55778. needWorldViewProjectionMatrix: boolean;
  55779. needAlphaBlending: boolean;
  55780. needAlphaTesting: boolean;
  55781. };
  55782. /**
  55783. * List of compilation checks
  55784. */
  55785. checks: {
  55786. emitVertex: boolean;
  55787. emitFragment: boolean;
  55788. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55789. };
  55790. /** Creates a new shared data */
  55791. constructor();
  55792. /**
  55793. * Emits console errors and exceptions if there is a failing check
  55794. */
  55795. emitErrors(): void;
  55796. }
  55797. }
  55798. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55799. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55800. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55801. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55802. /**
  55803. * Class used to store node based material build state
  55804. */
  55805. export class NodeMaterialBuildState {
  55806. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55807. supportUniformBuffers: boolean;
  55808. /**
  55809. * Gets the list of emitted attributes
  55810. */
  55811. attributes: string[];
  55812. /**
  55813. * Gets the list of emitted uniforms
  55814. */
  55815. uniforms: string[];
  55816. /**
  55817. * Gets the list of emitted constants
  55818. */
  55819. constants: string[];
  55820. /**
  55821. * Gets the list of emitted uniform buffers
  55822. */
  55823. uniformBuffers: string[];
  55824. /**
  55825. * Gets the list of emitted samplers
  55826. */
  55827. samplers: string[];
  55828. /**
  55829. * Gets the list of emitted functions
  55830. */
  55831. functions: {
  55832. [key: string]: string;
  55833. };
  55834. /**
  55835. * Gets the list of emitted extensions
  55836. */
  55837. extensions: {
  55838. [key: string]: string;
  55839. };
  55840. /**
  55841. * Gets the target of the compilation state
  55842. */
  55843. target: NodeMaterialBlockTargets;
  55844. /**
  55845. * Gets the list of emitted counters
  55846. */
  55847. counters: {
  55848. [key: string]: number;
  55849. };
  55850. /**
  55851. * Shared data between multiple NodeMaterialBuildState instances
  55852. */
  55853. sharedData: NodeMaterialBuildStateSharedData;
  55854. /** @hidden */
  55855. _vertexState: NodeMaterialBuildState;
  55856. /** @hidden */
  55857. _attributeDeclaration: string;
  55858. /** @hidden */
  55859. _uniformDeclaration: string;
  55860. /** @hidden */
  55861. _constantDeclaration: string;
  55862. /** @hidden */
  55863. _samplerDeclaration: string;
  55864. /** @hidden */
  55865. _varyingTransfer: string;
  55866. private _repeatableContentAnchorIndex;
  55867. /** @hidden */
  55868. _builtCompilationString: string;
  55869. /**
  55870. * Gets the emitted compilation strings
  55871. */
  55872. compilationString: string;
  55873. /**
  55874. * Finalize the compilation strings
  55875. * @param state defines the current compilation state
  55876. */
  55877. finalize(state: NodeMaterialBuildState): void;
  55878. /** @hidden */
  55879. readonly _repeatableContentAnchor: string;
  55880. /** @hidden */
  55881. _getFreeVariableName(prefix: string): string;
  55882. /** @hidden */
  55883. _getFreeDefineName(prefix: string): string;
  55884. /** @hidden */
  55885. _excludeVariableName(name: string): void;
  55886. /** @hidden */
  55887. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55888. /** @hidden */
  55889. _emitExtension(name: string, extension: string): void;
  55890. /** @hidden */
  55891. _emitFunction(name: string, code: string, comments: string): void;
  55892. /** @hidden */
  55893. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55894. replaceStrings?: {
  55895. search: RegExp;
  55896. replace: string;
  55897. }[];
  55898. repeatKey?: string;
  55899. }): string;
  55900. /** @hidden */
  55901. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55902. repeatKey?: string;
  55903. removeAttributes?: boolean;
  55904. removeUniforms?: boolean;
  55905. removeVaryings?: boolean;
  55906. removeIfDef?: boolean;
  55907. replaceStrings?: {
  55908. search: RegExp;
  55909. replace: string;
  55910. }[];
  55911. }, storeKey?: string): void;
  55912. /** @hidden */
  55913. _registerTempVariable(name: string): boolean;
  55914. /** @hidden */
  55915. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55916. /** @hidden */
  55917. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55918. /** @hidden */
  55919. _emitFloat(value: number): string;
  55920. }
  55921. }
  55922. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55923. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55924. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55925. import { Nullable } from "babylonjs/types";
  55926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55927. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55928. import { Effect } from "babylonjs/Materials/effect";
  55929. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55930. import { Mesh } from "babylonjs/Meshes/mesh";
  55931. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55932. import { Scene } from "babylonjs/scene";
  55933. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55934. /**
  55935. * Defines a block that can be used inside a node based material
  55936. */
  55937. export class NodeMaterialBlock {
  55938. private _buildId;
  55939. private _buildTarget;
  55940. private _target;
  55941. private _isFinalMerger;
  55942. private _isInput;
  55943. /** @hidden */
  55944. _codeVariableName: string;
  55945. /** @hidden */
  55946. _inputs: NodeMaterialConnectionPoint[];
  55947. /** @hidden */
  55948. _outputs: NodeMaterialConnectionPoint[];
  55949. /** @hidden */
  55950. _preparationId: number;
  55951. /**
  55952. * Gets or sets the name of the block
  55953. */
  55954. name: string;
  55955. /**
  55956. * Gets or sets the unique id of the node
  55957. */
  55958. uniqueId: number;
  55959. /**
  55960. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55961. */
  55962. readonly isFinalMerger: boolean;
  55963. /**
  55964. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55965. */
  55966. readonly isInput: boolean;
  55967. /**
  55968. * Gets or sets the build Id
  55969. */
  55970. buildId: number;
  55971. /**
  55972. * Gets or sets the target of the block
  55973. */
  55974. target: NodeMaterialBlockTargets;
  55975. /**
  55976. * Gets the list of input points
  55977. */
  55978. readonly inputs: NodeMaterialConnectionPoint[];
  55979. /** Gets the list of output points */
  55980. readonly outputs: NodeMaterialConnectionPoint[];
  55981. /**
  55982. * Find an input by its name
  55983. * @param name defines the name of the input to look for
  55984. * @returns the input or null if not found
  55985. */
  55986. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55987. /**
  55988. * Find an output by its name
  55989. * @param name defines the name of the outputto look for
  55990. * @returns the output or null if not found
  55991. */
  55992. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55993. /**
  55994. * Creates a new NodeMaterialBlock
  55995. * @param name defines the block name
  55996. * @param target defines the target of that block (Vertex by default)
  55997. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55998. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55999. */
  56000. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56001. /**
  56002. * Initialize the block and prepare the context for build
  56003. * @param state defines the state that will be used for the build
  56004. */
  56005. initialize(state: NodeMaterialBuildState): void;
  56006. /**
  56007. * Bind data to effect. Will only be called for blocks with isBindable === true
  56008. * @param effect defines the effect to bind data to
  56009. * @param nodeMaterial defines the hosting NodeMaterial
  56010. * @param mesh defines the mesh that will be rendered
  56011. */
  56012. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56013. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56014. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56015. protected _writeFloat(value: number): string;
  56016. /**
  56017. * Gets the current class name e.g. "NodeMaterialBlock"
  56018. * @returns the class name
  56019. */
  56020. getClassName(): string;
  56021. /**
  56022. * Register a new input. Must be called inside a block constructor
  56023. * @param name defines the connection point name
  56024. * @param type defines the connection point type
  56025. * @param isOptional defines a boolean indicating that this input can be omitted
  56026. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56027. * @returns the current block
  56028. */
  56029. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56030. /**
  56031. * Register a new output. Must be called inside a block constructor
  56032. * @param name defines the connection point name
  56033. * @param type defines the connection point type
  56034. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56035. * @returns the current block
  56036. */
  56037. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56038. /**
  56039. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56040. * @param forOutput defines an optional connection point to check compatibility with
  56041. * @returns the first available input or null
  56042. */
  56043. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56044. /**
  56045. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56046. * @param forBlock defines an optional block to check compatibility with
  56047. * @returns the first available input or null
  56048. */
  56049. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56050. /**
  56051. * Gets the sibling of the given output
  56052. * @param current defines the current output
  56053. * @returns the next output in the list or null
  56054. */
  56055. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56056. /**
  56057. * Connect current block with another block
  56058. * @param other defines the block to connect with
  56059. * @param options define the various options to help pick the right connections
  56060. * @returns the current block
  56061. */
  56062. connectTo(other: NodeMaterialBlock, options?: {
  56063. input?: string;
  56064. output?: string;
  56065. outputSwizzle?: string;
  56066. }): this | undefined;
  56067. protected _buildBlock(state: NodeMaterialBuildState): void;
  56068. /**
  56069. * Add uniforms, samplers and uniform buffers at compilation time
  56070. * @param state defines the state to update
  56071. * @param nodeMaterial defines the node material requesting the update
  56072. * @param defines defines the material defines to update
  56073. */
  56074. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56075. /**
  56076. * Add potential fallbacks if shader compilation fails
  56077. * @param mesh defines the mesh to be rendered
  56078. * @param fallbacks defines the current prioritized list of fallbacks
  56079. */
  56080. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56081. /**
  56082. * Initialize defines for shader compilation
  56083. * @param mesh defines the mesh to be rendered
  56084. * @param nodeMaterial defines the node material requesting the update
  56085. * @param defines defines the material defines to update
  56086. * @param useInstances specifies that instances should be used
  56087. */
  56088. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56089. /**
  56090. * Update defines for shader compilation
  56091. * @param mesh defines the mesh to be rendered
  56092. * @param nodeMaterial defines the node material requesting the update
  56093. * @param defines defines the material defines to update
  56094. * @param useInstances specifies that instances should be used
  56095. */
  56096. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56097. /**
  56098. * Lets the block try to connect some inputs automatically
  56099. * @param material defines the hosting NodeMaterial
  56100. */
  56101. autoConfigure(material: NodeMaterial): void;
  56102. /**
  56103. * Function called when a block is declared as repeatable content generator
  56104. * @param vertexShaderState defines the current compilation state for the vertex shader
  56105. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56106. * @param mesh defines the mesh to be rendered
  56107. * @param defines defines the material defines to update
  56108. */
  56109. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56110. /**
  56111. * Checks if the block is ready
  56112. * @param mesh defines the mesh to be rendered
  56113. * @param nodeMaterial defines the node material requesting the update
  56114. * @param defines defines the material defines to update
  56115. * @param useInstances specifies that instances should be used
  56116. * @returns true if the block is ready
  56117. */
  56118. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56119. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56120. private _processBuild;
  56121. /**
  56122. * Compile the current node and generate the shader code
  56123. * @param state defines the current compilation state (uniforms, samplers, current string)
  56124. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56125. * @returns true if already built
  56126. */
  56127. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56128. protected _inputRename(name: string): string;
  56129. protected _outputRename(name: string): string;
  56130. protected _dumpPropertiesCode(): string;
  56131. /** @hidden */
  56132. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56133. /**
  56134. * Clone the current block to a new identical block
  56135. * @param scene defines the hosting scene
  56136. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56137. * @returns a copy of the current block
  56138. */
  56139. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56140. /**
  56141. * Serializes this block in a JSON representation
  56142. * @returns the serialized block object
  56143. */
  56144. serialize(): any;
  56145. /** @hidden */
  56146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56147. }
  56148. }
  56149. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56150. /**
  56151. * Enum defining the type of animations supported by InputBlock
  56152. */
  56153. export enum AnimatedInputBlockTypes {
  56154. /** No animation */
  56155. None = 0,
  56156. /** Time based animation. Will only work for floats */
  56157. Time = 1
  56158. }
  56159. }
  56160. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56162. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56163. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56164. import { Nullable } from "babylonjs/types";
  56165. import { Effect } from "babylonjs/Materials/effect";
  56166. import { Matrix } from "babylonjs/Maths/math.vector";
  56167. import { Scene } from "babylonjs/scene";
  56168. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56169. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56170. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56171. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56172. /**
  56173. * Block used to expose an input value
  56174. */
  56175. export class InputBlock extends NodeMaterialBlock {
  56176. private _mode;
  56177. private _associatedVariableName;
  56178. private _storedValue;
  56179. private _valueCallback;
  56180. private _type;
  56181. private _animationType;
  56182. /** Gets or set a value used to limit the range of float values */
  56183. min: number;
  56184. /** Gets or set a value used to limit the range of float values */
  56185. max: number;
  56186. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56187. matrixMode: number;
  56188. /** @hidden */
  56189. _systemValue: Nullable<NodeMaterialSystemValues>;
  56190. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56191. visibleInInspector: boolean;
  56192. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56193. isConstant: boolean;
  56194. /**
  56195. * Gets or sets the connection point type (default is float)
  56196. */
  56197. readonly type: NodeMaterialBlockConnectionPointTypes;
  56198. /**
  56199. * Creates a new InputBlock
  56200. * @param name defines the block name
  56201. * @param target defines the target of that block (Vertex by default)
  56202. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56203. */
  56204. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56205. /**
  56206. * Gets the output component
  56207. */
  56208. readonly output: NodeMaterialConnectionPoint;
  56209. /**
  56210. * Set the source of this connection point to a vertex attribute
  56211. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56212. * @returns the current connection point
  56213. */
  56214. setAsAttribute(attributeName?: string): InputBlock;
  56215. /**
  56216. * Set the source of this connection point to a system value
  56217. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56218. * @returns the current connection point
  56219. */
  56220. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56221. /**
  56222. * Gets or sets the value of that point.
  56223. * Please note that this value will be ignored if valueCallback is defined
  56224. */
  56225. value: any;
  56226. /**
  56227. * Gets or sets a callback used to get the value of that point.
  56228. * Please note that setting this value will force the connection point to ignore the value property
  56229. */
  56230. valueCallback: () => any;
  56231. /**
  56232. * Gets or sets the associated variable name in the shader
  56233. */
  56234. associatedVariableName: string;
  56235. /** Gets or sets the type of animation applied to the input */
  56236. animationType: AnimatedInputBlockTypes;
  56237. /**
  56238. * Gets a boolean indicating that this connection point not defined yet
  56239. */
  56240. readonly isUndefined: boolean;
  56241. /**
  56242. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56243. * In this case the connection point name must be the name of the uniform to use.
  56244. * Can only be set on inputs
  56245. */
  56246. isUniform: boolean;
  56247. /**
  56248. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56249. * In this case the connection point name must be the name of the attribute to use
  56250. * Can only be set on inputs
  56251. */
  56252. isAttribute: boolean;
  56253. /**
  56254. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56255. * Can only be set on exit points
  56256. */
  56257. isVarying: boolean;
  56258. /**
  56259. * Gets a boolean indicating that the current connection point is a system value
  56260. */
  56261. readonly isSystemValue: boolean;
  56262. /**
  56263. * Gets or sets the current well known value or null if not defined as a system value
  56264. */
  56265. systemValue: Nullable<NodeMaterialSystemValues>;
  56266. /**
  56267. * Gets the current class name
  56268. * @returns the class name
  56269. */
  56270. getClassName(): string;
  56271. /**
  56272. * Animate the input if animationType !== None
  56273. * @param scene defines the rendering scene
  56274. */
  56275. animate(scene: Scene): void;
  56276. private _emitDefine;
  56277. initialize(state: NodeMaterialBuildState): void;
  56278. /**
  56279. * Set the input block to its default value (based on its type)
  56280. */
  56281. setDefaultValue(): void;
  56282. private _emitConstant;
  56283. private _emit;
  56284. /** @hidden */
  56285. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56286. /** @hidden */
  56287. _transmit(effect: Effect, scene: Scene): void;
  56288. protected _buildBlock(state: NodeMaterialBuildState): void;
  56289. protected _dumpPropertiesCode(): string;
  56290. serialize(): any;
  56291. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56292. }
  56293. }
  56294. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56295. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56296. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56297. import { Nullable } from "babylonjs/types";
  56298. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56299. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56300. /**
  56301. * Defines a connection point for a block
  56302. */
  56303. export class NodeMaterialConnectionPoint {
  56304. /** @hidden */
  56305. _ownerBlock: NodeMaterialBlock;
  56306. /** @hidden */
  56307. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56308. private _endpoints;
  56309. private _associatedVariableName;
  56310. /** @hidden */
  56311. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56312. /** @hidden */
  56313. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56314. private _type;
  56315. /** @hidden */
  56316. _enforceAssociatedVariableName: boolean;
  56317. /**
  56318. * Gets or sets the additional types supported by this connection point
  56319. */
  56320. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56321. /**
  56322. * Gets or sets the additional types excluded by this connection point
  56323. */
  56324. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56325. /**
  56326. * Gets or sets the associated variable name in the shader
  56327. */
  56328. associatedVariableName: string;
  56329. /**
  56330. * Gets or sets the connection point type (default is float)
  56331. */
  56332. type: NodeMaterialBlockConnectionPointTypes;
  56333. /**
  56334. * Gets or sets the connection point name
  56335. */
  56336. name: string;
  56337. /**
  56338. * Gets or sets a boolean indicating that this connection point can be omitted
  56339. */
  56340. isOptional: boolean;
  56341. /**
  56342. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56343. */
  56344. define: string;
  56345. /** Gets or sets the target of that connection point */
  56346. target: NodeMaterialBlockTargets;
  56347. /**
  56348. * Gets a boolean indicating that the current point is connected
  56349. */
  56350. readonly isConnected: boolean;
  56351. /**
  56352. * Gets a boolean indicating that the current point is connected to an input block
  56353. */
  56354. readonly isConnectedToInputBlock: boolean;
  56355. /**
  56356. * Gets a the connected input block (if any)
  56357. */
  56358. readonly connectInputBlock: Nullable<InputBlock>;
  56359. /** Get the other side of the connection (if any) */
  56360. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56361. /** Get the block that owns this connection point */
  56362. readonly ownerBlock: NodeMaterialBlock;
  56363. /** Get the block connected on the other side of this connection (if any) */
  56364. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56365. /** Get the block connected on the endpoints of this connection (if any) */
  56366. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56367. /** Gets the list of connected endpoints */
  56368. readonly endpoints: NodeMaterialConnectionPoint[];
  56369. /** Gets a boolean indicating if that output point is connected to at least one input */
  56370. readonly hasEndpoints: boolean;
  56371. /**
  56372. * Creates a new connection point
  56373. * @param name defines the connection point name
  56374. * @param ownerBlock defines the block hosting this connection point
  56375. */
  56376. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56377. /**
  56378. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56379. * @returns the class name
  56380. */
  56381. getClassName(): string;
  56382. /**
  56383. * Gets an boolean indicating if the current point can be connected to another point
  56384. * @param connectionPoint defines the other connection point
  56385. * @returns true if the connection is possible
  56386. */
  56387. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56388. /**
  56389. * Connect this point to another connection point
  56390. * @param connectionPoint defines the other connection point
  56391. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56392. * @returns the current connection point
  56393. */
  56394. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56395. /**
  56396. * Disconnect this point from one of his endpoint
  56397. * @param endpoint defines the other connection point
  56398. * @returns the current connection point
  56399. */
  56400. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56401. /**
  56402. * Serializes this point in a JSON representation
  56403. * @returns the serialized point object
  56404. */
  56405. serialize(): any;
  56406. }
  56407. }
  56408. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56412. import { Mesh } from "babylonjs/Meshes/mesh";
  56413. import { Effect } from "babylonjs/Materials/effect";
  56414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56415. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56416. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56417. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56418. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56419. /**
  56420. * Block used to add support for vertex skinning (bones)
  56421. */
  56422. export class BonesBlock extends NodeMaterialBlock {
  56423. /**
  56424. * Creates a new BonesBlock
  56425. * @param name defines the block name
  56426. */
  56427. constructor(name: string);
  56428. /**
  56429. * Initialize the block and prepare the context for build
  56430. * @param state defines the state that will be used for the build
  56431. */
  56432. initialize(state: NodeMaterialBuildState): void;
  56433. /**
  56434. * Gets the current class name
  56435. * @returns the class name
  56436. */
  56437. getClassName(): string;
  56438. /**
  56439. * Gets the matrix indices input component
  56440. */
  56441. readonly matricesIndices: NodeMaterialConnectionPoint;
  56442. /**
  56443. * Gets the matrix weights input component
  56444. */
  56445. readonly matricesWeights: NodeMaterialConnectionPoint;
  56446. /**
  56447. * Gets the extra matrix indices input component
  56448. */
  56449. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56450. /**
  56451. * Gets the extra matrix weights input component
  56452. */
  56453. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56454. /**
  56455. * Gets the world input component
  56456. */
  56457. readonly world: NodeMaterialConnectionPoint;
  56458. /**
  56459. * Gets the output component
  56460. */
  56461. readonly output: NodeMaterialConnectionPoint;
  56462. autoConfigure(material: NodeMaterial): void;
  56463. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56466. protected _buildBlock(state: NodeMaterialBuildState): this;
  56467. }
  56468. }
  56469. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56470. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56471. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56472. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56473. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56474. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56475. /**
  56476. * Block used to add support for instances
  56477. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56478. */
  56479. export class InstancesBlock extends NodeMaterialBlock {
  56480. /**
  56481. * Creates a new InstancesBlock
  56482. * @param name defines the block name
  56483. */
  56484. constructor(name: string);
  56485. /**
  56486. * Gets the current class name
  56487. * @returns the class name
  56488. */
  56489. getClassName(): string;
  56490. /**
  56491. * Gets the first world row input component
  56492. */
  56493. readonly world0: NodeMaterialConnectionPoint;
  56494. /**
  56495. * Gets the second world row input component
  56496. */
  56497. readonly world1: NodeMaterialConnectionPoint;
  56498. /**
  56499. * Gets the third world row input component
  56500. */
  56501. readonly world2: NodeMaterialConnectionPoint;
  56502. /**
  56503. * Gets the forth world row input component
  56504. */
  56505. readonly world3: NodeMaterialConnectionPoint;
  56506. /**
  56507. * Gets the world input component
  56508. */
  56509. readonly world: NodeMaterialConnectionPoint;
  56510. /**
  56511. * Gets the output component
  56512. */
  56513. readonly output: NodeMaterialConnectionPoint;
  56514. autoConfigure(material: NodeMaterial): void;
  56515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56516. protected _buildBlock(state: NodeMaterialBuildState): this;
  56517. }
  56518. }
  56519. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56520. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56521. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56522. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56523. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56524. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56525. import { Effect } from "babylonjs/Materials/effect";
  56526. import { Mesh } from "babylonjs/Meshes/mesh";
  56527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56528. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56529. /**
  56530. * Block used to add morph targets support to vertex shader
  56531. */
  56532. export class MorphTargetsBlock extends NodeMaterialBlock {
  56533. private _repeatableContentAnchor;
  56534. private _repeatebleContentGenerated;
  56535. /**
  56536. * Create a new MorphTargetsBlock
  56537. * @param name defines the block name
  56538. */
  56539. constructor(name: string);
  56540. /**
  56541. * Gets the current class name
  56542. * @returns the class name
  56543. */
  56544. getClassName(): string;
  56545. /**
  56546. * Gets the position input component
  56547. */
  56548. readonly position: NodeMaterialConnectionPoint;
  56549. /**
  56550. * Gets the normal input component
  56551. */
  56552. readonly normal: NodeMaterialConnectionPoint;
  56553. /**
  56554. * Gets the tangent input component
  56555. */
  56556. readonly tangent: NodeMaterialConnectionPoint;
  56557. /**
  56558. * Gets the tangent input component
  56559. */
  56560. readonly uv: NodeMaterialConnectionPoint;
  56561. /**
  56562. * Gets the position output component
  56563. */
  56564. readonly positionOutput: NodeMaterialConnectionPoint;
  56565. /**
  56566. * Gets the normal output component
  56567. */
  56568. readonly normalOutput: NodeMaterialConnectionPoint;
  56569. /**
  56570. * Gets the tangent output component
  56571. */
  56572. readonly tangentOutput: NodeMaterialConnectionPoint;
  56573. /**
  56574. * Gets the tangent output component
  56575. */
  56576. readonly uvOutput: NodeMaterialConnectionPoint;
  56577. initialize(state: NodeMaterialBuildState): void;
  56578. autoConfigure(material: NodeMaterial): void;
  56579. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56580. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56581. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56582. protected _buildBlock(state: NodeMaterialBuildState): this;
  56583. }
  56584. }
  56585. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56586. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56587. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56588. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56589. import { Nullable } from "babylonjs/types";
  56590. import { Scene } from "babylonjs/scene";
  56591. import { Effect } from "babylonjs/Materials/effect";
  56592. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56593. import { Mesh } from "babylonjs/Meshes/mesh";
  56594. import { Light } from "babylonjs/Lights/light";
  56595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56596. /**
  56597. * Block used to get data information from a light
  56598. */
  56599. export class LightInformationBlock extends NodeMaterialBlock {
  56600. private _lightDataUniformName;
  56601. private _lightColorUniformName;
  56602. private _lightTypeDefineName;
  56603. /**
  56604. * Gets or sets the light associated with this block
  56605. */
  56606. light: Nullable<Light>;
  56607. /**
  56608. * Creates a new LightInformationBlock
  56609. * @param name defines the block name
  56610. */
  56611. constructor(name: string);
  56612. /**
  56613. * Gets the current class name
  56614. * @returns the class name
  56615. */
  56616. getClassName(): string;
  56617. /**
  56618. * Gets the world position input component
  56619. */
  56620. readonly worldPosition: NodeMaterialConnectionPoint;
  56621. /**
  56622. * Gets the direction output component
  56623. */
  56624. readonly direction: NodeMaterialConnectionPoint;
  56625. /**
  56626. * Gets the direction output component
  56627. */
  56628. readonly color: NodeMaterialConnectionPoint;
  56629. /**
  56630. * Gets the direction output component
  56631. */
  56632. readonly intensity: NodeMaterialConnectionPoint;
  56633. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56635. protected _buildBlock(state: NodeMaterialBuildState): this;
  56636. serialize(): any;
  56637. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56638. }
  56639. }
  56640. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56641. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56642. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56643. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56644. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56645. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56646. }
  56647. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56648. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56649. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56650. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56651. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56652. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56653. import { Effect } from "babylonjs/Materials/effect";
  56654. import { Mesh } from "babylonjs/Meshes/mesh";
  56655. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56656. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56657. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56658. /**
  56659. * Block used to add image processing support to fragment shader
  56660. */
  56661. export class ImageProcessingBlock extends NodeMaterialBlock {
  56662. /**
  56663. * Create a new ImageProcessingBlock
  56664. * @param name defines the block name
  56665. */
  56666. constructor(name: string);
  56667. /**
  56668. * Gets the current class name
  56669. * @returns the class name
  56670. */
  56671. getClassName(): string;
  56672. /**
  56673. * Gets the color input component
  56674. */
  56675. readonly color: NodeMaterialConnectionPoint;
  56676. /**
  56677. * Gets the output component
  56678. */
  56679. readonly output: NodeMaterialConnectionPoint;
  56680. /**
  56681. * Initialize the block and prepare the context for build
  56682. * @param state defines the state that will be used for the build
  56683. */
  56684. initialize(state: NodeMaterialBuildState): void;
  56685. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56686. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56687. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56688. protected _buildBlock(state: NodeMaterialBuildState): this;
  56689. }
  56690. }
  56691. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56692. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56693. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56694. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56695. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56697. import { Effect } from "babylonjs/Materials/effect";
  56698. import { Mesh } from "babylonjs/Meshes/mesh";
  56699. import { Scene } from "babylonjs/scene";
  56700. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56701. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56702. /**
  56703. * Block used to pertub normals based on a normal map
  56704. */
  56705. export class PerturbNormalBlock extends NodeMaterialBlock {
  56706. private _tangentSpaceParameterName;
  56707. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56708. invertX: boolean;
  56709. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56710. invertY: boolean;
  56711. /**
  56712. * Create a new PerturbNormalBlock
  56713. * @param name defines the block name
  56714. */
  56715. constructor(name: string);
  56716. /**
  56717. * Gets the current class name
  56718. * @returns the class name
  56719. */
  56720. getClassName(): string;
  56721. /**
  56722. * Gets the world position input component
  56723. */
  56724. readonly worldPosition: NodeMaterialConnectionPoint;
  56725. /**
  56726. * Gets the world normal input component
  56727. */
  56728. readonly worldNormal: NodeMaterialConnectionPoint;
  56729. /**
  56730. * Gets the uv input component
  56731. */
  56732. readonly uv: NodeMaterialConnectionPoint;
  56733. /**
  56734. * Gets the normal map color input component
  56735. */
  56736. readonly normalMapColor: NodeMaterialConnectionPoint;
  56737. /**
  56738. * Gets the strength input component
  56739. */
  56740. readonly strength: NodeMaterialConnectionPoint;
  56741. /**
  56742. * Gets the output component
  56743. */
  56744. readonly output: NodeMaterialConnectionPoint;
  56745. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56746. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56747. autoConfigure(material: NodeMaterial): void;
  56748. protected _buildBlock(state: NodeMaterialBuildState): this;
  56749. protected _dumpPropertiesCode(): string;
  56750. serialize(): any;
  56751. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56752. }
  56753. }
  56754. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56758. /**
  56759. * Block used to discard a pixel if a value is smaller than a cutoff
  56760. */
  56761. export class DiscardBlock extends NodeMaterialBlock {
  56762. /**
  56763. * Create a new DiscardBlock
  56764. * @param name defines the block name
  56765. */
  56766. constructor(name: string);
  56767. /**
  56768. * Gets the current class name
  56769. * @returns the class name
  56770. */
  56771. getClassName(): string;
  56772. /**
  56773. * Gets the color input component
  56774. */
  56775. readonly value: NodeMaterialConnectionPoint;
  56776. /**
  56777. * Gets the cutoff input component
  56778. */
  56779. readonly cutoff: NodeMaterialConnectionPoint;
  56780. protected _buildBlock(state: NodeMaterialBuildState): this;
  56781. }
  56782. }
  56783. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56784. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56785. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56786. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56787. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56788. }
  56789. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56790. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56791. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56792. import { Mesh } from "babylonjs/Meshes/mesh";
  56793. import { Effect } from "babylonjs/Materials/effect";
  56794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56796. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56797. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56798. /**
  56799. * Block used to add support for scene fog
  56800. */
  56801. export class FogBlock extends NodeMaterialBlock {
  56802. private _fogDistanceName;
  56803. private _fogParameters;
  56804. /**
  56805. * Create a new FogBlock
  56806. * @param name defines the block name
  56807. */
  56808. constructor(name: string);
  56809. /**
  56810. * Gets the current class name
  56811. * @returns the class name
  56812. */
  56813. getClassName(): string;
  56814. /**
  56815. * Gets the world position input component
  56816. */
  56817. readonly worldPosition: NodeMaterialConnectionPoint;
  56818. /**
  56819. * Gets the view input component
  56820. */
  56821. readonly view: NodeMaterialConnectionPoint;
  56822. /**
  56823. * Gets the color input component
  56824. */
  56825. readonly input: NodeMaterialConnectionPoint;
  56826. /**
  56827. * Gets the fog color input component
  56828. */
  56829. readonly fogColor: NodeMaterialConnectionPoint;
  56830. /**
  56831. * Gets the output component
  56832. */
  56833. readonly output: NodeMaterialConnectionPoint;
  56834. autoConfigure(material: NodeMaterial): void;
  56835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56836. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56837. protected _buildBlock(state: NodeMaterialBuildState): this;
  56838. }
  56839. }
  56840. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56841. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56842. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56843. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56844. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56845. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56846. import { Effect } from "babylonjs/Materials/effect";
  56847. import { Mesh } from "babylonjs/Meshes/mesh";
  56848. import { Light } from "babylonjs/Lights/light";
  56849. import { Nullable } from "babylonjs/types";
  56850. import { Scene } from "babylonjs/scene";
  56851. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56852. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56853. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56854. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56855. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56856. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56857. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56858. /**
  56859. * Block used to add light in the fragment shader
  56860. */
  56861. export class LightBlock extends NodeMaterialBlock {
  56862. private _lightId;
  56863. /**
  56864. * Gets or sets the light associated with this block
  56865. */
  56866. light: Nullable<Light>;
  56867. /**
  56868. * Create a new LightBlock
  56869. * @param name defines the block name
  56870. */
  56871. constructor(name: string);
  56872. /**
  56873. * Gets the current class name
  56874. * @returns the class name
  56875. */
  56876. getClassName(): string;
  56877. /**
  56878. * Gets the world position input component
  56879. */
  56880. readonly worldPosition: NodeMaterialConnectionPoint;
  56881. /**
  56882. * Gets the world normal input component
  56883. */
  56884. readonly worldNormal: NodeMaterialConnectionPoint;
  56885. /**
  56886. * Gets the camera (or eye) position component
  56887. */
  56888. readonly cameraPosition: NodeMaterialConnectionPoint;
  56889. /**
  56890. * Gets the glossiness component
  56891. */
  56892. readonly glossiness: NodeMaterialConnectionPoint;
  56893. /**
  56894. * Gets the glossinness power component
  56895. */
  56896. readonly glossPower: NodeMaterialConnectionPoint;
  56897. /**
  56898. * Gets the diffuse color component
  56899. */
  56900. readonly diffuseColor: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the specular color component
  56903. */
  56904. readonly specularColor: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the diffuse output component
  56907. */
  56908. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the specular output component
  56911. */
  56912. readonly specularOutput: NodeMaterialConnectionPoint;
  56913. autoConfigure(material: NodeMaterial): void;
  56914. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56915. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56916. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56917. private _injectVertexCode;
  56918. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56919. serialize(): any;
  56920. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56921. }
  56922. }
  56923. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56924. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56925. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56926. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56927. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56928. }
  56929. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56930. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56931. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56932. }
  56933. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56934. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56935. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56936. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56937. /**
  56938. * Block used to multiply 2 values
  56939. */
  56940. export class MultiplyBlock extends NodeMaterialBlock {
  56941. /**
  56942. * Creates a new MultiplyBlock
  56943. * @param name defines the block name
  56944. */
  56945. constructor(name: string);
  56946. /**
  56947. * Gets the current class name
  56948. * @returns the class name
  56949. */
  56950. getClassName(): string;
  56951. /**
  56952. * Gets the left operand input component
  56953. */
  56954. readonly left: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the right operand input component
  56957. */
  56958. readonly right: NodeMaterialConnectionPoint;
  56959. /**
  56960. * Gets the output component
  56961. */
  56962. readonly output: NodeMaterialConnectionPoint;
  56963. protected _buildBlock(state: NodeMaterialBuildState): this;
  56964. }
  56965. }
  56966. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56970. /**
  56971. * Block used to add 2 vectors
  56972. */
  56973. export class AddBlock extends NodeMaterialBlock {
  56974. /**
  56975. * Creates a new AddBlock
  56976. * @param name defines the block name
  56977. */
  56978. constructor(name: string);
  56979. /**
  56980. * Gets the current class name
  56981. * @returns the class name
  56982. */
  56983. getClassName(): string;
  56984. /**
  56985. * Gets the left operand input component
  56986. */
  56987. readonly left: NodeMaterialConnectionPoint;
  56988. /**
  56989. * Gets the right operand input component
  56990. */
  56991. readonly right: NodeMaterialConnectionPoint;
  56992. /**
  56993. * Gets the output component
  56994. */
  56995. readonly output: NodeMaterialConnectionPoint;
  56996. protected _buildBlock(state: NodeMaterialBuildState): this;
  56997. }
  56998. }
  56999. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57003. /**
  57004. * Block used to scale a vector by a float
  57005. */
  57006. export class ScaleBlock extends NodeMaterialBlock {
  57007. /**
  57008. * Creates a new ScaleBlock
  57009. * @param name defines the block name
  57010. */
  57011. constructor(name: string);
  57012. /**
  57013. * Gets the current class name
  57014. * @returns the class name
  57015. */
  57016. getClassName(): string;
  57017. /**
  57018. * Gets the input component
  57019. */
  57020. readonly input: NodeMaterialConnectionPoint;
  57021. /**
  57022. * Gets the factor input component
  57023. */
  57024. readonly factor: NodeMaterialConnectionPoint;
  57025. /**
  57026. * Gets the output component
  57027. */
  57028. readonly output: NodeMaterialConnectionPoint;
  57029. protected _buildBlock(state: NodeMaterialBuildState): this;
  57030. }
  57031. }
  57032. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57036. import { Scene } from "babylonjs/scene";
  57037. /**
  57038. * Block used to clamp a float
  57039. */
  57040. export class ClampBlock extends NodeMaterialBlock {
  57041. /** Gets or sets the minimum range */
  57042. minimum: number;
  57043. /** Gets or sets the maximum range */
  57044. maximum: number;
  57045. /**
  57046. * Creates a new ClampBlock
  57047. * @param name defines the block name
  57048. */
  57049. constructor(name: string);
  57050. /**
  57051. * Gets the current class name
  57052. * @returns the class name
  57053. */
  57054. getClassName(): string;
  57055. /**
  57056. * Gets the value input component
  57057. */
  57058. readonly value: NodeMaterialConnectionPoint;
  57059. /**
  57060. * Gets the output component
  57061. */
  57062. readonly output: NodeMaterialConnectionPoint;
  57063. protected _buildBlock(state: NodeMaterialBuildState): this;
  57064. protected _dumpPropertiesCode(): string;
  57065. serialize(): any;
  57066. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57067. }
  57068. }
  57069. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57070. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57071. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57072. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57073. /**
  57074. * Block used to apply a cross product between 2 vectors
  57075. */
  57076. export class CrossBlock extends NodeMaterialBlock {
  57077. /**
  57078. * Creates a new CrossBlock
  57079. * @param name defines the block name
  57080. */
  57081. constructor(name: string);
  57082. /**
  57083. * Gets the current class name
  57084. * @returns the class name
  57085. */
  57086. getClassName(): string;
  57087. /**
  57088. * Gets the left operand input component
  57089. */
  57090. readonly left: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the right operand input component
  57093. */
  57094. readonly right: NodeMaterialConnectionPoint;
  57095. /**
  57096. * Gets the output component
  57097. */
  57098. readonly output: NodeMaterialConnectionPoint;
  57099. protected _buildBlock(state: NodeMaterialBuildState): this;
  57100. }
  57101. }
  57102. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57103. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57104. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57105. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57106. /**
  57107. * Block used to apply a dot product between 2 vectors
  57108. */
  57109. export class DotBlock extends NodeMaterialBlock {
  57110. /**
  57111. * Creates a new DotBlock
  57112. * @param name defines the block name
  57113. */
  57114. constructor(name: string);
  57115. /**
  57116. * Gets the current class name
  57117. * @returns the class name
  57118. */
  57119. getClassName(): string;
  57120. /**
  57121. * Gets the left operand input component
  57122. */
  57123. readonly left: NodeMaterialConnectionPoint;
  57124. /**
  57125. * Gets the right operand input component
  57126. */
  57127. readonly right: NodeMaterialConnectionPoint;
  57128. /**
  57129. * Gets the output component
  57130. */
  57131. readonly output: NodeMaterialConnectionPoint;
  57132. protected _buildBlock(state: NodeMaterialBuildState): this;
  57133. }
  57134. }
  57135. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57136. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57138. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57139. import { Vector2 } from "babylonjs/Maths/math.vector";
  57140. import { Scene } from "babylonjs/scene";
  57141. /**
  57142. * Block used to remap a float from a range to a new one
  57143. */
  57144. export class RemapBlock extends NodeMaterialBlock {
  57145. /**
  57146. * Gets or sets the source range
  57147. */
  57148. sourceRange: Vector2;
  57149. /**
  57150. * Gets or sets the target range
  57151. */
  57152. targetRange: Vector2;
  57153. /**
  57154. * Creates a new RemapBlock
  57155. * @param name defines the block name
  57156. */
  57157. constructor(name: string);
  57158. /**
  57159. * Gets the current class name
  57160. * @returns the class name
  57161. */
  57162. getClassName(): string;
  57163. /**
  57164. * Gets the input component
  57165. */
  57166. readonly input: NodeMaterialConnectionPoint;
  57167. /**
  57168. * Gets the source min input component
  57169. */
  57170. readonly sourceMin: NodeMaterialConnectionPoint;
  57171. /**
  57172. * Gets the source max input component
  57173. */
  57174. readonly sourceMax: NodeMaterialConnectionPoint;
  57175. /**
  57176. * Gets the target min input component
  57177. */
  57178. readonly targetMin: NodeMaterialConnectionPoint;
  57179. /**
  57180. * Gets the target max input component
  57181. */
  57182. readonly targetMax: NodeMaterialConnectionPoint;
  57183. /**
  57184. * Gets the output component
  57185. */
  57186. readonly output: NodeMaterialConnectionPoint;
  57187. protected _buildBlock(state: NodeMaterialBuildState): this;
  57188. protected _dumpPropertiesCode(): string;
  57189. serialize(): any;
  57190. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57191. }
  57192. }
  57193. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57197. /**
  57198. * Block used to normalize a vector
  57199. */
  57200. export class NormalizeBlock extends NodeMaterialBlock {
  57201. /**
  57202. * Creates a new NormalizeBlock
  57203. * @param name defines the block name
  57204. */
  57205. constructor(name: string);
  57206. /**
  57207. * Gets the current class name
  57208. * @returns the class name
  57209. */
  57210. getClassName(): string;
  57211. /**
  57212. * Gets the input component
  57213. */
  57214. readonly input: NodeMaterialConnectionPoint;
  57215. /**
  57216. * Gets the output component
  57217. */
  57218. readonly output: NodeMaterialConnectionPoint;
  57219. protected _buildBlock(state: NodeMaterialBuildState): this;
  57220. }
  57221. }
  57222. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57226. import { Scene } from "babylonjs/scene";
  57227. /**
  57228. * Operations supported by the Trigonometry block
  57229. */
  57230. export enum TrigonometryBlockOperations {
  57231. /** Cos */
  57232. Cos = 0,
  57233. /** Sin */
  57234. Sin = 1,
  57235. /** Abs */
  57236. Abs = 2,
  57237. /** Exp */
  57238. Exp = 3,
  57239. /** Exp2 */
  57240. Exp2 = 4,
  57241. /** Round */
  57242. Round = 5,
  57243. /** Floor */
  57244. Floor = 6,
  57245. /** Ceiling */
  57246. Ceiling = 7,
  57247. /** Square root */
  57248. Sqrt = 8,
  57249. /** Log */
  57250. Log = 9,
  57251. /** Tangent */
  57252. Tan = 10,
  57253. /** Arc tangent */
  57254. ArcTan = 11,
  57255. /** Arc cosinus */
  57256. ArcCos = 12,
  57257. /** Arc sinus */
  57258. ArcSin = 13,
  57259. /** Fraction */
  57260. Fract = 14,
  57261. /** Sign */
  57262. Sign = 15,
  57263. /** To radians (from degrees) */
  57264. Radians = 16,
  57265. /** To degrees (from radians) */
  57266. Degrees = 17
  57267. }
  57268. /**
  57269. * Block used to apply trigonometry operation to floats
  57270. */
  57271. export class TrigonometryBlock extends NodeMaterialBlock {
  57272. /**
  57273. * Gets or sets the operation applied by the block
  57274. */
  57275. operation: TrigonometryBlockOperations;
  57276. /**
  57277. * Creates a new TrigonometryBlock
  57278. * @param name defines the block name
  57279. */
  57280. constructor(name: string);
  57281. /**
  57282. * Gets the current class name
  57283. * @returns the class name
  57284. */
  57285. getClassName(): string;
  57286. /**
  57287. * Gets the input component
  57288. */
  57289. readonly input: NodeMaterialConnectionPoint;
  57290. /**
  57291. * Gets the output component
  57292. */
  57293. readonly output: NodeMaterialConnectionPoint;
  57294. protected _buildBlock(state: NodeMaterialBuildState): this;
  57295. serialize(): any;
  57296. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57297. }
  57298. }
  57299. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57300. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57301. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57302. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57303. /**
  57304. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57305. */
  57306. export class ColorMergerBlock extends NodeMaterialBlock {
  57307. /**
  57308. * Create a new ColorMergerBlock
  57309. * @param name defines the block name
  57310. */
  57311. constructor(name: string);
  57312. /**
  57313. * Gets the current class name
  57314. * @returns the class name
  57315. */
  57316. getClassName(): string;
  57317. /**
  57318. * Gets the r component (input)
  57319. */
  57320. readonly r: NodeMaterialConnectionPoint;
  57321. /**
  57322. * Gets the g component (input)
  57323. */
  57324. readonly g: NodeMaterialConnectionPoint;
  57325. /**
  57326. * Gets the b component (input)
  57327. */
  57328. readonly b: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the a component (input)
  57331. */
  57332. readonly a: NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the rgba component (output)
  57335. */
  57336. readonly rgba: NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the rgb component (output)
  57339. */
  57340. readonly rgb: NodeMaterialConnectionPoint;
  57341. protected _buildBlock(state: NodeMaterialBuildState): this;
  57342. }
  57343. }
  57344. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57345. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57346. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57347. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57348. /**
  57349. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57350. */
  57351. export class VectorMergerBlock extends NodeMaterialBlock {
  57352. /**
  57353. * Create a new VectorMergerBlock
  57354. * @param name defines the block name
  57355. */
  57356. constructor(name: string);
  57357. /**
  57358. * Gets the current class name
  57359. * @returns the class name
  57360. */
  57361. getClassName(): string;
  57362. /**
  57363. * Gets the x component (input)
  57364. */
  57365. readonly x: NodeMaterialConnectionPoint;
  57366. /**
  57367. * Gets the y component (input)
  57368. */
  57369. readonly y: NodeMaterialConnectionPoint;
  57370. /**
  57371. * Gets the z component (input)
  57372. */
  57373. readonly z: NodeMaterialConnectionPoint;
  57374. /**
  57375. * Gets the w component (input)
  57376. */
  57377. readonly w: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the xyzw component (output)
  57380. */
  57381. readonly xyzw: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the xyz component (output)
  57384. */
  57385. readonly xyz: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the xy component (output)
  57388. */
  57389. readonly xy: NodeMaterialConnectionPoint;
  57390. protected _buildBlock(state: NodeMaterialBuildState): this;
  57391. }
  57392. }
  57393. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57394. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57395. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57396. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57397. /**
  57398. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57399. */
  57400. export class ColorSplitterBlock extends NodeMaterialBlock {
  57401. /**
  57402. * Create a new ColorSplitterBlock
  57403. * @param name defines the block name
  57404. */
  57405. constructor(name: string);
  57406. /**
  57407. * Gets the current class name
  57408. * @returns the class name
  57409. */
  57410. getClassName(): string;
  57411. /**
  57412. * Gets the rgba component (input)
  57413. */
  57414. readonly rgba: NodeMaterialConnectionPoint;
  57415. /**
  57416. * Gets the rgb component (input)
  57417. */
  57418. readonly rgbIn: NodeMaterialConnectionPoint;
  57419. /**
  57420. * Gets the rgb component (output)
  57421. */
  57422. readonly rgbOut: NodeMaterialConnectionPoint;
  57423. /**
  57424. * Gets the r component (output)
  57425. */
  57426. readonly r: NodeMaterialConnectionPoint;
  57427. /**
  57428. * Gets the g component (output)
  57429. */
  57430. readonly g: NodeMaterialConnectionPoint;
  57431. /**
  57432. * Gets the b component (output)
  57433. */
  57434. readonly b: NodeMaterialConnectionPoint;
  57435. /**
  57436. * Gets the a component (output)
  57437. */
  57438. readonly a: NodeMaterialConnectionPoint;
  57439. protected _inputRename(name: string): string;
  57440. protected _outputRename(name: string): string;
  57441. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57442. }
  57443. }
  57444. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57445. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57446. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57447. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57448. /**
  57449. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57450. */
  57451. export class VectorSplitterBlock extends NodeMaterialBlock {
  57452. /**
  57453. * Create a new VectorSplitterBlock
  57454. * @param name defines the block name
  57455. */
  57456. constructor(name: string);
  57457. /**
  57458. * Gets the current class name
  57459. * @returns the class name
  57460. */
  57461. getClassName(): string;
  57462. /**
  57463. * Gets the xyzw component (input)
  57464. */
  57465. readonly xyzw: NodeMaterialConnectionPoint;
  57466. /**
  57467. * Gets the xyz component (input)
  57468. */
  57469. readonly xyzIn: NodeMaterialConnectionPoint;
  57470. /**
  57471. * Gets the xy component (input)
  57472. */
  57473. readonly xyIn: NodeMaterialConnectionPoint;
  57474. /**
  57475. * Gets the xyz component (output)
  57476. */
  57477. readonly xyzOut: NodeMaterialConnectionPoint;
  57478. /**
  57479. * Gets the xy component (output)
  57480. */
  57481. readonly xyOut: NodeMaterialConnectionPoint;
  57482. /**
  57483. * Gets the x component (output)
  57484. */
  57485. readonly x: NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the y component (output)
  57488. */
  57489. readonly y: NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the z component (output)
  57492. */
  57493. readonly z: NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the w component (output)
  57496. */
  57497. readonly w: NodeMaterialConnectionPoint;
  57498. protected _inputRename(name: string): string;
  57499. protected _outputRename(name: string): string;
  57500. protected _buildBlock(state: NodeMaterialBuildState): this;
  57501. }
  57502. }
  57503. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57507. /**
  57508. * Block used to lerp between 2 values
  57509. */
  57510. export class LerpBlock extends NodeMaterialBlock {
  57511. /**
  57512. * Creates a new LerpBlock
  57513. * @param name defines the block name
  57514. */
  57515. constructor(name: string);
  57516. /**
  57517. * Gets the current class name
  57518. * @returns the class name
  57519. */
  57520. getClassName(): string;
  57521. /**
  57522. * Gets the left operand input component
  57523. */
  57524. readonly left: NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the right operand input component
  57527. */
  57528. readonly right: NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the gradient operand input component
  57531. */
  57532. readonly gradient: NodeMaterialConnectionPoint;
  57533. /**
  57534. * Gets the output component
  57535. */
  57536. readonly output: NodeMaterialConnectionPoint;
  57537. protected _buildBlock(state: NodeMaterialBuildState): this;
  57538. }
  57539. }
  57540. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57541. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57542. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57543. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57544. /**
  57545. * Block used to divide 2 vectors
  57546. */
  57547. export class DivideBlock extends NodeMaterialBlock {
  57548. /**
  57549. * Creates a new DivideBlock
  57550. * @param name defines the block name
  57551. */
  57552. constructor(name: string);
  57553. /**
  57554. * Gets the current class name
  57555. * @returns the class name
  57556. */
  57557. getClassName(): string;
  57558. /**
  57559. * Gets the left operand input component
  57560. */
  57561. readonly left: NodeMaterialConnectionPoint;
  57562. /**
  57563. * Gets the right operand input component
  57564. */
  57565. readonly right: NodeMaterialConnectionPoint;
  57566. /**
  57567. * Gets the output component
  57568. */
  57569. readonly output: NodeMaterialConnectionPoint;
  57570. protected _buildBlock(state: NodeMaterialBuildState): this;
  57571. }
  57572. }
  57573. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57574. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57575. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57577. /**
  57578. * Block used to subtract 2 vectors
  57579. */
  57580. export class SubtractBlock extends NodeMaterialBlock {
  57581. /**
  57582. * Creates a new SubtractBlock
  57583. * @param name defines the block name
  57584. */
  57585. constructor(name: string);
  57586. /**
  57587. * Gets the current class name
  57588. * @returns the class name
  57589. */
  57590. getClassName(): string;
  57591. /**
  57592. * Gets the left operand input component
  57593. */
  57594. readonly left: NodeMaterialConnectionPoint;
  57595. /**
  57596. * Gets the right operand input component
  57597. */
  57598. readonly right: NodeMaterialConnectionPoint;
  57599. /**
  57600. * Gets the output component
  57601. */
  57602. readonly output: NodeMaterialConnectionPoint;
  57603. protected _buildBlock(state: NodeMaterialBuildState): this;
  57604. }
  57605. }
  57606. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57607. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57608. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57609. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57610. /**
  57611. * Block used to step a value
  57612. */
  57613. export class StepBlock extends NodeMaterialBlock {
  57614. /**
  57615. * Creates a new StepBlock
  57616. * @param name defines the block name
  57617. */
  57618. constructor(name: string);
  57619. /**
  57620. * Gets the current class name
  57621. * @returns the class name
  57622. */
  57623. getClassName(): string;
  57624. /**
  57625. * Gets the value operand input component
  57626. */
  57627. readonly value: NodeMaterialConnectionPoint;
  57628. /**
  57629. * Gets the edge operand input component
  57630. */
  57631. readonly edge: NodeMaterialConnectionPoint;
  57632. /**
  57633. * Gets the output component
  57634. */
  57635. readonly output: NodeMaterialConnectionPoint;
  57636. protected _buildBlock(state: NodeMaterialBuildState): this;
  57637. }
  57638. }
  57639. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57640. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57641. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57642. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57643. /**
  57644. * Block used to get the opposite (1 - x) of a value
  57645. */
  57646. export class OneMinusBlock extends NodeMaterialBlock {
  57647. /**
  57648. * Creates a new OneMinusBlock
  57649. * @param name defines the block name
  57650. */
  57651. constructor(name: string);
  57652. /**
  57653. * Gets the current class name
  57654. * @returns the class name
  57655. */
  57656. getClassName(): string;
  57657. /**
  57658. * Gets the input component
  57659. */
  57660. readonly input: NodeMaterialConnectionPoint;
  57661. /**
  57662. * Gets the output component
  57663. */
  57664. readonly output: NodeMaterialConnectionPoint;
  57665. protected _buildBlock(state: NodeMaterialBuildState): this;
  57666. }
  57667. }
  57668. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57669. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57670. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57671. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57672. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57673. /**
  57674. * Block used to get the view direction
  57675. */
  57676. export class ViewDirectionBlock extends NodeMaterialBlock {
  57677. /**
  57678. * Creates a new ViewDirectionBlock
  57679. * @param name defines the block name
  57680. */
  57681. constructor(name: string);
  57682. /**
  57683. * Gets the current class name
  57684. * @returns the class name
  57685. */
  57686. getClassName(): string;
  57687. /**
  57688. * Gets the world position component
  57689. */
  57690. readonly worldPosition: NodeMaterialConnectionPoint;
  57691. /**
  57692. * Gets the camera position component
  57693. */
  57694. readonly cameraPosition: NodeMaterialConnectionPoint;
  57695. /**
  57696. * Gets the output component
  57697. */
  57698. readonly output: NodeMaterialConnectionPoint;
  57699. autoConfigure(material: NodeMaterial): void;
  57700. protected _buildBlock(state: NodeMaterialBuildState): this;
  57701. }
  57702. }
  57703. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57704. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57705. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57706. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57707. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57708. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57709. /**
  57710. * Block used to compute fresnel value
  57711. */
  57712. export class FresnelBlock extends NodeMaterialBlock {
  57713. /**
  57714. * Create a new FresnelBlock
  57715. * @param name defines the block name
  57716. */
  57717. constructor(name: string);
  57718. /**
  57719. * Gets the current class name
  57720. * @returns the class name
  57721. */
  57722. getClassName(): string;
  57723. /**
  57724. * Gets the world normal input component
  57725. */
  57726. readonly worldNormal: NodeMaterialConnectionPoint;
  57727. /**
  57728. * Gets the view direction input component
  57729. */
  57730. readonly viewDirection: NodeMaterialConnectionPoint;
  57731. /**
  57732. * Gets the bias input component
  57733. */
  57734. readonly bias: NodeMaterialConnectionPoint;
  57735. /**
  57736. * Gets the camera (or eye) position component
  57737. */
  57738. readonly power: NodeMaterialConnectionPoint;
  57739. /**
  57740. * Gets the fresnel output component
  57741. */
  57742. readonly fresnel: NodeMaterialConnectionPoint;
  57743. autoConfigure(material: NodeMaterial): void;
  57744. protected _buildBlock(state: NodeMaterialBuildState): this;
  57745. }
  57746. }
  57747. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57751. /**
  57752. * Block used to get the max of 2 values
  57753. */
  57754. export class MaxBlock extends NodeMaterialBlock {
  57755. /**
  57756. * Creates a new MaxBlock
  57757. * @param name defines the block name
  57758. */
  57759. constructor(name: string);
  57760. /**
  57761. * Gets the current class name
  57762. * @returns the class name
  57763. */
  57764. getClassName(): string;
  57765. /**
  57766. * Gets the left operand input component
  57767. */
  57768. readonly left: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the right operand input component
  57771. */
  57772. readonly right: NodeMaterialConnectionPoint;
  57773. /**
  57774. * Gets the output component
  57775. */
  57776. readonly output: NodeMaterialConnectionPoint;
  57777. protected _buildBlock(state: NodeMaterialBuildState): this;
  57778. }
  57779. }
  57780. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57781. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57782. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57783. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57784. /**
  57785. * Block used to get the min of 2 values
  57786. */
  57787. export class MinBlock extends NodeMaterialBlock {
  57788. /**
  57789. * Creates a new MinBlock
  57790. * @param name defines the block name
  57791. */
  57792. constructor(name: string);
  57793. /**
  57794. * Gets the current class name
  57795. * @returns the class name
  57796. */
  57797. getClassName(): string;
  57798. /**
  57799. * Gets the left operand input component
  57800. */
  57801. readonly left: NodeMaterialConnectionPoint;
  57802. /**
  57803. * Gets the right operand input component
  57804. */
  57805. readonly right: NodeMaterialConnectionPoint;
  57806. /**
  57807. * Gets the output component
  57808. */
  57809. readonly output: NodeMaterialConnectionPoint;
  57810. protected _buildBlock(state: NodeMaterialBuildState): this;
  57811. }
  57812. }
  57813. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57814. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57815. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57816. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57817. /**
  57818. * Block used to get the distance between 2 values
  57819. */
  57820. export class DistanceBlock extends NodeMaterialBlock {
  57821. /**
  57822. * Creates a new DistanceBlock
  57823. * @param name defines the block name
  57824. */
  57825. constructor(name: string);
  57826. /**
  57827. * Gets the current class name
  57828. * @returns the class name
  57829. */
  57830. getClassName(): string;
  57831. /**
  57832. * Gets the left operand input component
  57833. */
  57834. readonly left: NodeMaterialConnectionPoint;
  57835. /**
  57836. * Gets the right operand input component
  57837. */
  57838. readonly right: NodeMaterialConnectionPoint;
  57839. /**
  57840. * Gets the output component
  57841. */
  57842. readonly output: NodeMaterialConnectionPoint;
  57843. protected _buildBlock(state: NodeMaterialBuildState): this;
  57844. }
  57845. }
  57846. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57847. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57848. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57849. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57850. /**
  57851. * Block used to get the length of a vector
  57852. */
  57853. export class LengthBlock extends NodeMaterialBlock {
  57854. /**
  57855. * Creates a new LengthBlock
  57856. * @param name defines the block name
  57857. */
  57858. constructor(name: string);
  57859. /**
  57860. * Gets the current class name
  57861. * @returns the class name
  57862. */
  57863. getClassName(): string;
  57864. /**
  57865. * Gets the value input component
  57866. */
  57867. readonly value: NodeMaterialConnectionPoint;
  57868. /**
  57869. * Gets the output component
  57870. */
  57871. readonly output: NodeMaterialConnectionPoint;
  57872. protected _buildBlock(state: NodeMaterialBuildState): this;
  57873. }
  57874. }
  57875. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57876. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57877. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57878. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57879. /**
  57880. * Block used to get negative version of a value (i.e. x * -1)
  57881. */
  57882. export class NegateBlock extends NodeMaterialBlock {
  57883. /**
  57884. * Creates a new NegateBlock
  57885. * @param name defines the block name
  57886. */
  57887. constructor(name: string);
  57888. /**
  57889. * Gets the current class name
  57890. * @returns the class name
  57891. */
  57892. getClassName(): string;
  57893. /**
  57894. * Gets the value input component
  57895. */
  57896. readonly value: NodeMaterialConnectionPoint;
  57897. /**
  57898. * Gets the output component
  57899. */
  57900. readonly output: NodeMaterialConnectionPoint;
  57901. protected _buildBlock(state: NodeMaterialBuildState): this;
  57902. }
  57903. }
  57904. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57905. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57906. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57907. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57908. /**
  57909. * Block used to get the value of the first parameter raised to the power of the second
  57910. */
  57911. export class PowBlock extends NodeMaterialBlock {
  57912. /**
  57913. * Creates a new PowBlock
  57914. * @param name defines the block name
  57915. */
  57916. constructor(name: string);
  57917. /**
  57918. * Gets the current class name
  57919. * @returns the class name
  57920. */
  57921. getClassName(): string;
  57922. /**
  57923. * Gets the value operand input component
  57924. */
  57925. readonly value: NodeMaterialConnectionPoint;
  57926. /**
  57927. * Gets the power operand input component
  57928. */
  57929. readonly power: NodeMaterialConnectionPoint;
  57930. /**
  57931. * Gets the output component
  57932. */
  57933. readonly output: NodeMaterialConnectionPoint;
  57934. protected _buildBlock(state: NodeMaterialBuildState): this;
  57935. }
  57936. }
  57937. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57942. /**
  57943. * Block used to get a random number
  57944. */
  57945. export class RandomNumberBlock extends NodeMaterialBlock {
  57946. /**
  57947. * Creates a new RandomNumberBlock
  57948. * @param name defines the block name
  57949. */
  57950. constructor(name: string);
  57951. /**
  57952. * Gets the current class name
  57953. * @returns the class name
  57954. */
  57955. getClassName(): string;
  57956. /**
  57957. * Gets the seed input component
  57958. */
  57959. readonly seed: NodeMaterialConnectionPoint;
  57960. /**
  57961. * Gets the output component
  57962. */
  57963. readonly output: NodeMaterialConnectionPoint;
  57964. protected _buildBlock(state: NodeMaterialBuildState): this;
  57965. }
  57966. }
  57967. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57971. /**
  57972. * Block used to compute arc tangent of 2 values
  57973. */
  57974. export class ArcTan2Block extends NodeMaterialBlock {
  57975. /**
  57976. * Creates a new ArcTan2Block
  57977. * @param name defines the block name
  57978. */
  57979. constructor(name: string);
  57980. /**
  57981. * Gets the current class name
  57982. * @returns the class name
  57983. */
  57984. getClassName(): string;
  57985. /**
  57986. * Gets the x operand input component
  57987. */
  57988. readonly x: NodeMaterialConnectionPoint;
  57989. /**
  57990. * Gets the y operand input component
  57991. */
  57992. readonly y: NodeMaterialConnectionPoint;
  57993. /**
  57994. * Gets the output component
  57995. */
  57996. readonly output: NodeMaterialConnectionPoint;
  57997. protected _buildBlock(state: NodeMaterialBuildState): this;
  57998. }
  57999. }
  58000. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58004. /**
  58005. * Block used to smooth step a value
  58006. */
  58007. export class SmoothStepBlock extends NodeMaterialBlock {
  58008. /**
  58009. * Creates a new SmoothStepBlock
  58010. * @param name defines the block name
  58011. */
  58012. constructor(name: string);
  58013. /**
  58014. * Gets the current class name
  58015. * @returns the class name
  58016. */
  58017. getClassName(): string;
  58018. /**
  58019. * Gets the value operand input component
  58020. */
  58021. readonly value: NodeMaterialConnectionPoint;
  58022. /**
  58023. * Gets the first edge operand input component
  58024. */
  58025. readonly edge0: NodeMaterialConnectionPoint;
  58026. /**
  58027. * Gets the second edge operand input component
  58028. */
  58029. readonly edge1: NodeMaterialConnectionPoint;
  58030. /**
  58031. * Gets the output component
  58032. */
  58033. readonly output: NodeMaterialConnectionPoint;
  58034. protected _buildBlock(state: NodeMaterialBuildState): this;
  58035. }
  58036. }
  58037. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58039. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58040. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58041. /**
  58042. * Block used to get the reciprocal (1 / x) of a value
  58043. */
  58044. export class ReciprocalBlock extends NodeMaterialBlock {
  58045. /**
  58046. * Creates a new ReciprocalBlock
  58047. * @param name defines the block name
  58048. */
  58049. constructor(name: string);
  58050. /**
  58051. * Gets the current class name
  58052. * @returns the class name
  58053. */
  58054. getClassName(): string;
  58055. /**
  58056. * Gets the input component
  58057. */
  58058. readonly input: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the output component
  58061. */
  58062. readonly output: NodeMaterialConnectionPoint;
  58063. protected _buildBlock(state: NodeMaterialBuildState): this;
  58064. }
  58065. }
  58066. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58070. /**
  58071. * Block used to replace a color by another one
  58072. */
  58073. export class ReplaceColorBlock extends NodeMaterialBlock {
  58074. /**
  58075. * Creates a new ReplaceColorBlock
  58076. * @param name defines the block name
  58077. */
  58078. constructor(name: string);
  58079. /**
  58080. * Gets the current class name
  58081. * @returns the class name
  58082. */
  58083. getClassName(): string;
  58084. /**
  58085. * Gets the value input component
  58086. */
  58087. readonly value: NodeMaterialConnectionPoint;
  58088. /**
  58089. * Gets the reference input component
  58090. */
  58091. readonly reference: NodeMaterialConnectionPoint;
  58092. /**
  58093. * Gets the distance input component
  58094. */
  58095. readonly distance: NodeMaterialConnectionPoint;
  58096. /**
  58097. * Gets the replacement input component
  58098. */
  58099. readonly replacement: NodeMaterialConnectionPoint;
  58100. /**
  58101. * Gets the output component
  58102. */
  58103. readonly output: NodeMaterialConnectionPoint;
  58104. protected _buildBlock(state: NodeMaterialBuildState): this;
  58105. }
  58106. }
  58107. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58108. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58109. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58110. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58111. /**
  58112. * Block used to posterize a value
  58113. * @see https://en.wikipedia.org/wiki/Posterization
  58114. */
  58115. export class PosterizeBlock extends NodeMaterialBlock {
  58116. /**
  58117. * Creates a new PosterizeBlock
  58118. * @param name defines the block name
  58119. */
  58120. constructor(name: string);
  58121. /**
  58122. * Gets the current class name
  58123. * @returns the class name
  58124. */
  58125. getClassName(): string;
  58126. /**
  58127. * Gets the value input component
  58128. */
  58129. readonly value: NodeMaterialConnectionPoint;
  58130. /**
  58131. * Gets the steps input component
  58132. */
  58133. readonly steps: NodeMaterialConnectionPoint;
  58134. /**
  58135. * Gets the output component
  58136. */
  58137. readonly output: NodeMaterialConnectionPoint;
  58138. protected _buildBlock(state: NodeMaterialBuildState): this;
  58139. }
  58140. }
  58141. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58142. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58143. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58144. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58145. import { Scene } from "babylonjs/scene";
  58146. /**
  58147. * Operations supported by the Wave block
  58148. */
  58149. export enum WaveBlockKind {
  58150. /** SawTooth */
  58151. SawTooth = 0,
  58152. /** Square */
  58153. Square = 1,
  58154. /** Triangle */
  58155. Triangle = 2
  58156. }
  58157. /**
  58158. * Block used to apply wave operation to floats
  58159. */
  58160. export class WaveBlock extends NodeMaterialBlock {
  58161. /**
  58162. * Gets or sets the kibnd of wave to be applied by the block
  58163. */
  58164. kind: WaveBlockKind;
  58165. /**
  58166. * Creates a new WaveBlock
  58167. * @param name defines the block name
  58168. */
  58169. constructor(name: string);
  58170. /**
  58171. * Gets the current class name
  58172. * @returns the class name
  58173. */
  58174. getClassName(): string;
  58175. /**
  58176. * Gets the input component
  58177. */
  58178. readonly input: NodeMaterialConnectionPoint;
  58179. /**
  58180. * Gets the output component
  58181. */
  58182. readonly output: NodeMaterialConnectionPoint;
  58183. protected _buildBlock(state: NodeMaterialBuildState): this;
  58184. serialize(): any;
  58185. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58186. }
  58187. }
  58188. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58189. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58190. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58191. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58192. import { Color3 } from "babylonjs/Maths/math.color";
  58193. import { Scene } from "babylonjs/scene";
  58194. /**
  58195. * Class used to store a color step for the GradientBlock
  58196. */
  58197. export class GradientBlockColorStep {
  58198. /**
  58199. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58200. */
  58201. step: number;
  58202. /**
  58203. * Gets or sets the color associated with this step
  58204. */
  58205. color: Color3;
  58206. /**
  58207. * Creates a new GradientBlockColorStep
  58208. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58209. * @param color defines the color associated with this step
  58210. */
  58211. constructor(
  58212. /**
  58213. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58214. */
  58215. step: number,
  58216. /**
  58217. * Gets or sets the color associated with this step
  58218. */
  58219. color: Color3);
  58220. }
  58221. /**
  58222. * Block used to return a color from a gradient based on an input value between 0 and 1
  58223. */
  58224. export class GradientBlock extends NodeMaterialBlock {
  58225. /**
  58226. * Gets or sets the list of color steps
  58227. */
  58228. colorSteps: GradientBlockColorStep[];
  58229. /**
  58230. * Creates a new GradientBlock
  58231. * @param name defines the block name
  58232. */
  58233. constructor(name: string);
  58234. /**
  58235. * Gets the current class name
  58236. * @returns the class name
  58237. */
  58238. getClassName(): string;
  58239. /**
  58240. * Gets the gradient input component
  58241. */
  58242. readonly gradient: NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the output component
  58245. */
  58246. readonly output: NodeMaterialConnectionPoint;
  58247. private _writeColorConstant;
  58248. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58249. serialize(): any;
  58250. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58251. protected _dumpPropertiesCode(): string;
  58252. }
  58253. }
  58254. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58256. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58257. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58258. /**
  58259. * Block used to normalize lerp between 2 values
  58260. */
  58261. export class NLerpBlock extends NodeMaterialBlock {
  58262. /**
  58263. * Creates a new NLerpBlock
  58264. * @param name defines the block name
  58265. */
  58266. constructor(name: string);
  58267. /**
  58268. * Gets the current class name
  58269. * @returns the class name
  58270. */
  58271. getClassName(): string;
  58272. /**
  58273. * Gets the left operand input component
  58274. */
  58275. readonly left: NodeMaterialConnectionPoint;
  58276. /**
  58277. * Gets the right operand input component
  58278. */
  58279. readonly right: NodeMaterialConnectionPoint;
  58280. /**
  58281. * Gets the gradient operand input component
  58282. */
  58283. readonly gradient: NodeMaterialConnectionPoint;
  58284. /**
  58285. * Gets the output component
  58286. */
  58287. readonly output: NodeMaterialConnectionPoint;
  58288. protected _buildBlock(state: NodeMaterialBuildState): this;
  58289. }
  58290. }
  58291. declare module "babylonjs/Materials/Node/Blocks/index" {
  58292. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58293. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58294. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58295. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58296. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58297. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58298. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58299. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58300. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58301. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58302. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58303. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58304. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58305. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58306. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58307. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58308. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58309. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58310. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58311. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58312. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58313. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58314. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58315. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58316. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58325. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58332. }
  58333. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58334. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58335. }
  58336. declare module "babylonjs/Materials/Node/index" {
  58337. export * from "babylonjs/Materials/Node/Enums/index";
  58338. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58339. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58340. export * from "babylonjs/Materials/Node/nodeMaterial";
  58341. export * from "babylonjs/Materials/Node/Blocks/index";
  58342. export * from "babylonjs/Materials/Node/Optimizers/index";
  58343. }
  58344. declare module "babylonjs/Materials/effectRenderer" {
  58345. import { Nullable } from "babylonjs/types";
  58346. import { Texture } from "babylonjs/Materials/Textures/texture";
  58347. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58348. import { Viewport } from "babylonjs/Maths/math.viewport";
  58349. import { Observable } from "babylonjs/Misc/observable";
  58350. import { Effect } from "babylonjs/Materials/effect";
  58351. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58352. import "babylonjs/Shaders/postprocess.vertex";
  58353. /**
  58354. * Effect Render Options
  58355. */
  58356. export interface IEffectRendererOptions {
  58357. /**
  58358. * Defines the vertices positions.
  58359. */
  58360. positions?: number[];
  58361. /**
  58362. * Defines the indices.
  58363. */
  58364. indices?: number[];
  58365. }
  58366. /**
  58367. * Helper class to render one or more effects
  58368. */
  58369. export class EffectRenderer {
  58370. private engine;
  58371. private static _DefaultOptions;
  58372. private _vertexBuffers;
  58373. private _indexBuffer;
  58374. private _ringBufferIndex;
  58375. private _ringScreenBuffer;
  58376. private _fullscreenViewport;
  58377. private _getNextFrameBuffer;
  58378. /**
  58379. * Creates an effect renderer
  58380. * @param engine the engine to use for rendering
  58381. * @param options defines the options of the effect renderer
  58382. */
  58383. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58384. /**
  58385. * Sets the current viewport in normalized coordinates 0-1
  58386. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58387. */
  58388. setViewport(viewport?: Viewport): void;
  58389. /**
  58390. * Binds the embedded attributes buffer to the effect.
  58391. * @param effect Defines the effect to bind the attributes for
  58392. */
  58393. bindBuffers(effect: Effect): void;
  58394. /**
  58395. * Sets the current effect wrapper to use during draw.
  58396. * The effect needs to be ready before calling this api.
  58397. * This also sets the default full screen position attribute.
  58398. * @param effectWrapper Defines the effect to draw with
  58399. */
  58400. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58401. /**
  58402. * Draws a full screen quad.
  58403. */
  58404. draw(): void;
  58405. /**
  58406. * renders one or more effects to a specified texture
  58407. * @param effectWrappers list of effects to renderer
  58408. * @param outputTexture texture to draw to, if null it will render to the screen
  58409. */
  58410. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58411. /**
  58412. * Disposes of the effect renderer
  58413. */
  58414. dispose(): void;
  58415. }
  58416. /**
  58417. * Options to create an EffectWrapper
  58418. */
  58419. interface EffectWrapperCreationOptions {
  58420. /**
  58421. * Engine to use to create the effect
  58422. */
  58423. engine: ThinEngine;
  58424. /**
  58425. * Fragment shader for the effect
  58426. */
  58427. fragmentShader: string;
  58428. /**
  58429. * Vertex shader for the effect
  58430. */
  58431. vertexShader?: string;
  58432. /**
  58433. * Attributes to use in the shader
  58434. */
  58435. attributeNames?: Array<string>;
  58436. /**
  58437. * Uniforms to use in the shader
  58438. */
  58439. uniformNames?: Array<string>;
  58440. /**
  58441. * Texture sampler names to use in the shader
  58442. */
  58443. samplerNames?: Array<string>;
  58444. /**
  58445. * The friendly name of the effect displayed in Spector.
  58446. */
  58447. name?: string;
  58448. }
  58449. /**
  58450. * Wraps an effect to be used for rendering
  58451. */
  58452. export class EffectWrapper {
  58453. /**
  58454. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58455. */
  58456. onApplyObservable: Observable<{}>;
  58457. /**
  58458. * The underlying effect
  58459. */
  58460. effect: Effect;
  58461. /**
  58462. * Creates an effect to be renderer
  58463. * @param creationOptions options to create the effect
  58464. */
  58465. constructor(creationOptions: EffectWrapperCreationOptions);
  58466. /**
  58467. * Disposes of the effect wrapper
  58468. */
  58469. dispose(): void;
  58470. }
  58471. }
  58472. declare module "babylonjs/Materials/index" {
  58473. export * from "babylonjs/Materials/Background/index";
  58474. export * from "babylonjs/Materials/colorCurves";
  58475. export * from "babylonjs/Materials/iEffectFallbacks";
  58476. export * from "babylonjs/Materials/effectFallbacks";
  58477. export * from "babylonjs/Materials/effect";
  58478. export * from "babylonjs/Materials/fresnelParameters";
  58479. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58480. export * from "babylonjs/Materials/material";
  58481. export * from "babylonjs/Materials/materialDefines";
  58482. export * from "babylonjs/Materials/materialHelper";
  58483. export * from "babylonjs/Materials/multiMaterial";
  58484. export * from "babylonjs/Materials/PBR/index";
  58485. export * from "babylonjs/Materials/pushMaterial";
  58486. export * from "babylonjs/Materials/shaderMaterial";
  58487. export * from "babylonjs/Materials/standardMaterial";
  58488. export * from "babylonjs/Materials/Textures/index";
  58489. export * from "babylonjs/Materials/uniformBuffer";
  58490. export * from "babylonjs/Materials/materialFlags";
  58491. export * from "babylonjs/Materials/Node/index";
  58492. export * from "babylonjs/Materials/effectRenderer";
  58493. }
  58494. declare module "babylonjs/Maths/index" {
  58495. export * from "babylonjs/Maths/math.scalar";
  58496. export * from "babylonjs/Maths/math";
  58497. export * from "babylonjs/Maths/sphericalPolynomial";
  58498. }
  58499. declare module "babylonjs/Misc/workerPool" {
  58500. import { IDisposable } from "babylonjs/scene";
  58501. /**
  58502. * Helper class to push actions to a pool of workers.
  58503. */
  58504. export class WorkerPool implements IDisposable {
  58505. private _workerInfos;
  58506. private _pendingActions;
  58507. /**
  58508. * Constructor
  58509. * @param workers Array of workers to use for actions
  58510. */
  58511. constructor(workers: Array<Worker>);
  58512. /**
  58513. * Terminates all workers and clears any pending actions.
  58514. */
  58515. dispose(): void;
  58516. /**
  58517. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58518. * pended until a worker has completed its action.
  58519. * @param action The action to perform. Call onComplete when the action is complete.
  58520. */
  58521. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58522. private _execute;
  58523. }
  58524. }
  58525. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58526. import { IDisposable } from "babylonjs/scene";
  58527. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58528. /**
  58529. * Configuration for Draco compression
  58530. */
  58531. export interface IDracoCompressionConfiguration {
  58532. /**
  58533. * Configuration for the decoder.
  58534. */
  58535. decoder: {
  58536. /**
  58537. * The url to the WebAssembly module.
  58538. */
  58539. wasmUrl?: string;
  58540. /**
  58541. * The url to the WebAssembly binary.
  58542. */
  58543. wasmBinaryUrl?: string;
  58544. /**
  58545. * The url to the fallback JavaScript module.
  58546. */
  58547. fallbackUrl?: string;
  58548. };
  58549. }
  58550. /**
  58551. * Draco compression (https://google.github.io/draco/)
  58552. *
  58553. * This class wraps the Draco module.
  58554. *
  58555. * **Encoder**
  58556. *
  58557. * The encoder is not currently implemented.
  58558. *
  58559. * **Decoder**
  58560. *
  58561. * 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.
  58562. *
  58563. * To update the configuration, use the following code:
  58564. * ```javascript
  58565. * DracoCompression.Configuration = {
  58566. * decoder: {
  58567. * wasmUrl: "<url to the WebAssembly library>",
  58568. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58569. * fallbackUrl: "<url to the fallback JavaScript library>",
  58570. * }
  58571. * };
  58572. * ```
  58573. *
  58574. * 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.
  58575. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58576. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58577. *
  58578. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58579. * ```javascript
  58580. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58581. * ```
  58582. *
  58583. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58584. */
  58585. export class DracoCompression implements IDisposable {
  58586. private _workerPoolPromise?;
  58587. private _decoderModulePromise?;
  58588. /**
  58589. * The configuration. Defaults to the following urls:
  58590. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58591. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58592. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58593. */
  58594. static Configuration: IDracoCompressionConfiguration;
  58595. /**
  58596. * Returns true if the decoder configuration is available.
  58597. */
  58598. static readonly DecoderAvailable: boolean;
  58599. /**
  58600. * Default number of workers to create when creating the draco compression object.
  58601. */
  58602. static DefaultNumWorkers: number;
  58603. private static GetDefaultNumWorkers;
  58604. private static _Default;
  58605. /**
  58606. * Default instance for the draco compression object.
  58607. */
  58608. static readonly Default: DracoCompression;
  58609. /**
  58610. * Constructor
  58611. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58612. */
  58613. constructor(numWorkers?: number);
  58614. /**
  58615. * Stop all async operations and release resources.
  58616. */
  58617. dispose(): void;
  58618. /**
  58619. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58620. * @returns a promise that resolves when ready
  58621. */
  58622. whenReadyAsync(): Promise<void>;
  58623. /**
  58624. * Decode Draco compressed mesh data to vertex data.
  58625. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58626. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58627. * @returns A promise that resolves with the decoded vertex data
  58628. */
  58629. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58630. [kind: string]: number;
  58631. }): Promise<VertexData>;
  58632. }
  58633. }
  58634. declare module "babylonjs/Meshes/Compression/index" {
  58635. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58636. }
  58637. declare module "babylonjs/Meshes/csg" {
  58638. import { Nullable } from "babylonjs/types";
  58639. import { Scene } from "babylonjs/scene";
  58640. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58641. import { Mesh } from "babylonjs/Meshes/mesh";
  58642. import { Material } from "babylonjs/Materials/material";
  58643. /**
  58644. * Class for building Constructive Solid Geometry
  58645. */
  58646. export class CSG {
  58647. private polygons;
  58648. /**
  58649. * The world matrix
  58650. */
  58651. matrix: Matrix;
  58652. /**
  58653. * Stores the position
  58654. */
  58655. position: Vector3;
  58656. /**
  58657. * Stores the rotation
  58658. */
  58659. rotation: Vector3;
  58660. /**
  58661. * Stores the rotation quaternion
  58662. */
  58663. rotationQuaternion: Nullable<Quaternion>;
  58664. /**
  58665. * Stores the scaling vector
  58666. */
  58667. scaling: Vector3;
  58668. /**
  58669. * Convert the Mesh to CSG
  58670. * @param mesh The Mesh to convert to CSG
  58671. * @returns A new CSG from the Mesh
  58672. */
  58673. static FromMesh(mesh: Mesh): CSG;
  58674. /**
  58675. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58676. * @param polygons Polygons used to construct a CSG solid
  58677. */
  58678. private static FromPolygons;
  58679. /**
  58680. * Clones, or makes a deep copy, of the CSG
  58681. * @returns A new CSG
  58682. */
  58683. clone(): CSG;
  58684. /**
  58685. * Unions this CSG with another CSG
  58686. * @param csg The CSG to union against this CSG
  58687. * @returns The unioned CSG
  58688. */
  58689. union(csg: CSG): CSG;
  58690. /**
  58691. * Unions this CSG with another CSG in place
  58692. * @param csg The CSG to union against this CSG
  58693. */
  58694. unionInPlace(csg: CSG): void;
  58695. /**
  58696. * Subtracts this CSG with another CSG
  58697. * @param csg The CSG to subtract against this CSG
  58698. * @returns A new CSG
  58699. */
  58700. subtract(csg: CSG): CSG;
  58701. /**
  58702. * Subtracts this CSG with another CSG in place
  58703. * @param csg The CSG to subtact against this CSG
  58704. */
  58705. subtractInPlace(csg: CSG): void;
  58706. /**
  58707. * Intersect this CSG with another CSG
  58708. * @param csg The CSG to intersect against this CSG
  58709. * @returns A new CSG
  58710. */
  58711. intersect(csg: CSG): CSG;
  58712. /**
  58713. * Intersects this CSG with another CSG in place
  58714. * @param csg The CSG to intersect against this CSG
  58715. */
  58716. intersectInPlace(csg: CSG): void;
  58717. /**
  58718. * Return a new CSG solid with solid and empty space switched. This solid is
  58719. * not modified.
  58720. * @returns A new CSG solid with solid and empty space switched
  58721. */
  58722. inverse(): CSG;
  58723. /**
  58724. * Inverses the CSG in place
  58725. */
  58726. inverseInPlace(): void;
  58727. /**
  58728. * This is used to keep meshes transformations so they can be restored
  58729. * when we build back a Babylon Mesh
  58730. * NB : All CSG operations are performed in world coordinates
  58731. * @param csg The CSG to copy the transform attributes from
  58732. * @returns This CSG
  58733. */
  58734. copyTransformAttributes(csg: CSG): CSG;
  58735. /**
  58736. * Build Raw mesh from CSG
  58737. * Coordinates here are in world space
  58738. * @param name The name of the mesh geometry
  58739. * @param scene The Scene
  58740. * @param keepSubMeshes Specifies if the submeshes should be kept
  58741. * @returns A new Mesh
  58742. */
  58743. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58744. /**
  58745. * Build Mesh from CSG taking material and transforms into account
  58746. * @param name The name of the Mesh
  58747. * @param material The material of the Mesh
  58748. * @param scene The Scene
  58749. * @param keepSubMeshes Specifies if submeshes should be kept
  58750. * @returns The new Mesh
  58751. */
  58752. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58753. }
  58754. }
  58755. declare module "babylonjs/Meshes/trailMesh" {
  58756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58757. import { Mesh } from "babylonjs/Meshes/mesh";
  58758. import { Scene } from "babylonjs/scene";
  58759. /**
  58760. * Class used to create a trail following a mesh
  58761. */
  58762. export class TrailMesh extends Mesh {
  58763. private _generator;
  58764. private _autoStart;
  58765. private _running;
  58766. private _diameter;
  58767. private _length;
  58768. private _sectionPolygonPointsCount;
  58769. private _sectionVectors;
  58770. private _sectionNormalVectors;
  58771. private _beforeRenderObserver;
  58772. /**
  58773. * @constructor
  58774. * @param name The value used by scene.getMeshByName() to do a lookup.
  58775. * @param generator The mesh to generate a trail.
  58776. * @param scene The scene to add this mesh to.
  58777. * @param diameter Diameter of trailing mesh. Default is 1.
  58778. * @param length Length of trailing mesh. Default is 60.
  58779. * @param autoStart Automatically start trailing mesh. Default true.
  58780. */
  58781. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58782. /**
  58783. * "TrailMesh"
  58784. * @returns "TrailMesh"
  58785. */
  58786. getClassName(): string;
  58787. private _createMesh;
  58788. /**
  58789. * Start trailing mesh.
  58790. */
  58791. start(): void;
  58792. /**
  58793. * Stop trailing mesh.
  58794. */
  58795. stop(): void;
  58796. /**
  58797. * Update trailing mesh geometry.
  58798. */
  58799. update(): void;
  58800. /**
  58801. * Returns a new TrailMesh object.
  58802. * @param name is a string, the name given to the new mesh
  58803. * @param newGenerator use new generator object for cloned trail mesh
  58804. * @returns a new mesh
  58805. */
  58806. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58807. /**
  58808. * Serializes this trail mesh
  58809. * @param serializationObject object to write serialization to
  58810. */
  58811. serialize(serializationObject: any): void;
  58812. /**
  58813. * Parses a serialized trail mesh
  58814. * @param parsedMesh the serialized mesh
  58815. * @param scene the scene to create the trail mesh in
  58816. * @returns the created trail mesh
  58817. */
  58818. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58819. }
  58820. }
  58821. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58822. import { Nullable } from "babylonjs/types";
  58823. import { Scene } from "babylonjs/scene";
  58824. import { Vector4 } from "babylonjs/Maths/math.vector";
  58825. import { Color4 } from "babylonjs/Maths/math.color";
  58826. import { Mesh } from "babylonjs/Meshes/mesh";
  58827. /**
  58828. * Class containing static functions to help procedurally build meshes
  58829. */
  58830. export class TiledBoxBuilder {
  58831. /**
  58832. * Creates a box mesh
  58833. * 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)
  58834. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58838. * @param name defines the name of the mesh
  58839. * @param options defines the options used to create the mesh
  58840. * @param scene defines the hosting scene
  58841. * @returns the box mesh
  58842. */
  58843. static CreateTiledBox(name: string, options: {
  58844. pattern?: number;
  58845. width?: number;
  58846. height?: number;
  58847. depth?: number;
  58848. tileSize?: number;
  58849. tileWidth?: number;
  58850. tileHeight?: number;
  58851. alignHorizontal?: number;
  58852. alignVertical?: number;
  58853. faceUV?: Vector4[];
  58854. faceColors?: Color4[];
  58855. sideOrientation?: number;
  58856. updatable?: boolean;
  58857. }, scene?: Nullable<Scene>): Mesh;
  58858. }
  58859. }
  58860. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58861. import { Vector4 } from "babylonjs/Maths/math.vector";
  58862. import { Mesh } from "babylonjs/Meshes/mesh";
  58863. /**
  58864. * Class containing static functions to help procedurally build meshes
  58865. */
  58866. export class TorusKnotBuilder {
  58867. /**
  58868. * Creates a torus knot mesh
  58869. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58870. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58871. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58872. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58873. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58874. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58876. * @param name defines the name of the mesh
  58877. * @param options defines the options used to create the mesh
  58878. * @param scene defines the hosting scene
  58879. * @returns the torus knot mesh
  58880. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58881. */
  58882. static CreateTorusKnot(name: string, options: {
  58883. radius?: number;
  58884. tube?: number;
  58885. radialSegments?: number;
  58886. tubularSegments?: number;
  58887. p?: number;
  58888. q?: number;
  58889. updatable?: boolean;
  58890. sideOrientation?: number;
  58891. frontUVs?: Vector4;
  58892. backUVs?: Vector4;
  58893. }, scene: any): Mesh;
  58894. }
  58895. }
  58896. declare module "babylonjs/Meshes/polygonMesh" {
  58897. import { Scene } from "babylonjs/scene";
  58898. import { Vector2 } from "babylonjs/Maths/math.vector";
  58899. import { Mesh } from "babylonjs/Meshes/mesh";
  58900. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58901. import { Path2 } from "babylonjs/Maths/math.path";
  58902. /**
  58903. * Polygon
  58904. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58905. */
  58906. export class Polygon {
  58907. /**
  58908. * Creates a rectangle
  58909. * @param xmin bottom X coord
  58910. * @param ymin bottom Y coord
  58911. * @param xmax top X coord
  58912. * @param ymax top Y coord
  58913. * @returns points that make the resulting rectation
  58914. */
  58915. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58916. /**
  58917. * Creates a circle
  58918. * @param radius radius of circle
  58919. * @param cx scale in x
  58920. * @param cy scale in y
  58921. * @param numberOfSides number of sides that make up the circle
  58922. * @returns points that make the resulting circle
  58923. */
  58924. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58925. /**
  58926. * Creates a polygon from input string
  58927. * @param input Input polygon data
  58928. * @returns the parsed points
  58929. */
  58930. static Parse(input: string): Vector2[];
  58931. /**
  58932. * Starts building a polygon from x and y coordinates
  58933. * @param x x coordinate
  58934. * @param y y coordinate
  58935. * @returns the started path2
  58936. */
  58937. static StartingAt(x: number, y: number): Path2;
  58938. }
  58939. /**
  58940. * Builds a polygon
  58941. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58942. */
  58943. export class PolygonMeshBuilder {
  58944. private _points;
  58945. private _outlinepoints;
  58946. private _holes;
  58947. private _name;
  58948. private _scene;
  58949. private _epoints;
  58950. private _eholes;
  58951. private _addToepoint;
  58952. /**
  58953. * Babylon reference to the earcut plugin.
  58954. */
  58955. bjsEarcut: any;
  58956. /**
  58957. * Creates a PolygonMeshBuilder
  58958. * @param name name of the builder
  58959. * @param contours Path of the polygon
  58960. * @param scene scene to add to when creating the mesh
  58961. * @param earcutInjection can be used to inject your own earcut reference
  58962. */
  58963. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58964. /**
  58965. * Adds a whole within the polygon
  58966. * @param hole Array of points defining the hole
  58967. * @returns this
  58968. */
  58969. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58970. /**
  58971. * Creates the polygon
  58972. * @param updatable If the mesh should be updatable
  58973. * @param depth The depth of the mesh created
  58974. * @returns the created mesh
  58975. */
  58976. build(updatable?: boolean, depth?: number): Mesh;
  58977. /**
  58978. * Creates the polygon
  58979. * @param depth The depth of the mesh created
  58980. * @returns the created VertexData
  58981. */
  58982. buildVertexData(depth?: number): VertexData;
  58983. /**
  58984. * Adds a side to the polygon
  58985. * @param positions points that make the polygon
  58986. * @param normals normals of the polygon
  58987. * @param uvs uvs of the polygon
  58988. * @param indices indices of the polygon
  58989. * @param bounds bounds of the polygon
  58990. * @param points points of the polygon
  58991. * @param depth depth of the polygon
  58992. * @param flip flip of the polygon
  58993. */
  58994. private addSide;
  58995. }
  58996. }
  58997. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58998. import { Scene } from "babylonjs/scene";
  58999. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59000. import { Color4 } from "babylonjs/Maths/math.color";
  59001. import { Mesh } from "babylonjs/Meshes/mesh";
  59002. import { Nullable } from "babylonjs/types";
  59003. /**
  59004. * Class containing static functions to help procedurally build meshes
  59005. */
  59006. export class PolygonBuilder {
  59007. /**
  59008. * Creates a polygon mesh
  59009. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59010. * * 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
  59011. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59013. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59014. * * Remember you can only change the shape positions, not their number when updating a polygon
  59015. * @param name defines the name of the mesh
  59016. * @param options defines the options used to create the mesh
  59017. * @param scene defines the hosting scene
  59018. * @param earcutInjection can be used to inject your own earcut reference
  59019. * @returns the polygon mesh
  59020. */
  59021. static CreatePolygon(name: string, options: {
  59022. shape: Vector3[];
  59023. holes?: Vector3[][];
  59024. depth?: number;
  59025. faceUV?: Vector4[];
  59026. faceColors?: Color4[];
  59027. updatable?: boolean;
  59028. sideOrientation?: number;
  59029. frontUVs?: Vector4;
  59030. backUVs?: Vector4;
  59031. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59032. /**
  59033. * Creates an extruded polygon mesh, with depth in the Y direction.
  59034. * * 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)
  59035. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59036. * @param name defines the name of the mesh
  59037. * @param options defines the options used to create the mesh
  59038. * @param scene defines the hosting scene
  59039. * @param earcutInjection can be used to inject your own earcut reference
  59040. * @returns the polygon mesh
  59041. */
  59042. static ExtrudePolygon(name: string, options: {
  59043. shape: Vector3[];
  59044. holes?: Vector3[][];
  59045. depth?: number;
  59046. faceUV?: Vector4[];
  59047. faceColors?: Color4[];
  59048. updatable?: boolean;
  59049. sideOrientation?: number;
  59050. frontUVs?: Vector4;
  59051. backUVs?: Vector4;
  59052. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59053. }
  59054. }
  59055. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59056. import { Scene } from "babylonjs/scene";
  59057. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59058. import { Mesh } from "babylonjs/Meshes/mesh";
  59059. import { Nullable } from "babylonjs/types";
  59060. /**
  59061. * Class containing static functions to help procedurally build meshes
  59062. */
  59063. export class LatheBuilder {
  59064. /**
  59065. * Creates lathe mesh.
  59066. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59067. * * 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
  59068. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59069. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59070. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59071. * * 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
  59072. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59073. * * 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
  59074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59075. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59078. * @param name defines the name of the mesh
  59079. * @param options defines the options used to create the mesh
  59080. * @param scene defines the hosting scene
  59081. * @returns the lathe mesh
  59082. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59083. */
  59084. static CreateLathe(name: string, options: {
  59085. shape: Vector3[];
  59086. radius?: number;
  59087. tessellation?: number;
  59088. clip?: number;
  59089. arc?: number;
  59090. closed?: boolean;
  59091. updatable?: boolean;
  59092. sideOrientation?: number;
  59093. frontUVs?: Vector4;
  59094. backUVs?: Vector4;
  59095. cap?: number;
  59096. invertUV?: boolean;
  59097. }, scene?: Nullable<Scene>): Mesh;
  59098. }
  59099. }
  59100. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59101. import { Nullable } from "babylonjs/types";
  59102. import { Scene } from "babylonjs/scene";
  59103. import { Vector4 } from "babylonjs/Maths/math.vector";
  59104. import { Mesh } from "babylonjs/Meshes/mesh";
  59105. /**
  59106. * Class containing static functions to help procedurally build meshes
  59107. */
  59108. export class TiledPlaneBuilder {
  59109. /**
  59110. * Creates a tiled plane mesh
  59111. * * The parameter `pattern` will, depending on value, do nothing or
  59112. * * * flip (reflect about central vertical) alternate tiles across and up
  59113. * * * flip every tile on alternate rows
  59114. * * * rotate (180 degs) alternate tiles across and up
  59115. * * * rotate every tile on alternate rows
  59116. * * * flip and rotate alternate tiles across and up
  59117. * * * flip and rotate every tile on alternate rows
  59118. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59119. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59120. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59121. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59122. * * 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)
  59123. * * 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)
  59124. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59125. * @param name defines the name of the mesh
  59126. * @param options defines the options used to create the mesh
  59127. * @param scene defines the hosting scene
  59128. * @returns the box mesh
  59129. */
  59130. static CreateTiledPlane(name: string, options: {
  59131. pattern?: number;
  59132. tileSize?: number;
  59133. tileWidth?: number;
  59134. tileHeight?: number;
  59135. size?: number;
  59136. width?: number;
  59137. height?: number;
  59138. alignHorizontal?: number;
  59139. alignVertical?: number;
  59140. sideOrientation?: number;
  59141. frontUVs?: Vector4;
  59142. backUVs?: Vector4;
  59143. updatable?: boolean;
  59144. }, scene?: Nullable<Scene>): Mesh;
  59145. }
  59146. }
  59147. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59148. import { Nullable } from "babylonjs/types";
  59149. import { Scene } from "babylonjs/scene";
  59150. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59151. import { Mesh } from "babylonjs/Meshes/mesh";
  59152. /**
  59153. * Class containing static functions to help procedurally build meshes
  59154. */
  59155. export class TubeBuilder {
  59156. /**
  59157. * Creates a tube mesh.
  59158. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59159. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59160. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59161. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59162. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59163. * * 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)
  59164. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59165. * * 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
  59166. * * 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
  59167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59169. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59171. * @param name defines the name of the mesh
  59172. * @param options defines the options used to create the mesh
  59173. * @param scene defines the hosting scene
  59174. * @returns the tube mesh
  59175. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59176. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59177. */
  59178. static CreateTube(name: string, options: {
  59179. path: Vector3[];
  59180. radius?: number;
  59181. tessellation?: number;
  59182. radiusFunction?: {
  59183. (i: number, distance: number): number;
  59184. };
  59185. cap?: number;
  59186. arc?: number;
  59187. updatable?: boolean;
  59188. sideOrientation?: number;
  59189. frontUVs?: Vector4;
  59190. backUVs?: Vector4;
  59191. instance?: Mesh;
  59192. invertUV?: boolean;
  59193. }, scene?: Nullable<Scene>): Mesh;
  59194. }
  59195. }
  59196. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59197. import { Scene } from "babylonjs/scene";
  59198. import { Vector4 } from "babylonjs/Maths/math.vector";
  59199. import { Mesh } from "babylonjs/Meshes/mesh";
  59200. import { Nullable } from "babylonjs/types";
  59201. /**
  59202. * Class containing static functions to help procedurally build meshes
  59203. */
  59204. export class IcoSphereBuilder {
  59205. /**
  59206. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59207. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59208. * * 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`)
  59209. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59210. * * 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
  59211. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59212. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59213. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59214. * @param name defines the name of the mesh
  59215. * @param options defines the options used to create the mesh
  59216. * @param scene defines the hosting scene
  59217. * @returns the icosahedron mesh
  59218. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59219. */
  59220. static CreateIcoSphere(name: string, options: {
  59221. radius?: number;
  59222. radiusX?: number;
  59223. radiusY?: number;
  59224. radiusZ?: number;
  59225. flat?: boolean;
  59226. subdivisions?: number;
  59227. sideOrientation?: number;
  59228. frontUVs?: Vector4;
  59229. backUVs?: Vector4;
  59230. updatable?: boolean;
  59231. }, scene?: Nullable<Scene>): Mesh;
  59232. }
  59233. }
  59234. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59235. import { Vector3 } from "babylonjs/Maths/math.vector";
  59236. import { Mesh } from "babylonjs/Meshes/mesh";
  59237. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59238. /**
  59239. * Class containing static functions to help procedurally build meshes
  59240. */
  59241. export class DecalBuilder {
  59242. /**
  59243. * Creates a decal mesh.
  59244. * 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
  59245. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59246. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59247. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59248. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59249. * @param name defines the name of the mesh
  59250. * @param sourceMesh defines the mesh where the decal must be applied
  59251. * @param options defines the options used to create the mesh
  59252. * @param scene defines the hosting scene
  59253. * @returns the decal mesh
  59254. * @see https://doc.babylonjs.com/how_to/decals
  59255. */
  59256. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59257. position?: Vector3;
  59258. normal?: Vector3;
  59259. size?: Vector3;
  59260. angle?: number;
  59261. }): Mesh;
  59262. }
  59263. }
  59264. declare module "babylonjs/Meshes/meshBuilder" {
  59265. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59266. import { Nullable } from "babylonjs/types";
  59267. import { Scene } from "babylonjs/scene";
  59268. import { Mesh } from "babylonjs/Meshes/mesh";
  59269. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59270. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59271. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59272. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59273. import { Plane } from "babylonjs/Maths/math.plane";
  59274. /**
  59275. * Class containing static functions to help procedurally build meshes
  59276. */
  59277. export class MeshBuilder {
  59278. /**
  59279. * Creates a box mesh
  59280. * * The parameter `size` sets the size (float) of each box side (default 1)
  59281. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59282. * * 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)
  59283. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59285. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59287. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59288. * @param name defines the name of the mesh
  59289. * @param options defines the options used to create the mesh
  59290. * @param scene defines the hosting scene
  59291. * @returns the box mesh
  59292. */
  59293. static CreateBox(name: string, options: {
  59294. size?: number;
  59295. width?: number;
  59296. height?: number;
  59297. depth?: number;
  59298. faceUV?: Vector4[];
  59299. faceColors?: Color4[];
  59300. sideOrientation?: number;
  59301. frontUVs?: Vector4;
  59302. backUVs?: Vector4;
  59303. updatable?: boolean;
  59304. }, scene?: Nullable<Scene>): Mesh;
  59305. /**
  59306. * Creates a tiled box mesh
  59307. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59308. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59309. * @param name defines the name of the mesh
  59310. * @param options defines the options used to create the mesh
  59311. * @param scene defines the hosting scene
  59312. * @returns the tiled box mesh
  59313. */
  59314. static CreateTiledBox(name: string, options: {
  59315. pattern?: number;
  59316. size?: number;
  59317. width?: number;
  59318. height?: number;
  59319. depth: number;
  59320. tileSize?: number;
  59321. tileWidth?: number;
  59322. tileHeight?: number;
  59323. faceUV?: Vector4[];
  59324. faceColors?: Color4[];
  59325. alignHorizontal?: number;
  59326. alignVertical?: number;
  59327. sideOrientation?: number;
  59328. updatable?: boolean;
  59329. }, scene?: Nullable<Scene>): Mesh;
  59330. /**
  59331. * Creates a sphere mesh
  59332. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59333. * * 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`)
  59334. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59335. * * 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
  59336. * * 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)
  59337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59340. * @param name defines the name of the mesh
  59341. * @param options defines the options used to create the mesh
  59342. * @param scene defines the hosting scene
  59343. * @returns the sphere mesh
  59344. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59345. */
  59346. static CreateSphere(name: string, options: {
  59347. segments?: number;
  59348. diameter?: number;
  59349. diameterX?: number;
  59350. diameterY?: number;
  59351. diameterZ?: number;
  59352. arc?: number;
  59353. slice?: number;
  59354. sideOrientation?: number;
  59355. frontUVs?: Vector4;
  59356. backUVs?: Vector4;
  59357. updatable?: boolean;
  59358. }, scene?: Nullable<Scene>): Mesh;
  59359. /**
  59360. * Creates a plane polygonal mesh. By default, this is a disc
  59361. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59362. * * 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
  59363. * * 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
  59364. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59365. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59367. * @param name defines the name of the mesh
  59368. * @param options defines the options used to create the mesh
  59369. * @param scene defines the hosting scene
  59370. * @returns the plane polygonal mesh
  59371. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59372. */
  59373. static CreateDisc(name: string, options: {
  59374. radius?: number;
  59375. tessellation?: number;
  59376. arc?: number;
  59377. updatable?: boolean;
  59378. sideOrientation?: number;
  59379. frontUVs?: Vector4;
  59380. backUVs?: Vector4;
  59381. }, scene?: Nullable<Scene>): Mesh;
  59382. /**
  59383. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59384. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59385. * * 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`)
  59386. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59387. * * 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
  59388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59389. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59391. * @param name defines the name of the mesh
  59392. * @param options defines the options used to create the mesh
  59393. * @param scene defines the hosting scene
  59394. * @returns the icosahedron mesh
  59395. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59396. */
  59397. static CreateIcoSphere(name: string, options: {
  59398. radius?: number;
  59399. radiusX?: number;
  59400. radiusY?: number;
  59401. radiusZ?: number;
  59402. flat?: boolean;
  59403. subdivisions?: number;
  59404. sideOrientation?: number;
  59405. frontUVs?: Vector4;
  59406. backUVs?: Vector4;
  59407. updatable?: boolean;
  59408. }, scene?: Nullable<Scene>): Mesh;
  59409. /**
  59410. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59411. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59412. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59413. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59414. * * 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
  59415. * * 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
  59416. * * 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
  59417. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59418. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59419. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59420. * * 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
  59421. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59422. * * 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
  59423. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59425. * @param name defines the name of the mesh
  59426. * @param options defines the options used to create the mesh
  59427. * @param scene defines the hosting scene
  59428. * @returns the ribbon mesh
  59429. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59430. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59431. */
  59432. static CreateRibbon(name: string, options: {
  59433. pathArray: Vector3[][];
  59434. closeArray?: boolean;
  59435. closePath?: boolean;
  59436. offset?: number;
  59437. updatable?: boolean;
  59438. sideOrientation?: number;
  59439. frontUVs?: Vector4;
  59440. backUVs?: Vector4;
  59441. instance?: Mesh;
  59442. invertUV?: boolean;
  59443. uvs?: Vector2[];
  59444. colors?: Color4[];
  59445. }, scene?: Nullable<Scene>): Mesh;
  59446. /**
  59447. * Creates a cylinder or a cone mesh
  59448. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59449. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59450. * * 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.
  59451. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59452. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59453. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59454. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59455. * * 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).
  59456. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59457. * * 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).
  59458. * * 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
  59459. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59460. * * 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
  59461. * * 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.
  59462. * * If `enclose` is false, a ring surface is one element.
  59463. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59464. * * 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
  59465. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59466. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59467. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59468. * @param name defines the name of the mesh
  59469. * @param options defines the options used to create the mesh
  59470. * @param scene defines the hosting scene
  59471. * @returns the cylinder mesh
  59472. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59473. */
  59474. static CreateCylinder(name: string, options: {
  59475. height?: number;
  59476. diameterTop?: number;
  59477. diameterBottom?: number;
  59478. diameter?: number;
  59479. tessellation?: number;
  59480. subdivisions?: number;
  59481. arc?: number;
  59482. faceColors?: Color4[];
  59483. faceUV?: Vector4[];
  59484. updatable?: boolean;
  59485. hasRings?: boolean;
  59486. enclose?: boolean;
  59487. cap?: number;
  59488. sideOrientation?: number;
  59489. frontUVs?: Vector4;
  59490. backUVs?: Vector4;
  59491. }, scene?: Nullable<Scene>): Mesh;
  59492. /**
  59493. * Creates a torus mesh
  59494. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59495. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59496. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59500. * @param name defines the name of the mesh
  59501. * @param options defines the options used to create the mesh
  59502. * @param scene defines the hosting scene
  59503. * @returns the torus mesh
  59504. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59505. */
  59506. static CreateTorus(name: string, options: {
  59507. diameter?: number;
  59508. thickness?: number;
  59509. tessellation?: number;
  59510. updatable?: boolean;
  59511. sideOrientation?: number;
  59512. frontUVs?: Vector4;
  59513. backUVs?: Vector4;
  59514. }, scene?: Nullable<Scene>): Mesh;
  59515. /**
  59516. * Creates a torus knot mesh
  59517. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59518. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59519. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59520. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59521. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59522. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59523. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59524. * @param name defines the name of the mesh
  59525. * @param options defines the options used to create the mesh
  59526. * @param scene defines the hosting scene
  59527. * @returns the torus knot mesh
  59528. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59529. */
  59530. static CreateTorusKnot(name: string, options: {
  59531. radius?: number;
  59532. tube?: number;
  59533. radialSegments?: number;
  59534. tubularSegments?: number;
  59535. p?: number;
  59536. q?: number;
  59537. updatable?: boolean;
  59538. sideOrientation?: number;
  59539. frontUVs?: Vector4;
  59540. backUVs?: Vector4;
  59541. }, scene?: Nullable<Scene>): Mesh;
  59542. /**
  59543. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59544. * * 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
  59545. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59546. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59547. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59548. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59549. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59550. * * 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
  59551. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59554. * @param name defines the name of the new line system
  59555. * @param options defines the options used to create the line system
  59556. * @param scene defines the hosting scene
  59557. * @returns a new line system mesh
  59558. */
  59559. static CreateLineSystem(name: string, options: {
  59560. lines: Vector3[][];
  59561. updatable?: boolean;
  59562. instance?: Nullable<LinesMesh>;
  59563. colors?: Nullable<Color4[][]>;
  59564. useVertexAlpha?: boolean;
  59565. }, scene: Nullable<Scene>): LinesMesh;
  59566. /**
  59567. * Creates a line mesh
  59568. * 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
  59569. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59570. * * The parameter `points` is an array successive Vector3
  59571. * * The 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
  59572. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59573. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59574. * * When updating an instance, remember that only point positions can change, not the number of points
  59575. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59576. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59577. * @param name defines the name of the new line system
  59578. * @param options defines the options used to create the line system
  59579. * @param scene defines the hosting scene
  59580. * @returns a new line mesh
  59581. */
  59582. static CreateLines(name: string, options: {
  59583. points: Vector3[];
  59584. updatable?: boolean;
  59585. instance?: Nullable<LinesMesh>;
  59586. colors?: Color4[];
  59587. useVertexAlpha?: boolean;
  59588. }, scene?: Nullable<Scene>): LinesMesh;
  59589. /**
  59590. * Creates a dashed line mesh
  59591. * * 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
  59592. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59593. * * The parameter `points` is an array successive Vector3
  59594. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59595. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59596. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59597. * * 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
  59598. * * When updating an instance, remember that only point positions can change, not the number of points
  59599. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59600. * @param name defines the name of the mesh
  59601. * @param options defines the options used to create the mesh
  59602. * @param scene defines the hosting scene
  59603. * @returns the dashed line mesh
  59604. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59605. */
  59606. static CreateDashedLines(name: string, options: {
  59607. points: Vector3[];
  59608. dashSize?: number;
  59609. gapSize?: number;
  59610. dashNb?: number;
  59611. updatable?: boolean;
  59612. instance?: LinesMesh;
  59613. }, scene?: Nullable<Scene>): LinesMesh;
  59614. /**
  59615. * 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.
  59616. * * 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.
  59617. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59618. * * 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.
  59619. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59620. * * 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
  59621. * * 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
  59622. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59627. * @param name defines the name of the mesh
  59628. * @param options defines the options used to create the mesh
  59629. * @param scene defines the hosting scene
  59630. * @returns the extruded shape mesh
  59631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59632. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59633. */
  59634. static ExtrudeShape(name: string, options: {
  59635. shape: Vector3[];
  59636. path: Vector3[];
  59637. scale?: number;
  59638. rotation?: number;
  59639. cap?: number;
  59640. updatable?: boolean;
  59641. sideOrientation?: number;
  59642. frontUVs?: Vector4;
  59643. backUVs?: Vector4;
  59644. instance?: Mesh;
  59645. invertUV?: boolean;
  59646. }, scene?: Nullable<Scene>): Mesh;
  59647. /**
  59648. * Creates an custom extruded shape mesh.
  59649. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59650. * * 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.
  59651. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59652. * * 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
  59653. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59654. * * 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
  59655. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59656. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59657. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59658. * * 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
  59659. * * 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
  59660. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59661. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59662. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59663. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59665. * @param name defines the name of the mesh
  59666. * @param options defines the options used to create the mesh
  59667. * @param scene defines the hosting scene
  59668. * @returns the custom extruded shape mesh
  59669. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59672. */
  59673. static ExtrudeShapeCustom(name: string, options: {
  59674. shape: Vector3[];
  59675. path: Vector3[];
  59676. scaleFunction?: any;
  59677. rotationFunction?: any;
  59678. ribbonCloseArray?: boolean;
  59679. ribbonClosePath?: boolean;
  59680. cap?: number;
  59681. updatable?: boolean;
  59682. sideOrientation?: number;
  59683. frontUVs?: Vector4;
  59684. backUVs?: Vector4;
  59685. instance?: Mesh;
  59686. invertUV?: boolean;
  59687. }, scene?: Nullable<Scene>): Mesh;
  59688. /**
  59689. * Creates lathe mesh.
  59690. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59691. * * 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
  59692. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59693. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59694. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59695. * * 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
  59696. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59697. * * 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
  59698. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59699. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59700. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59702. * @param name defines the name of the mesh
  59703. * @param options defines the options used to create the mesh
  59704. * @param scene defines the hosting scene
  59705. * @returns the lathe mesh
  59706. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59707. */
  59708. static CreateLathe(name: string, options: {
  59709. shape: Vector3[];
  59710. radius?: number;
  59711. tessellation?: number;
  59712. clip?: number;
  59713. arc?: number;
  59714. closed?: boolean;
  59715. updatable?: boolean;
  59716. sideOrientation?: number;
  59717. frontUVs?: Vector4;
  59718. backUVs?: Vector4;
  59719. cap?: number;
  59720. invertUV?: boolean;
  59721. }, scene?: Nullable<Scene>): Mesh;
  59722. /**
  59723. * Creates a tiled plane mesh
  59724. * * You can set a limited pattern arrangement with the tiles
  59725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59726. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59727. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59728. * @param name defines the name of the mesh
  59729. * @param options defines the options used to create the mesh
  59730. * @param scene defines the hosting scene
  59731. * @returns the plane mesh
  59732. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59733. */
  59734. static CreateTiledPlane(name: string, options: {
  59735. pattern?: number;
  59736. tileSize?: number;
  59737. tileWidth?: number;
  59738. tileHeight?: number;
  59739. size?: number;
  59740. width?: number;
  59741. height?: number;
  59742. alignHorizontal?: number;
  59743. alignVertical?: number;
  59744. sideOrientation?: number;
  59745. frontUVs?: Vector4;
  59746. backUVs?: Vector4;
  59747. updatable?: boolean;
  59748. }, scene?: Nullable<Scene>): Mesh;
  59749. /**
  59750. * Creates a plane mesh
  59751. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59752. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59753. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59754. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59755. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59756. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59757. * @param name defines the name of the mesh
  59758. * @param options defines the options used to create the mesh
  59759. * @param scene defines the hosting scene
  59760. * @returns the plane mesh
  59761. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59762. */
  59763. static CreatePlane(name: string, options: {
  59764. size?: number;
  59765. width?: number;
  59766. height?: number;
  59767. sideOrientation?: number;
  59768. frontUVs?: Vector4;
  59769. backUVs?: Vector4;
  59770. updatable?: boolean;
  59771. sourcePlane?: Plane;
  59772. }, scene?: Nullable<Scene>): Mesh;
  59773. /**
  59774. * Creates a ground mesh
  59775. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59776. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59778. * @param name defines the name of the mesh
  59779. * @param options defines the options used to create the mesh
  59780. * @param scene defines the hosting scene
  59781. * @returns the ground mesh
  59782. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59783. */
  59784. static CreateGround(name: string, options: {
  59785. width?: number;
  59786. height?: number;
  59787. subdivisions?: number;
  59788. subdivisionsX?: number;
  59789. subdivisionsY?: number;
  59790. updatable?: boolean;
  59791. }, scene?: Nullable<Scene>): Mesh;
  59792. /**
  59793. * Creates a tiled ground mesh
  59794. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59795. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59796. * * 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
  59797. * * 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
  59798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59799. * @param name defines the name of the mesh
  59800. * @param options defines the options used to create the mesh
  59801. * @param scene defines the hosting scene
  59802. * @returns the tiled ground mesh
  59803. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59804. */
  59805. static CreateTiledGround(name: string, options: {
  59806. xmin: number;
  59807. zmin: number;
  59808. xmax: number;
  59809. zmax: number;
  59810. subdivisions?: {
  59811. w: number;
  59812. h: number;
  59813. };
  59814. precision?: {
  59815. w: number;
  59816. h: number;
  59817. };
  59818. updatable?: boolean;
  59819. }, scene?: Nullable<Scene>): Mesh;
  59820. /**
  59821. * Creates a ground mesh from a height map
  59822. * * The parameter `url` sets the URL of the height map image resource.
  59823. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59824. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59825. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59826. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59827. * * 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.
  59828. * * 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).
  59829. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59831. * @param name defines the name of the mesh
  59832. * @param url defines the url to the height map
  59833. * @param options defines the options used to create the mesh
  59834. * @param scene defines the hosting scene
  59835. * @returns the ground mesh
  59836. * @see https://doc.babylonjs.com/babylon101/height_map
  59837. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59838. */
  59839. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59840. width?: number;
  59841. height?: number;
  59842. subdivisions?: number;
  59843. minHeight?: number;
  59844. maxHeight?: number;
  59845. colorFilter?: Color3;
  59846. alphaFilter?: number;
  59847. updatable?: boolean;
  59848. onReady?: (mesh: GroundMesh) => void;
  59849. }, scene?: Nullable<Scene>): GroundMesh;
  59850. /**
  59851. * Creates a polygon mesh
  59852. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59853. * * 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
  59854. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59856. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59857. * * Remember you can only change the shape positions, not their number when updating a polygon
  59858. * @param name defines the name of the mesh
  59859. * @param options defines the options used to create the mesh
  59860. * @param scene defines the hosting scene
  59861. * @param earcutInjection can be used to inject your own earcut reference
  59862. * @returns the polygon mesh
  59863. */
  59864. static CreatePolygon(name: string, options: {
  59865. shape: Vector3[];
  59866. holes?: Vector3[][];
  59867. depth?: number;
  59868. faceUV?: Vector4[];
  59869. faceColors?: Color4[];
  59870. updatable?: boolean;
  59871. sideOrientation?: number;
  59872. frontUVs?: Vector4;
  59873. backUVs?: Vector4;
  59874. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59875. /**
  59876. * Creates an extruded polygon mesh, with depth in the Y direction.
  59877. * * 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)
  59878. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59879. * @param name defines the name of the mesh
  59880. * @param options defines the options used to create the mesh
  59881. * @param scene defines the hosting scene
  59882. * @param earcutInjection can be used to inject your own earcut reference
  59883. * @returns the polygon mesh
  59884. */
  59885. static ExtrudePolygon(name: string, options: {
  59886. shape: Vector3[];
  59887. holes?: Vector3[][];
  59888. depth?: number;
  59889. faceUV?: Vector4[];
  59890. faceColors?: Color4[];
  59891. updatable?: boolean;
  59892. sideOrientation?: number;
  59893. frontUVs?: Vector4;
  59894. backUVs?: Vector4;
  59895. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59896. /**
  59897. * Creates a tube mesh.
  59898. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59899. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59900. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59901. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59902. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59903. * * 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)
  59904. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59905. * * 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
  59906. * * 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
  59907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59911. * @param name defines the name of the mesh
  59912. * @param options defines the options used to create the mesh
  59913. * @param scene defines the hosting scene
  59914. * @returns the tube mesh
  59915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59916. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59917. */
  59918. static CreateTube(name: string, options: {
  59919. path: Vector3[];
  59920. radius?: number;
  59921. tessellation?: number;
  59922. radiusFunction?: {
  59923. (i: number, distance: number): number;
  59924. };
  59925. cap?: number;
  59926. arc?: number;
  59927. updatable?: boolean;
  59928. sideOrientation?: number;
  59929. frontUVs?: Vector4;
  59930. backUVs?: Vector4;
  59931. instance?: Mesh;
  59932. invertUV?: boolean;
  59933. }, scene?: Nullable<Scene>): Mesh;
  59934. /**
  59935. * Creates a polyhedron mesh
  59936. * * 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
  59937. * * The parameter `size` (positive float, default 1) sets the polygon size
  59938. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59939. * * 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`
  59940. * * 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
  59941. * * 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)`)
  59942. * * 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
  59943. * * 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
  59944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59947. * @param name defines the name of the mesh
  59948. * @param options defines the options used to create the mesh
  59949. * @param scene defines the hosting scene
  59950. * @returns the polyhedron mesh
  59951. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59952. */
  59953. static CreatePolyhedron(name: string, options: {
  59954. type?: number;
  59955. size?: number;
  59956. sizeX?: number;
  59957. sizeY?: number;
  59958. sizeZ?: number;
  59959. custom?: any;
  59960. faceUV?: Vector4[];
  59961. faceColors?: Color4[];
  59962. flat?: boolean;
  59963. updatable?: boolean;
  59964. sideOrientation?: number;
  59965. frontUVs?: Vector4;
  59966. backUVs?: Vector4;
  59967. }, scene?: Nullable<Scene>): Mesh;
  59968. /**
  59969. * Creates a decal mesh.
  59970. * 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
  59971. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59972. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59973. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59974. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59975. * @param name defines the name of the mesh
  59976. * @param sourceMesh defines the mesh where the decal must be applied
  59977. * @param options defines the options used to create the mesh
  59978. * @param scene defines the hosting scene
  59979. * @returns the decal mesh
  59980. * @see https://doc.babylonjs.com/how_to/decals
  59981. */
  59982. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59983. position?: Vector3;
  59984. normal?: Vector3;
  59985. size?: Vector3;
  59986. angle?: number;
  59987. }): Mesh;
  59988. }
  59989. }
  59990. declare module "babylonjs/Meshes/meshSimplification" {
  59991. import { Mesh } from "babylonjs/Meshes/mesh";
  59992. /**
  59993. * A simplifier interface for future simplification implementations
  59994. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59995. */
  59996. export interface ISimplifier {
  59997. /**
  59998. * Simplification of a given mesh according to the given settings.
  59999. * Since this requires computation, it is assumed that the function runs async.
  60000. * @param settings The settings of the simplification, including quality and distance
  60001. * @param successCallback A callback that will be called after the mesh was simplified.
  60002. * @param errorCallback in case of an error, this callback will be called. optional.
  60003. */
  60004. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60005. }
  60006. /**
  60007. * Expected simplification settings.
  60008. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60010. */
  60011. export interface ISimplificationSettings {
  60012. /**
  60013. * Gets or sets the expected quality
  60014. */
  60015. quality: number;
  60016. /**
  60017. * Gets or sets the distance when this optimized version should be used
  60018. */
  60019. distance: number;
  60020. /**
  60021. * Gets an already optimized mesh
  60022. */
  60023. optimizeMesh?: boolean;
  60024. }
  60025. /**
  60026. * Class used to specify simplification options
  60027. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60028. */
  60029. export class SimplificationSettings implements ISimplificationSettings {
  60030. /** expected quality */
  60031. quality: number;
  60032. /** distance when this optimized version should be used */
  60033. distance: number;
  60034. /** already optimized mesh */
  60035. optimizeMesh?: boolean | undefined;
  60036. /**
  60037. * Creates a SimplificationSettings
  60038. * @param quality expected quality
  60039. * @param distance distance when this optimized version should be used
  60040. * @param optimizeMesh already optimized mesh
  60041. */
  60042. constructor(
  60043. /** expected quality */
  60044. quality: number,
  60045. /** distance when this optimized version should be used */
  60046. distance: number,
  60047. /** already optimized mesh */
  60048. optimizeMesh?: boolean | undefined);
  60049. }
  60050. /**
  60051. * Interface used to define a simplification task
  60052. */
  60053. export interface ISimplificationTask {
  60054. /**
  60055. * Array of settings
  60056. */
  60057. settings: Array<ISimplificationSettings>;
  60058. /**
  60059. * Simplification type
  60060. */
  60061. simplificationType: SimplificationType;
  60062. /**
  60063. * Mesh to simplify
  60064. */
  60065. mesh: Mesh;
  60066. /**
  60067. * Callback called on success
  60068. */
  60069. successCallback?: () => void;
  60070. /**
  60071. * Defines if parallel processing can be used
  60072. */
  60073. parallelProcessing: boolean;
  60074. }
  60075. /**
  60076. * Queue used to order the simplification tasks
  60077. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60078. */
  60079. export class SimplificationQueue {
  60080. private _simplificationArray;
  60081. /**
  60082. * Gets a boolean indicating that the process is still running
  60083. */
  60084. running: boolean;
  60085. /**
  60086. * Creates a new queue
  60087. */
  60088. constructor();
  60089. /**
  60090. * Adds a new simplification task
  60091. * @param task defines a task to add
  60092. */
  60093. addTask(task: ISimplificationTask): void;
  60094. /**
  60095. * Execute next task
  60096. */
  60097. executeNext(): void;
  60098. /**
  60099. * Execute a simplification task
  60100. * @param task defines the task to run
  60101. */
  60102. runSimplification(task: ISimplificationTask): void;
  60103. private getSimplifier;
  60104. }
  60105. /**
  60106. * The implemented types of simplification
  60107. * At the moment only Quadratic Error Decimation is implemented
  60108. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60109. */
  60110. export enum SimplificationType {
  60111. /** Quadratic error decimation */
  60112. QUADRATIC = 0
  60113. }
  60114. }
  60115. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60116. import { Scene } from "babylonjs/scene";
  60117. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60118. import { ISceneComponent } from "babylonjs/sceneComponent";
  60119. module "babylonjs/scene" {
  60120. interface Scene {
  60121. /** @hidden (Backing field) */
  60122. _simplificationQueue: SimplificationQueue;
  60123. /**
  60124. * Gets or sets the simplification queue attached to the scene
  60125. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60126. */
  60127. simplificationQueue: SimplificationQueue;
  60128. }
  60129. }
  60130. module "babylonjs/Meshes/mesh" {
  60131. interface Mesh {
  60132. /**
  60133. * Simplify the mesh according to the given array of settings.
  60134. * Function will return immediately and will simplify async
  60135. * @param settings a collection of simplification settings
  60136. * @param parallelProcessing should all levels calculate parallel or one after the other
  60137. * @param simplificationType the type of simplification to run
  60138. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60139. * @returns the current mesh
  60140. */
  60141. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60142. }
  60143. }
  60144. /**
  60145. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60146. * created in a scene
  60147. */
  60148. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60149. /**
  60150. * The component name helpfull to identify the component in the list of scene components.
  60151. */
  60152. readonly name: string;
  60153. /**
  60154. * The scene the component belongs to.
  60155. */
  60156. scene: Scene;
  60157. /**
  60158. * Creates a new instance of the component for the given scene
  60159. * @param scene Defines the scene to register the component in
  60160. */
  60161. constructor(scene: Scene);
  60162. /**
  60163. * Registers the component in a given scene
  60164. */
  60165. register(): void;
  60166. /**
  60167. * Rebuilds the elements related to this component in case of
  60168. * context lost for instance.
  60169. */
  60170. rebuild(): void;
  60171. /**
  60172. * Disposes the component and the associated ressources
  60173. */
  60174. dispose(): void;
  60175. private _beforeCameraUpdate;
  60176. }
  60177. }
  60178. declare module "babylonjs/Meshes/Builders/index" {
  60179. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60180. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60181. export * from "babylonjs/Meshes/Builders/discBuilder";
  60182. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60183. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60184. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60185. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60186. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60187. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60188. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60189. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60190. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60191. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60192. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60193. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60194. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60195. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60196. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60197. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60198. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60199. }
  60200. declare module "babylonjs/Meshes/index" {
  60201. export * from "babylonjs/Meshes/abstractMesh";
  60202. export * from "babylonjs/Meshes/buffer";
  60203. export * from "babylonjs/Meshes/Compression/index";
  60204. export * from "babylonjs/Meshes/csg";
  60205. export * from "babylonjs/Meshes/geometry";
  60206. export * from "babylonjs/Meshes/groundMesh";
  60207. export * from "babylonjs/Meshes/trailMesh";
  60208. export * from "babylonjs/Meshes/instancedMesh";
  60209. export * from "babylonjs/Meshes/linesMesh";
  60210. export * from "babylonjs/Meshes/mesh";
  60211. export * from "babylonjs/Meshes/mesh.vertexData";
  60212. export * from "babylonjs/Meshes/meshBuilder";
  60213. export * from "babylonjs/Meshes/meshSimplification";
  60214. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60215. export * from "babylonjs/Meshes/polygonMesh";
  60216. export * from "babylonjs/Meshes/subMesh";
  60217. export * from "babylonjs/Meshes/meshLODLevel";
  60218. export * from "babylonjs/Meshes/transformNode";
  60219. export * from "babylonjs/Meshes/Builders/index";
  60220. export * from "babylonjs/Meshes/dataBuffer";
  60221. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60222. }
  60223. declare module "babylonjs/Morph/index" {
  60224. export * from "babylonjs/Morph/morphTarget";
  60225. export * from "babylonjs/Morph/morphTargetManager";
  60226. }
  60227. declare module "babylonjs/Navigation/INavigationEngine" {
  60228. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60229. import { Vector3 } from "babylonjs/Maths/math";
  60230. import { Mesh } from "babylonjs/Meshes/mesh";
  60231. import { Scene } from "babylonjs/scene";
  60232. /**
  60233. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60234. */
  60235. export interface INavigationEnginePlugin {
  60236. /**
  60237. * plugin name
  60238. */
  60239. name: string;
  60240. /**
  60241. * Creates a navigation mesh
  60242. * @param meshes array of all the geometry used to compute the navigatio mesh
  60243. * @param parameters bunch of parameters used to filter geometry
  60244. */
  60245. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60246. /**
  60247. * Create a navigation mesh debug mesh
  60248. * @param scene is where the mesh will be added
  60249. * @returns debug display mesh
  60250. */
  60251. createDebugNavMesh(scene: Scene): Mesh;
  60252. /**
  60253. * Get a navigation mesh constrained position, closest to the parameter position
  60254. * @param position world position
  60255. * @returns the closest point to position constrained by the navigation mesh
  60256. */
  60257. getClosestPoint(position: Vector3): Vector3;
  60258. /**
  60259. * Get a navigation mesh constrained position, within a particular radius
  60260. * @param position world position
  60261. * @param maxRadius the maximum distance to the constrained world position
  60262. * @returns the closest point to position constrained by the navigation mesh
  60263. */
  60264. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60265. /**
  60266. * Compute the final position from a segment made of destination-position
  60267. * @param position world position
  60268. * @param destination world position
  60269. * @returns the resulting point along the navmesh
  60270. */
  60271. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60272. /**
  60273. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60274. * @param start world position
  60275. * @param end world position
  60276. * @returns array containing world position composing the path
  60277. */
  60278. computePath(start: Vector3, end: Vector3): Vector3[];
  60279. /**
  60280. * If this plugin is supported
  60281. * @returns true if plugin is supported
  60282. */
  60283. isSupported(): boolean;
  60284. /**
  60285. * Create a new Crowd so you can add agents
  60286. * @param maxAgents the maximum agent count in the crowd
  60287. * @param maxAgentRadius the maximum radius an agent can have
  60288. * @param scene to attach the crowd to
  60289. * @returns the crowd you can add agents to
  60290. */
  60291. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60292. /**
  60293. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60294. * The queries will try to find a solution within those bounds
  60295. * default is (1,1,1)
  60296. * @param extent x,y,z value that define the extent around the queries point of reference
  60297. */
  60298. setDefaultQueryExtent(extent: Vector3): void;
  60299. /**
  60300. * Get the Bounding box extent specified by setDefaultQueryExtent
  60301. * @returns the box extent values
  60302. */
  60303. getDefaultQueryExtent(): Vector3;
  60304. /**
  60305. * Release all resources
  60306. */
  60307. dispose(): void;
  60308. }
  60309. /**
  60310. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60311. */
  60312. export interface ICrowd {
  60313. /**
  60314. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60315. * You can attach anything to that node. The node position is updated in the scene update tick.
  60316. * @param pos world position that will be constrained by the navigation mesh
  60317. * @param parameters agent parameters
  60318. * @param transform hooked to the agent that will be update by the scene
  60319. * @returns agent index
  60320. */
  60321. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60322. /**
  60323. * Returns the agent position in world space
  60324. * @param index agent index returned by addAgent
  60325. * @returns world space position
  60326. */
  60327. getAgentPosition(index: number): Vector3;
  60328. /**
  60329. * Gets the agent velocity in world space
  60330. * @param index agent index returned by addAgent
  60331. * @returns world space velocity
  60332. */
  60333. getAgentVelocity(index: number): Vector3;
  60334. /**
  60335. * remove a particular agent previously created
  60336. * @param index agent index returned by addAgent
  60337. */
  60338. removeAgent(index: number): void;
  60339. /**
  60340. * get the list of all agents attached to this crowd
  60341. * @returns list of agent indices
  60342. */
  60343. getAgents(): number[];
  60344. /**
  60345. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60346. * @param deltaTime in seconds
  60347. */
  60348. update(deltaTime: number): void;
  60349. /**
  60350. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60351. * @param index agent index returned by addAgent
  60352. * @param destination targeted world position
  60353. */
  60354. agentGoto(index: number, destination: Vector3): void;
  60355. /**
  60356. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60357. * The queries will try to find a solution within those bounds
  60358. * default is (1,1,1)
  60359. * @param extent x,y,z value that define the extent around the queries point of reference
  60360. */
  60361. setDefaultQueryExtent(extent: Vector3): void;
  60362. /**
  60363. * Get the Bounding box extent specified by setDefaultQueryExtent
  60364. * @returns the box extent values
  60365. */
  60366. getDefaultQueryExtent(): Vector3;
  60367. /**
  60368. * Release all resources
  60369. */
  60370. dispose(): void;
  60371. }
  60372. /**
  60373. * Configures an agent
  60374. */
  60375. export interface IAgentParameters {
  60376. /**
  60377. * Agent radius. [Limit: >= 0]
  60378. */
  60379. radius: number;
  60380. /**
  60381. * Agent height. [Limit: > 0]
  60382. */
  60383. height: number;
  60384. /**
  60385. * Maximum allowed acceleration. [Limit: >= 0]
  60386. */
  60387. maxAcceleration: number;
  60388. /**
  60389. * Maximum allowed speed. [Limit: >= 0]
  60390. */
  60391. maxSpeed: number;
  60392. /**
  60393. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60394. */
  60395. collisionQueryRange: number;
  60396. /**
  60397. * The path visibility optimization range. [Limit: > 0]
  60398. */
  60399. pathOptimizationRange: number;
  60400. /**
  60401. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60402. */
  60403. separationWeight: number;
  60404. }
  60405. /**
  60406. * Configures the navigation mesh creation
  60407. */
  60408. export interface INavMeshParameters {
  60409. /**
  60410. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60411. */
  60412. cs: number;
  60413. /**
  60414. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60415. */
  60416. ch: number;
  60417. /**
  60418. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60419. */
  60420. walkableSlopeAngle: number;
  60421. /**
  60422. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60423. * be considered walkable. [Limit: >= 3] [Units: vx]
  60424. */
  60425. walkableHeight: number;
  60426. /**
  60427. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60428. */
  60429. walkableClimb: number;
  60430. /**
  60431. * The distance to erode/shrink the walkable area of the heightfield away from
  60432. * obstructions. [Limit: >=0] [Units: vx]
  60433. */
  60434. walkableRadius: number;
  60435. /**
  60436. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60437. */
  60438. maxEdgeLen: number;
  60439. /**
  60440. * The maximum distance a simplfied contour's border edges should deviate
  60441. * the original raw contour. [Limit: >=0] [Units: vx]
  60442. */
  60443. maxSimplificationError: number;
  60444. /**
  60445. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60446. */
  60447. minRegionArea: number;
  60448. /**
  60449. * Any regions with a span count smaller than this value will, if possible,
  60450. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60451. */
  60452. mergeRegionArea: number;
  60453. /**
  60454. * The maximum number of vertices allowed for polygons generated during the
  60455. * contour to polygon conversion process. [Limit: >= 3]
  60456. */
  60457. maxVertsPerPoly: number;
  60458. /**
  60459. * Sets the sampling distance to use when generating the detail mesh.
  60460. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60461. */
  60462. detailSampleDist: number;
  60463. /**
  60464. * The maximum distance the detail mesh surface should deviate from heightfield
  60465. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60466. */
  60467. detailSampleMaxError: number;
  60468. }
  60469. }
  60470. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60471. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60472. import { Mesh } from "babylonjs/Meshes/mesh";
  60473. import { Scene } from "babylonjs/scene";
  60474. import { Vector3 } from "babylonjs/Maths/math";
  60475. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60476. /**
  60477. * RecastJS navigation plugin
  60478. */
  60479. export class RecastJSPlugin implements INavigationEnginePlugin {
  60480. /**
  60481. * Reference to the Recast library
  60482. */
  60483. bjsRECAST: any;
  60484. /**
  60485. * plugin name
  60486. */
  60487. name: string;
  60488. /**
  60489. * the first navmesh created. We might extend this to support multiple navmeshes
  60490. */
  60491. navMesh: any;
  60492. /**
  60493. * Initializes the recastJS plugin
  60494. * @param recastInjection can be used to inject your own recast reference
  60495. */
  60496. constructor(recastInjection?: any);
  60497. /**
  60498. * Creates a navigation mesh
  60499. * @param meshes array of all the geometry used to compute the navigatio mesh
  60500. * @param parameters bunch of parameters used to filter geometry
  60501. */
  60502. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60503. /**
  60504. * Create a navigation mesh debug mesh
  60505. * @param scene is where the mesh will be added
  60506. * @returns debug display mesh
  60507. */
  60508. createDebugNavMesh(scene: Scene): Mesh;
  60509. /**
  60510. * Get a navigation mesh constrained position, closest to the parameter position
  60511. * @param position world position
  60512. * @returns the closest point to position constrained by the navigation mesh
  60513. */
  60514. getClosestPoint(position: Vector3): Vector3;
  60515. /**
  60516. * Get a navigation mesh constrained position, within a particular radius
  60517. * @param position world position
  60518. * @param maxRadius the maximum distance to the constrained world position
  60519. * @returns the closest point to position constrained by the navigation mesh
  60520. */
  60521. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60522. /**
  60523. * Compute the final position from a segment made of destination-position
  60524. * @param position world position
  60525. * @param destination world position
  60526. * @returns the resulting point along the navmesh
  60527. */
  60528. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60529. /**
  60530. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60531. * @param start world position
  60532. * @param end world position
  60533. * @returns array containing world position composing the path
  60534. */
  60535. computePath(start: Vector3, end: Vector3): Vector3[];
  60536. /**
  60537. * Create a new Crowd so you can add agents
  60538. * @param maxAgents the maximum agent count in the crowd
  60539. * @param maxAgentRadius the maximum radius an agent can have
  60540. * @param scene to attach the crowd to
  60541. * @returns the crowd you can add agents to
  60542. */
  60543. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60544. /**
  60545. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60546. * The queries will try to find a solution within those bounds
  60547. * default is (1,1,1)
  60548. * @param extent x,y,z value that define the extent around the queries point of reference
  60549. */
  60550. setDefaultQueryExtent(extent: Vector3): void;
  60551. /**
  60552. * Get the Bounding box extent specified by setDefaultQueryExtent
  60553. * @returns the box extent values
  60554. */
  60555. getDefaultQueryExtent(): Vector3;
  60556. /**
  60557. * Disposes
  60558. */
  60559. dispose(): void;
  60560. /**
  60561. * If this plugin is supported
  60562. * @returns true if plugin is supported
  60563. */
  60564. isSupported(): boolean;
  60565. }
  60566. /**
  60567. * Recast detour crowd implementation
  60568. */
  60569. export class RecastJSCrowd implements ICrowd {
  60570. /**
  60571. * Recast/detour plugin
  60572. */
  60573. bjsRECASTPlugin: RecastJSPlugin;
  60574. /**
  60575. * Link to the detour crowd
  60576. */
  60577. recastCrowd: any;
  60578. /**
  60579. * One transform per agent
  60580. */
  60581. transforms: TransformNode[];
  60582. /**
  60583. * All agents created
  60584. */
  60585. agents: number[];
  60586. /**
  60587. * Link to the scene is kept to unregister the crowd from the scene
  60588. */
  60589. private _scene;
  60590. /**
  60591. * Observer for crowd updates
  60592. */
  60593. private _onBeforeAnimationsObserver;
  60594. /**
  60595. * Constructor
  60596. * @param plugin recastJS plugin
  60597. * @param maxAgents the maximum agent count in the crowd
  60598. * @param maxAgentRadius the maximum radius an agent can have
  60599. * @param scene to attach the crowd to
  60600. * @returns the crowd you can add agents to
  60601. */
  60602. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60603. /**
  60604. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60605. * You can attach anything to that node. The node position is updated in the scene update tick.
  60606. * @param pos world position that will be constrained by the navigation mesh
  60607. * @param parameters agent parameters
  60608. * @param transform hooked to the agent that will be update by the scene
  60609. * @returns agent index
  60610. */
  60611. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60612. /**
  60613. * Returns the agent position in world space
  60614. * @param index agent index returned by addAgent
  60615. * @returns world space position
  60616. */
  60617. getAgentPosition(index: number): Vector3;
  60618. /**
  60619. * Returns the agent velocity in world space
  60620. * @param index agent index returned by addAgent
  60621. * @returns world space velocity
  60622. */
  60623. getAgentVelocity(index: number): Vector3;
  60624. /**
  60625. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60626. * @param index agent index returned by addAgent
  60627. * @param destination targeted world position
  60628. */
  60629. agentGoto(index: number, destination: Vector3): void;
  60630. /**
  60631. * remove a particular agent previously created
  60632. * @param index agent index returned by addAgent
  60633. */
  60634. removeAgent(index: number): void;
  60635. /**
  60636. * get the list of all agents attached to this crowd
  60637. * @returns list of agent indices
  60638. */
  60639. getAgents(): number[];
  60640. /**
  60641. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60642. * @param deltaTime in seconds
  60643. */
  60644. update(deltaTime: number): void;
  60645. /**
  60646. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60647. * The queries will try to find a solution within those bounds
  60648. * default is (1,1,1)
  60649. * @param extent x,y,z value that define the extent around the queries point of reference
  60650. */
  60651. setDefaultQueryExtent(extent: Vector3): void;
  60652. /**
  60653. * Get the Bounding box extent specified by setDefaultQueryExtent
  60654. * @returns the box extent values
  60655. */
  60656. getDefaultQueryExtent(): Vector3;
  60657. /**
  60658. * Release all resources
  60659. */
  60660. dispose(): void;
  60661. }
  60662. }
  60663. declare module "babylonjs/Navigation/Plugins/index" {
  60664. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60665. }
  60666. declare module "babylonjs/Navigation/index" {
  60667. export * from "babylonjs/Navigation/INavigationEngine";
  60668. export * from "babylonjs/Navigation/Plugins/index";
  60669. }
  60670. declare module "babylonjs/Offline/database" {
  60671. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60672. /**
  60673. * Class used to enable access to IndexedDB
  60674. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60675. */
  60676. export class Database implements IOfflineProvider {
  60677. private _callbackManifestChecked;
  60678. private _currentSceneUrl;
  60679. private _db;
  60680. private _enableSceneOffline;
  60681. private _enableTexturesOffline;
  60682. private _manifestVersionFound;
  60683. private _mustUpdateRessources;
  60684. private _hasReachedQuota;
  60685. private _isSupported;
  60686. private _idbFactory;
  60687. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60688. private static IsUASupportingBlobStorage;
  60689. /**
  60690. * Gets a boolean indicating if Database storate is enabled (off by default)
  60691. */
  60692. static IDBStorageEnabled: boolean;
  60693. /**
  60694. * Gets a boolean indicating if scene must be saved in the database
  60695. */
  60696. readonly enableSceneOffline: boolean;
  60697. /**
  60698. * Gets a boolean indicating if textures must be saved in the database
  60699. */
  60700. readonly enableTexturesOffline: boolean;
  60701. /**
  60702. * Creates a new Database
  60703. * @param urlToScene defines the url to load the scene
  60704. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60705. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60706. */
  60707. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60708. private static _ParseURL;
  60709. private static _ReturnFullUrlLocation;
  60710. private _checkManifestFile;
  60711. /**
  60712. * Open the database and make it available
  60713. * @param successCallback defines the callback to call on success
  60714. * @param errorCallback defines the callback to call on error
  60715. */
  60716. open(successCallback: () => void, errorCallback: () => void): void;
  60717. /**
  60718. * Loads an image from the database
  60719. * @param url defines the url to load from
  60720. * @param image defines the target DOM image
  60721. */
  60722. loadImage(url: string, image: HTMLImageElement): void;
  60723. private _loadImageFromDBAsync;
  60724. private _saveImageIntoDBAsync;
  60725. private _checkVersionFromDB;
  60726. private _loadVersionFromDBAsync;
  60727. private _saveVersionIntoDBAsync;
  60728. /**
  60729. * Loads a file from database
  60730. * @param url defines the URL to load from
  60731. * @param sceneLoaded defines a callback to call on success
  60732. * @param progressCallBack defines a callback to call when progress changed
  60733. * @param errorCallback defines a callback to call on error
  60734. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60735. */
  60736. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60737. private _loadFileAsync;
  60738. private _saveFileAsync;
  60739. /**
  60740. * Validates if xhr data is correct
  60741. * @param xhr defines the request to validate
  60742. * @param dataType defines the expected data type
  60743. * @returns true if data is correct
  60744. */
  60745. private static _ValidateXHRData;
  60746. }
  60747. }
  60748. declare module "babylonjs/Offline/index" {
  60749. export * from "babylonjs/Offline/database";
  60750. export * from "babylonjs/Offline/IOfflineProvider";
  60751. }
  60752. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60753. /** @hidden */
  60754. export var gpuUpdateParticlesPixelShader: {
  60755. name: string;
  60756. shader: string;
  60757. };
  60758. }
  60759. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60760. /** @hidden */
  60761. export var gpuUpdateParticlesVertexShader: {
  60762. name: string;
  60763. shader: string;
  60764. };
  60765. }
  60766. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60767. /** @hidden */
  60768. export var clipPlaneFragmentDeclaration2: {
  60769. name: string;
  60770. shader: string;
  60771. };
  60772. }
  60773. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60774. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60775. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60776. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60777. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60779. /** @hidden */
  60780. export var gpuRenderParticlesPixelShader: {
  60781. name: string;
  60782. shader: string;
  60783. };
  60784. }
  60785. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60786. /** @hidden */
  60787. export var clipPlaneVertexDeclaration2: {
  60788. name: string;
  60789. shader: string;
  60790. };
  60791. }
  60792. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60793. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60794. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60795. /** @hidden */
  60796. export var gpuRenderParticlesVertexShader: {
  60797. name: string;
  60798. shader: string;
  60799. };
  60800. }
  60801. declare module "babylonjs/Particles/gpuParticleSystem" {
  60802. import { Nullable } from "babylonjs/types";
  60803. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60804. import { Observable } from "babylonjs/Misc/observable";
  60805. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60806. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60807. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60808. import { Scene, IDisposable } from "babylonjs/scene";
  60809. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60810. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60811. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60812. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60813. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60814. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60815. /**
  60816. * This represents a GPU particle system in Babylon
  60817. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60818. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60819. */
  60820. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60821. /**
  60822. * The layer mask we are rendering the particles through.
  60823. */
  60824. layerMask: number;
  60825. private _capacity;
  60826. private _activeCount;
  60827. private _currentActiveCount;
  60828. private _accumulatedCount;
  60829. private _renderEffect;
  60830. private _updateEffect;
  60831. private _buffer0;
  60832. private _buffer1;
  60833. private _spriteBuffer;
  60834. private _updateVAO;
  60835. private _renderVAO;
  60836. private _targetIndex;
  60837. private _sourceBuffer;
  60838. private _targetBuffer;
  60839. private _engine;
  60840. private _currentRenderId;
  60841. private _started;
  60842. private _stopped;
  60843. private _timeDelta;
  60844. private _randomTexture;
  60845. private _randomTexture2;
  60846. private _attributesStrideSize;
  60847. private _updateEffectOptions;
  60848. private _randomTextureSize;
  60849. private _actualFrame;
  60850. private readonly _rawTextureWidth;
  60851. /**
  60852. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60853. */
  60854. static readonly IsSupported: boolean;
  60855. /**
  60856. * An event triggered when the system is disposed.
  60857. */
  60858. onDisposeObservable: Observable<GPUParticleSystem>;
  60859. /**
  60860. * Gets the maximum number of particles active at the same time.
  60861. * @returns The max number of active particles.
  60862. */
  60863. getCapacity(): number;
  60864. /**
  60865. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60866. * to override the particles.
  60867. */
  60868. forceDepthWrite: boolean;
  60869. /**
  60870. * Gets or set the number of active particles
  60871. */
  60872. activeParticleCount: number;
  60873. private _preWarmDone;
  60874. /**
  60875. * Is this system ready to be used/rendered
  60876. * @return true if the system is ready
  60877. */
  60878. isReady(): boolean;
  60879. /**
  60880. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60881. * @returns True if it has been started, otherwise false.
  60882. */
  60883. isStarted(): boolean;
  60884. /**
  60885. * Starts the particle system and begins to emit
  60886. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60887. */
  60888. start(delay?: number): void;
  60889. /**
  60890. * Stops the particle system.
  60891. */
  60892. stop(): void;
  60893. /**
  60894. * Remove all active particles
  60895. */
  60896. reset(): void;
  60897. /**
  60898. * Returns the string "GPUParticleSystem"
  60899. * @returns a string containing the class name
  60900. */
  60901. getClassName(): string;
  60902. private _colorGradientsTexture;
  60903. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60904. /**
  60905. * Adds a new color gradient
  60906. * @param gradient defines the gradient to use (between 0 and 1)
  60907. * @param color1 defines the color to affect to the specified gradient
  60908. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60909. * @returns the current particle system
  60910. */
  60911. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60912. /**
  60913. * Remove a specific color gradient
  60914. * @param gradient defines the gradient to remove
  60915. * @returns the current particle system
  60916. */
  60917. removeColorGradient(gradient: number): GPUParticleSystem;
  60918. private _angularSpeedGradientsTexture;
  60919. private _sizeGradientsTexture;
  60920. private _velocityGradientsTexture;
  60921. private _limitVelocityGradientsTexture;
  60922. private _dragGradientsTexture;
  60923. private _addFactorGradient;
  60924. /**
  60925. * Adds a new size gradient
  60926. * @param gradient defines the gradient to use (between 0 and 1)
  60927. * @param factor defines the size factor to affect to the specified gradient
  60928. * @returns the current particle system
  60929. */
  60930. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60931. /**
  60932. * Remove a specific size gradient
  60933. * @param gradient defines the gradient to remove
  60934. * @returns the current particle system
  60935. */
  60936. removeSizeGradient(gradient: number): GPUParticleSystem;
  60937. /**
  60938. * Adds a new angular speed gradient
  60939. * @param gradient defines the gradient to use (between 0 and 1)
  60940. * @param factor defines the angular speed to affect to the specified gradient
  60941. * @returns the current particle system
  60942. */
  60943. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60944. /**
  60945. * Remove a specific angular speed gradient
  60946. * @param gradient defines the gradient to remove
  60947. * @returns the current particle system
  60948. */
  60949. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60950. /**
  60951. * Adds a new velocity gradient
  60952. * @param gradient defines the gradient to use (between 0 and 1)
  60953. * @param factor defines the velocity to affect to the specified gradient
  60954. * @returns the current particle system
  60955. */
  60956. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60957. /**
  60958. * Remove a specific velocity gradient
  60959. * @param gradient defines the gradient to remove
  60960. * @returns the current particle system
  60961. */
  60962. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60963. /**
  60964. * Adds a new limit velocity gradient
  60965. * @param gradient defines the gradient to use (between 0 and 1)
  60966. * @param factor defines the limit velocity value to affect to the specified gradient
  60967. * @returns the current particle system
  60968. */
  60969. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60970. /**
  60971. * Remove a specific limit velocity gradient
  60972. * @param gradient defines the gradient to remove
  60973. * @returns the current particle system
  60974. */
  60975. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60976. /**
  60977. * Adds a new drag gradient
  60978. * @param gradient defines the gradient to use (between 0 and 1)
  60979. * @param factor defines the drag value to affect to the specified gradient
  60980. * @returns the current particle system
  60981. */
  60982. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60983. /**
  60984. * Remove a specific drag gradient
  60985. * @param gradient defines the gradient to remove
  60986. * @returns the current particle system
  60987. */
  60988. removeDragGradient(gradient: number): GPUParticleSystem;
  60989. /**
  60990. * Not supported by GPUParticleSystem
  60991. * @param gradient defines the gradient to use (between 0 and 1)
  60992. * @param factor defines the emit rate value to affect to the specified gradient
  60993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60994. * @returns the current particle system
  60995. */
  60996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60997. /**
  60998. * Not supported by GPUParticleSystem
  60999. * @param gradient defines the gradient to remove
  61000. * @returns the current particle system
  61001. */
  61002. removeEmitRateGradient(gradient: number): IParticleSystem;
  61003. /**
  61004. * Not supported by GPUParticleSystem
  61005. * @param gradient defines the gradient to use (between 0 and 1)
  61006. * @param factor defines the start size value to affect to the specified gradient
  61007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61008. * @returns the current particle system
  61009. */
  61010. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61011. /**
  61012. * Not supported by GPUParticleSystem
  61013. * @param gradient defines the gradient to remove
  61014. * @returns the current particle system
  61015. */
  61016. removeStartSizeGradient(gradient: number): IParticleSystem;
  61017. /**
  61018. * Not supported by GPUParticleSystem
  61019. * @param gradient defines the gradient to use (between 0 and 1)
  61020. * @param min defines the color remap minimal range
  61021. * @param max defines the color remap maximal range
  61022. * @returns the current particle system
  61023. */
  61024. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61025. /**
  61026. * Not supported by GPUParticleSystem
  61027. * @param gradient defines the gradient to remove
  61028. * @returns the current particle system
  61029. */
  61030. removeColorRemapGradient(): IParticleSystem;
  61031. /**
  61032. * Not supported by GPUParticleSystem
  61033. * @param gradient defines the gradient to use (between 0 and 1)
  61034. * @param min defines the alpha remap minimal range
  61035. * @param max defines the alpha remap maximal range
  61036. * @returns the current particle system
  61037. */
  61038. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61039. /**
  61040. * Not supported by GPUParticleSystem
  61041. * @param gradient defines the gradient to remove
  61042. * @returns the current particle system
  61043. */
  61044. removeAlphaRemapGradient(): IParticleSystem;
  61045. /**
  61046. * Not supported by GPUParticleSystem
  61047. * @param gradient defines the gradient to use (between 0 and 1)
  61048. * @param color defines the color to affect to the specified gradient
  61049. * @returns the current particle system
  61050. */
  61051. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61052. /**
  61053. * Not supported by GPUParticleSystem
  61054. * @param gradient defines the gradient to remove
  61055. * @returns the current particle system
  61056. */
  61057. removeRampGradient(): IParticleSystem;
  61058. /**
  61059. * Not supported by GPUParticleSystem
  61060. * @returns the list of ramp gradients
  61061. */
  61062. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61063. /**
  61064. * Not supported by GPUParticleSystem
  61065. * Gets or sets a boolean indicating that ramp gradients must be used
  61066. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61067. */
  61068. useRampGradients: boolean;
  61069. /**
  61070. * Not supported by GPUParticleSystem
  61071. * @param gradient defines the gradient to use (between 0 and 1)
  61072. * @param factor defines the life time factor to affect to the specified gradient
  61073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61074. * @returns the current particle system
  61075. */
  61076. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61077. /**
  61078. * Not supported by GPUParticleSystem
  61079. * @param gradient defines the gradient to remove
  61080. * @returns the current particle system
  61081. */
  61082. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61083. /**
  61084. * Instantiates a GPU particle system.
  61085. * 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.
  61086. * @param name The name of the particle system
  61087. * @param options The options used to create the system
  61088. * @param scene The scene the particle system belongs to
  61089. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61090. */
  61091. constructor(name: string, options: Partial<{
  61092. capacity: number;
  61093. randomTextureSize: number;
  61094. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61095. protected _reset(): void;
  61096. private _createUpdateVAO;
  61097. private _createRenderVAO;
  61098. private _initialize;
  61099. /** @hidden */
  61100. _recreateUpdateEffect(): void;
  61101. /** @hidden */
  61102. _recreateRenderEffect(): void;
  61103. /**
  61104. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61105. * @param preWarm defines if we are in the pre-warmimg phase
  61106. */
  61107. animate(preWarm?: boolean): void;
  61108. private _createFactorGradientTexture;
  61109. private _createSizeGradientTexture;
  61110. private _createAngularSpeedGradientTexture;
  61111. private _createVelocityGradientTexture;
  61112. private _createLimitVelocityGradientTexture;
  61113. private _createDragGradientTexture;
  61114. private _createColorGradientTexture;
  61115. /**
  61116. * Renders the particle system in its current state
  61117. * @param preWarm defines if the system should only update the particles but not render them
  61118. * @returns the current number of particles
  61119. */
  61120. render(preWarm?: boolean): number;
  61121. /**
  61122. * Rebuilds the particle system
  61123. */
  61124. rebuild(): void;
  61125. private _releaseBuffers;
  61126. private _releaseVAOs;
  61127. /**
  61128. * Disposes the particle system and free the associated resources
  61129. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61130. */
  61131. dispose(disposeTexture?: boolean): void;
  61132. /**
  61133. * Clones the particle system.
  61134. * @param name The name of the cloned object
  61135. * @param newEmitter The new emitter to use
  61136. * @returns the cloned particle system
  61137. */
  61138. clone(name: string, newEmitter: any): GPUParticleSystem;
  61139. /**
  61140. * Serializes the particle system to a JSON object.
  61141. * @returns the JSON object
  61142. */
  61143. serialize(): any;
  61144. /**
  61145. * Parses a JSON object to create a GPU particle system.
  61146. * @param parsedParticleSystem The JSON object to parse
  61147. * @param scene The scene to create the particle system in
  61148. * @param rootUrl The root url to use to load external dependencies like texture
  61149. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61150. * @returns the parsed GPU particle system
  61151. */
  61152. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61153. }
  61154. }
  61155. declare module "babylonjs/Particles/particleSystemSet" {
  61156. import { Nullable } from "babylonjs/types";
  61157. import { Color3 } from "babylonjs/Maths/math.color";
  61158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61160. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61161. import { Scene, IDisposable } from "babylonjs/scene";
  61162. /**
  61163. * Represents a set of particle systems working together to create a specific effect
  61164. */
  61165. export class ParticleSystemSet implements IDisposable {
  61166. private _emitterCreationOptions;
  61167. private _emitterNode;
  61168. /**
  61169. * Gets the particle system list
  61170. */
  61171. systems: IParticleSystem[];
  61172. /**
  61173. * Gets the emitter node used with this set
  61174. */
  61175. readonly emitterNode: Nullable<TransformNode>;
  61176. /**
  61177. * Creates a new emitter mesh as a sphere
  61178. * @param options defines the options used to create the sphere
  61179. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61180. * @param scene defines the hosting scene
  61181. */
  61182. setEmitterAsSphere(options: {
  61183. diameter: number;
  61184. segments: number;
  61185. color: Color3;
  61186. }, renderingGroupId: number, scene: Scene): void;
  61187. /**
  61188. * Starts all particle systems of the set
  61189. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61190. */
  61191. start(emitter?: AbstractMesh): void;
  61192. /**
  61193. * Release all associated resources
  61194. */
  61195. dispose(): void;
  61196. /**
  61197. * Serialize the set into a JSON compatible object
  61198. * @returns a JSON compatible representation of the set
  61199. */
  61200. serialize(): any;
  61201. /**
  61202. * Parse a new ParticleSystemSet from a serialized source
  61203. * @param data defines a JSON compatible representation of the set
  61204. * @param scene defines the hosting scene
  61205. * @param gpu defines if we want GPU particles or CPU particles
  61206. * @returns a new ParticleSystemSet
  61207. */
  61208. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61209. }
  61210. }
  61211. declare module "babylonjs/Particles/particleHelper" {
  61212. import { Nullable } from "babylonjs/types";
  61213. import { Scene } from "babylonjs/scene";
  61214. import { Vector3 } from "babylonjs/Maths/math.vector";
  61215. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61216. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61217. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61218. /**
  61219. * This class is made for on one-liner static method to help creating particle system set.
  61220. */
  61221. export class ParticleHelper {
  61222. /**
  61223. * Gets or sets base Assets URL
  61224. */
  61225. static BaseAssetsUrl: string;
  61226. /**
  61227. * Create a default particle system that you can tweak
  61228. * @param emitter defines the emitter to use
  61229. * @param capacity defines the system capacity (default is 500 particles)
  61230. * @param scene defines the hosting scene
  61231. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61232. * @returns the new Particle system
  61233. */
  61234. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61235. /**
  61236. * This is the main static method (one-liner) of this helper to create different particle systems
  61237. * @param type This string represents the type to the particle system to create
  61238. * @param scene The scene where the particle system should live
  61239. * @param gpu If the system will use gpu
  61240. * @returns the ParticleSystemSet created
  61241. */
  61242. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61243. /**
  61244. * Static function used to export a particle system to a ParticleSystemSet variable.
  61245. * Please note that the emitter shape is not exported
  61246. * @param systems defines the particle systems to export
  61247. * @returns the created particle system set
  61248. */
  61249. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61250. }
  61251. }
  61252. declare module "babylonjs/Particles/particleSystemComponent" {
  61253. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61254. import { Effect } from "babylonjs/Materials/effect";
  61255. import "babylonjs/Shaders/particles.vertex";
  61256. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61257. module "babylonjs/Engines/engine" {
  61258. interface Engine {
  61259. /**
  61260. * Create an effect to use with particle systems.
  61261. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61262. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61263. * @param uniformsNames defines a list of attribute names
  61264. * @param samplers defines an array of string used to represent textures
  61265. * @param defines defines the string containing the defines to use to compile the shaders
  61266. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61267. * @param onCompiled defines a function to call when the effect creation is successful
  61268. * @param onError defines a function to call when the effect creation has failed
  61269. * @returns the new Effect
  61270. */
  61271. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61272. }
  61273. }
  61274. module "babylonjs/Meshes/mesh" {
  61275. interface Mesh {
  61276. /**
  61277. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61278. * @returns an array of IParticleSystem
  61279. */
  61280. getEmittedParticleSystems(): IParticleSystem[];
  61281. /**
  61282. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61283. * @returns an array of IParticleSystem
  61284. */
  61285. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61286. }
  61287. }
  61288. /**
  61289. * @hidden
  61290. */
  61291. export var _IDoNeedToBeInTheBuild: number;
  61292. }
  61293. declare module "babylonjs/Particles/index" {
  61294. export * from "babylonjs/Particles/baseParticleSystem";
  61295. export * from "babylonjs/Particles/EmitterTypes/index";
  61296. export * from "babylonjs/Particles/gpuParticleSystem";
  61297. export * from "babylonjs/Particles/IParticleSystem";
  61298. export * from "babylonjs/Particles/particle";
  61299. export * from "babylonjs/Particles/particleHelper";
  61300. export * from "babylonjs/Particles/particleSystem";
  61301. export * from "babylonjs/Particles/particleSystemComponent";
  61302. export * from "babylonjs/Particles/particleSystemSet";
  61303. export * from "babylonjs/Particles/solidParticle";
  61304. export * from "babylonjs/Particles/solidParticleSystem";
  61305. export * from "babylonjs/Particles/subEmitter";
  61306. }
  61307. declare module "babylonjs/Physics/physicsEngineComponent" {
  61308. import { Nullable } from "babylonjs/types";
  61309. import { Observable, Observer } from "babylonjs/Misc/observable";
  61310. import { Vector3 } from "babylonjs/Maths/math.vector";
  61311. import { Mesh } from "babylonjs/Meshes/mesh";
  61312. import { ISceneComponent } from "babylonjs/sceneComponent";
  61313. import { Scene } from "babylonjs/scene";
  61314. import { Node } from "babylonjs/node";
  61315. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61316. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61317. module "babylonjs/scene" {
  61318. interface Scene {
  61319. /** @hidden (Backing field) */
  61320. _physicsEngine: Nullable<IPhysicsEngine>;
  61321. /**
  61322. * Gets the current physics engine
  61323. * @returns a IPhysicsEngine or null if none attached
  61324. */
  61325. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61326. /**
  61327. * Enables physics to the current scene
  61328. * @param gravity defines the scene's gravity for the physics engine
  61329. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61330. * @return a boolean indicating if the physics engine was initialized
  61331. */
  61332. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61333. /**
  61334. * Disables and disposes the physics engine associated with the scene
  61335. */
  61336. disablePhysicsEngine(): void;
  61337. /**
  61338. * Gets a boolean indicating if there is an active physics engine
  61339. * @returns a boolean indicating if there is an active physics engine
  61340. */
  61341. isPhysicsEnabled(): boolean;
  61342. /**
  61343. * Deletes a physics compound impostor
  61344. * @param compound defines the compound to delete
  61345. */
  61346. deleteCompoundImpostor(compound: any): void;
  61347. /**
  61348. * An event triggered when physic simulation is about to be run
  61349. */
  61350. onBeforePhysicsObservable: Observable<Scene>;
  61351. /**
  61352. * An event triggered when physic simulation has been done
  61353. */
  61354. onAfterPhysicsObservable: Observable<Scene>;
  61355. }
  61356. }
  61357. module "babylonjs/Meshes/abstractMesh" {
  61358. interface AbstractMesh {
  61359. /** @hidden */
  61360. _physicsImpostor: Nullable<PhysicsImpostor>;
  61361. /**
  61362. * Gets or sets impostor used for physic simulation
  61363. * @see http://doc.babylonjs.com/features/physics_engine
  61364. */
  61365. physicsImpostor: Nullable<PhysicsImpostor>;
  61366. /**
  61367. * Gets the current physics impostor
  61368. * @see http://doc.babylonjs.com/features/physics_engine
  61369. * @returns a physics impostor or null
  61370. */
  61371. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61372. /** Apply a physic impulse to the mesh
  61373. * @param force defines the force to apply
  61374. * @param contactPoint defines where to apply the force
  61375. * @returns the current mesh
  61376. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61377. */
  61378. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61379. /**
  61380. * Creates a physic joint between two meshes
  61381. * @param otherMesh defines the other mesh to use
  61382. * @param pivot1 defines the pivot to use on this mesh
  61383. * @param pivot2 defines the pivot to use on the other mesh
  61384. * @param options defines additional options (can be plugin dependent)
  61385. * @returns the current mesh
  61386. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61387. */
  61388. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61389. /** @hidden */
  61390. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61391. }
  61392. }
  61393. /**
  61394. * Defines the physics engine scene component responsible to manage a physics engine
  61395. */
  61396. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61397. /**
  61398. * The component name helpful to identify the component in the list of scene components.
  61399. */
  61400. readonly name: string;
  61401. /**
  61402. * The scene the component belongs to.
  61403. */
  61404. scene: Scene;
  61405. /**
  61406. * Creates a new instance of the component for the given scene
  61407. * @param scene Defines the scene to register the component in
  61408. */
  61409. constructor(scene: Scene);
  61410. /**
  61411. * Registers the component in a given scene
  61412. */
  61413. register(): void;
  61414. /**
  61415. * Rebuilds the elements related to this component in case of
  61416. * context lost for instance.
  61417. */
  61418. rebuild(): void;
  61419. /**
  61420. * Disposes the component and the associated ressources
  61421. */
  61422. dispose(): void;
  61423. }
  61424. }
  61425. declare module "babylonjs/Physics/physicsHelper" {
  61426. import { Nullable } from "babylonjs/types";
  61427. import { Vector3 } from "babylonjs/Maths/math.vector";
  61428. import { Mesh } from "babylonjs/Meshes/mesh";
  61429. import { Scene } from "babylonjs/scene";
  61430. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61431. /**
  61432. * A helper for physics simulations
  61433. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61434. */
  61435. export class PhysicsHelper {
  61436. private _scene;
  61437. private _physicsEngine;
  61438. /**
  61439. * Initializes the Physics helper
  61440. * @param scene Babylon.js scene
  61441. */
  61442. constructor(scene: Scene);
  61443. /**
  61444. * Applies a radial explosion impulse
  61445. * @param origin the origin of the explosion
  61446. * @param radiusOrEventOptions the radius or the options of radial explosion
  61447. * @param strength the explosion strength
  61448. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61449. * @returns A physics radial explosion event, or null
  61450. */
  61451. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61452. /**
  61453. * Applies a radial explosion force
  61454. * @param origin the origin of the explosion
  61455. * @param radiusOrEventOptions the radius or the options of radial explosion
  61456. * @param strength the explosion strength
  61457. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61458. * @returns A physics radial explosion event, or null
  61459. */
  61460. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61461. /**
  61462. * Creates a gravitational field
  61463. * @param origin the origin of the explosion
  61464. * @param radiusOrEventOptions the radius or the options of radial explosion
  61465. * @param strength the explosion strength
  61466. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61467. * @returns A physics gravitational field event, or null
  61468. */
  61469. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61470. /**
  61471. * Creates a physics updraft event
  61472. * @param origin the origin of the updraft
  61473. * @param radiusOrEventOptions the radius or the options of the updraft
  61474. * @param strength the strength of the updraft
  61475. * @param height the height of the updraft
  61476. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61477. * @returns A physics updraft event, or null
  61478. */
  61479. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61480. /**
  61481. * Creates a physics vortex event
  61482. * @param origin the of the vortex
  61483. * @param radiusOrEventOptions the radius or the options of the vortex
  61484. * @param strength the strength of the vortex
  61485. * @param height the height of the vortex
  61486. * @returns a Physics vortex event, or null
  61487. * A physics vortex event or null
  61488. */
  61489. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61490. }
  61491. /**
  61492. * Represents a physics radial explosion event
  61493. */
  61494. class PhysicsRadialExplosionEvent {
  61495. private _scene;
  61496. private _options;
  61497. private _sphere;
  61498. private _dataFetched;
  61499. /**
  61500. * Initializes a radial explosioin event
  61501. * @param _scene BabylonJS scene
  61502. * @param _options The options for the vortex event
  61503. */
  61504. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61505. /**
  61506. * Returns the data related to the radial explosion event (sphere).
  61507. * @returns The radial explosion event data
  61508. */
  61509. getData(): PhysicsRadialExplosionEventData;
  61510. /**
  61511. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61512. * @param impostor A physics imposter
  61513. * @param origin the origin of the explosion
  61514. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61515. */
  61516. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61517. /**
  61518. * Triggers affecterd impostors callbacks
  61519. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61520. */
  61521. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61522. /**
  61523. * Disposes the sphere.
  61524. * @param force Specifies if the sphere should be disposed by force
  61525. */
  61526. dispose(force?: boolean): void;
  61527. /*** Helpers ***/
  61528. private _prepareSphere;
  61529. private _intersectsWithSphere;
  61530. }
  61531. /**
  61532. * Represents a gravitational field event
  61533. */
  61534. class PhysicsGravitationalFieldEvent {
  61535. private _physicsHelper;
  61536. private _scene;
  61537. private _origin;
  61538. private _options;
  61539. private _tickCallback;
  61540. private _sphere;
  61541. private _dataFetched;
  61542. /**
  61543. * Initializes the physics gravitational field event
  61544. * @param _physicsHelper A physics helper
  61545. * @param _scene BabylonJS scene
  61546. * @param _origin The origin position of the gravitational field event
  61547. * @param _options The options for the vortex event
  61548. */
  61549. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61550. /**
  61551. * Returns the data related to the gravitational field event (sphere).
  61552. * @returns A gravitational field event
  61553. */
  61554. getData(): PhysicsGravitationalFieldEventData;
  61555. /**
  61556. * Enables the gravitational field.
  61557. */
  61558. enable(): void;
  61559. /**
  61560. * Disables the gravitational field.
  61561. */
  61562. disable(): void;
  61563. /**
  61564. * Disposes the sphere.
  61565. * @param force The force to dispose from the gravitational field event
  61566. */
  61567. dispose(force?: boolean): void;
  61568. private _tick;
  61569. }
  61570. /**
  61571. * Represents a physics updraft event
  61572. */
  61573. class PhysicsUpdraftEvent {
  61574. private _scene;
  61575. private _origin;
  61576. private _options;
  61577. private _physicsEngine;
  61578. private _originTop;
  61579. private _originDirection;
  61580. private _tickCallback;
  61581. private _cylinder;
  61582. private _cylinderPosition;
  61583. private _dataFetched;
  61584. /**
  61585. * Initializes the physics updraft event
  61586. * @param _scene BabylonJS scene
  61587. * @param _origin The origin position of the updraft
  61588. * @param _options The options for the updraft event
  61589. */
  61590. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61591. /**
  61592. * Returns the data related to the updraft event (cylinder).
  61593. * @returns A physics updraft event
  61594. */
  61595. getData(): PhysicsUpdraftEventData;
  61596. /**
  61597. * Enables the updraft.
  61598. */
  61599. enable(): void;
  61600. /**
  61601. * Disables the updraft.
  61602. */
  61603. disable(): void;
  61604. /**
  61605. * Disposes the cylinder.
  61606. * @param force Specifies if the updraft should be disposed by force
  61607. */
  61608. dispose(force?: boolean): void;
  61609. private getImpostorHitData;
  61610. private _tick;
  61611. /*** Helpers ***/
  61612. private _prepareCylinder;
  61613. private _intersectsWithCylinder;
  61614. }
  61615. /**
  61616. * Represents a physics vortex event
  61617. */
  61618. class PhysicsVortexEvent {
  61619. private _scene;
  61620. private _origin;
  61621. private _options;
  61622. private _physicsEngine;
  61623. private _originTop;
  61624. private _tickCallback;
  61625. private _cylinder;
  61626. private _cylinderPosition;
  61627. private _dataFetched;
  61628. /**
  61629. * Initializes the physics vortex event
  61630. * @param _scene The BabylonJS scene
  61631. * @param _origin The origin position of the vortex
  61632. * @param _options The options for the vortex event
  61633. */
  61634. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61635. /**
  61636. * Returns the data related to the vortex event (cylinder).
  61637. * @returns The physics vortex event data
  61638. */
  61639. getData(): PhysicsVortexEventData;
  61640. /**
  61641. * Enables the vortex.
  61642. */
  61643. enable(): void;
  61644. /**
  61645. * Disables the cortex.
  61646. */
  61647. disable(): void;
  61648. /**
  61649. * Disposes the sphere.
  61650. * @param force
  61651. */
  61652. dispose(force?: boolean): void;
  61653. private getImpostorHitData;
  61654. private _tick;
  61655. /*** Helpers ***/
  61656. private _prepareCylinder;
  61657. private _intersectsWithCylinder;
  61658. }
  61659. /**
  61660. * Options fot the radial explosion event
  61661. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61662. */
  61663. export class PhysicsRadialExplosionEventOptions {
  61664. /**
  61665. * The radius of the sphere for the radial explosion.
  61666. */
  61667. radius: number;
  61668. /**
  61669. * The strenth of the explosion.
  61670. */
  61671. strength: number;
  61672. /**
  61673. * The strenght of the force in correspondence to the distance of the affected object
  61674. */
  61675. falloff: PhysicsRadialImpulseFalloff;
  61676. /**
  61677. * Sphere options for the radial explosion.
  61678. */
  61679. sphere: {
  61680. segments: number;
  61681. diameter: number;
  61682. };
  61683. /**
  61684. * Sphere options for the radial explosion.
  61685. */
  61686. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61687. }
  61688. /**
  61689. * Options fot the updraft event
  61690. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61691. */
  61692. export class PhysicsUpdraftEventOptions {
  61693. /**
  61694. * The radius of the cylinder for the vortex
  61695. */
  61696. radius: number;
  61697. /**
  61698. * The strenth of the updraft.
  61699. */
  61700. strength: number;
  61701. /**
  61702. * The height of the cylinder for the updraft.
  61703. */
  61704. height: number;
  61705. /**
  61706. * The mode for the the updraft.
  61707. */
  61708. updraftMode: PhysicsUpdraftMode;
  61709. }
  61710. /**
  61711. * Options fot the vortex event
  61712. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61713. */
  61714. export class PhysicsVortexEventOptions {
  61715. /**
  61716. * The radius of the cylinder for the vortex
  61717. */
  61718. radius: number;
  61719. /**
  61720. * The strenth of the vortex.
  61721. */
  61722. strength: number;
  61723. /**
  61724. * The height of the cylinder for the vortex.
  61725. */
  61726. height: number;
  61727. /**
  61728. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61729. */
  61730. centripetalForceThreshold: number;
  61731. /**
  61732. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61733. */
  61734. centripetalForceMultiplier: number;
  61735. /**
  61736. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61737. */
  61738. centrifugalForceMultiplier: number;
  61739. /**
  61740. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61741. */
  61742. updraftForceMultiplier: number;
  61743. }
  61744. /**
  61745. * The strenght of the force in correspondence to the distance of the affected object
  61746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61747. */
  61748. export enum PhysicsRadialImpulseFalloff {
  61749. /** Defines that impulse is constant in strength across it's whole radius */
  61750. Constant = 0,
  61751. /** Defines that impulse gets weaker if it's further from the origin */
  61752. Linear = 1
  61753. }
  61754. /**
  61755. * The strength of the force in correspondence to the distance of the affected object
  61756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61757. */
  61758. export enum PhysicsUpdraftMode {
  61759. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61760. Center = 0,
  61761. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61762. Perpendicular = 1
  61763. }
  61764. /**
  61765. * Interface for a physics hit data
  61766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61767. */
  61768. export interface PhysicsHitData {
  61769. /**
  61770. * The force applied at the contact point
  61771. */
  61772. force: Vector3;
  61773. /**
  61774. * The contact point
  61775. */
  61776. contactPoint: Vector3;
  61777. /**
  61778. * The distance from the origin to the contact point
  61779. */
  61780. distanceFromOrigin: number;
  61781. }
  61782. /**
  61783. * Interface for radial explosion event data
  61784. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61785. */
  61786. export interface PhysicsRadialExplosionEventData {
  61787. /**
  61788. * A sphere used for the radial explosion event
  61789. */
  61790. sphere: Mesh;
  61791. }
  61792. /**
  61793. * Interface for gravitational field event data
  61794. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61795. */
  61796. export interface PhysicsGravitationalFieldEventData {
  61797. /**
  61798. * A sphere mesh used for the gravitational field event
  61799. */
  61800. sphere: Mesh;
  61801. }
  61802. /**
  61803. * Interface for updraft event data
  61804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61805. */
  61806. export interface PhysicsUpdraftEventData {
  61807. /**
  61808. * A cylinder used for the updraft event
  61809. */
  61810. cylinder: Mesh;
  61811. }
  61812. /**
  61813. * Interface for vortex event data
  61814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61815. */
  61816. export interface PhysicsVortexEventData {
  61817. /**
  61818. * A cylinder used for the vortex event
  61819. */
  61820. cylinder: Mesh;
  61821. }
  61822. /**
  61823. * Interface for an affected physics impostor
  61824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61825. */
  61826. export interface PhysicsAffectedImpostorWithData {
  61827. /**
  61828. * The impostor affected by the effect
  61829. */
  61830. impostor: PhysicsImpostor;
  61831. /**
  61832. * The data about the hit/horce from the explosion
  61833. */
  61834. hitData: PhysicsHitData;
  61835. }
  61836. }
  61837. declare module "babylonjs/Physics/Plugins/index" {
  61838. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61839. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61840. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61841. }
  61842. declare module "babylonjs/Physics/index" {
  61843. export * from "babylonjs/Physics/IPhysicsEngine";
  61844. export * from "babylonjs/Physics/physicsEngine";
  61845. export * from "babylonjs/Physics/physicsEngineComponent";
  61846. export * from "babylonjs/Physics/physicsHelper";
  61847. export * from "babylonjs/Physics/physicsImpostor";
  61848. export * from "babylonjs/Physics/physicsJoint";
  61849. export * from "babylonjs/Physics/Plugins/index";
  61850. }
  61851. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61852. /** @hidden */
  61853. export var blackAndWhitePixelShader: {
  61854. name: string;
  61855. shader: string;
  61856. };
  61857. }
  61858. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61860. import { Camera } from "babylonjs/Cameras/camera";
  61861. import { Engine } from "babylonjs/Engines/engine";
  61862. import "babylonjs/Shaders/blackAndWhite.fragment";
  61863. /**
  61864. * Post process used to render in black and white
  61865. */
  61866. export class BlackAndWhitePostProcess extends PostProcess {
  61867. /**
  61868. * Linear about to convert he result to black and white (default: 1)
  61869. */
  61870. degree: number;
  61871. /**
  61872. * Creates a black and white post process
  61873. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61874. * @param name The name of the effect.
  61875. * @param options The required width/height ratio to downsize to before computing the render pass.
  61876. * @param camera The camera to apply the render pass to.
  61877. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61878. * @param engine The engine which the post process will be applied. (default: current engine)
  61879. * @param reusable If the post process can be reused on the same frame. (default: false)
  61880. */
  61881. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61882. }
  61883. }
  61884. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61885. import { Nullable } from "babylonjs/types";
  61886. import { Camera } from "babylonjs/Cameras/camera";
  61887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61888. import { Engine } from "babylonjs/Engines/engine";
  61889. /**
  61890. * This represents a set of one or more post processes in Babylon.
  61891. * A post process can be used to apply a shader to a texture after it is rendered.
  61892. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61893. */
  61894. export class PostProcessRenderEffect {
  61895. private _postProcesses;
  61896. private _getPostProcesses;
  61897. private _singleInstance;
  61898. private _cameras;
  61899. private _indicesForCamera;
  61900. /**
  61901. * Name of the effect
  61902. * @hidden
  61903. */
  61904. _name: string;
  61905. /**
  61906. * Instantiates a post process render effect.
  61907. * A post process can be used to apply a shader to a texture after it is rendered.
  61908. * @param engine The engine the effect is tied to
  61909. * @param name The name of the effect
  61910. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61911. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61912. */
  61913. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61914. /**
  61915. * Checks if all the post processes in the effect are supported.
  61916. */
  61917. readonly isSupported: boolean;
  61918. /**
  61919. * Updates the current state of the effect
  61920. * @hidden
  61921. */
  61922. _update(): void;
  61923. /**
  61924. * Attaches the effect on cameras
  61925. * @param cameras The camera to attach to.
  61926. * @hidden
  61927. */
  61928. _attachCameras(cameras: Camera): void;
  61929. /**
  61930. * Attaches the effect on cameras
  61931. * @param cameras The camera to attach to.
  61932. * @hidden
  61933. */
  61934. _attachCameras(cameras: Camera[]): void;
  61935. /**
  61936. * Detaches the effect on cameras
  61937. * @param cameras The camera to detatch from.
  61938. * @hidden
  61939. */
  61940. _detachCameras(cameras: Camera): void;
  61941. /**
  61942. * Detatches the effect on cameras
  61943. * @param cameras The camera to detatch from.
  61944. * @hidden
  61945. */
  61946. _detachCameras(cameras: Camera[]): void;
  61947. /**
  61948. * Enables the effect on given cameras
  61949. * @param cameras The camera to enable.
  61950. * @hidden
  61951. */
  61952. _enable(cameras: Camera): void;
  61953. /**
  61954. * Enables the effect on given cameras
  61955. * @param cameras The camera to enable.
  61956. * @hidden
  61957. */
  61958. _enable(cameras: Nullable<Camera[]>): void;
  61959. /**
  61960. * Disables the effect on the given cameras
  61961. * @param cameras The camera to disable.
  61962. * @hidden
  61963. */
  61964. _disable(cameras: Camera): void;
  61965. /**
  61966. * Disables the effect on the given cameras
  61967. * @param cameras The camera to disable.
  61968. * @hidden
  61969. */
  61970. _disable(cameras: Nullable<Camera[]>): void;
  61971. /**
  61972. * Gets a list of the post processes contained in the effect.
  61973. * @param camera The camera to get the post processes on.
  61974. * @returns The list of the post processes in the effect.
  61975. */
  61976. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61977. }
  61978. }
  61979. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61980. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61981. /** @hidden */
  61982. export var extractHighlightsPixelShader: {
  61983. name: string;
  61984. shader: string;
  61985. };
  61986. }
  61987. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61988. import { Nullable } from "babylonjs/types";
  61989. import { Camera } from "babylonjs/Cameras/camera";
  61990. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61991. import { Engine } from "babylonjs/Engines/engine";
  61992. import "babylonjs/Shaders/extractHighlights.fragment";
  61993. /**
  61994. * 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.
  61995. */
  61996. export class ExtractHighlightsPostProcess extends PostProcess {
  61997. /**
  61998. * The luminance threshold, pixels below this value will be set to black.
  61999. */
  62000. threshold: number;
  62001. /** @hidden */
  62002. _exposure: number;
  62003. /**
  62004. * Post process which has the input texture to be used when performing highlight extraction
  62005. * @hidden
  62006. */
  62007. _inputPostProcess: Nullable<PostProcess>;
  62008. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62009. }
  62010. }
  62011. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62012. /** @hidden */
  62013. export var bloomMergePixelShader: {
  62014. name: string;
  62015. shader: string;
  62016. };
  62017. }
  62018. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62020. import { Nullable } from "babylonjs/types";
  62021. import { Engine } from "babylonjs/Engines/engine";
  62022. import { Camera } from "babylonjs/Cameras/camera";
  62023. import "babylonjs/Shaders/bloomMerge.fragment";
  62024. /**
  62025. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62026. */
  62027. export class BloomMergePostProcess extends PostProcess {
  62028. /** Weight of the bloom to be added to the original input. */
  62029. weight: number;
  62030. /**
  62031. * Creates a new instance of @see BloomMergePostProcess
  62032. * @param name The name of the effect.
  62033. * @param originalFromInput Post process which's input will be used for the merge.
  62034. * @param blurred Blurred highlights post process which's output will be used.
  62035. * @param weight Weight of the bloom to be added to the original input.
  62036. * @param options The required width/height ratio to downsize to before computing the render pass.
  62037. * @param camera The camera to apply the render pass to.
  62038. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62039. * @param engine The engine which the post process will be applied. (default: current engine)
  62040. * @param reusable If the post process can be reused on the same frame. (default: false)
  62041. * @param textureType Type of textures used when performing the post process. (default: 0)
  62042. * @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)
  62043. */
  62044. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62045. /** Weight of the bloom to be added to the original input. */
  62046. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62047. }
  62048. }
  62049. declare module "babylonjs/PostProcesses/bloomEffect" {
  62050. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62051. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62052. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62053. import { Camera } from "babylonjs/Cameras/camera";
  62054. import { Scene } from "babylonjs/scene";
  62055. /**
  62056. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62057. */
  62058. export class BloomEffect extends PostProcessRenderEffect {
  62059. private bloomScale;
  62060. /**
  62061. * @hidden Internal
  62062. */
  62063. _effects: Array<PostProcess>;
  62064. /**
  62065. * @hidden Internal
  62066. */
  62067. _downscale: ExtractHighlightsPostProcess;
  62068. private _blurX;
  62069. private _blurY;
  62070. private _merge;
  62071. /**
  62072. * The luminance threshold to find bright areas of the image to bloom.
  62073. */
  62074. threshold: number;
  62075. /**
  62076. * The strength of the bloom.
  62077. */
  62078. weight: number;
  62079. /**
  62080. * Specifies the size of the bloom blur kernel, relative to the final output size
  62081. */
  62082. kernel: number;
  62083. /**
  62084. * Creates a new instance of @see BloomEffect
  62085. * @param scene The scene the effect belongs to.
  62086. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62087. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62088. * @param bloomWeight The the strength of bloom.
  62089. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62090. * @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)
  62091. */
  62092. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62093. /**
  62094. * Disposes each of the internal effects for a given camera.
  62095. * @param camera The camera to dispose the effect on.
  62096. */
  62097. disposeEffects(camera: Camera): void;
  62098. /**
  62099. * @hidden Internal
  62100. */
  62101. _updateEffects(): void;
  62102. /**
  62103. * Internal
  62104. * @returns if all the contained post processes are ready.
  62105. * @hidden
  62106. */
  62107. _isReady(): boolean;
  62108. }
  62109. }
  62110. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62111. /** @hidden */
  62112. export var chromaticAberrationPixelShader: {
  62113. name: string;
  62114. shader: string;
  62115. };
  62116. }
  62117. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62118. import { Vector2 } from "babylonjs/Maths/math.vector";
  62119. import { Nullable } from "babylonjs/types";
  62120. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62121. import { Camera } from "babylonjs/Cameras/camera";
  62122. import { Engine } from "babylonjs/Engines/engine";
  62123. import "babylonjs/Shaders/chromaticAberration.fragment";
  62124. /**
  62125. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62126. */
  62127. export class ChromaticAberrationPostProcess extends PostProcess {
  62128. /**
  62129. * The amount of seperation of rgb channels (default: 30)
  62130. */
  62131. aberrationAmount: number;
  62132. /**
  62133. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62134. */
  62135. radialIntensity: number;
  62136. /**
  62137. * 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))
  62138. */
  62139. direction: Vector2;
  62140. /**
  62141. * 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))
  62142. */
  62143. centerPosition: Vector2;
  62144. /**
  62145. * Creates a new instance ChromaticAberrationPostProcess
  62146. * @param name The name of the effect.
  62147. * @param screenWidth The width of the screen to apply the effect on.
  62148. * @param screenHeight The height of the screen to apply the effect on.
  62149. * @param options The required width/height ratio to downsize to before computing the render pass.
  62150. * @param camera The camera to apply the render pass to.
  62151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62152. * @param engine The engine which the post process will be applied. (default: current engine)
  62153. * @param reusable If the post process can be reused on the same frame. (default: false)
  62154. * @param textureType Type of textures used when performing the post process. (default: 0)
  62155. * @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)
  62156. */
  62157. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62158. }
  62159. }
  62160. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62161. /** @hidden */
  62162. export var circleOfConfusionPixelShader: {
  62163. name: string;
  62164. shader: string;
  62165. };
  62166. }
  62167. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62168. import { Nullable } from "babylonjs/types";
  62169. import { Engine } from "babylonjs/Engines/engine";
  62170. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62171. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62172. import { Camera } from "babylonjs/Cameras/camera";
  62173. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62174. /**
  62175. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62176. */
  62177. export class CircleOfConfusionPostProcess extends PostProcess {
  62178. /**
  62179. * 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.
  62180. */
  62181. lensSize: number;
  62182. /**
  62183. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62184. */
  62185. fStop: number;
  62186. /**
  62187. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62188. */
  62189. focusDistance: number;
  62190. /**
  62191. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62192. */
  62193. focalLength: number;
  62194. private _depthTexture;
  62195. /**
  62196. * Creates a new instance CircleOfConfusionPostProcess
  62197. * @param name The name of the effect.
  62198. * @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.
  62199. * @param options The required width/height ratio to downsize to before computing the render pass.
  62200. * @param camera The camera to apply the render pass to.
  62201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62202. * @param engine The engine which the post process will be applied. (default: current engine)
  62203. * @param reusable If the post process can be reused on the same frame. (default: false)
  62204. * @param textureType Type of textures used when performing the post process. (default: 0)
  62205. * @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)
  62206. */
  62207. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62208. /**
  62209. * 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.
  62210. */
  62211. depthTexture: RenderTargetTexture;
  62212. }
  62213. }
  62214. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62215. /** @hidden */
  62216. export var colorCorrectionPixelShader: {
  62217. name: string;
  62218. shader: string;
  62219. };
  62220. }
  62221. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62222. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62223. import { Engine } from "babylonjs/Engines/engine";
  62224. import { Camera } from "babylonjs/Cameras/camera";
  62225. import "babylonjs/Shaders/colorCorrection.fragment";
  62226. /**
  62227. *
  62228. * This post-process allows the modification of rendered colors by using
  62229. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62230. *
  62231. * The object needs to be provided an url to a texture containing the color
  62232. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62233. * Use an image editing software to tweak the LUT to match your needs.
  62234. *
  62235. * For an example of a color LUT, see here:
  62236. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62237. * For explanations on color grading, see here:
  62238. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62239. *
  62240. */
  62241. export class ColorCorrectionPostProcess extends PostProcess {
  62242. private _colorTableTexture;
  62243. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62244. }
  62245. }
  62246. declare module "babylonjs/Shaders/convolution.fragment" {
  62247. /** @hidden */
  62248. export var convolutionPixelShader: {
  62249. name: string;
  62250. shader: string;
  62251. };
  62252. }
  62253. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62254. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62255. import { Nullable } from "babylonjs/types";
  62256. import { Camera } from "babylonjs/Cameras/camera";
  62257. import { Engine } from "babylonjs/Engines/engine";
  62258. import "babylonjs/Shaders/convolution.fragment";
  62259. /**
  62260. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62261. * input texture to perform effects such as edge detection or sharpening
  62262. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62263. */
  62264. export class ConvolutionPostProcess extends PostProcess {
  62265. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62266. kernel: number[];
  62267. /**
  62268. * Creates a new instance ConvolutionPostProcess
  62269. * @param name The name of the effect.
  62270. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62271. * @param options The required width/height ratio to downsize to before computing the render pass.
  62272. * @param camera The camera to apply the render pass to.
  62273. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62274. * @param engine The engine which the post process will be applied. (default: current engine)
  62275. * @param reusable If the post process can be reused on the same frame. (default: false)
  62276. * @param textureType Type of textures used when performing the post process. (default: 0)
  62277. */
  62278. constructor(name: string,
  62279. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62280. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62281. /**
  62282. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62283. */
  62284. static EdgeDetect0Kernel: number[];
  62285. /**
  62286. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62287. */
  62288. static EdgeDetect1Kernel: number[];
  62289. /**
  62290. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62291. */
  62292. static EdgeDetect2Kernel: number[];
  62293. /**
  62294. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62295. */
  62296. static SharpenKernel: number[];
  62297. /**
  62298. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62299. */
  62300. static EmbossKernel: number[];
  62301. /**
  62302. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62303. */
  62304. static GaussianKernel: number[];
  62305. }
  62306. }
  62307. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62308. import { Nullable } from "babylonjs/types";
  62309. import { Vector2 } from "babylonjs/Maths/math.vector";
  62310. import { Camera } from "babylonjs/Cameras/camera";
  62311. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62312. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62313. import { Engine } from "babylonjs/Engines/engine";
  62314. import { Scene } from "babylonjs/scene";
  62315. /**
  62316. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62317. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62318. * based on samples that have a large difference in distance than the center pixel.
  62319. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62320. */
  62321. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62322. direction: Vector2;
  62323. /**
  62324. * Creates a new instance CircleOfConfusionPostProcess
  62325. * @param name The name of the effect.
  62326. * @param scene The scene the effect belongs to.
  62327. * @param direction The direction the blur should be applied.
  62328. * @param kernel The size of the kernel used to blur.
  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 circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62332. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62333. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62334. * @param engine The engine which the post process will be applied. (default: current engine)
  62335. * @param reusable If the post process can be reused on the same frame. (default: false)
  62336. * @param textureType Type of textures used when performing the post process. (default: 0)
  62337. * @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)
  62338. */
  62339. 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);
  62340. }
  62341. }
  62342. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62343. /** @hidden */
  62344. export var depthOfFieldMergePixelShader: {
  62345. name: string;
  62346. shader: string;
  62347. };
  62348. }
  62349. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62350. import { Nullable } from "babylonjs/types";
  62351. import { Camera } from "babylonjs/Cameras/camera";
  62352. import { Effect } from "babylonjs/Materials/effect";
  62353. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62354. import { Engine } from "babylonjs/Engines/engine";
  62355. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62356. /**
  62357. * Options to be set when merging outputs from the default pipeline.
  62358. */
  62359. export class DepthOfFieldMergePostProcessOptions {
  62360. /**
  62361. * The original image to merge on top of
  62362. */
  62363. originalFromInput: PostProcess;
  62364. /**
  62365. * Parameters to perform the merge of the depth of field effect
  62366. */
  62367. depthOfField?: {
  62368. circleOfConfusion: PostProcess;
  62369. blurSteps: Array<PostProcess>;
  62370. };
  62371. /**
  62372. * Parameters to perform the merge of bloom effect
  62373. */
  62374. bloom?: {
  62375. blurred: PostProcess;
  62376. weight: number;
  62377. };
  62378. }
  62379. /**
  62380. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62381. */
  62382. export class DepthOfFieldMergePostProcess extends PostProcess {
  62383. private blurSteps;
  62384. /**
  62385. * Creates a new instance of DepthOfFieldMergePostProcess
  62386. * @param name The name of the effect.
  62387. * @param originalFromInput Post process which's input will be used for the merge.
  62388. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62389. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62390. * @param options The required width/height ratio to downsize to before computing the render pass.
  62391. * @param camera The camera to apply the render pass to.
  62392. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62393. * @param engine The engine which the post process will be applied. (default: current engine)
  62394. * @param reusable If the post process can be reused on the same frame. (default: false)
  62395. * @param textureType Type of textures used when performing the post process. (default: 0)
  62396. * @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)
  62397. */
  62398. 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);
  62399. /**
  62400. * Updates the effect with the current post process compile time values and recompiles the shader.
  62401. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62402. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62403. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62404. * @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
  62405. * @param onCompiled Called when the shader has been compiled.
  62406. * @param onError Called if there is an error when compiling a shader.
  62407. */
  62408. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62409. }
  62410. }
  62411. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62412. import { Nullable } from "babylonjs/types";
  62413. import { Camera } from "babylonjs/Cameras/camera";
  62414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62416. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62417. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62418. import { Scene } from "babylonjs/scene";
  62419. /**
  62420. * Specifies the level of max blur that should be applied when using the depth of field effect
  62421. */
  62422. export enum DepthOfFieldEffectBlurLevel {
  62423. /**
  62424. * Subtle blur
  62425. */
  62426. Low = 0,
  62427. /**
  62428. * Medium blur
  62429. */
  62430. Medium = 1,
  62431. /**
  62432. * Large blur
  62433. */
  62434. High = 2
  62435. }
  62436. /**
  62437. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62438. */
  62439. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62440. private _circleOfConfusion;
  62441. /**
  62442. * @hidden Internal, blurs from high to low
  62443. */
  62444. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62445. private _depthOfFieldBlurY;
  62446. private _dofMerge;
  62447. /**
  62448. * @hidden Internal post processes in depth of field effect
  62449. */
  62450. _effects: Array<PostProcess>;
  62451. /**
  62452. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62453. */
  62454. focalLength: number;
  62455. /**
  62456. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62457. */
  62458. fStop: number;
  62459. /**
  62460. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62461. */
  62462. focusDistance: number;
  62463. /**
  62464. * 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.
  62465. */
  62466. lensSize: number;
  62467. /**
  62468. * Creates a new instance DepthOfFieldEffect
  62469. * @param scene The scene the effect belongs to.
  62470. * @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.
  62471. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62472. * @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)
  62473. */
  62474. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62475. /**
  62476. * Get the current class name of the current effet
  62477. * @returns "DepthOfFieldEffect"
  62478. */
  62479. getClassName(): string;
  62480. /**
  62481. * 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.
  62482. */
  62483. depthTexture: RenderTargetTexture;
  62484. /**
  62485. * Disposes each of the internal effects for a given camera.
  62486. * @param camera The camera to dispose the effect on.
  62487. */
  62488. disposeEffects(camera: Camera): void;
  62489. /**
  62490. * @hidden Internal
  62491. */
  62492. _updateEffects(): void;
  62493. /**
  62494. * Internal
  62495. * @returns if all the contained post processes are ready.
  62496. * @hidden
  62497. */
  62498. _isReady(): boolean;
  62499. }
  62500. }
  62501. declare module "babylonjs/Shaders/displayPass.fragment" {
  62502. /** @hidden */
  62503. export var displayPassPixelShader: {
  62504. name: string;
  62505. shader: string;
  62506. };
  62507. }
  62508. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62509. import { Nullable } from "babylonjs/types";
  62510. import { Camera } from "babylonjs/Cameras/camera";
  62511. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62512. import { Engine } from "babylonjs/Engines/engine";
  62513. import "babylonjs/Shaders/displayPass.fragment";
  62514. /**
  62515. * DisplayPassPostProcess which produces an output the same as it's input
  62516. */
  62517. export class DisplayPassPostProcess extends PostProcess {
  62518. /**
  62519. * Creates the DisplayPassPostProcess
  62520. * @param name The name of the effect.
  62521. * @param options The required width/height ratio to downsize to before computing the render pass.
  62522. * @param camera The camera to apply the render pass to.
  62523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62524. * @param engine The engine which the post process will be applied. (default: current engine)
  62525. * @param reusable If the post process can be reused on the same frame. (default: false)
  62526. */
  62527. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62528. }
  62529. }
  62530. declare module "babylonjs/Shaders/filter.fragment" {
  62531. /** @hidden */
  62532. export var filterPixelShader: {
  62533. name: string;
  62534. shader: string;
  62535. };
  62536. }
  62537. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62538. import { Nullable } from "babylonjs/types";
  62539. import { Matrix } from "babylonjs/Maths/math.vector";
  62540. import { Camera } from "babylonjs/Cameras/camera";
  62541. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62542. import { Engine } from "babylonjs/Engines/engine";
  62543. import "babylonjs/Shaders/filter.fragment";
  62544. /**
  62545. * Applies a kernel filter to the image
  62546. */
  62547. export class FilterPostProcess extends PostProcess {
  62548. /** The matrix to be applied to the image */
  62549. kernelMatrix: Matrix;
  62550. /**
  62551. *
  62552. * @param name The name of the effect.
  62553. * @param kernelMatrix The matrix to be applied to the image
  62554. * @param options The required width/height ratio to downsize to before computing the render pass.
  62555. * @param camera The camera to apply the render pass to.
  62556. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62557. * @param engine The engine which the post process will be applied. (default: current engine)
  62558. * @param reusable If the post process can be reused on the same frame. (default: false)
  62559. */
  62560. constructor(name: string,
  62561. /** The matrix to be applied to the image */
  62562. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62563. }
  62564. }
  62565. declare module "babylonjs/Shaders/fxaa.fragment" {
  62566. /** @hidden */
  62567. export var fxaaPixelShader: {
  62568. name: string;
  62569. shader: string;
  62570. };
  62571. }
  62572. declare module "babylonjs/Shaders/fxaa.vertex" {
  62573. /** @hidden */
  62574. export var fxaaVertexShader: {
  62575. name: string;
  62576. shader: string;
  62577. };
  62578. }
  62579. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62580. import { Nullable } from "babylonjs/types";
  62581. import { Camera } from "babylonjs/Cameras/camera";
  62582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62583. import { Engine } from "babylonjs/Engines/engine";
  62584. import "babylonjs/Shaders/fxaa.fragment";
  62585. import "babylonjs/Shaders/fxaa.vertex";
  62586. /**
  62587. * Fxaa post process
  62588. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62589. */
  62590. export class FxaaPostProcess extends PostProcess {
  62591. /** @hidden */
  62592. texelWidth: number;
  62593. /** @hidden */
  62594. texelHeight: number;
  62595. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62596. private _getDefines;
  62597. }
  62598. }
  62599. declare module "babylonjs/Shaders/grain.fragment" {
  62600. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62601. /** @hidden */
  62602. export var grainPixelShader: {
  62603. name: string;
  62604. shader: string;
  62605. };
  62606. }
  62607. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62608. import { Nullable } from "babylonjs/types";
  62609. import { Camera } from "babylonjs/Cameras/camera";
  62610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62611. import { Engine } from "babylonjs/Engines/engine";
  62612. import "babylonjs/Shaders/grain.fragment";
  62613. /**
  62614. * The GrainPostProcess adds noise to the image at mid luminance levels
  62615. */
  62616. export class GrainPostProcess extends PostProcess {
  62617. /**
  62618. * The intensity of the grain added (default: 30)
  62619. */
  62620. intensity: number;
  62621. /**
  62622. * If the grain should be randomized on every frame
  62623. */
  62624. animated: boolean;
  62625. /**
  62626. * Creates a new instance of @see GrainPostProcess
  62627. * @param name The name of the effect.
  62628. * @param options The required width/height ratio to downsize to before computing the render pass.
  62629. * @param camera The camera to apply the render pass to.
  62630. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62631. * @param engine The engine which the post process will be applied. (default: current engine)
  62632. * @param reusable If the post process can be reused on the same frame. (default: false)
  62633. * @param textureType Type of textures used when performing the post process. (default: 0)
  62634. * @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)
  62635. */
  62636. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62637. }
  62638. }
  62639. declare module "babylonjs/Shaders/highlights.fragment" {
  62640. /** @hidden */
  62641. export var highlightsPixelShader: {
  62642. name: string;
  62643. shader: string;
  62644. };
  62645. }
  62646. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62647. import { Nullable } from "babylonjs/types";
  62648. import { Camera } from "babylonjs/Cameras/camera";
  62649. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62650. import { Engine } from "babylonjs/Engines/engine";
  62651. import "babylonjs/Shaders/highlights.fragment";
  62652. /**
  62653. * Extracts highlights from the image
  62654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62655. */
  62656. export class HighlightsPostProcess extends PostProcess {
  62657. /**
  62658. * Extracts highlights from the image
  62659. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62660. * @param name The name of the effect.
  62661. * @param options The required width/height ratio to downsize to before computing the render pass.
  62662. * @param camera The camera to apply the render pass to.
  62663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62664. * @param engine The engine which the post process will be applied. (default: current engine)
  62665. * @param reusable If the post process can be reused on the same frame. (default: false)
  62666. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62667. */
  62668. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62669. }
  62670. }
  62671. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62672. /** @hidden */
  62673. export var mrtFragmentDeclaration: {
  62674. name: string;
  62675. shader: string;
  62676. };
  62677. }
  62678. declare module "babylonjs/Shaders/geometry.fragment" {
  62679. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62680. /** @hidden */
  62681. export var geometryPixelShader: {
  62682. name: string;
  62683. shader: string;
  62684. };
  62685. }
  62686. declare module "babylonjs/Shaders/geometry.vertex" {
  62687. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62688. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62689. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62690. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62691. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62692. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62693. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62694. /** @hidden */
  62695. export var geometryVertexShader: {
  62696. name: string;
  62697. shader: string;
  62698. };
  62699. }
  62700. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62701. import { Matrix } from "babylonjs/Maths/math.vector";
  62702. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62703. import { Mesh } from "babylonjs/Meshes/mesh";
  62704. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62705. import { Effect } from "babylonjs/Materials/effect";
  62706. import { Scene } from "babylonjs/scene";
  62707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62708. import "babylonjs/Shaders/geometry.fragment";
  62709. import "babylonjs/Shaders/geometry.vertex";
  62710. /** @hidden */
  62711. interface ISavedTransformationMatrix {
  62712. world: Matrix;
  62713. viewProjection: Matrix;
  62714. }
  62715. /**
  62716. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62717. */
  62718. export class GeometryBufferRenderer {
  62719. /**
  62720. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62721. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62722. */
  62723. static readonly POSITION_TEXTURE_TYPE: number;
  62724. /**
  62725. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62726. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62727. */
  62728. static readonly VELOCITY_TEXTURE_TYPE: number;
  62729. /**
  62730. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62731. * in order to compute objects velocities when enableVelocity is set to "true"
  62732. * @hidden
  62733. */
  62734. _previousTransformationMatrices: {
  62735. [index: number]: ISavedTransformationMatrix;
  62736. };
  62737. /**
  62738. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62739. * in order to compute objects velocities when enableVelocity is set to "true"
  62740. * @hidden
  62741. */
  62742. _previousBonesTransformationMatrices: {
  62743. [index: number]: Float32Array;
  62744. };
  62745. /**
  62746. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62747. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62748. */
  62749. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62750. private _scene;
  62751. private _multiRenderTarget;
  62752. private _ratio;
  62753. private _enablePosition;
  62754. private _enableVelocity;
  62755. private _positionIndex;
  62756. private _velocityIndex;
  62757. protected _effect: Effect;
  62758. protected _cachedDefines: string;
  62759. /**
  62760. * Set the render list (meshes to be rendered) used in the G buffer.
  62761. */
  62762. renderList: Mesh[];
  62763. /**
  62764. * Gets wether or not G buffer are supported by the running hardware.
  62765. * This requires draw buffer supports
  62766. */
  62767. readonly isSupported: boolean;
  62768. /**
  62769. * Returns the index of the given texture type in the G-Buffer textures array
  62770. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62771. * @returns the index of the given texture type in the G-Buffer textures array
  62772. */
  62773. getTextureIndex(textureType: number): number;
  62774. /**
  62775. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62776. */
  62777. /**
  62778. * Sets whether or not objects positions are enabled for the G buffer.
  62779. */
  62780. enablePosition: boolean;
  62781. /**
  62782. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62783. */
  62784. /**
  62785. * Sets wether or not objects velocities are enabled for the G buffer.
  62786. */
  62787. enableVelocity: boolean;
  62788. /**
  62789. * Gets the scene associated with the buffer.
  62790. */
  62791. readonly scene: Scene;
  62792. /**
  62793. * Gets the ratio used by the buffer during its creation.
  62794. * How big is the buffer related to the main canvas.
  62795. */
  62796. readonly ratio: number;
  62797. /** @hidden */
  62798. static _SceneComponentInitialization: (scene: Scene) => void;
  62799. /**
  62800. * Creates a new G Buffer for the scene
  62801. * @param scene The scene the buffer belongs to
  62802. * @param ratio How big is the buffer related to the main canvas.
  62803. */
  62804. constructor(scene: Scene, ratio?: number);
  62805. /**
  62806. * Checks wether everything is ready to render a submesh to the G buffer.
  62807. * @param subMesh the submesh to check readiness for
  62808. * @param useInstances is the mesh drawn using instance or not
  62809. * @returns true if ready otherwise false
  62810. */
  62811. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62812. /**
  62813. * Gets the current underlying G Buffer.
  62814. * @returns the buffer
  62815. */
  62816. getGBuffer(): MultiRenderTarget;
  62817. /**
  62818. * Gets the number of samples used to render the buffer (anti aliasing).
  62819. */
  62820. /**
  62821. * Sets the number of samples used to render the buffer (anti aliasing).
  62822. */
  62823. samples: number;
  62824. /**
  62825. * Disposes the renderer and frees up associated resources.
  62826. */
  62827. dispose(): void;
  62828. protected _createRenderTargets(): void;
  62829. private _copyBonesTransformationMatrices;
  62830. }
  62831. }
  62832. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62833. import { Nullable } from "babylonjs/types";
  62834. import { Scene } from "babylonjs/scene";
  62835. import { ISceneComponent } from "babylonjs/sceneComponent";
  62836. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62837. module "babylonjs/scene" {
  62838. interface Scene {
  62839. /** @hidden (Backing field) */
  62840. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62841. /**
  62842. * Gets or Sets the current geometry buffer associated to the scene.
  62843. */
  62844. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62845. /**
  62846. * Enables a GeometryBufferRender and associates it with the scene
  62847. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62848. * @returns the GeometryBufferRenderer
  62849. */
  62850. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62851. /**
  62852. * Disables the GeometryBufferRender associated with the scene
  62853. */
  62854. disableGeometryBufferRenderer(): void;
  62855. }
  62856. }
  62857. /**
  62858. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62859. * in several rendering techniques.
  62860. */
  62861. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62862. /**
  62863. * The component name helpful to identify the component in the list of scene components.
  62864. */
  62865. readonly name: string;
  62866. /**
  62867. * The scene the component belongs to.
  62868. */
  62869. scene: Scene;
  62870. /**
  62871. * Creates a new instance of the component for the given scene
  62872. * @param scene Defines the scene to register the component in
  62873. */
  62874. constructor(scene: Scene);
  62875. /**
  62876. * Registers the component in a given scene
  62877. */
  62878. register(): void;
  62879. /**
  62880. * Rebuilds the elements related to this component in case of
  62881. * context lost for instance.
  62882. */
  62883. rebuild(): void;
  62884. /**
  62885. * Disposes the component and the associated ressources
  62886. */
  62887. dispose(): void;
  62888. private _gatherRenderTargets;
  62889. }
  62890. }
  62891. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62892. /** @hidden */
  62893. export var motionBlurPixelShader: {
  62894. name: string;
  62895. shader: string;
  62896. };
  62897. }
  62898. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62899. import { Nullable } from "babylonjs/types";
  62900. import { Camera } from "babylonjs/Cameras/camera";
  62901. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62902. import { Scene } from "babylonjs/scene";
  62903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62904. import "babylonjs/Animations/animatable";
  62905. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62906. import "babylonjs/Shaders/motionBlur.fragment";
  62907. import { Engine } from "babylonjs/Engines/engine";
  62908. /**
  62909. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62910. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62911. * As an example, all you have to do is to create the post-process:
  62912. * var mb = new BABYLON.MotionBlurPostProcess(
  62913. * 'mb', // The name of the effect.
  62914. * scene, // The scene containing the objects to blur according to their velocity.
  62915. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62916. * camera // The camera to apply the render pass to.
  62917. * );
  62918. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62919. */
  62920. export class MotionBlurPostProcess extends PostProcess {
  62921. /**
  62922. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62923. */
  62924. motionStrength: number;
  62925. /**
  62926. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62927. */
  62928. /**
  62929. * Sets the number of iterations to be used for motion blur quality
  62930. */
  62931. motionBlurSamples: number;
  62932. private _motionBlurSamples;
  62933. private _geometryBufferRenderer;
  62934. /**
  62935. * Creates a new instance MotionBlurPostProcess
  62936. * @param name The name of the effect.
  62937. * @param scene The scene containing the objects to blur according to their velocity.
  62938. * @param options The required width/height ratio to downsize to before computing the render pass.
  62939. * @param camera The camera to apply the render pass to.
  62940. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62941. * @param engine The engine which the post process will be applied. (default: current engine)
  62942. * @param reusable If the post process can be reused on the same frame. (default: false)
  62943. * @param textureType Type of textures used when performing the post process. (default: 0)
  62944. * @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)
  62945. */
  62946. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62947. /**
  62948. * Excludes the given skinned mesh from computing bones velocities.
  62949. * 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.
  62950. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62951. */
  62952. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62953. /**
  62954. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62955. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62956. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62957. */
  62958. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62959. /**
  62960. * Disposes the post process.
  62961. * @param camera The camera to dispose the post process on.
  62962. */
  62963. dispose(camera?: Camera): void;
  62964. }
  62965. }
  62966. declare module "babylonjs/Shaders/refraction.fragment" {
  62967. /** @hidden */
  62968. export var refractionPixelShader: {
  62969. name: string;
  62970. shader: string;
  62971. };
  62972. }
  62973. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62974. import { Color3 } from "babylonjs/Maths/math.color";
  62975. import { Camera } from "babylonjs/Cameras/camera";
  62976. import { Texture } from "babylonjs/Materials/Textures/texture";
  62977. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62978. import { Engine } from "babylonjs/Engines/engine";
  62979. import "babylonjs/Shaders/refraction.fragment";
  62980. /**
  62981. * Post process which applies a refractin texture
  62982. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62983. */
  62984. export class RefractionPostProcess extends PostProcess {
  62985. /** the base color of the refraction (used to taint the rendering) */
  62986. color: Color3;
  62987. /** simulated refraction depth */
  62988. depth: number;
  62989. /** the coefficient of the base color (0 to remove base color tainting) */
  62990. colorLevel: number;
  62991. private _refTexture;
  62992. private _ownRefractionTexture;
  62993. /**
  62994. * Gets or sets the refraction texture
  62995. * Please note that you are responsible for disposing the texture if you set it manually
  62996. */
  62997. refractionTexture: Texture;
  62998. /**
  62999. * Initializes the RefractionPostProcess
  63000. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63001. * @param name The name of the effect.
  63002. * @param refractionTextureUrl Url of the refraction texture to use
  63003. * @param color the base color of the refraction (used to taint the rendering)
  63004. * @param depth simulated refraction depth
  63005. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63006. * @param camera The camera to apply the render pass to.
  63007. * @param options The required width/height ratio to downsize to before computing the render pass.
  63008. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63009. * @param engine The engine which the post process will be applied. (default: current engine)
  63010. * @param reusable If the post process can be reused on the same frame. (default: false)
  63011. */
  63012. constructor(name: string, refractionTextureUrl: string,
  63013. /** the base color of the refraction (used to taint the rendering) */
  63014. color: Color3,
  63015. /** simulated refraction depth */
  63016. depth: number,
  63017. /** the coefficient of the base color (0 to remove base color tainting) */
  63018. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63019. /**
  63020. * Disposes of the post process
  63021. * @param camera Camera to dispose post process on
  63022. */
  63023. dispose(camera: Camera): void;
  63024. }
  63025. }
  63026. declare module "babylonjs/Shaders/sharpen.fragment" {
  63027. /** @hidden */
  63028. export var sharpenPixelShader: {
  63029. name: string;
  63030. shader: string;
  63031. };
  63032. }
  63033. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63034. import { Nullable } from "babylonjs/types";
  63035. import { Camera } from "babylonjs/Cameras/camera";
  63036. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63037. import "babylonjs/Shaders/sharpen.fragment";
  63038. import { Engine } from "babylonjs/Engines/engine";
  63039. /**
  63040. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63041. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63042. */
  63043. export class SharpenPostProcess extends PostProcess {
  63044. /**
  63045. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63046. */
  63047. colorAmount: number;
  63048. /**
  63049. * How much sharpness should be applied (default: 0.3)
  63050. */
  63051. edgeAmount: number;
  63052. /**
  63053. * Creates a new instance ConvolutionPostProcess
  63054. * @param name The name of the effect.
  63055. * @param options The required width/height ratio to downsize to before computing the render pass.
  63056. * @param camera The camera to apply the render pass to.
  63057. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63058. * @param engine The engine which the post process will be applied. (default: current engine)
  63059. * @param reusable If the post process can be reused on the same frame. (default: false)
  63060. * @param textureType Type of textures used when performing the post process. (default: 0)
  63061. * @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)
  63062. */
  63063. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63064. }
  63065. }
  63066. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63067. import { Nullable } from "babylonjs/types";
  63068. import { Camera } from "babylonjs/Cameras/camera";
  63069. import { Engine } from "babylonjs/Engines/engine";
  63070. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63071. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63072. /**
  63073. * PostProcessRenderPipeline
  63074. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63075. */
  63076. export class PostProcessRenderPipeline {
  63077. private engine;
  63078. private _renderEffects;
  63079. private _renderEffectsForIsolatedPass;
  63080. /**
  63081. * List of inspectable custom properties (used by the Inspector)
  63082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63083. */
  63084. inspectableCustomProperties: IInspectable[];
  63085. /**
  63086. * @hidden
  63087. */
  63088. protected _cameras: Camera[];
  63089. /** @hidden */
  63090. _name: string;
  63091. /**
  63092. * Gets pipeline name
  63093. */
  63094. readonly name: string;
  63095. /**
  63096. * Initializes a PostProcessRenderPipeline
  63097. * @param engine engine to add the pipeline to
  63098. * @param name name of the pipeline
  63099. */
  63100. constructor(engine: Engine, name: string);
  63101. /**
  63102. * Gets the class name
  63103. * @returns "PostProcessRenderPipeline"
  63104. */
  63105. getClassName(): string;
  63106. /**
  63107. * If all the render effects in the pipeline are supported
  63108. */
  63109. readonly isSupported: boolean;
  63110. /**
  63111. * Adds an effect to the pipeline
  63112. * @param renderEffect the effect to add
  63113. */
  63114. addEffect(renderEffect: PostProcessRenderEffect): void;
  63115. /** @hidden */
  63116. _rebuild(): void;
  63117. /** @hidden */
  63118. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63119. /** @hidden */
  63120. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63121. /** @hidden */
  63122. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63123. /** @hidden */
  63124. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63125. /** @hidden */
  63126. _attachCameras(cameras: Camera, unique: boolean): void;
  63127. /** @hidden */
  63128. _attachCameras(cameras: Camera[], unique: boolean): void;
  63129. /** @hidden */
  63130. _detachCameras(cameras: Camera): void;
  63131. /** @hidden */
  63132. _detachCameras(cameras: Nullable<Camera[]>): void;
  63133. /** @hidden */
  63134. _update(): void;
  63135. /** @hidden */
  63136. _reset(): void;
  63137. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63138. /**
  63139. * Disposes of the pipeline
  63140. */
  63141. dispose(): void;
  63142. }
  63143. }
  63144. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63145. import { Camera } from "babylonjs/Cameras/camera";
  63146. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63147. /**
  63148. * PostProcessRenderPipelineManager class
  63149. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63150. */
  63151. export class PostProcessRenderPipelineManager {
  63152. private _renderPipelines;
  63153. /**
  63154. * Initializes a PostProcessRenderPipelineManager
  63155. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63156. */
  63157. constructor();
  63158. /**
  63159. * Gets the list of supported render pipelines
  63160. */
  63161. readonly supportedPipelines: PostProcessRenderPipeline[];
  63162. /**
  63163. * Adds a pipeline to the manager
  63164. * @param renderPipeline The pipeline to add
  63165. */
  63166. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63167. /**
  63168. * Attaches a camera to the pipeline
  63169. * @param renderPipelineName The name of the pipeline to attach to
  63170. * @param cameras the camera to attach
  63171. * @param unique if the camera can be attached multiple times to the pipeline
  63172. */
  63173. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63174. /**
  63175. * Detaches a camera from the pipeline
  63176. * @param renderPipelineName The name of the pipeline to detach from
  63177. * @param cameras the camera to detach
  63178. */
  63179. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63180. /**
  63181. * Enables an effect by name on a pipeline
  63182. * @param renderPipelineName the name of the pipeline to enable the effect in
  63183. * @param renderEffectName the name of the effect to enable
  63184. * @param cameras the cameras that the effect should be enabled on
  63185. */
  63186. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63187. /**
  63188. * Disables an effect by name on a pipeline
  63189. * @param renderPipelineName the name of the pipeline to disable the effect in
  63190. * @param renderEffectName the name of the effect to disable
  63191. * @param cameras the cameras that the effect should be disabled on
  63192. */
  63193. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63194. /**
  63195. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63196. */
  63197. update(): void;
  63198. /** @hidden */
  63199. _rebuild(): void;
  63200. /**
  63201. * Disposes of the manager and pipelines
  63202. */
  63203. dispose(): void;
  63204. }
  63205. }
  63206. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63207. import { ISceneComponent } from "babylonjs/sceneComponent";
  63208. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63209. import { Scene } from "babylonjs/scene";
  63210. module "babylonjs/scene" {
  63211. interface Scene {
  63212. /** @hidden (Backing field) */
  63213. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63214. /**
  63215. * Gets the postprocess render pipeline manager
  63216. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63217. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63218. */
  63219. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63220. }
  63221. }
  63222. /**
  63223. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63224. */
  63225. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63226. /**
  63227. * The component name helpfull to identify the component in the list of scene components.
  63228. */
  63229. readonly name: string;
  63230. /**
  63231. * The scene the component belongs to.
  63232. */
  63233. scene: Scene;
  63234. /**
  63235. * Creates a new instance of the component for the given scene
  63236. * @param scene Defines the scene to register the component in
  63237. */
  63238. constructor(scene: Scene);
  63239. /**
  63240. * Registers the component in a given scene
  63241. */
  63242. register(): void;
  63243. /**
  63244. * Rebuilds the elements related to this component in case of
  63245. * context lost for instance.
  63246. */
  63247. rebuild(): void;
  63248. /**
  63249. * Disposes the component and the associated ressources
  63250. */
  63251. dispose(): void;
  63252. private _gatherRenderTargets;
  63253. }
  63254. }
  63255. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63256. import { Nullable } from "babylonjs/types";
  63257. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63258. import { Camera } from "babylonjs/Cameras/camera";
  63259. import { IDisposable } from "babylonjs/scene";
  63260. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63261. import { Scene } from "babylonjs/scene";
  63262. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63263. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63264. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63265. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63266. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63267. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63268. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63269. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63270. import { Animation } from "babylonjs/Animations/animation";
  63271. /**
  63272. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63273. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63274. */
  63275. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63276. private _scene;
  63277. private _camerasToBeAttached;
  63278. /**
  63279. * ID of the sharpen post process,
  63280. */
  63281. private readonly SharpenPostProcessId;
  63282. /**
  63283. * @ignore
  63284. * ID of the image processing post process;
  63285. */
  63286. readonly ImageProcessingPostProcessId: string;
  63287. /**
  63288. * @ignore
  63289. * ID of the Fast Approximate Anti-Aliasing post process;
  63290. */
  63291. readonly FxaaPostProcessId: string;
  63292. /**
  63293. * ID of the chromatic aberration post process,
  63294. */
  63295. private readonly ChromaticAberrationPostProcessId;
  63296. /**
  63297. * ID of the grain post process
  63298. */
  63299. private readonly GrainPostProcessId;
  63300. /**
  63301. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63302. */
  63303. sharpen: SharpenPostProcess;
  63304. private _sharpenEffect;
  63305. private bloom;
  63306. /**
  63307. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63308. */
  63309. depthOfField: DepthOfFieldEffect;
  63310. /**
  63311. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63312. */
  63313. fxaa: FxaaPostProcess;
  63314. /**
  63315. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63316. */
  63317. imageProcessing: ImageProcessingPostProcess;
  63318. /**
  63319. * Chromatic aberration post process which will shift rgb colors in the image
  63320. */
  63321. chromaticAberration: ChromaticAberrationPostProcess;
  63322. private _chromaticAberrationEffect;
  63323. /**
  63324. * Grain post process which add noise to the image
  63325. */
  63326. grain: GrainPostProcess;
  63327. private _grainEffect;
  63328. /**
  63329. * Glow post process which adds a glow to emissive areas of the image
  63330. */
  63331. private _glowLayer;
  63332. /**
  63333. * Animations which can be used to tweak settings over a period of time
  63334. */
  63335. animations: Animation[];
  63336. private _imageProcessingConfigurationObserver;
  63337. private _sharpenEnabled;
  63338. private _bloomEnabled;
  63339. private _depthOfFieldEnabled;
  63340. private _depthOfFieldBlurLevel;
  63341. private _fxaaEnabled;
  63342. private _imageProcessingEnabled;
  63343. private _defaultPipelineTextureType;
  63344. private _bloomScale;
  63345. private _chromaticAberrationEnabled;
  63346. private _grainEnabled;
  63347. private _buildAllowed;
  63348. /**
  63349. * Gets active scene
  63350. */
  63351. readonly scene: Scene;
  63352. /**
  63353. * Enable or disable the sharpen process from the pipeline
  63354. */
  63355. sharpenEnabled: boolean;
  63356. private _resizeObserver;
  63357. private _hardwareScaleLevel;
  63358. private _bloomKernel;
  63359. /**
  63360. * Specifies the size of the bloom blur kernel, relative to the final output size
  63361. */
  63362. bloomKernel: number;
  63363. /**
  63364. * Specifies the weight of the bloom in the final rendering
  63365. */
  63366. private _bloomWeight;
  63367. /**
  63368. * Specifies the luma threshold for the area that will be blurred by the bloom
  63369. */
  63370. private _bloomThreshold;
  63371. private _hdr;
  63372. /**
  63373. * The strength of the bloom.
  63374. */
  63375. bloomWeight: number;
  63376. /**
  63377. * The strength of the bloom.
  63378. */
  63379. bloomThreshold: number;
  63380. /**
  63381. * The scale of the bloom, lower value will provide better performance.
  63382. */
  63383. bloomScale: number;
  63384. /**
  63385. * Enable or disable the bloom from the pipeline
  63386. */
  63387. bloomEnabled: boolean;
  63388. private _rebuildBloom;
  63389. /**
  63390. * If the depth of field is enabled.
  63391. */
  63392. depthOfFieldEnabled: boolean;
  63393. /**
  63394. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63395. */
  63396. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63397. /**
  63398. * If the anti aliasing is enabled.
  63399. */
  63400. fxaaEnabled: boolean;
  63401. private _samples;
  63402. /**
  63403. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63404. */
  63405. samples: number;
  63406. /**
  63407. * If image processing is enabled.
  63408. */
  63409. imageProcessingEnabled: boolean;
  63410. /**
  63411. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63412. */
  63413. glowLayerEnabled: boolean;
  63414. /**
  63415. * Gets the glow layer (or null if not defined)
  63416. */
  63417. readonly glowLayer: Nullable<GlowLayer>;
  63418. /**
  63419. * Enable or disable the chromaticAberration process from the pipeline
  63420. */
  63421. chromaticAberrationEnabled: boolean;
  63422. /**
  63423. * Enable or disable the grain process from the pipeline
  63424. */
  63425. grainEnabled: boolean;
  63426. /**
  63427. * @constructor
  63428. * @param name - The rendering pipeline name (default: "")
  63429. * @param hdr - If high dynamic range textures should be used (default: true)
  63430. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63431. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63432. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63433. */
  63434. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63435. /**
  63436. * Get the class name
  63437. * @returns "DefaultRenderingPipeline"
  63438. */
  63439. getClassName(): string;
  63440. /**
  63441. * Force the compilation of the entire pipeline.
  63442. */
  63443. prepare(): void;
  63444. private _hasCleared;
  63445. private _prevPostProcess;
  63446. private _prevPrevPostProcess;
  63447. private _setAutoClearAndTextureSharing;
  63448. private _depthOfFieldSceneObserver;
  63449. private _buildPipeline;
  63450. private _disposePostProcesses;
  63451. /**
  63452. * Adds a camera to the pipeline
  63453. * @param camera the camera to be added
  63454. */
  63455. addCamera(camera: Camera): void;
  63456. /**
  63457. * Removes a camera from the pipeline
  63458. * @param camera the camera to remove
  63459. */
  63460. removeCamera(camera: Camera): void;
  63461. /**
  63462. * Dispose of the pipeline and stop all post processes
  63463. */
  63464. dispose(): void;
  63465. /**
  63466. * Serialize the rendering pipeline (Used when exporting)
  63467. * @returns the serialized object
  63468. */
  63469. serialize(): any;
  63470. /**
  63471. * Parse the serialized pipeline
  63472. * @param source Source pipeline.
  63473. * @param scene The scene to load the pipeline to.
  63474. * @param rootUrl The URL of the serialized pipeline.
  63475. * @returns An instantiated pipeline from the serialized object.
  63476. */
  63477. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63478. }
  63479. }
  63480. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63481. /** @hidden */
  63482. export var lensHighlightsPixelShader: {
  63483. name: string;
  63484. shader: string;
  63485. };
  63486. }
  63487. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63488. /** @hidden */
  63489. export var depthOfFieldPixelShader: {
  63490. name: string;
  63491. shader: string;
  63492. };
  63493. }
  63494. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63495. import { Camera } from "babylonjs/Cameras/camera";
  63496. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63497. import { Scene } from "babylonjs/scene";
  63498. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63499. import "babylonjs/Shaders/chromaticAberration.fragment";
  63500. import "babylonjs/Shaders/lensHighlights.fragment";
  63501. import "babylonjs/Shaders/depthOfField.fragment";
  63502. /**
  63503. * BABYLON.JS Chromatic Aberration GLSL Shader
  63504. * Author: Olivier Guyot
  63505. * Separates very slightly R, G and B colors on the edges of the screen
  63506. * Inspired by Francois Tarlier & Martins Upitis
  63507. */
  63508. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63509. /**
  63510. * @ignore
  63511. * The chromatic aberration PostProcess id in the pipeline
  63512. */
  63513. LensChromaticAberrationEffect: string;
  63514. /**
  63515. * @ignore
  63516. * The highlights enhancing PostProcess id in the pipeline
  63517. */
  63518. HighlightsEnhancingEffect: string;
  63519. /**
  63520. * @ignore
  63521. * The depth-of-field PostProcess id in the pipeline
  63522. */
  63523. LensDepthOfFieldEffect: string;
  63524. private _scene;
  63525. private _depthTexture;
  63526. private _grainTexture;
  63527. private _chromaticAberrationPostProcess;
  63528. private _highlightsPostProcess;
  63529. private _depthOfFieldPostProcess;
  63530. private _edgeBlur;
  63531. private _grainAmount;
  63532. private _chromaticAberration;
  63533. private _distortion;
  63534. private _highlightsGain;
  63535. private _highlightsThreshold;
  63536. private _dofDistance;
  63537. private _dofAperture;
  63538. private _dofDarken;
  63539. private _dofPentagon;
  63540. private _blurNoise;
  63541. /**
  63542. * @constructor
  63543. *
  63544. * Effect parameters are as follow:
  63545. * {
  63546. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63547. * edge_blur: number; // from 0 to x (1 for realism)
  63548. * distortion: number; // from 0 to x (1 for realism)
  63549. * grain_amount: number; // from 0 to 1
  63550. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63551. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63552. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63553. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63554. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63555. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63556. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63557. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63558. * }
  63559. * Note: if an effect parameter is unset, effect is disabled
  63560. *
  63561. * @param name The rendering pipeline name
  63562. * @param parameters - An object containing all parameters (see above)
  63563. * @param scene The scene linked to this pipeline
  63564. * @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)
  63565. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63566. */
  63567. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63568. /**
  63569. * Get the class name
  63570. * @returns "LensRenderingPipeline"
  63571. */
  63572. getClassName(): string;
  63573. /**
  63574. * Gets associated scene
  63575. */
  63576. readonly scene: Scene;
  63577. /**
  63578. * Gets or sets the edge blur
  63579. */
  63580. edgeBlur: number;
  63581. /**
  63582. * Gets or sets the grain amount
  63583. */
  63584. grainAmount: number;
  63585. /**
  63586. * Gets or sets the chromatic aberration amount
  63587. */
  63588. chromaticAberration: number;
  63589. /**
  63590. * Gets or sets the depth of field aperture
  63591. */
  63592. dofAperture: number;
  63593. /**
  63594. * Gets or sets the edge distortion
  63595. */
  63596. edgeDistortion: number;
  63597. /**
  63598. * Gets or sets the depth of field distortion
  63599. */
  63600. dofDistortion: number;
  63601. /**
  63602. * Gets or sets the darken out of focus amount
  63603. */
  63604. darkenOutOfFocus: number;
  63605. /**
  63606. * Gets or sets a boolean indicating if blur noise is enabled
  63607. */
  63608. blurNoise: boolean;
  63609. /**
  63610. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63611. */
  63612. pentagonBokeh: boolean;
  63613. /**
  63614. * Gets or sets the highlight grain amount
  63615. */
  63616. highlightsGain: number;
  63617. /**
  63618. * Gets or sets the highlight threshold
  63619. */
  63620. highlightsThreshold: number;
  63621. /**
  63622. * Sets the amount of blur at the edges
  63623. * @param amount blur amount
  63624. */
  63625. setEdgeBlur(amount: number): void;
  63626. /**
  63627. * Sets edge blur to 0
  63628. */
  63629. disableEdgeBlur(): void;
  63630. /**
  63631. * Sets the amout of grain
  63632. * @param amount Amount of grain
  63633. */
  63634. setGrainAmount(amount: number): void;
  63635. /**
  63636. * Set grain amount to 0
  63637. */
  63638. disableGrain(): void;
  63639. /**
  63640. * Sets the chromatic aberration amount
  63641. * @param amount amount of chromatic aberration
  63642. */
  63643. setChromaticAberration(amount: number): void;
  63644. /**
  63645. * Sets chromatic aberration amount to 0
  63646. */
  63647. disableChromaticAberration(): void;
  63648. /**
  63649. * Sets the EdgeDistortion amount
  63650. * @param amount amount of EdgeDistortion
  63651. */
  63652. setEdgeDistortion(amount: number): void;
  63653. /**
  63654. * Sets edge distortion to 0
  63655. */
  63656. disableEdgeDistortion(): void;
  63657. /**
  63658. * Sets the FocusDistance amount
  63659. * @param amount amount of FocusDistance
  63660. */
  63661. setFocusDistance(amount: number): void;
  63662. /**
  63663. * Disables depth of field
  63664. */
  63665. disableDepthOfField(): void;
  63666. /**
  63667. * Sets the Aperture amount
  63668. * @param amount amount of Aperture
  63669. */
  63670. setAperture(amount: number): void;
  63671. /**
  63672. * Sets the DarkenOutOfFocus amount
  63673. * @param amount amount of DarkenOutOfFocus
  63674. */
  63675. setDarkenOutOfFocus(amount: number): void;
  63676. private _pentagonBokehIsEnabled;
  63677. /**
  63678. * Creates a pentagon bokeh effect
  63679. */
  63680. enablePentagonBokeh(): void;
  63681. /**
  63682. * Disables the pentagon bokeh effect
  63683. */
  63684. disablePentagonBokeh(): void;
  63685. /**
  63686. * Enables noise blur
  63687. */
  63688. enableNoiseBlur(): void;
  63689. /**
  63690. * Disables noise blur
  63691. */
  63692. disableNoiseBlur(): void;
  63693. /**
  63694. * Sets the HighlightsGain amount
  63695. * @param amount amount of HighlightsGain
  63696. */
  63697. setHighlightsGain(amount: number): void;
  63698. /**
  63699. * Sets the HighlightsThreshold amount
  63700. * @param amount amount of HighlightsThreshold
  63701. */
  63702. setHighlightsThreshold(amount: number): void;
  63703. /**
  63704. * Disables highlights
  63705. */
  63706. disableHighlights(): void;
  63707. /**
  63708. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63709. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63710. */
  63711. dispose(disableDepthRender?: boolean): void;
  63712. private _createChromaticAberrationPostProcess;
  63713. private _createHighlightsPostProcess;
  63714. private _createDepthOfFieldPostProcess;
  63715. private _createGrainTexture;
  63716. }
  63717. }
  63718. declare module "babylonjs/Shaders/ssao2.fragment" {
  63719. /** @hidden */
  63720. export var ssao2PixelShader: {
  63721. name: string;
  63722. shader: string;
  63723. };
  63724. }
  63725. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63726. /** @hidden */
  63727. export var ssaoCombinePixelShader: {
  63728. name: string;
  63729. shader: string;
  63730. };
  63731. }
  63732. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63733. import { Camera } from "babylonjs/Cameras/camera";
  63734. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63735. import { Scene } from "babylonjs/scene";
  63736. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63737. import "babylonjs/Shaders/ssao2.fragment";
  63738. import "babylonjs/Shaders/ssaoCombine.fragment";
  63739. /**
  63740. * Render pipeline to produce ssao effect
  63741. */
  63742. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63743. /**
  63744. * @ignore
  63745. * The PassPostProcess id in the pipeline that contains the original scene color
  63746. */
  63747. SSAOOriginalSceneColorEffect: string;
  63748. /**
  63749. * @ignore
  63750. * The SSAO PostProcess id in the pipeline
  63751. */
  63752. SSAORenderEffect: string;
  63753. /**
  63754. * @ignore
  63755. * The horizontal blur PostProcess id in the pipeline
  63756. */
  63757. SSAOBlurHRenderEffect: string;
  63758. /**
  63759. * @ignore
  63760. * The vertical blur PostProcess id in the pipeline
  63761. */
  63762. SSAOBlurVRenderEffect: string;
  63763. /**
  63764. * @ignore
  63765. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63766. */
  63767. SSAOCombineRenderEffect: string;
  63768. /**
  63769. * The output strength of the SSAO post-process. Default value is 1.0.
  63770. */
  63771. totalStrength: number;
  63772. /**
  63773. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63774. */
  63775. maxZ: number;
  63776. /**
  63777. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63778. */
  63779. minZAspect: number;
  63780. private _samples;
  63781. /**
  63782. * Number of samples used for the SSAO calculations. Default value is 8
  63783. */
  63784. samples: number;
  63785. private _textureSamples;
  63786. /**
  63787. * Number of samples to use for antialiasing
  63788. */
  63789. textureSamples: number;
  63790. /**
  63791. * Ratio object used for SSAO ratio and blur ratio
  63792. */
  63793. private _ratio;
  63794. /**
  63795. * Dynamically generated sphere sampler.
  63796. */
  63797. private _sampleSphere;
  63798. /**
  63799. * Blur filter offsets
  63800. */
  63801. private _samplerOffsets;
  63802. private _expensiveBlur;
  63803. /**
  63804. * If bilateral blur should be used
  63805. */
  63806. expensiveBlur: boolean;
  63807. /**
  63808. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63809. */
  63810. radius: number;
  63811. /**
  63812. * The base color of the SSAO post-process
  63813. * The final result is "base + ssao" between [0, 1]
  63814. */
  63815. base: number;
  63816. /**
  63817. * Support test.
  63818. */
  63819. static readonly IsSupported: boolean;
  63820. private _scene;
  63821. private _depthTexture;
  63822. private _normalTexture;
  63823. private _randomTexture;
  63824. private _originalColorPostProcess;
  63825. private _ssaoPostProcess;
  63826. private _blurHPostProcess;
  63827. private _blurVPostProcess;
  63828. private _ssaoCombinePostProcess;
  63829. private _firstUpdate;
  63830. /**
  63831. * Gets active scene
  63832. */
  63833. readonly scene: Scene;
  63834. /**
  63835. * @constructor
  63836. * @param name The rendering pipeline name
  63837. * @param scene The scene linked to this pipeline
  63838. * @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 }
  63839. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63840. */
  63841. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63842. /**
  63843. * Get the class name
  63844. * @returns "SSAO2RenderingPipeline"
  63845. */
  63846. getClassName(): string;
  63847. /**
  63848. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63849. */
  63850. dispose(disableGeometryBufferRenderer?: boolean): void;
  63851. private _createBlurPostProcess;
  63852. /** @hidden */
  63853. _rebuild(): void;
  63854. private _bits;
  63855. private _radicalInverse_VdC;
  63856. private _hammersley;
  63857. private _hemisphereSample_uniform;
  63858. private _generateHemisphere;
  63859. private _createSSAOPostProcess;
  63860. private _createSSAOCombinePostProcess;
  63861. private _createRandomTexture;
  63862. /**
  63863. * Serialize the rendering pipeline (Used when exporting)
  63864. * @returns the serialized object
  63865. */
  63866. serialize(): any;
  63867. /**
  63868. * Parse the serialized pipeline
  63869. * @param source Source pipeline.
  63870. * @param scene The scene to load the pipeline to.
  63871. * @param rootUrl The URL of the serialized pipeline.
  63872. * @returns An instantiated pipeline from the serialized object.
  63873. */
  63874. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63875. }
  63876. }
  63877. declare module "babylonjs/Shaders/ssao.fragment" {
  63878. /** @hidden */
  63879. export var ssaoPixelShader: {
  63880. name: string;
  63881. shader: string;
  63882. };
  63883. }
  63884. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63885. import { Camera } from "babylonjs/Cameras/camera";
  63886. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63887. import { Scene } from "babylonjs/scene";
  63888. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63889. import "babylonjs/Shaders/ssao.fragment";
  63890. import "babylonjs/Shaders/ssaoCombine.fragment";
  63891. /**
  63892. * Render pipeline to produce ssao effect
  63893. */
  63894. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63895. /**
  63896. * @ignore
  63897. * The PassPostProcess id in the pipeline that contains the original scene color
  63898. */
  63899. SSAOOriginalSceneColorEffect: string;
  63900. /**
  63901. * @ignore
  63902. * The SSAO PostProcess id in the pipeline
  63903. */
  63904. SSAORenderEffect: string;
  63905. /**
  63906. * @ignore
  63907. * The horizontal blur PostProcess id in the pipeline
  63908. */
  63909. SSAOBlurHRenderEffect: string;
  63910. /**
  63911. * @ignore
  63912. * The vertical blur PostProcess id in the pipeline
  63913. */
  63914. SSAOBlurVRenderEffect: string;
  63915. /**
  63916. * @ignore
  63917. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63918. */
  63919. SSAOCombineRenderEffect: string;
  63920. /**
  63921. * The output strength of the SSAO post-process. Default value is 1.0.
  63922. */
  63923. totalStrength: number;
  63924. /**
  63925. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63926. */
  63927. radius: number;
  63928. /**
  63929. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63930. * Must not be equal to fallOff and superior to fallOff.
  63931. * Default value is 0.0075
  63932. */
  63933. area: number;
  63934. /**
  63935. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63936. * Must not be equal to area and inferior to area.
  63937. * Default value is 0.000001
  63938. */
  63939. fallOff: number;
  63940. /**
  63941. * The base color of the SSAO post-process
  63942. * The final result is "base + ssao" between [0, 1]
  63943. */
  63944. base: number;
  63945. private _scene;
  63946. private _depthTexture;
  63947. private _randomTexture;
  63948. private _originalColorPostProcess;
  63949. private _ssaoPostProcess;
  63950. private _blurHPostProcess;
  63951. private _blurVPostProcess;
  63952. private _ssaoCombinePostProcess;
  63953. private _firstUpdate;
  63954. /**
  63955. * Gets active scene
  63956. */
  63957. readonly scene: Scene;
  63958. /**
  63959. * @constructor
  63960. * @param name - The rendering pipeline name
  63961. * @param scene - The scene linked to this pipeline
  63962. * @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 }
  63963. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63964. */
  63965. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63966. /**
  63967. * Get the class name
  63968. * @returns "SSAORenderingPipeline"
  63969. */
  63970. getClassName(): string;
  63971. /**
  63972. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63973. */
  63974. dispose(disableDepthRender?: boolean): void;
  63975. private _createBlurPostProcess;
  63976. /** @hidden */
  63977. _rebuild(): void;
  63978. private _createSSAOPostProcess;
  63979. private _createSSAOCombinePostProcess;
  63980. private _createRandomTexture;
  63981. }
  63982. }
  63983. declare module "babylonjs/Shaders/standard.fragment" {
  63984. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63985. /** @hidden */
  63986. export var standardPixelShader: {
  63987. name: string;
  63988. shader: string;
  63989. };
  63990. }
  63991. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63992. import { Nullable } from "babylonjs/types";
  63993. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63994. import { Camera } from "babylonjs/Cameras/camera";
  63995. import { Texture } from "babylonjs/Materials/Textures/texture";
  63996. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63997. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63998. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63999. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64000. import { IDisposable } from "babylonjs/scene";
  64001. import { SpotLight } from "babylonjs/Lights/spotLight";
  64002. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64003. import { Scene } from "babylonjs/scene";
  64004. import { Animation } from "babylonjs/Animations/animation";
  64005. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64006. import "babylonjs/Shaders/standard.fragment";
  64007. /**
  64008. * Standard rendering pipeline
  64009. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64010. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64011. */
  64012. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64013. /**
  64014. * Public members
  64015. */
  64016. /**
  64017. * Post-process which contains the original scene color before the pipeline applies all the effects
  64018. */
  64019. originalPostProcess: Nullable<PostProcess>;
  64020. /**
  64021. * Post-process used to down scale an image x4
  64022. */
  64023. downSampleX4PostProcess: Nullable<PostProcess>;
  64024. /**
  64025. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64026. */
  64027. brightPassPostProcess: Nullable<PostProcess>;
  64028. /**
  64029. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64030. */
  64031. blurHPostProcesses: PostProcess[];
  64032. /**
  64033. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64034. */
  64035. blurVPostProcesses: PostProcess[];
  64036. /**
  64037. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64038. */
  64039. textureAdderPostProcess: Nullable<PostProcess>;
  64040. /**
  64041. * Post-process used to create volumetric lighting effect
  64042. */
  64043. volumetricLightPostProcess: Nullable<PostProcess>;
  64044. /**
  64045. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64046. */
  64047. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64048. /**
  64049. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64050. */
  64051. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64052. /**
  64053. * Post-process used to merge the volumetric light effect and the real scene color
  64054. */
  64055. volumetricLightMergePostProces: Nullable<PostProcess>;
  64056. /**
  64057. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64058. */
  64059. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64060. /**
  64061. * Base post-process used to calculate the average luminance of the final image for HDR
  64062. */
  64063. luminancePostProcess: Nullable<PostProcess>;
  64064. /**
  64065. * Post-processes used to create down sample post-processes in order to get
  64066. * the average luminance of the final image for HDR
  64067. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64068. */
  64069. luminanceDownSamplePostProcesses: PostProcess[];
  64070. /**
  64071. * Post-process used to create a HDR effect (light adaptation)
  64072. */
  64073. hdrPostProcess: Nullable<PostProcess>;
  64074. /**
  64075. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64076. */
  64077. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64078. /**
  64079. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64080. */
  64081. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64082. /**
  64083. * Post-process used to merge the final HDR post-process and the real scene color
  64084. */
  64085. hdrFinalPostProcess: Nullable<PostProcess>;
  64086. /**
  64087. * Post-process used to create a lens flare effect
  64088. */
  64089. lensFlarePostProcess: Nullable<PostProcess>;
  64090. /**
  64091. * Post-process that merges the result of the lens flare post-process and the real scene color
  64092. */
  64093. lensFlareComposePostProcess: Nullable<PostProcess>;
  64094. /**
  64095. * Post-process used to create a motion blur effect
  64096. */
  64097. motionBlurPostProcess: Nullable<PostProcess>;
  64098. /**
  64099. * Post-process used to create a depth of field effect
  64100. */
  64101. depthOfFieldPostProcess: Nullable<PostProcess>;
  64102. /**
  64103. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64104. */
  64105. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64106. /**
  64107. * Represents the brightness threshold in order to configure the illuminated surfaces
  64108. */
  64109. brightThreshold: number;
  64110. /**
  64111. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64112. */
  64113. blurWidth: number;
  64114. /**
  64115. * Sets if the blur for highlighted surfaces must be only horizontal
  64116. */
  64117. horizontalBlur: boolean;
  64118. /**
  64119. * Gets the overall exposure used by the pipeline
  64120. */
  64121. /**
  64122. * Sets the overall exposure used by the pipeline
  64123. */
  64124. exposure: number;
  64125. /**
  64126. * Texture used typically to simulate "dirty" on camera lens
  64127. */
  64128. lensTexture: Nullable<Texture>;
  64129. /**
  64130. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64131. */
  64132. volumetricLightCoefficient: number;
  64133. /**
  64134. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64135. */
  64136. volumetricLightPower: number;
  64137. /**
  64138. * Used the set the blur intensity to smooth the volumetric lights
  64139. */
  64140. volumetricLightBlurScale: number;
  64141. /**
  64142. * Light (spot or directional) used to generate the volumetric lights rays
  64143. * The source light must have a shadow generate so the pipeline can get its
  64144. * depth map
  64145. */
  64146. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64147. /**
  64148. * For eye adaptation, represents the minimum luminance the eye can see
  64149. */
  64150. hdrMinimumLuminance: number;
  64151. /**
  64152. * For eye adaptation, represents the decrease luminance speed
  64153. */
  64154. hdrDecreaseRate: number;
  64155. /**
  64156. * For eye adaptation, represents the increase luminance speed
  64157. */
  64158. hdrIncreaseRate: number;
  64159. /**
  64160. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64161. */
  64162. /**
  64163. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64164. */
  64165. hdrAutoExposure: boolean;
  64166. /**
  64167. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64168. */
  64169. lensColorTexture: Nullable<Texture>;
  64170. /**
  64171. * The overall strengh for the lens flare effect
  64172. */
  64173. lensFlareStrength: number;
  64174. /**
  64175. * Dispersion coefficient for lens flare ghosts
  64176. */
  64177. lensFlareGhostDispersal: number;
  64178. /**
  64179. * Main lens flare halo width
  64180. */
  64181. lensFlareHaloWidth: number;
  64182. /**
  64183. * Based on the lens distortion effect, defines how much the lens flare result
  64184. * is distorted
  64185. */
  64186. lensFlareDistortionStrength: number;
  64187. /**
  64188. * Configures the blur intensity used for for lens flare (halo)
  64189. */
  64190. lensFlareBlurWidth: number;
  64191. /**
  64192. * Lens star texture must be used to simulate rays on the flares and is available
  64193. * in the documentation
  64194. */
  64195. lensStarTexture: Nullable<Texture>;
  64196. /**
  64197. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64198. * flare effect by taking account of the dirt texture
  64199. */
  64200. lensFlareDirtTexture: Nullable<Texture>;
  64201. /**
  64202. * Represents the focal length for the depth of field effect
  64203. */
  64204. depthOfFieldDistance: number;
  64205. /**
  64206. * Represents the blur intensity for the blurred part of the depth of field effect
  64207. */
  64208. depthOfFieldBlurWidth: number;
  64209. /**
  64210. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64211. */
  64212. /**
  64213. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64214. */
  64215. motionStrength: number;
  64216. /**
  64217. * Gets wether or not the motion blur post-process is object based or screen based.
  64218. */
  64219. /**
  64220. * Sets wether or not the motion blur post-process should be object based or screen based
  64221. */
  64222. objectBasedMotionBlur: boolean;
  64223. /**
  64224. * List of animations for the pipeline (IAnimatable implementation)
  64225. */
  64226. animations: Animation[];
  64227. /**
  64228. * Private members
  64229. */
  64230. private _scene;
  64231. private _currentDepthOfFieldSource;
  64232. private _basePostProcess;
  64233. private _fixedExposure;
  64234. private _currentExposure;
  64235. private _hdrAutoExposure;
  64236. private _hdrCurrentLuminance;
  64237. private _motionStrength;
  64238. private _isObjectBasedMotionBlur;
  64239. private _floatTextureType;
  64240. private _camerasToBeAttached;
  64241. private _ratio;
  64242. private _bloomEnabled;
  64243. private _depthOfFieldEnabled;
  64244. private _vlsEnabled;
  64245. private _lensFlareEnabled;
  64246. private _hdrEnabled;
  64247. private _motionBlurEnabled;
  64248. private _fxaaEnabled;
  64249. private _motionBlurSamples;
  64250. private _volumetricLightStepsCount;
  64251. private _samples;
  64252. /**
  64253. * @ignore
  64254. * Specifies if the bloom pipeline is enabled
  64255. */
  64256. BloomEnabled: boolean;
  64257. /**
  64258. * @ignore
  64259. * Specifies if the depth of field pipeline is enabed
  64260. */
  64261. DepthOfFieldEnabled: boolean;
  64262. /**
  64263. * @ignore
  64264. * Specifies if the lens flare pipeline is enabed
  64265. */
  64266. LensFlareEnabled: boolean;
  64267. /**
  64268. * @ignore
  64269. * Specifies if the HDR pipeline is enabled
  64270. */
  64271. HDREnabled: boolean;
  64272. /**
  64273. * @ignore
  64274. * Specifies if the volumetric lights scattering effect is enabled
  64275. */
  64276. VLSEnabled: boolean;
  64277. /**
  64278. * @ignore
  64279. * Specifies if the motion blur effect is enabled
  64280. */
  64281. MotionBlurEnabled: boolean;
  64282. /**
  64283. * Specifies if anti-aliasing is enabled
  64284. */
  64285. fxaaEnabled: boolean;
  64286. /**
  64287. * Specifies the number of steps used to calculate the volumetric lights
  64288. * Typically in interval [50, 200]
  64289. */
  64290. volumetricLightStepsCount: number;
  64291. /**
  64292. * Specifies the number of samples used for the motion blur effect
  64293. * Typically in interval [16, 64]
  64294. */
  64295. motionBlurSamples: number;
  64296. /**
  64297. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64298. */
  64299. samples: number;
  64300. /**
  64301. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64302. * @constructor
  64303. * @param name The rendering pipeline name
  64304. * @param scene The scene linked to this pipeline
  64305. * @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)
  64306. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64307. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64308. */
  64309. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64310. private _buildPipeline;
  64311. private _createDownSampleX4PostProcess;
  64312. private _createBrightPassPostProcess;
  64313. private _createBlurPostProcesses;
  64314. private _createTextureAdderPostProcess;
  64315. private _createVolumetricLightPostProcess;
  64316. private _createLuminancePostProcesses;
  64317. private _createHdrPostProcess;
  64318. private _createLensFlarePostProcess;
  64319. private _createDepthOfFieldPostProcess;
  64320. private _createMotionBlurPostProcess;
  64321. private _getDepthTexture;
  64322. private _disposePostProcesses;
  64323. /**
  64324. * Dispose of the pipeline and stop all post processes
  64325. */
  64326. dispose(): void;
  64327. /**
  64328. * Serialize the rendering pipeline (Used when exporting)
  64329. * @returns the serialized object
  64330. */
  64331. serialize(): any;
  64332. /**
  64333. * Parse the serialized pipeline
  64334. * @param source Source pipeline.
  64335. * @param scene The scene to load the pipeline to.
  64336. * @param rootUrl The URL of the serialized pipeline.
  64337. * @returns An instantiated pipeline from the serialized object.
  64338. */
  64339. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64340. /**
  64341. * Luminance steps
  64342. */
  64343. static LuminanceSteps: number;
  64344. }
  64345. }
  64346. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64347. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64348. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64349. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64350. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64351. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64352. }
  64353. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64354. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64355. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64356. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64357. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64358. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64359. }
  64360. declare module "babylonjs/Shaders/tonemap.fragment" {
  64361. /** @hidden */
  64362. export var tonemapPixelShader: {
  64363. name: string;
  64364. shader: string;
  64365. };
  64366. }
  64367. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64368. import { Camera } from "babylonjs/Cameras/camera";
  64369. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64370. import "babylonjs/Shaders/tonemap.fragment";
  64371. import { Engine } from "babylonjs/Engines/engine";
  64372. /** Defines operator used for tonemapping */
  64373. export enum TonemappingOperator {
  64374. /** Hable */
  64375. Hable = 0,
  64376. /** Reinhard */
  64377. Reinhard = 1,
  64378. /** HejiDawson */
  64379. HejiDawson = 2,
  64380. /** Photographic */
  64381. Photographic = 3
  64382. }
  64383. /**
  64384. * Defines a post process to apply tone mapping
  64385. */
  64386. export class TonemapPostProcess extends PostProcess {
  64387. private _operator;
  64388. /** Defines the required exposure adjustement */
  64389. exposureAdjustment: number;
  64390. /**
  64391. * Creates a new TonemapPostProcess
  64392. * @param name defines the name of the postprocess
  64393. * @param _operator defines the operator to use
  64394. * @param exposureAdjustment defines the required exposure adjustement
  64395. * @param camera defines the camera to use (can be null)
  64396. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64397. * @param engine defines the hosting engine (can be ignore if camera is set)
  64398. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64399. */
  64400. constructor(name: string, _operator: TonemappingOperator,
  64401. /** Defines the required exposure adjustement */
  64402. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64403. }
  64404. }
  64405. declare module "babylonjs/Shaders/depth.vertex" {
  64406. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64409. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64411. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64412. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64413. /** @hidden */
  64414. export var depthVertexShader: {
  64415. name: string;
  64416. shader: string;
  64417. };
  64418. }
  64419. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64420. /** @hidden */
  64421. export var volumetricLightScatteringPixelShader: {
  64422. name: string;
  64423. shader: string;
  64424. };
  64425. }
  64426. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64427. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64429. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64430. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64431. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64432. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64433. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64434. /** @hidden */
  64435. export var volumetricLightScatteringPassVertexShader: {
  64436. name: string;
  64437. shader: string;
  64438. };
  64439. }
  64440. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64441. /** @hidden */
  64442. export var volumetricLightScatteringPassPixelShader: {
  64443. name: string;
  64444. shader: string;
  64445. };
  64446. }
  64447. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64448. import { Vector3 } from "babylonjs/Maths/math.vector";
  64449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64450. import { Mesh } from "babylonjs/Meshes/mesh";
  64451. import { Camera } from "babylonjs/Cameras/camera";
  64452. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64453. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64454. import { Scene } from "babylonjs/scene";
  64455. import "babylonjs/Meshes/Builders/planeBuilder";
  64456. import "babylonjs/Shaders/depth.vertex";
  64457. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64458. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64459. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64460. import { Engine } from "babylonjs/Engines/engine";
  64461. /**
  64462. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64463. */
  64464. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64465. private _volumetricLightScatteringPass;
  64466. private _volumetricLightScatteringRTT;
  64467. private _viewPort;
  64468. private _screenCoordinates;
  64469. private _cachedDefines;
  64470. /**
  64471. * If not undefined, the mesh position is computed from the attached node position
  64472. */
  64473. attachedNode: {
  64474. position: Vector3;
  64475. };
  64476. /**
  64477. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64478. */
  64479. customMeshPosition: Vector3;
  64480. /**
  64481. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64482. */
  64483. useCustomMeshPosition: boolean;
  64484. /**
  64485. * If the post-process should inverse the light scattering direction
  64486. */
  64487. invert: boolean;
  64488. /**
  64489. * The internal mesh used by the post-process
  64490. */
  64491. mesh: Mesh;
  64492. /**
  64493. * @hidden
  64494. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64495. */
  64496. useDiffuseColor: boolean;
  64497. /**
  64498. * Array containing the excluded meshes not rendered in the internal pass
  64499. */
  64500. excludedMeshes: AbstractMesh[];
  64501. /**
  64502. * Controls the overall intensity of the post-process
  64503. */
  64504. exposure: number;
  64505. /**
  64506. * Dissipates each sample's contribution in range [0, 1]
  64507. */
  64508. decay: number;
  64509. /**
  64510. * Controls the overall intensity of each sample
  64511. */
  64512. weight: number;
  64513. /**
  64514. * Controls the density of each sample
  64515. */
  64516. density: number;
  64517. /**
  64518. * @constructor
  64519. * @param name The post-process name
  64520. * @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)
  64521. * @param camera The camera that the post-process will be attached to
  64522. * @param mesh The mesh used to create the light scattering
  64523. * @param samples The post-process quality, default 100
  64524. * @param samplingModeThe post-process filtering mode
  64525. * @param engine The babylon engine
  64526. * @param reusable If the post-process is reusable
  64527. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64528. */
  64529. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64530. /**
  64531. * Returns the string "VolumetricLightScatteringPostProcess"
  64532. * @returns "VolumetricLightScatteringPostProcess"
  64533. */
  64534. getClassName(): string;
  64535. private _isReady;
  64536. /**
  64537. * Sets the new light position for light scattering effect
  64538. * @param position The new custom light position
  64539. */
  64540. setCustomMeshPosition(position: Vector3): void;
  64541. /**
  64542. * Returns the light position for light scattering effect
  64543. * @return Vector3 The custom light position
  64544. */
  64545. getCustomMeshPosition(): Vector3;
  64546. /**
  64547. * Disposes the internal assets and detaches the post-process from the camera
  64548. */
  64549. dispose(camera: Camera): void;
  64550. /**
  64551. * Returns the render target texture used by the post-process
  64552. * @return the render target texture used by the post-process
  64553. */
  64554. getPass(): RenderTargetTexture;
  64555. private _meshExcluded;
  64556. private _createPass;
  64557. private _updateMeshScreenCoordinates;
  64558. /**
  64559. * Creates a default mesh for the Volumeric Light Scattering post-process
  64560. * @param name The mesh name
  64561. * @param scene The scene where to create the mesh
  64562. * @return the default mesh
  64563. */
  64564. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64565. }
  64566. }
  64567. declare module "babylonjs/PostProcesses/index" {
  64568. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64569. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64570. export * from "babylonjs/PostProcesses/bloomEffect";
  64571. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64572. export * from "babylonjs/PostProcesses/blurPostProcess";
  64573. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64574. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64575. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64576. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64577. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64578. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64579. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64580. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64581. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64582. export * from "babylonjs/PostProcesses/filterPostProcess";
  64583. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64584. export * from "babylonjs/PostProcesses/grainPostProcess";
  64585. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64586. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64587. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64588. export * from "babylonjs/PostProcesses/passPostProcess";
  64589. export * from "babylonjs/PostProcesses/postProcess";
  64590. export * from "babylonjs/PostProcesses/postProcessManager";
  64591. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64592. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64593. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64594. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64595. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64596. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64597. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64598. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64599. }
  64600. declare module "babylonjs/Probes/index" {
  64601. export * from "babylonjs/Probes/reflectionProbe";
  64602. }
  64603. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64604. import { Scene } from "babylonjs/scene";
  64605. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64606. import { SmartArray } from "babylonjs/Misc/smartArray";
  64607. import { ISceneComponent } from "babylonjs/sceneComponent";
  64608. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64609. import "babylonjs/Meshes/Builders/boxBuilder";
  64610. import "babylonjs/Shaders/color.fragment";
  64611. import "babylonjs/Shaders/color.vertex";
  64612. import { Color3 } from "babylonjs/Maths/math.color";
  64613. module "babylonjs/scene" {
  64614. interface Scene {
  64615. /** @hidden (Backing field) */
  64616. _boundingBoxRenderer: BoundingBoxRenderer;
  64617. /** @hidden (Backing field) */
  64618. _forceShowBoundingBoxes: boolean;
  64619. /**
  64620. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64621. */
  64622. forceShowBoundingBoxes: boolean;
  64623. /**
  64624. * Gets the bounding box renderer associated with the scene
  64625. * @returns a BoundingBoxRenderer
  64626. */
  64627. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64628. }
  64629. }
  64630. module "babylonjs/Meshes/abstractMesh" {
  64631. interface AbstractMesh {
  64632. /** @hidden (Backing field) */
  64633. _showBoundingBox: boolean;
  64634. /**
  64635. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64636. */
  64637. showBoundingBox: boolean;
  64638. }
  64639. }
  64640. /**
  64641. * Component responsible of rendering the bounding box of the meshes in a scene.
  64642. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64643. */
  64644. export class BoundingBoxRenderer implements ISceneComponent {
  64645. /**
  64646. * The component name helpfull to identify the component in the list of scene components.
  64647. */
  64648. readonly name: string;
  64649. /**
  64650. * The scene the component belongs to.
  64651. */
  64652. scene: Scene;
  64653. /**
  64654. * Color of the bounding box lines placed in front of an object
  64655. */
  64656. frontColor: Color3;
  64657. /**
  64658. * Color of the bounding box lines placed behind an object
  64659. */
  64660. backColor: Color3;
  64661. /**
  64662. * Defines if the renderer should show the back lines or not
  64663. */
  64664. showBackLines: boolean;
  64665. /**
  64666. * @hidden
  64667. */
  64668. renderList: SmartArray<BoundingBox>;
  64669. private _colorShader;
  64670. private _vertexBuffers;
  64671. private _indexBuffer;
  64672. private _fillIndexBuffer;
  64673. private _fillIndexData;
  64674. /**
  64675. * Instantiates a new bounding box renderer in a scene.
  64676. * @param scene the scene the renderer renders in
  64677. */
  64678. constructor(scene: Scene);
  64679. /**
  64680. * Registers the component in a given scene
  64681. */
  64682. register(): void;
  64683. private _evaluateSubMesh;
  64684. private _activeMesh;
  64685. private _prepareRessources;
  64686. private _createIndexBuffer;
  64687. /**
  64688. * Rebuilds the elements related to this component in case of
  64689. * context lost for instance.
  64690. */
  64691. rebuild(): void;
  64692. /**
  64693. * @hidden
  64694. */
  64695. reset(): void;
  64696. /**
  64697. * Render the bounding boxes of a specific rendering group
  64698. * @param renderingGroupId defines the rendering group to render
  64699. */
  64700. render(renderingGroupId: number): void;
  64701. /**
  64702. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64703. * @param mesh Define the mesh to render the occlusion bounding box for
  64704. */
  64705. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64706. /**
  64707. * Dispose and release the resources attached to this renderer.
  64708. */
  64709. dispose(): void;
  64710. }
  64711. }
  64712. declare module "babylonjs/Shaders/depth.fragment" {
  64713. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64714. /** @hidden */
  64715. export var depthPixelShader: {
  64716. name: string;
  64717. shader: string;
  64718. };
  64719. }
  64720. declare module "babylonjs/Rendering/depthRenderer" {
  64721. import { Nullable } from "babylonjs/types";
  64722. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64723. import { Scene } from "babylonjs/scene";
  64724. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64725. import { Camera } from "babylonjs/Cameras/camera";
  64726. import "babylonjs/Shaders/depth.fragment";
  64727. import "babylonjs/Shaders/depth.vertex";
  64728. /**
  64729. * This represents a depth renderer in Babylon.
  64730. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64731. */
  64732. export class DepthRenderer {
  64733. private _scene;
  64734. private _depthMap;
  64735. private _effect;
  64736. private readonly _storeNonLinearDepth;
  64737. private readonly _clearColor;
  64738. /** Get if the depth renderer is using packed depth or not */
  64739. readonly isPacked: boolean;
  64740. private _cachedDefines;
  64741. private _camera;
  64742. /**
  64743. * Specifiess that the depth renderer will only be used within
  64744. * the camera it is created for.
  64745. * This can help forcing its rendering during the camera processing.
  64746. */
  64747. useOnlyInActiveCamera: boolean;
  64748. /** @hidden */
  64749. static _SceneComponentInitialization: (scene: Scene) => void;
  64750. /**
  64751. * Instantiates a depth renderer
  64752. * @param scene The scene the renderer belongs to
  64753. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64754. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64755. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64756. */
  64757. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64758. /**
  64759. * Creates the depth rendering effect and checks if the effect is ready.
  64760. * @param subMesh The submesh to be used to render the depth map of
  64761. * @param useInstances If multiple world instances should be used
  64762. * @returns if the depth renderer is ready to render the depth map
  64763. */
  64764. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64765. /**
  64766. * Gets the texture which the depth map will be written to.
  64767. * @returns The depth map texture
  64768. */
  64769. getDepthMap(): RenderTargetTexture;
  64770. /**
  64771. * Disposes of the depth renderer.
  64772. */
  64773. dispose(): void;
  64774. }
  64775. }
  64776. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64777. import { Nullable } from "babylonjs/types";
  64778. import { Scene } from "babylonjs/scene";
  64779. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64780. import { Camera } from "babylonjs/Cameras/camera";
  64781. import { ISceneComponent } from "babylonjs/sceneComponent";
  64782. module "babylonjs/scene" {
  64783. interface Scene {
  64784. /** @hidden (Backing field) */
  64785. _depthRenderer: {
  64786. [id: string]: DepthRenderer;
  64787. };
  64788. /**
  64789. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64790. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64791. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64792. * @returns the created depth renderer
  64793. */
  64794. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64795. /**
  64796. * Disables a depth renderer for a given camera
  64797. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64798. */
  64799. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64800. }
  64801. }
  64802. /**
  64803. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64804. * in several rendering techniques.
  64805. */
  64806. export class DepthRendererSceneComponent implements ISceneComponent {
  64807. /**
  64808. * The component name helpfull to identify the component in the list of scene components.
  64809. */
  64810. readonly name: string;
  64811. /**
  64812. * The scene the component belongs to.
  64813. */
  64814. scene: Scene;
  64815. /**
  64816. * Creates a new instance of the component for the given scene
  64817. * @param scene Defines the scene to register the component in
  64818. */
  64819. constructor(scene: Scene);
  64820. /**
  64821. * Registers the component in a given scene
  64822. */
  64823. register(): void;
  64824. /**
  64825. * Rebuilds the elements related to this component in case of
  64826. * context lost for instance.
  64827. */
  64828. rebuild(): void;
  64829. /**
  64830. * Disposes the component and the associated ressources
  64831. */
  64832. dispose(): void;
  64833. private _gatherRenderTargets;
  64834. private _gatherActiveCameraRenderTargets;
  64835. }
  64836. }
  64837. declare module "babylonjs/Shaders/outline.fragment" {
  64838. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64839. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64840. /** @hidden */
  64841. export var outlinePixelShader: {
  64842. name: string;
  64843. shader: string;
  64844. };
  64845. }
  64846. declare module "babylonjs/Shaders/outline.vertex" {
  64847. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64848. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64849. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64850. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64851. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64852. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64853. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64854. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64855. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64856. /** @hidden */
  64857. export var outlineVertexShader: {
  64858. name: string;
  64859. shader: string;
  64860. };
  64861. }
  64862. declare module "babylonjs/Rendering/outlineRenderer" {
  64863. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64864. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64865. import { Scene } from "babylonjs/scene";
  64866. import { ISceneComponent } from "babylonjs/sceneComponent";
  64867. import "babylonjs/Shaders/outline.fragment";
  64868. import "babylonjs/Shaders/outline.vertex";
  64869. module "babylonjs/scene" {
  64870. interface Scene {
  64871. /** @hidden */
  64872. _outlineRenderer: OutlineRenderer;
  64873. /**
  64874. * Gets the outline renderer associated with the scene
  64875. * @returns a OutlineRenderer
  64876. */
  64877. getOutlineRenderer(): OutlineRenderer;
  64878. }
  64879. }
  64880. module "babylonjs/Meshes/abstractMesh" {
  64881. interface AbstractMesh {
  64882. /** @hidden (Backing field) */
  64883. _renderOutline: boolean;
  64884. /**
  64885. * Gets or sets a boolean indicating if the outline must be rendered as well
  64886. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64887. */
  64888. renderOutline: boolean;
  64889. /** @hidden (Backing field) */
  64890. _renderOverlay: boolean;
  64891. /**
  64892. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64893. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64894. */
  64895. renderOverlay: boolean;
  64896. }
  64897. }
  64898. /**
  64899. * This class is responsible to draw bothe outline/overlay of meshes.
  64900. * It should not be used directly but through the available method on mesh.
  64901. */
  64902. export class OutlineRenderer implements ISceneComponent {
  64903. /**
  64904. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64905. */
  64906. private static _StencilReference;
  64907. /**
  64908. * The name of the component. Each component must have a unique name.
  64909. */
  64910. name: string;
  64911. /**
  64912. * The scene the component belongs to.
  64913. */
  64914. scene: Scene;
  64915. /**
  64916. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64917. */
  64918. zOffset: number;
  64919. private _engine;
  64920. private _effect;
  64921. private _cachedDefines;
  64922. private _savedDepthWrite;
  64923. /**
  64924. * Instantiates a new outline renderer. (There could be only one per scene).
  64925. * @param scene Defines the scene it belongs to
  64926. */
  64927. constructor(scene: Scene);
  64928. /**
  64929. * Register the component to one instance of a scene.
  64930. */
  64931. register(): void;
  64932. /**
  64933. * Rebuilds the elements related to this component in case of
  64934. * context lost for instance.
  64935. */
  64936. rebuild(): void;
  64937. /**
  64938. * Disposes the component and the associated ressources.
  64939. */
  64940. dispose(): void;
  64941. /**
  64942. * Renders the outline in the canvas.
  64943. * @param subMesh Defines the sumesh to render
  64944. * @param batch Defines the batch of meshes in case of instances
  64945. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64946. */
  64947. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64948. /**
  64949. * Returns whether or not the outline renderer is ready for a given submesh.
  64950. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64951. * @param subMesh Defines the submesh to check readyness for
  64952. * @param useInstances Defines wheter wee are trying to render instances or not
  64953. * @returns true if ready otherwise false
  64954. */
  64955. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64956. private _beforeRenderingMesh;
  64957. private _afterRenderingMesh;
  64958. }
  64959. }
  64960. declare module "babylonjs/Rendering/index" {
  64961. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64962. export * from "babylonjs/Rendering/depthRenderer";
  64963. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64964. export * from "babylonjs/Rendering/edgesRenderer";
  64965. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64966. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64967. export * from "babylonjs/Rendering/outlineRenderer";
  64968. export * from "babylonjs/Rendering/renderingGroup";
  64969. export * from "babylonjs/Rendering/renderingManager";
  64970. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64971. }
  64972. declare module "babylonjs/Sprites/spritePackedManager" {
  64973. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64974. import { Scene } from "babylonjs/scene";
  64975. /**
  64976. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64977. * @see http://doc.babylonjs.com/babylon101/sprites
  64978. */
  64979. export class SpritePackedManager extends SpriteManager {
  64980. /** defines the packed manager's name */
  64981. name: string;
  64982. /**
  64983. * Creates a new sprite manager from a packed sprite sheet
  64984. * @param name defines the manager's name
  64985. * @param imgUrl defines the sprite sheet url
  64986. * @param capacity defines the maximum allowed number of sprites
  64987. * @param scene defines the hosting scene
  64988. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64989. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64990. * @param samplingMode defines the smapling mode to use with spritesheet
  64991. * @param fromPacked set to true; do not alter
  64992. */
  64993. constructor(
  64994. /** defines the packed manager's name */
  64995. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64996. }
  64997. }
  64998. declare module "babylonjs/Sprites/index" {
  64999. export * from "babylonjs/Sprites/sprite";
  65000. export * from "babylonjs/Sprites/spriteManager";
  65001. export * from "babylonjs/Sprites/spritePackedManager";
  65002. export * from "babylonjs/Sprites/spriteSceneComponent";
  65003. }
  65004. declare module "babylonjs/States/index" {
  65005. export * from "babylonjs/States/alphaCullingState";
  65006. export * from "babylonjs/States/depthCullingState";
  65007. export * from "babylonjs/States/stencilState";
  65008. }
  65009. declare module "babylonjs/Misc/assetsManager" {
  65010. import { Scene } from "babylonjs/scene";
  65011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65012. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65013. import { Skeleton } from "babylonjs/Bones/skeleton";
  65014. import { Observable } from "babylonjs/Misc/observable";
  65015. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65016. import { Texture } from "babylonjs/Materials/Textures/texture";
  65017. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65018. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65019. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65020. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65021. /**
  65022. * Defines the list of states available for a task inside a AssetsManager
  65023. */
  65024. export enum AssetTaskState {
  65025. /**
  65026. * Initialization
  65027. */
  65028. INIT = 0,
  65029. /**
  65030. * Running
  65031. */
  65032. RUNNING = 1,
  65033. /**
  65034. * Done
  65035. */
  65036. DONE = 2,
  65037. /**
  65038. * Error
  65039. */
  65040. ERROR = 3
  65041. }
  65042. /**
  65043. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65044. */
  65045. export abstract class AbstractAssetTask {
  65046. /**
  65047. * Task name
  65048. */ name: string;
  65049. /**
  65050. * Callback called when the task is successful
  65051. */
  65052. onSuccess: (task: any) => void;
  65053. /**
  65054. * Callback called when the task is not successful
  65055. */
  65056. onError: (task: any, message?: string, exception?: any) => void;
  65057. /**
  65058. * Creates a new AssetsManager
  65059. * @param name defines the name of the task
  65060. */
  65061. constructor(
  65062. /**
  65063. * Task name
  65064. */ name: string);
  65065. private _isCompleted;
  65066. private _taskState;
  65067. private _errorObject;
  65068. /**
  65069. * Get if the task is completed
  65070. */
  65071. readonly isCompleted: boolean;
  65072. /**
  65073. * Gets the current state of the task
  65074. */
  65075. readonly taskState: AssetTaskState;
  65076. /**
  65077. * Gets the current error object (if task is in error)
  65078. */
  65079. readonly errorObject: {
  65080. message?: string;
  65081. exception?: any;
  65082. };
  65083. /**
  65084. * Internal only
  65085. * @hidden
  65086. */
  65087. _setErrorObject(message?: string, exception?: any): void;
  65088. /**
  65089. * Execute the current task
  65090. * @param scene defines the scene where you want your assets to be loaded
  65091. * @param onSuccess is a callback called when the task is successfully executed
  65092. * @param onError is a callback called if an error occurs
  65093. */
  65094. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65095. /**
  65096. * Execute the current task
  65097. * @param scene defines the scene where you want your assets to be loaded
  65098. * @param onSuccess is a callback called when the task is successfully executed
  65099. * @param onError is a callback called if an error occurs
  65100. */
  65101. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65102. /**
  65103. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65104. * This can be used with failed tasks that have the reason for failure fixed.
  65105. */
  65106. reset(): void;
  65107. private onErrorCallback;
  65108. private onDoneCallback;
  65109. }
  65110. /**
  65111. * Define the interface used by progress events raised during assets loading
  65112. */
  65113. export interface IAssetsProgressEvent {
  65114. /**
  65115. * Defines the number of remaining tasks to process
  65116. */
  65117. remainingCount: number;
  65118. /**
  65119. * Defines the total number of tasks
  65120. */
  65121. totalCount: number;
  65122. /**
  65123. * Defines the task that was just processed
  65124. */
  65125. task: AbstractAssetTask;
  65126. }
  65127. /**
  65128. * Class used to share progress information about assets loading
  65129. */
  65130. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65131. /**
  65132. * Defines the number of remaining tasks to process
  65133. */
  65134. remainingCount: number;
  65135. /**
  65136. * Defines the total number of tasks
  65137. */
  65138. totalCount: number;
  65139. /**
  65140. * Defines the task that was just processed
  65141. */
  65142. task: AbstractAssetTask;
  65143. /**
  65144. * Creates a AssetsProgressEvent
  65145. * @param remainingCount defines the number of remaining tasks to process
  65146. * @param totalCount defines the total number of tasks
  65147. * @param task defines the task that was just processed
  65148. */
  65149. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65150. }
  65151. /**
  65152. * Define a task used by AssetsManager to load meshes
  65153. */
  65154. export class MeshAssetTask extends AbstractAssetTask {
  65155. /**
  65156. * Defines the name of the task
  65157. */
  65158. name: string;
  65159. /**
  65160. * Defines the list of mesh's names you want to load
  65161. */
  65162. meshesNames: any;
  65163. /**
  65164. * Defines the root url to use as a base to load your meshes and associated resources
  65165. */
  65166. rootUrl: string;
  65167. /**
  65168. * Defines the filename of the scene to load from
  65169. */
  65170. sceneFilename: string;
  65171. /**
  65172. * Gets the list of loaded meshes
  65173. */
  65174. loadedMeshes: Array<AbstractMesh>;
  65175. /**
  65176. * Gets the list of loaded particle systems
  65177. */
  65178. loadedParticleSystems: Array<IParticleSystem>;
  65179. /**
  65180. * Gets the list of loaded skeletons
  65181. */
  65182. loadedSkeletons: Array<Skeleton>;
  65183. /**
  65184. * Gets the list of loaded animation groups
  65185. */
  65186. loadedAnimationGroups: Array<AnimationGroup>;
  65187. /**
  65188. * Callback called when the task is successful
  65189. */
  65190. onSuccess: (task: MeshAssetTask) => void;
  65191. /**
  65192. * Callback called when the task is successful
  65193. */
  65194. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65195. /**
  65196. * Creates a new MeshAssetTask
  65197. * @param name defines the name of the task
  65198. * @param meshesNames defines the list of mesh's names you want to load
  65199. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65200. * @param sceneFilename defines the filename of the scene to load from
  65201. */
  65202. constructor(
  65203. /**
  65204. * Defines the name of the task
  65205. */
  65206. name: string,
  65207. /**
  65208. * Defines the list of mesh's names you want to load
  65209. */
  65210. meshesNames: any,
  65211. /**
  65212. * Defines the root url to use as a base to load your meshes and associated resources
  65213. */
  65214. rootUrl: string,
  65215. /**
  65216. * Defines the filename of the scene to load from
  65217. */
  65218. sceneFilename: string);
  65219. /**
  65220. * Execute the current task
  65221. * @param scene defines the scene where you want your assets to be loaded
  65222. * @param onSuccess is a callback called when the task is successfully executed
  65223. * @param onError is a callback called if an error occurs
  65224. */
  65225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65226. }
  65227. /**
  65228. * Define a task used by AssetsManager to load text content
  65229. */
  65230. export class TextFileAssetTask extends AbstractAssetTask {
  65231. /**
  65232. * Defines the name of the task
  65233. */
  65234. name: string;
  65235. /**
  65236. * Defines the location of the file to load
  65237. */
  65238. url: string;
  65239. /**
  65240. * Gets the loaded text string
  65241. */
  65242. text: string;
  65243. /**
  65244. * Callback called when the task is successful
  65245. */
  65246. onSuccess: (task: TextFileAssetTask) => void;
  65247. /**
  65248. * Callback called when the task is successful
  65249. */
  65250. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65251. /**
  65252. * Creates a new TextFileAssetTask object
  65253. * @param name defines the name of the task
  65254. * @param url defines the location of the file to load
  65255. */
  65256. constructor(
  65257. /**
  65258. * Defines the name of the task
  65259. */
  65260. name: string,
  65261. /**
  65262. * Defines the location of the file to load
  65263. */
  65264. url: string);
  65265. /**
  65266. * Execute the current task
  65267. * @param scene defines the scene where you want your assets to be loaded
  65268. * @param onSuccess is a callback called when the task is successfully executed
  65269. * @param onError is a callback called if an error occurs
  65270. */
  65271. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65272. }
  65273. /**
  65274. * Define a task used by AssetsManager to load binary data
  65275. */
  65276. export class BinaryFileAssetTask extends AbstractAssetTask {
  65277. /**
  65278. * Defines the name of the task
  65279. */
  65280. name: string;
  65281. /**
  65282. * Defines the location of the file to load
  65283. */
  65284. url: string;
  65285. /**
  65286. * Gets the lodaded data (as an array buffer)
  65287. */
  65288. data: ArrayBuffer;
  65289. /**
  65290. * Callback called when the task is successful
  65291. */
  65292. onSuccess: (task: BinaryFileAssetTask) => void;
  65293. /**
  65294. * Callback called when the task is successful
  65295. */
  65296. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65297. /**
  65298. * Creates a new BinaryFileAssetTask object
  65299. * @param name defines the name of the new task
  65300. * @param url defines the location of the file to load
  65301. */
  65302. constructor(
  65303. /**
  65304. * Defines the name of the task
  65305. */
  65306. name: string,
  65307. /**
  65308. * Defines the location of the file to load
  65309. */
  65310. url: string);
  65311. /**
  65312. * Execute the current task
  65313. * @param scene defines the scene where you want your assets to be loaded
  65314. * @param onSuccess is a callback called when the task is successfully executed
  65315. * @param onError is a callback called if an error occurs
  65316. */
  65317. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65318. }
  65319. /**
  65320. * Define a task used by AssetsManager to load images
  65321. */
  65322. export class ImageAssetTask extends AbstractAssetTask {
  65323. /**
  65324. * Defines the name of the task
  65325. */
  65326. name: string;
  65327. /**
  65328. * Defines the location of the image to load
  65329. */
  65330. url: string;
  65331. /**
  65332. * Gets the loaded images
  65333. */
  65334. image: HTMLImageElement;
  65335. /**
  65336. * Callback called when the task is successful
  65337. */
  65338. onSuccess: (task: ImageAssetTask) => void;
  65339. /**
  65340. * Callback called when the task is successful
  65341. */
  65342. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65343. /**
  65344. * Creates a new ImageAssetTask
  65345. * @param name defines the name of the task
  65346. * @param url defines the location of the image to load
  65347. */
  65348. constructor(
  65349. /**
  65350. * Defines the name of the task
  65351. */
  65352. name: string,
  65353. /**
  65354. * Defines the location of the image to load
  65355. */
  65356. url: string);
  65357. /**
  65358. * Execute the current task
  65359. * @param scene defines the scene where you want your assets to be loaded
  65360. * @param onSuccess is a callback called when the task is successfully executed
  65361. * @param onError is a callback called if an error occurs
  65362. */
  65363. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65364. }
  65365. /**
  65366. * Defines the interface used by texture loading tasks
  65367. */
  65368. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65369. /**
  65370. * Gets the loaded texture
  65371. */
  65372. texture: TEX;
  65373. }
  65374. /**
  65375. * Define a task used by AssetsManager to load 2D textures
  65376. */
  65377. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65378. /**
  65379. * Defines the name of the task
  65380. */
  65381. name: string;
  65382. /**
  65383. * Defines the location of the file to load
  65384. */
  65385. url: string;
  65386. /**
  65387. * Defines if mipmap should not be generated (default is false)
  65388. */
  65389. noMipmap?: boolean | undefined;
  65390. /**
  65391. * Defines if texture must be inverted on Y axis (default is false)
  65392. */
  65393. invertY?: boolean | undefined;
  65394. /**
  65395. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65396. */
  65397. samplingMode: number;
  65398. /**
  65399. * Gets the loaded texture
  65400. */
  65401. texture: Texture;
  65402. /**
  65403. * Callback called when the task is successful
  65404. */
  65405. onSuccess: (task: TextureAssetTask) => void;
  65406. /**
  65407. * Callback called when the task is successful
  65408. */
  65409. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65410. /**
  65411. * Creates a new TextureAssetTask object
  65412. * @param name defines the name of the task
  65413. * @param url defines the location of the file to load
  65414. * @param noMipmap defines if mipmap should not be generated (default is false)
  65415. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65416. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65417. */
  65418. constructor(
  65419. /**
  65420. * Defines the name of the task
  65421. */
  65422. name: string,
  65423. /**
  65424. * Defines the location of the file to load
  65425. */
  65426. url: string,
  65427. /**
  65428. * Defines if mipmap should not be generated (default is false)
  65429. */
  65430. noMipmap?: boolean | undefined,
  65431. /**
  65432. * Defines if texture must be inverted on Y axis (default is false)
  65433. */
  65434. invertY?: boolean | undefined,
  65435. /**
  65436. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65437. */
  65438. samplingMode?: number);
  65439. /**
  65440. * Execute the current task
  65441. * @param scene defines the scene where you want your assets to be loaded
  65442. * @param onSuccess is a callback called when the task is successfully executed
  65443. * @param onError is a callback called if an error occurs
  65444. */
  65445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65446. }
  65447. /**
  65448. * Define a task used by AssetsManager to load cube textures
  65449. */
  65450. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65451. /**
  65452. * Defines the name of the task
  65453. */
  65454. name: string;
  65455. /**
  65456. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65457. */
  65458. url: string;
  65459. /**
  65460. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65461. */
  65462. extensions?: string[] | undefined;
  65463. /**
  65464. * Defines if mipmaps should not be generated (default is false)
  65465. */
  65466. noMipmap?: boolean | undefined;
  65467. /**
  65468. * Defines the explicit list of files (undefined by default)
  65469. */
  65470. files?: string[] | undefined;
  65471. /**
  65472. * Gets the loaded texture
  65473. */
  65474. texture: CubeTexture;
  65475. /**
  65476. * Callback called when the task is successful
  65477. */
  65478. onSuccess: (task: CubeTextureAssetTask) => void;
  65479. /**
  65480. * Callback called when the task is successful
  65481. */
  65482. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65483. /**
  65484. * Creates a new CubeTextureAssetTask
  65485. * @param name defines the name of the task
  65486. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65487. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65488. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65489. * @param files defines the explicit list of files (undefined by default)
  65490. */
  65491. constructor(
  65492. /**
  65493. * Defines the name of the task
  65494. */
  65495. name: string,
  65496. /**
  65497. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65498. */
  65499. url: string,
  65500. /**
  65501. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65502. */
  65503. extensions?: string[] | undefined,
  65504. /**
  65505. * Defines if mipmaps should not be generated (default is false)
  65506. */
  65507. noMipmap?: boolean | undefined,
  65508. /**
  65509. * Defines the explicit list of files (undefined by default)
  65510. */
  65511. files?: string[] | undefined);
  65512. /**
  65513. * Execute the current task
  65514. * @param scene defines the scene where you want your assets to be loaded
  65515. * @param onSuccess is a callback called when the task is successfully executed
  65516. * @param onError is a callback called if an error occurs
  65517. */
  65518. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65519. }
  65520. /**
  65521. * Define a task used by AssetsManager to load HDR cube textures
  65522. */
  65523. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65524. /**
  65525. * Defines the name of the task
  65526. */
  65527. name: string;
  65528. /**
  65529. * Defines the location of the file to load
  65530. */
  65531. url: string;
  65532. /**
  65533. * Defines the desired size (the more it increases the longer the generation will be)
  65534. */
  65535. size: number;
  65536. /**
  65537. * Defines if mipmaps should not be generated (default is false)
  65538. */
  65539. noMipmap: boolean;
  65540. /**
  65541. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65542. */
  65543. generateHarmonics: boolean;
  65544. /**
  65545. * 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)
  65546. */
  65547. gammaSpace: boolean;
  65548. /**
  65549. * Internal Use Only
  65550. */
  65551. reserved: boolean;
  65552. /**
  65553. * Gets the loaded texture
  65554. */
  65555. texture: HDRCubeTexture;
  65556. /**
  65557. * Callback called when the task is successful
  65558. */
  65559. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65560. /**
  65561. * Callback called when the task is successful
  65562. */
  65563. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65564. /**
  65565. * Creates a new HDRCubeTextureAssetTask object
  65566. * @param name defines the name of the task
  65567. * @param url defines the location of the file to load
  65568. * @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.
  65569. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65570. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65571. * @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)
  65572. * @param reserved Internal use only
  65573. */
  65574. constructor(
  65575. /**
  65576. * Defines the name of the task
  65577. */
  65578. name: string,
  65579. /**
  65580. * Defines the location of the file to load
  65581. */
  65582. url: string,
  65583. /**
  65584. * Defines the desired size (the more it increases the longer the generation will be)
  65585. */
  65586. size: number,
  65587. /**
  65588. * Defines if mipmaps should not be generated (default is false)
  65589. */
  65590. noMipmap?: boolean,
  65591. /**
  65592. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65593. */
  65594. generateHarmonics?: boolean,
  65595. /**
  65596. * 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)
  65597. */
  65598. gammaSpace?: boolean,
  65599. /**
  65600. * Internal Use Only
  65601. */
  65602. reserved?: boolean);
  65603. /**
  65604. * Execute the current task
  65605. * @param scene defines the scene where you want your assets to be loaded
  65606. * @param onSuccess is a callback called when the task is successfully executed
  65607. * @param onError is a callback called if an error occurs
  65608. */
  65609. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65610. }
  65611. /**
  65612. * Define a task used by AssetsManager to load Equirectangular cube textures
  65613. */
  65614. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65615. /**
  65616. * Defines the name of the task
  65617. */
  65618. name: string;
  65619. /**
  65620. * Defines the location of the file to load
  65621. */
  65622. url: string;
  65623. /**
  65624. * Defines the desired size (the more it increases the longer the generation will be)
  65625. */
  65626. size: number;
  65627. /**
  65628. * Defines if mipmaps should not be generated (default is false)
  65629. */
  65630. noMipmap: boolean;
  65631. /**
  65632. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65633. * but the standard material would require them in Gamma space) (default is true)
  65634. */
  65635. gammaSpace: boolean;
  65636. /**
  65637. * Gets the loaded texture
  65638. */
  65639. texture: EquiRectangularCubeTexture;
  65640. /**
  65641. * Callback called when the task is successful
  65642. */
  65643. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65644. /**
  65645. * Callback called when the task is successful
  65646. */
  65647. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65648. /**
  65649. * Creates a new EquiRectangularCubeTextureAssetTask object
  65650. * @param name defines the name of the task
  65651. * @param url defines the location of the file to load
  65652. * @param size defines the desired size (the more it increases the longer the generation will be)
  65653. * If the size is omitted this implies you are using a preprocessed cubemap.
  65654. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65655. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65656. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65657. * (default is true)
  65658. */
  65659. constructor(
  65660. /**
  65661. * Defines the name of the task
  65662. */
  65663. name: string,
  65664. /**
  65665. * Defines the location of the file to load
  65666. */
  65667. url: string,
  65668. /**
  65669. * Defines the desired size (the more it increases the longer the generation will be)
  65670. */
  65671. size: number,
  65672. /**
  65673. * Defines if mipmaps should not be generated (default is false)
  65674. */
  65675. noMipmap?: boolean,
  65676. /**
  65677. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65678. * but the standard material would require them in Gamma space) (default is true)
  65679. */
  65680. gammaSpace?: boolean);
  65681. /**
  65682. * Execute the current task
  65683. * @param scene defines the scene where you want your assets to be loaded
  65684. * @param onSuccess is a callback called when the task is successfully executed
  65685. * @param onError is a callback called if an error occurs
  65686. */
  65687. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65688. }
  65689. /**
  65690. * This class can be used to easily import assets into a scene
  65691. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65692. */
  65693. export class AssetsManager {
  65694. private _scene;
  65695. private _isLoading;
  65696. protected _tasks: AbstractAssetTask[];
  65697. protected _waitingTasksCount: number;
  65698. protected _totalTasksCount: number;
  65699. /**
  65700. * Callback called when all tasks are processed
  65701. */
  65702. onFinish: (tasks: AbstractAssetTask[]) => void;
  65703. /**
  65704. * Callback called when a task is successful
  65705. */
  65706. onTaskSuccess: (task: AbstractAssetTask) => void;
  65707. /**
  65708. * Callback called when a task had an error
  65709. */
  65710. onTaskError: (task: AbstractAssetTask) => void;
  65711. /**
  65712. * Callback called when a task is done (whatever the result is)
  65713. */
  65714. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65715. /**
  65716. * Observable called when all tasks are processed
  65717. */
  65718. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65719. /**
  65720. * Observable called when a task had an error
  65721. */
  65722. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65723. /**
  65724. * Observable called when all tasks were executed
  65725. */
  65726. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65727. /**
  65728. * Observable called when a task is done (whatever the result is)
  65729. */
  65730. onProgressObservable: Observable<IAssetsProgressEvent>;
  65731. /**
  65732. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65733. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65734. */
  65735. useDefaultLoadingScreen: boolean;
  65736. /**
  65737. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65738. * when all assets have been downloaded.
  65739. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65740. */
  65741. autoHideLoadingUI: boolean;
  65742. /**
  65743. * Creates a new AssetsManager
  65744. * @param scene defines the scene to work on
  65745. */
  65746. constructor(scene: Scene);
  65747. /**
  65748. * Add a MeshAssetTask to the list of active tasks
  65749. * @param taskName defines the name of the new task
  65750. * @param meshesNames defines the name of meshes to load
  65751. * @param rootUrl defines the root url to use to locate files
  65752. * @param sceneFilename defines the filename of the scene file
  65753. * @returns a new MeshAssetTask object
  65754. */
  65755. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65756. /**
  65757. * Add a TextFileAssetTask to the list of active tasks
  65758. * @param taskName defines the name of the new task
  65759. * @param url defines the url of the file to load
  65760. * @returns a new TextFileAssetTask object
  65761. */
  65762. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65763. /**
  65764. * Add a BinaryFileAssetTask to the list of active tasks
  65765. * @param taskName defines the name of the new task
  65766. * @param url defines the url of the file to load
  65767. * @returns a new BinaryFileAssetTask object
  65768. */
  65769. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65770. /**
  65771. * Add a ImageAssetTask to the list of active tasks
  65772. * @param taskName defines the name of the new task
  65773. * @param url defines the url of the file to load
  65774. * @returns a new ImageAssetTask object
  65775. */
  65776. addImageTask(taskName: string, url: string): ImageAssetTask;
  65777. /**
  65778. * Add a TextureAssetTask to the list of active tasks
  65779. * @param taskName defines the name of the new task
  65780. * @param url defines the url of the file to load
  65781. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65782. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65783. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65784. * @returns a new TextureAssetTask object
  65785. */
  65786. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65787. /**
  65788. * Add a CubeTextureAssetTask to the list of active tasks
  65789. * @param taskName defines the name of the new task
  65790. * @param url defines the url of the file to load
  65791. * @param extensions defines the extension to use to load the cube map (can be null)
  65792. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65793. * @param files defines the list of files to load (can be null)
  65794. * @returns a new CubeTextureAssetTask object
  65795. */
  65796. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65797. /**
  65798. *
  65799. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65800. * @param taskName defines the name of the new task
  65801. * @param url defines the url of the file to load
  65802. * @param size defines the size you want for the cubemap (can be null)
  65803. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65804. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65805. * @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)
  65806. * @param reserved Internal use only
  65807. * @returns a new HDRCubeTextureAssetTask object
  65808. */
  65809. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65810. /**
  65811. *
  65812. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65813. * @param taskName defines the name of the new task
  65814. * @param url defines the url of the file to load
  65815. * @param size defines the size you want for the cubemap (can be null)
  65816. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65817. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65818. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65819. * @returns a new EquiRectangularCubeTextureAssetTask object
  65820. */
  65821. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65822. /**
  65823. * Remove a task from the assets manager.
  65824. * @param task the task to remove
  65825. */
  65826. removeTask(task: AbstractAssetTask): void;
  65827. private _decreaseWaitingTasksCount;
  65828. private _runTask;
  65829. /**
  65830. * Reset the AssetsManager and remove all tasks
  65831. * @return the current instance of the AssetsManager
  65832. */
  65833. reset(): AssetsManager;
  65834. /**
  65835. * Start the loading process
  65836. * @return the current instance of the AssetsManager
  65837. */
  65838. load(): AssetsManager;
  65839. /**
  65840. * Start the loading process as an async operation
  65841. * @return a promise returning the list of failed tasks
  65842. */
  65843. loadAsync(): Promise<void>;
  65844. }
  65845. }
  65846. declare module "babylonjs/Misc/deferred" {
  65847. /**
  65848. * Wrapper class for promise with external resolve and reject.
  65849. */
  65850. export class Deferred<T> {
  65851. /**
  65852. * The promise associated with this deferred object.
  65853. */
  65854. readonly promise: Promise<T>;
  65855. private _resolve;
  65856. private _reject;
  65857. /**
  65858. * The resolve method of the promise associated with this deferred object.
  65859. */
  65860. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65861. /**
  65862. * The reject method of the promise associated with this deferred object.
  65863. */
  65864. readonly reject: (reason?: any) => void;
  65865. /**
  65866. * Constructor for this deferred object.
  65867. */
  65868. constructor();
  65869. }
  65870. }
  65871. declare module "babylonjs/Misc/meshExploder" {
  65872. import { Mesh } from "babylonjs/Meshes/mesh";
  65873. /**
  65874. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65875. */
  65876. export class MeshExploder {
  65877. private _centerMesh;
  65878. private _meshes;
  65879. private _meshesOrigins;
  65880. private _toCenterVectors;
  65881. private _scaledDirection;
  65882. private _newPosition;
  65883. private _centerPosition;
  65884. /**
  65885. * Explodes meshes from a center mesh.
  65886. * @param meshes The meshes to explode.
  65887. * @param centerMesh The mesh to be center of explosion.
  65888. */
  65889. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65890. private _setCenterMesh;
  65891. /**
  65892. * Get class name
  65893. * @returns "MeshExploder"
  65894. */
  65895. getClassName(): string;
  65896. /**
  65897. * "Exploded meshes"
  65898. * @returns Array of meshes with the centerMesh at index 0.
  65899. */
  65900. getMeshes(): Array<Mesh>;
  65901. /**
  65902. * Explodes meshes giving a specific direction
  65903. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65904. */
  65905. explode(direction?: number): void;
  65906. }
  65907. }
  65908. declare module "babylonjs/Misc/filesInput" {
  65909. import { Engine } from "babylonjs/Engines/engine";
  65910. import { Scene } from "babylonjs/scene";
  65911. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65912. /**
  65913. * Class used to help managing file picking and drag'n'drop
  65914. */
  65915. export class FilesInput {
  65916. /**
  65917. * List of files ready to be loaded
  65918. */
  65919. static readonly FilesToLoad: {
  65920. [key: string]: File;
  65921. };
  65922. /**
  65923. * Callback called when a file is processed
  65924. */
  65925. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65926. private _engine;
  65927. private _currentScene;
  65928. private _sceneLoadedCallback;
  65929. private _progressCallback;
  65930. private _additionalRenderLoopLogicCallback;
  65931. private _textureLoadingCallback;
  65932. private _startingProcessingFilesCallback;
  65933. private _onReloadCallback;
  65934. private _errorCallback;
  65935. private _elementToMonitor;
  65936. private _sceneFileToLoad;
  65937. private _filesToLoad;
  65938. /**
  65939. * Creates a new FilesInput
  65940. * @param engine defines the rendering engine
  65941. * @param scene defines the hosting scene
  65942. * @param sceneLoadedCallback callback called when scene is loaded
  65943. * @param progressCallback callback called to track progress
  65944. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65945. * @param textureLoadingCallback callback called when a texture is loading
  65946. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65947. * @param onReloadCallback callback called when a reload is requested
  65948. * @param errorCallback callback call if an error occurs
  65949. */
  65950. 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);
  65951. private _dragEnterHandler;
  65952. private _dragOverHandler;
  65953. private _dropHandler;
  65954. /**
  65955. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65956. * @param elementToMonitor defines the DOM element to track
  65957. */
  65958. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65959. /**
  65960. * Release all associated resources
  65961. */
  65962. dispose(): void;
  65963. private renderFunction;
  65964. private drag;
  65965. private drop;
  65966. private _traverseFolder;
  65967. private _processFiles;
  65968. /**
  65969. * Load files from a drop event
  65970. * @param event defines the drop event to use as source
  65971. */
  65972. loadFiles(event: any): void;
  65973. private _processReload;
  65974. /**
  65975. * Reload the current scene from the loaded files
  65976. */
  65977. reload(): void;
  65978. }
  65979. }
  65980. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65981. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65982. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65983. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65984. }
  65985. declare module "babylonjs/Misc/sceneOptimizer" {
  65986. import { Scene, IDisposable } from "babylonjs/scene";
  65987. import { Observable } from "babylonjs/Misc/observable";
  65988. /**
  65989. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65990. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65991. */
  65992. export class SceneOptimization {
  65993. /**
  65994. * Defines the priority of this optimization (0 by default which means first in the list)
  65995. */
  65996. priority: number;
  65997. /**
  65998. * Gets a string describing the action executed by the current optimization
  65999. * @returns description string
  66000. */
  66001. getDescription(): string;
  66002. /**
  66003. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66004. * @param scene defines the current scene where to apply this optimization
  66005. * @param optimizer defines the current optimizer
  66006. * @returns true if everything that can be done was applied
  66007. */
  66008. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66009. /**
  66010. * Creates the SceneOptimization object
  66011. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66012. * @param desc defines the description associated with the optimization
  66013. */
  66014. constructor(
  66015. /**
  66016. * Defines the priority of this optimization (0 by default which means first in the list)
  66017. */
  66018. priority?: number);
  66019. }
  66020. /**
  66021. * Defines an optimization used to reduce the size of render target textures
  66022. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66023. */
  66024. export class TextureOptimization extends SceneOptimization {
  66025. /**
  66026. * Defines the priority of this optimization (0 by default which means first in the list)
  66027. */
  66028. priority: number;
  66029. /**
  66030. * 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
  66031. */
  66032. maximumSize: number;
  66033. /**
  66034. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66035. */
  66036. step: number;
  66037. /**
  66038. * Gets a string describing the action executed by the current optimization
  66039. * @returns description string
  66040. */
  66041. getDescription(): string;
  66042. /**
  66043. * Creates the TextureOptimization object
  66044. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66045. * @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
  66046. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66047. */
  66048. constructor(
  66049. /**
  66050. * Defines the priority of this optimization (0 by default which means first in the list)
  66051. */
  66052. priority?: number,
  66053. /**
  66054. * 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
  66055. */
  66056. maximumSize?: number,
  66057. /**
  66058. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66059. */
  66060. step?: number);
  66061. /**
  66062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66063. * @param scene defines the current scene where to apply this optimization
  66064. * @param optimizer defines the current optimizer
  66065. * @returns true if everything that can be done was applied
  66066. */
  66067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66068. }
  66069. /**
  66070. * Defines an optimization used to increase or decrease the rendering resolution
  66071. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66072. */
  66073. export class HardwareScalingOptimization extends SceneOptimization {
  66074. /**
  66075. * Defines the priority of this optimization (0 by default which means first in the list)
  66076. */
  66077. priority: number;
  66078. /**
  66079. * Defines the maximum scale to use (2 by default)
  66080. */
  66081. maximumScale: number;
  66082. /**
  66083. * Defines the step to use between two passes (0.5 by default)
  66084. */
  66085. step: number;
  66086. private _currentScale;
  66087. private _directionOffset;
  66088. /**
  66089. * Gets a string describing the action executed by the current optimization
  66090. * @return description string
  66091. */
  66092. getDescription(): string;
  66093. /**
  66094. * Creates the HardwareScalingOptimization object
  66095. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66096. * @param maximumScale defines the maximum scale to use (2 by default)
  66097. * @param step defines the step to use between two passes (0.5 by default)
  66098. */
  66099. constructor(
  66100. /**
  66101. * Defines the priority of this optimization (0 by default which means first in the list)
  66102. */
  66103. priority?: number,
  66104. /**
  66105. * Defines the maximum scale to use (2 by default)
  66106. */
  66107. maximumScale?: number,
  66108. /**
  66109. * Defines the step to use between two passes (0.5 by default)
  66110. */
  66111. step?: number);
  66112. /**
  66113. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66114. * @param scene defines the current scene where to apply this optimization
  66115. * @param optimizer defines the current optimizer
  66116. * @returns true if everything that can be done was applied
  66117. */
  66118. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66119. }
  66120. /**
  66121. * Defines an optimization used to remove shadows
  66122. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66123. */
  66124. export class ShadowsOptimization extends SceneOptimization {
  66125. /**
  66126. * Gets a string describing the action executed by the current optimization
  66127. * @return description string
  66128. */
  66129. getDescription(): string;
  66130. /**
  66131. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66132. * @param scene defines the current scene where to apply this optimization
  66133. * @param optimizer defines the current optimizer
  66134. * @returns true if everything that can be done was applied
  66135. */
  66136. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66137. }
  66138. /**
  66139. * Defines an optimization used to turn post-processes off
  66140. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66141. */
  66142. export class PostProcessesOptimization extends SceneOptimization {
  66143. /**
  66144. * Gets a string describing the action executed by the current optimization
  66145. * @return description string
  66146. */
  66147. getDescription(): string;
  66148. /**
  66149. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66150. * @param scene defines the current scene where to apply this optimization
  66151. * @param optimizer defines the current optimizer
  66152. * @returns true if everything that can be done was applied
  66153. */
  66154. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66155. }
  66156. /**
  66157. * Defines an optimization used to turn lens flares off
  66158. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66159. */
  66160. export class LensFlaresOptimization extends SceneOptimization {
  66161. /**
  66162. * Gets a string describing the action executed by the current optimization
  66163. * @return description string
  66164. */
  66165. getDescription(): string;
  66166. /**
  66167. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66168. * @param scene defines the current scene where to apply this optimization
  66169. * @param optimizer defines the current optimizer
  66170. * @returns true if everything that can be done was applied
  66171. */
  66172. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66173. }
  66174. /**
  66175. * Defines an optimization based on user defined callback.
  66176. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66177. */
  66178. export class CustomOptimization extends SceneOptimization {
  66179. /**
  66180. * Callback called to apply the custom optimization.
  66181. */
  66182. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66183. /**
  66184. * Callback called to get custom description
  66185. */
  66186. onGetDescription: () => string;
  66187. /**
  66188. * Gets a string describing the action executed by the current optimization
  66189. * @returns description string
  66190. */
  66191. getDescription(): string;
  66192. /**
  66193. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66194. * @param scene defines the current scene where to apply this optimization
  66195. * @param optimizer defines the current optimizer
  66196. * @returns true if everything that can be done was applied
  66197. */
  66198. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66199. }
  66200. /**
  66201. * Defines an optimization used to turn particles off
  66202. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66203. */
  66204. export class ParticlesOptimization extends SceneOptimization {
  66205. /**
  66206. * Gets a string describing the action executed by the current optimization
  66207. * @return description string
  66208. */
  66209. getDescription(): string;
  66210. /**
  66211. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66212. * @param scene defines the current scene where to apply this optimization
  66213. * @param optimizer defines the current optimizer
  66214. * @returns true if everything that can be done was applied
  66215. */
  66216. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66217. }
  66218. /**
  66219. * Defines an optimization used to turn render targets off
  66220. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66221. */
  66222. export class RenderTargetsOptimization extends SceneOptimization {
  66223. /**
  66224. * Gets a string describing the action executed by the current optimization
  66225. * @return description string
  66226. */
  66227. getDescription(): string;
  66228. /**
  66229. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66230. * @param scene defines the current scene where to apply this optimization
  66231. * @param optimizer defines the current optimizer
  66232. * @returns true if everything that can be done was applied
  66233. */
  66234. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66235. }
  66236. /**
  66237. * Defines an optimization used to merge meshes with compatible materials
  66238. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66239. */
  66240. export class MergeMeshesOptimization extends SceneOptimization {
  66241. private static _UpdateSelectionTree;
  66242. /**
  66243. * Gets or sets a boolean which defines if optimization octree has to be updated
  66244. */
  66245. /**
  66246. * Gets or sets a boolean which defines if optimization octree has to be updated
  66247. */
  66248. static UpdateSelectionTree: boolean;
  66249. /**
  66250. * Gets a string describing the action executed by the current optimization
  66251. * @return description string
  66252. */
  66253. getDescription(): string;
  66254. private _canBeMerged;
  66255. /**
  66256. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66257. * @param scene defines the current scene where to apply this optimization
  66258. * @param optimizer defines the current optimizer
  66259. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66260. * @returns true if everything that can be done was applied
  66261. */
  66262. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66263. }
  66264. /**
  66265. * Defines a list of options used by SceneOptimizer
  66266. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66267. */
  66268. export class SceneOptimizerOptions {
  66269. /**
  66270. * Defines the target frame rate to reach (60 by default)
  66271. */
  66272. targetFrameRate: number;
  66273. /**
  66274. * Defines the interval between two checkes (2000ms by default)
  66275. */
  66276. trackerDuration: number;
  66277. /**
  66278. * Gets the list of optimizations to apply
  66279. */
  66280. optimizations: SceneOptimization[];
  66281. /**
  66282. * Creates a new list of options used by SceneOptimizer
  66283. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66284. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66285. */
  66286. constructor(
  66287. /**
  66288. * Defines the target frame rate to reach (60 by default)
  66289. */
  66290. targetFrameRate?: number,
  66291. /**
  66292. * Defines the interval between two checkes (2000ms by default)
  66293. */
  66294. trackerDuration?: number);
  66295. /**
  66296. * Add a new optimization
  66297. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66298. * @returns the current SceneOptimizerOptions
  66299. */
  66300. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66301. /**
  66302. * Add a new custom optimization
  66303. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66304. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66305. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66306. * @returns the current SceneOptimizerOptions
  66307. */
  66308. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66309. /**
  66310. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66311. * @param targetFrameRate defines the target frame rate (60 by default)
  66312. * @returns a SceneOptimizerOptions object
  66313. */
  66314. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66315. /**
  66316. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66317. * @param targetFrameRate defines the target frame rate (60 by default)
  66318. * @returns a SceneOptimizerOptions object
  66319. */
  66320. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66321. /**
  66322. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66323. * @param targetFrameRate defines the target frame rate (60 by default)
  66324. * @returns a SceneOptimizerOptions object
  66325. */
  66326. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66327. }
  66328. /**
  66329. * Class used to run optimizations in order to reach a target frame rate
  66330. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66331. */
  66332. export class SceneOptimizer implements IDisposable {
  66333. private _isRunning;
  66334. private _options;
  66335. private _scene;
  66336. private _currentPriorityLevel;
  66337. private _targetFrameRate;
  66338. private _trackerDuration;
  66339. private _currentFrameRate;
  66340. private _sceneDisposeObserver;
  66341. private _improvementMode;
  66342. /**
  66343. * Defines an observable called when the optimizer reaches the target frame rate
  66344. */
  66345. onSuccessObservable: Observable<SceneOptimizer>;
  66346. /**
  66347. * Defines an observable called when the optimizer enables an optimization
  66348. */
  66349. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66350. /**
  66351. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66352. */
  66353. onFailureObservable: Observable<SceneOptimizer>;
  66354. /**
  66355. * Gets a boolean indicating if the optimizer is in improvement mode
  66356. */
  66357. readonly isInImprovementMode: boolean;
  66358. /**
  66359. * Gets the current priority level (0 at start)
  66360. */
  66361. readonly currentPriorityLevel: number;
  66362. /**
  66363. * Gets the current frame rate checked by the SceneOptimizer
  66364. */
  66365. readonly currentFrameRate: number;
  66366. /**
  66367. * Gets or sets the current target frame rate (60 by default)
  66368. */
  66369. /**
  66370. * Gets or sets the current target frame rate (60 by default)
  66371. */
  66372. targetFrameRate: number;
  66373. /**
  66374. * Gets or sets the current interval between two checks (every 2000ms by default)
  66375. */
  66376. /**
  66377. * Gets or sets the current interval between two checks (every 2000ms by default)
  66378. */
  66379. trackerDuration: number;
  66380. /**
  66381. * Gets the list of active optimizations
  66382. */
  66383. readonly optimizations: SceneOptimization[];
  66384. /**
  66385. * Creates a new SceneOptimizer
  66386. * @param scene defines the scene to work on
  66387. * @param options defines the options to use with the SceneOptimizer
  66388. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66389. * @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)
  66390. */
  66391. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66392. /**
  66393. * Stops the current optimizer
  66394. */
  66395. stop(): void;
  66396. /**
  66397. * Reset the optimizer to initial step (current priority level = 0)
  66398. */
  66399. reset(): void;
  66400. /**
  66401. * Start the optimizer. By default it will try to reach a specific framerate
  66402. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66403. */
  66404. start(): void;
  66405. private _checkCurrentState;
  66406. /**
  66407. * Release all resources
  66408. */
  66409. dispose(): void;
  66410. /**
  66411. * Helper function to create a SceneOptimizer with one single line of code
  66412. * @param scene defines the scene to work on
  66413. * @param options defines the options to use with the SceneOptimizer
  66414. * @param onSuccess defines a callback to call on success
  66415. * @param onFailure defines a callback to call on failure
  66416. * @returns the new SceneOptimizer object
  66417. */
  66418. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66419. }
  66420. }
  66421. declare module "babylonjs/Misc/sceneSerializer" {
  66422. import { Scene } from "babylonjs/scene";
  66423. /**
  66424. * Class used to serialize a scene into a string
  66425. */
  66426. export class SceneSerializer {
  66427. /**
  66428. * Clear cache used by a previous serialization
  66429. */
  66430. static ClearCache(): void;
  66431. /**
  66432. * Serialize a scene into a JSON compatible object
  66433. * @param scene defines the scene to serialize
  66434. * @returns a JSON compatible object
  66435. */
  66436. static Serialize(scene: Scene): any;
  66437. /**
  66438. * Serialize a mesh into a JSON compatible object
  66439. * @param toSerialize defines the mesh to serialize
  66440. * @param withParents defines if parents must be serialized as well
  66441. * @param withChildren defines if children must be serialized as well
  66442. * @returns a JSON compatible object
  66443. */
  66444. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66445. }
  66446. }
  66447. declare module "babylonjs/Misc/textureTools" {
  66448. import { Texture } from "babylonjs/Materials/Textures/texture";
  66449. /**
  66450. * Class used to host texture specific utilities
  66451. */
  66452. export class TextureTools {
  66453. /**
  66454. * Uses the GPU to create a copy texture rescaled at a given size
  66455. * @param texture Texture to copy from
  66456. * @param width defines the desired width
  66457. * @param height defines the desired height
  66458. * @param useBilinearMode defines if bilinear mode has to be used
  66459. * @return the generated texture
  66460. */
  66461. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66462. }
  66463. }
  66464. declare module "babylonjs/Misc/videoRecorder" {
  66465. import { Nullable } from "babylonjs/types";
  66466. import { Engine } from "babylonjs/Engines/engine";
  66467. /**
  66468. * This represents the different options available for the video capture.
  66469. */
  66470. export interface VideoRecorderOptions {
  66471. /** Defines the mime type of the video. */
  66472. mimeType: string;
  66473. /** Defines the FPS the video should be recorded at. */
  66474. fps: number;
  66475. /** Defines the chunk size for the recording data. */
  66476. recordChunckSize: number;
  66477. /** The audio tracks to attach to the recording. */
  66478. audioTracks?: MediaStreamTrack[];
  66479. }
  66480. /**
  66481. * This can help with recording videos from BabylonJS.
  66482. * This is based on the available WebRTC functionalities of the browser.
  66483. *
  66484. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66485. */
  66486. export class VideoRecorder {
  66487. private static readonly _defaultOptions;
  66488. /**
  66489. * Returns whether or not the VideoRecorder is available in your browser.
  66490. * @param engine Defines the Babylon Engine.
  66491. * @returns true if supported otherwise false.
  66492. */
  66493. static IsSupported(engine: Engine): boolean;
  66494. private readonly _options;
  66495. private _canvas;
  66496. private _mediaRecorder;
  66497. private _recordedChunks;
  66498. private _fileName;
  66499. private _resolve;
  66500. private _reject;
  66501. /**
  66502. * True when a recording is already in progress.
  66503. */
  66504. readonly isRecording: boolean;
  66505. /**
  66506. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66507. * @param engine Defines the BabylonJS Engine you wish to record.
  66508. * @param options Defines options that can be used to customize the capture.
  66509. */
  66510. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66511. /**
  66512. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66513. */
  66514. stopRecording(): void;
  66515. /**
  66516. * Starts recording the canvas for a max duration specified in parameters.
  66517. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66518. * If null no automatic download will start and you can rely on the promise to get the data back.
  66519. * @param maxDuration Defines the maximum recording time in seconds.
  66520. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66521. * @return A promise callback at the end of the recording with the video data in Blob.
  66522. */
  66523. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66524. /**
  66525. * Releases internal resources used during the recording.
  66526. */
  66527. dispose(): void;
  66528. private _handleDataAvailable;
  66529. private _handleError;
  66530. private _handleStop;
  66531. }
  66532. }
  66533. declare module "babylonjs/Misc/screenshotTools" {
  66534. import { Camera } from "babylonjs/Cameras/camera";
  66535. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66536. import { Engine } from "babylonjs/Engines/engine";
  66537. /**
  66538. * Class containing a set of static utilities functions for screenshots
  66539. */
  66540. export class ScreenshotTools {
  66541. /**
  66542. * Captures a screenshot of the current rendering
  66543. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66544. * @param engine defines the rendering engine
  66545. * @param camera defines the source camera
  66546. * @param size This parameter can be set to a single number or to an object with the
  66547. * following (optional) properties: precision, width, height. If a single number is passed,
  66548. * it will be used for both width and height. If an object is passed, the screenshot size
  66549. * will be derived from the parameters. The precision property is a multiplier allowing
  66550. * rendering at a higher or lower resolution
  66551. * @param successCallback defines the callback receives a single parameter which contains the
  66552. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66553. * src parameter of an <img> to display it
  66554. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66555. * Check your browser for supported MIME types
  66556. */
  66557. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66558. /**
  66559. * Captures a screenshot of the current rendering
  66560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66561. * @param engine defines the rendering engine
  66562. * @param camera defines the source camera
  66563. * @param size This parameter can be set to a single number or to an object with the
  66564. * following (optional) properties: precision, width, height. If a single number is passed,
  66565. * it will be used for both width and height. If an object is passed, the screenshot size
  66566. * will be derived from the parameters. The precision property is a multiplier allowing
  66567. * rendering at a higher or lower resolution
  66568. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66569. * Check your browser for supported MIME types
  66570. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66571. * to the src parameter of an <img> to display it
  66572. */
  66573. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66574. /**
  66575. * Generates an image screenshot from the specified camera.
  66576. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66577. * @param engine The engine to use for rendering
  66578. * @param camera The camera to use for rendering
  66579. * @param size This parameter can be set to a single number or to an object with the
  66580. * following (optional) properties: precision, width, height. If a single number is passed,
  66581. * it will be used for both width and height. If an object is passed, the screenshot size
  66582. * will be derived from the parameters. The precision property is a multiplier allowing
  66583. * rendering at a higher or lower resolution
  66584. * @param successCallback The callback receives a single parameter which contains the
  66585. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66586. * src parameter of an <img> to display it
  66587. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66588. * Check your browser for supported MIME types
  66589. * @param samples Texture samples (default: 1)
  66590. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66591. * @param fileName A name for for the downloaded file.
  66592. */
  66593. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66594. /**
  66595. * Generates an image screenshot from the specified camera.
  66596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66597. * @param engine The engine to use for rendering
  66598. * @param camera The camera to use for rendering
  66599. * @param size This parameter can be set to a single number or to an object with the
  66600. * following (optional) properties: precision, width, height. If a single number is passed,
  66601. * it will be used for both width and height. If an object is passed, the screenshot size
  66602. * will be derived from the parameters. The precision property is a multiplier allowing
  66603. * rendering at a higher or lower resolution
  66604. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66605. * Check your browser for supported MIME types
  66606. * @param samples Texture samples (default: 1)
  66607. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66608. * @param fileName A name for for the downloaded file.
  66609. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66610. * to the src parameter of an <img> to display it
  66611. */
  66612. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66613. /**
  66614. * Gets height and width for screenshot size
  66615. * @private
  66616. */
  66617. private static _getScreenshotSize;
  66618. }
  66619. }
  66620. declare module "babylonjs/Misc/index" {
  66621. export * from "babylonjs/Misc/andOrNotEvaluator";
  66622. export * from "babylonjs/Misc/assetsManager";
  66623. export * from "babylonjs/Misc/dds";
  66624. export * from "babylonjs/Misc/decorators";
  66625. export * from "babylonjs/Misc/deferred";
  66626. export * from "babylonjs/Misc/environmentTextureTools";
  66627. export * from "babylonjs/Misc/meshExploder";
  66628. export * from "babylonjs/Misc/filesInput";
  66629. export * from "babylonjs/Misc/HighDynamicRange/index";
  66630. export * from "babylonjs/Misc/khronosTextureContainer";
  66631. export * from "babylonjs/Misc/observable";
  66632. export * from "babylonjs/Misc/performanceMonitor";
  66633. export * from "babylonjs/Misc/promise";
  66634. export * from "babylonjs/Misc/sceneOptimizer";
  66635. export * from "babylonjs/Misc/sceneSerializer";
  66636. export * from "babylonjs/Misc/smartArray";
  66637. export * from "babylonjs/Misc/stringDictionary";
  66638. export * from "babylonjs/Misc/tags";
  66639. export * from "babylonjs/Misc/textureTools";
  66640. export * from "babylonjs/Misc/tga";
  66641. export * from "babylonjs/Misc/tools";
  66642. export * from "babylonjs/Misc/videoRecorder";
  66643. export * from "babylonjs/Misc/virtualJoystick";
  66644. export * from "babylonjs/Misc/workerPool";
  66645. export * from "babylonjs/Misc/logger";
  66646. export * from "babylonjs/Misc/typeStore";
  66647. export * from "babylonjs/Misc/filesInputStore";
  66648. export * from "babylonjs/Misc/deepCopier";
  66649. export * from "babylonjs/Misc/pivotTools";
  66650. export * from "babylonjs/Misc/precisionDate";
  66651. export * from "babylonjs/Misc/screenshotTools";
  66652. export * from "babylonjs/Misc/typeStore";
  66653. export * from "babylonjs/Misc/webRequest";
  66654. export * from "babylonjs/Misc/iInspectable";
  66655. export * from "babylonjs/Misc/brdfTextureTools";
  66656. export * from "babylonjs/Misc/rgbdTextureTools";
  66657. export * from "babylonjs/Misc/gradients";
  66658. export * from "babylonjs/Misc/perfCounter";
  66659. export * from "babylonjs/Misc/fileRequest";
  66660. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66661. export * from "babylonjs/Misc/retryStrategy";
  66662. export * from "babylonjs/Misc/loadFileError";
  66663. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66664. }
  66665. declare module "babylonjs/index" {
  66666. export * from "babylonjs/abstractScene";
  66667. export * from "babylonjs/Actions/index";
  66668. export * from "babylonjs/Animations/index";
  66669. export * from "babylonjs/assetContainer";
  66670. export * from "babylonjs/Audio/index";
  66671. export * from "babylonjs/Behaviors/index";
  66672. export * from "babylonjs/Bones/index";
  66673. export * from "babylonjs/Cameras/index";
  66674. export * from "babylonjs/Collisions/index";
  66675. export * from "babylonjs/Culling/index";
  66676. export * from "babylonjs/Debug/index";
  66677. export * from "babylonjs/Engines/index";
  66678. export * from "babylonjs/Events/index";
  66679. export * from "babylonjs/Gamepads/index";
  66680. export * from "babylonjs/Gizmos/index";
  66681. export * from "babylonjs/Helpers/index";
  66682. export * from "babylonjs/Instrumentation/index";
  66683. export * from "babylonjs/Layers/index";
  66684. export * from "babylonjs/LensFlares/index";
  66685. export * from "babylonjs/Lights/index";
  66686. export * from "babylonjs/Loading/index";
  66687. export * from "babylonjs/Materials/index";
  66688. export * from "babylonjs/Maths/index";
  66689. export * from "babylonjs/Meshes/index";
  66690. export * from "babylonjs/Morph/index";
  66691. export * from "babylonjs/Navigation/index";
  66692. export * from "babylonjs/node";
  66693. export * from "babylonjs/Offline/index";
  66694. export * from "babylonjs/Particles/index";
  66695. export * from "babylonjs/Physics/index";
  66696. export * from "babylonjs/PostProcesses/index";
  66697. export * from "babylonjs/Probes/index";
  66698. export * from "babylonjs/Rendering/index";
  66699. export * from "babylonjs/scene";
  66700. export * from "babylonjs/sceneComponent";
  66701. export * from "babylonjs/Sprites/index";
  66702. export * from "babylonjs/States/index";
  66703. export * from "babylonjs/Misc/index";
  66704. export * from "babylonjs/types";
  66705. }
  66706. declare module "babylonjs/Animations/pathCursor" {
  66707. import { Vector3 } from "babylonjs/Maths/math.vector";
  66708. import { Path2 } from "babylonjs/Maths/math.path";
  66709. /**
  66710. * A cursor which tracks a point on a path
  66711. */
  66712. export class PathCursor {
  66713. private path;
  66714. /**
  66715. * Stores path cursor callbacks for when an onchange event is triggered
  66716. */
  66717. private _onchange;
  66718. /**
  66719. * The value of the path cursor
  66720. */
  66721. value: number;
  66722. /**
  66723. * The animation array of the path cursor
  66724. */
  66725. animations: Animation[];
  66726. /**
  66727. * Initializes the path cursor
  66728. * @param path The path to track
  66729. */
  66730. constructor(path: Path2);
  66731. /**
  66732. * Gets the cursor point on the path
  66733. * @returns A point on the path cursor at the cursor location
  66734. */
  66735. getPoint(): Vector3;
  66736. /**
  66737. * Moves the cursor ahead by the step amount
  66738. * @param step The amount to move the cursor forward
  66739. * @returns This path cursor
  66740. */
  66741. moveAhead(step?: number): PathCursor;
  66742. /**
  66743. * Moves the cursor behind by the step amount
  66744. * @param step The amount to move the cursor back
  66745. * @returns This path cursor
  66746. */
  66747. moveBack(step?: number): PathCursor;
  66748. /**
  66749. * Moves the cursor by the step amount
  66750. * If the step amount is greater than one, an exception is thrown
  66751. * @param step The amount to move the cursor
  66752. * @returns This path cursor
  66753. */
  66754. move(step: number): PathCursor;
  66755. /**
  66756. * Ensures that the value is limited between zero and one
  66757. * @returns This path cursor
  66758. */
  66759. private ensureLimits;
  66760. /**
  66761. * Runs onchange callbacks on change (used by the animation engine)
  66762. * @returns This path cursor
  66763. */
  66764. private raiseOnChange;
  66765. /**
  66766. * Executes a function on change
  66767. * @param f A path cursor onchange callback
  66768. * @returns This path cursor
  66769. */
  66770. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66771. }
  66772. }
  66773. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66774. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66775. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66776. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66777. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66778. }
  66779. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66780. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66781. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66782. }
  66783. declare module "babylonjs/Engines/Processors/index" {
  66784. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66785. export * from "babylonjs/Engines/Processors/Expressions/index";
  66786. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66787. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66788. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66789. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66790. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66791. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66792. }
  66793. declare module "babylonjs/Legacy/legacy" {
  66794. import * as Babylon from "babylonjs/index";
  66795. export * from "babylonjs/index";
  66796. }
  66797. declare module "babylonjs/Shaders/blur.fragment" {
  66798. /** @hidden */
  66799. export var blurPixelShader: {
  66800. name: string;
  66801. shader: string;
  66802. };
  66803. }
  66804. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66805. /** @hidden */
  66806. export var pointCloudVertexDeclaration: {
  66807. name: string;
  66808. shader: string;
  66809. };
  66810. }
  66811. declare module "babylonjs" {
  66812. export * from "babylonjs/Legacy/legacy";
  66813. }
  66814. declare module BABYLON {
  66815. /** Alias type for value that can be null */
  66816. export type Nullable<T> = T | null;
  66817. /**
  66818. * Alias type for number that are floats
  66819. * @ignorenaming
  66820. */
  66821. export type float = number;
  66822. /**
  66823. * Alias type for number that are doubles.
  66824. * @ignorenaming
  66825. */
  66826. export type double = number;
  66827. /**
  66828. * Alias type for number that are integer
  66829. * @ignorenaming
  66830. */
  66831. export type int = number;
  66832. /** Alias type for number array or Float32Array */
  66833. export type FloatArray = number[] | Float32Array;
  66834. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66835. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66836. /**
  66837. * Alias for types that can be used by a Buffer or VertexBuffer.
  66838. */
  66839. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66840. /**
  66841. * Alias type for primitive types
  66842. * @ignorenaming
  66843. */
  66844. type Primitive = undefined | null | boolean | string | number | Function;
  66845. /**
  66846. * Type modifier to make all the properties of an object Readonly
  66847. */
  66848. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66849. /**
  66850. * Type modifier to make all the properties of an object Readonly recursively
  66851. */
  66852. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66853. /**
  66854. * Type modifier to make object properties readonly.
  66855. */
  66856. export type DeepImmutableObject<T> = {
  66857. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66858. };
  66859. /** @hidden */
  66860. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66861. }
  66862. }
  66863. declare module BABYLON {
  66864. /**
  66865. * A class serves as a medium between the observable and its observers
  66866. */
  66867. export class EventState {
  66868. /**
  66869. * Create a new EventState
  66870. * @param mask defines the mask associated with this state
  66871. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66872. * @param target defines the original target of the state
  66873. * @param currentTarget defines the current target of the state
  66874. */
  66875. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66876. /**
  66877. * Initialize the current event state
  66878. * @param mask defines the mask associated with this state
  66879. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66880. * @param target defines the original target of the state
  66881. * @param currentTarget defines the current target of the state
  66882. * @returns the current event state
  66883. */
  66884. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66885. /**
  66886. * An Observer can set this property to true to prevent subsequent observers of being notified
  66887. */
  66888. skipNextObservers: boolean;
  66889. /**
  66890. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66891. */
  66892. mask: number;
  66893. /**
  66894. * The object that originally notified the event
  66895. */
  66896. target?: any;
  66897. /**
  66898. * The current object in the bubbling phase
  66899. */
  66900. currentTarget?: any;
  66901. /**
  66902. * This will be populated with the return value of the last function that was executed.
  66903. * If it is the first function in the callback chain it will be the event data.
  66904. */
  66905. lastReturnValue?: any;
  66906. }
  66907. /**
  66908. * Represent an Observer registered to a given Observable object.
  66909. */
  66910. export class Observer<T> {
  66911. /**
  66912. * Defines the callback to call when the observer is notified
  66913. */
  66914. callback: (eventData: T, eventState: EventState) => void;
  66915. /**
  66916. * Defines the mask of the observer (used to filter notifications)
  66917. */
  66918. mask: number;
  66919. /**
  66920. * Defines the current scope used to restore the JS context
  66921. */
  66922. scope: any;
  66923. /** @hidden */
  66924. _willBeUnregistered: boolean;
  66925. /**
  66926. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66927. */
  66928. unregisterOnNextCall: boolean;
  66929. /**
  66930. * Creates a new observer
  66931. * @param callback defines the callback to call when the observer is notified
  66932. * @param mask defines the mask of the observer (used to filter notifications)
  66933. * @param scope defines the current scope used to restore the JS context
  66934. */
  66935. constructor(
  66936. /**
  66937. * Defines the callback to call when the observer is notified
  66938. */
  66939. callback: (eventData: T, eventState: EventState) => void,
  66940. /**
  66941. * Defines the mask of the observer (used to filter notifications)
  66942. */
  66943. mask: number,
  66944. /**
  66945. * Defines the current scope used to restore the JS context
  66946. */
  66947. scope?: any);
  66948. }
  66949. /**
  66950. * Represent a list of observers registered to multiple Observables object.
  66951. */
  66952. export class MultiObserver<T> {
  66953. private _observers;
  66954. private _observables;
  66955. /**
  66956. * Release associated resources
  66957. */
  66958. dispose(): void;
  66959. /**
  66960. * Raise a callback when one of the observable will notify
  66961. * @param observables defines a list of observables to watch
  66962. * @param callback defines the callback to call on notification
  66963. * @param mask defines the mask used to filter notifications
  66964. * @param scope defines the current scope used to restore the JS context
  66965. * @returns the new MultiObserver
  66966. */
  66967. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66968. }
  66969. /**
  66970. * The Observable class is a simple implementation of the Observable pattern.
  66971. *
  66972. * 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.
  66973. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66974. * 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).
  66975. * 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.
  66976. */
  66977. export class Observable<T> {
  66978. private _observers;
  66979. private _eventState;
  66980. private _onObserverAdded;
  66981. /**
  66982. * Gets the list of observers
  66983. */
  66984. readonly observers: Array<Observer<T>>;
  66985. /**
  66986. * Creates a new observable
  66987. * @param onObserverAdded defines a callback to call when a new observer is added
  66988. */
  66989. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66990. /**
  66991. * Create a new Observer with the specified callback
  66992. * @param callback the callback that will be executed for that Observer
  66993. * @param mask the mask used to filter observers
  66994. * @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.
  66995. * @param scope optional scope for the callback to be called from
  66996. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66997. * @returns the new observer created for the callback
  66998. */
  66999. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67000. /**
  67001. * Create a new Observer with the specified callback and unregisters after the next notification
  67002. * @param callback the callback that will be executed for that Observer
  67003. * @returns the new observer created for the callback
  67004. */
  67005. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67006. /**
  67007. * Remove an Observer from the Observable object
  67008. * @param observer the instance of the Observer to remove
  67009. * @returns false if it doesn't belong to this Observable
  67010. */
  67011. remove(observer: Nullable<Observer<T>>): boolean;
  67012. /**
  67013. * Remove a callback from the Observable object
  67014. * @param callback the callback to remove
  67015. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67016. * @returns false if it doesn't belong to this Observable
  67017. */
  67018. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67019. private _deferUnregister;
  67020. private _remove;
  67021. /**
  67022. * Moves the observable to the top of the observer list making it get called first when notified
  67023. * @param observer the observer to move
  67024. */
  67025. makeObserverTopPriority(observer: Observer<T>): void;
  67026. /**
  67027. * Moves the observable to the bottom of the observer list making it get called last when notified
  67028. * @param observer the observer to move
  67029. */
  67030. makeObserverBottomPriority(observer: Observer<T>): void;
  67031. /**
  67032. * Notify all Observers by calling their respective callback with the given data
  67033. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67034. * @param eventData defines the data to send to all observers
  67035. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67036. * @param target defines the original target of the state
  67037. * @param currentTarget defines the current target of the state
  67038. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67039. */
  67040. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67041. /**
  67042. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67043. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67044. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67045. * and it is crucial that all callbacks will be executed.
  67046. * The order of the callbacks is kept, callbacks are not executed parallel.
  67047. *
  67048. * @param eventData The data to be sent to each callback
  67049. * @param mask is used to filter observers defaults to -1
  67050. * @param target defines the callback target (see EventState)
  67051. * @param currentTarget defines he current object in the bubbling phase
  67052. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67053. */
  67054. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67055. /**
  67056. * Notify a specific observer
  67057. * @param observer defines the observer to notify
  67058. * @param eventData defines the data to be sent to each callback
  67059. * @param mask is used to filter observers defaults to -1
  67060. */
  67061. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67062. /**
  67063. * Gets a boolean indicating if the observable has at least one observer
  67064. * @returns true is the Observable has at least one Observer registered
  67065. */
  67066. hasObservers(): boolean;
  67067. /**
  67068. * Clear the list of observers
  67069. */
  67070. clear(): void;
  67071. /**
  67072. * Clone the current observable
  67073. * @returns a new observable
  67074. */
  67075. clone(): Observable<T>;
  67076. /**
  67077. * Does this observable handles observer registered with a given mask
  67078. * @param mask defines the mask to be tested
  67079. * @return whether or not one observer registered with the given mask is handeled
  67080. **/
  67081. hasSpecificMask(mask?: number): boolean;
  67082. }
  67083. }
  67084. declare module BABYLON {
  67085. /**
  67086. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67087. * Babylon.js
  67088. */
  67089. export class DomManagement {
  67090. /**
  67091. * Checks if the window object exists
  67092. * @returns true if the window object exists
  67093. */
  67094. static IsWindowObjectExist(): boolean;
  67095. /**
  67096. * Checks if the navigator object exists
  67097. * @returns true if the navigator object exists
  67098. */
  67099. static IsNavigatorAvailable(): boolean;
  67100. /**
  67101. * Extracts text content from a DOM element hierarchy
  67102. * @param element defines the root element
  67103. * @returns a string
  67104. */
  67105. static GetDOMTextContent(element: HTMLElement): string;
  67106. }
  67107. }
  67108. declare module BABYLON {
  67109. /**
  67110. * Logger used througouht the application to allow configuration of
  67111. * the log level required for the messages.
  67112. */
  67113. export class Logger {
  67114. /**
  67115. * No log
  67116. */
  67117. static readonly NoneLogLevel: number;
  67118. /**
  67119. * Only message logs
  67120. */
  67121. static readonly MessageLogLevel: number;
  67122. /**
  67123. * Only warning logs
  67124. */
  67125. static readonly WarningLogLevel: number;
  67126. /**
  67127. * Only error logs
  67128. */
  67129. static readonly ErrorLogLevel: number;
  67130. /**
  67131. * All logs
  67132. */
  67133. static readonly AllLogLevel: number;
  67134. private static _LogCache;
  67135. /**
  67136. * Gets a value indicating the number of loading errors
  67137. * @ignorenaming
  67138. */
  67139. static errorsCount: number;
  67140. /**
  67141. * Callback called when a new log is added
  67142. */
  67143. static OnNewCacheEntry: (entry: string) => void;
  67144. private static _AddLogEntry;
  67145. private static _FormatMessage;
  67146. private static _LogDisabled;
  67147. private static _LogEnabled;
  67148. private static _WarnDisabled;
  67149. private static _WarnEnabled;
  67150. private static _ErrorDisabled;
  67151. private static _ErrorEnabled;
  67152. /**
  67153. * Log a message to the console
  67154. */
  67155. static Log: (message: string) => void;
  67156. /**
  67157. * Write a warning message to the console
  67158. */
  67159. static Warn: (message: string) => void;
  67160. /**
  67161. * Write an error message to the console
  67162. */
  67163. static Error: (message: string) => void;
  67164. /**
  67165. * Gets current log cache (list of logs)
  67166. */
  67167. static readonly LogCache: string;
  67168. /**
  67169. * Clears the log cache
  67170. */
  67171. static ClearLogCache(): void;
  67172. /**
  67173. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67174. */
  67175. static LogLevels: number;
  67176. }
  67177. }
  67178. declare module BABYLON {
  67179. /** @hidden */
  67180. export class _TypeStore {
  67181. /** @hidden */
  67182. static RegisteredTypes: {
  67183. [key: string]: Object;
  67184. };
  67185. /** @hidden */
  67186. static GetClass(fqdn: string): any;
  67187. }
  67188. }
  67189. declare module BABYLON {
  67190. /**
  67191. * Class containing a set of static utilities functions for deep copy.
  67192. */
  67193. export class DeepCopier {
  67194. /**
  67195. * Tries to copy an object by duplicating every property
  67196. * @param source defines the source object
  67197. * @param destination defines the target object
  67198. * @param doNotCopyList defines a list of properties to avoid
  67199. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67200. */
  67201. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67202. }
  67203. }
  67204. declare module BABYLON {
  67205. /**
  67206. * Class containing a set of static utilities functions for precision date
  67207. */
  67208. export class PrecisionDate {
  67209. /**
  67210. * Gets either window.performance.now() if supported or Date.now() else
  67211. */
  67212. static readonly Now: number;
  67213. }
  67214. }
  67215. declare module BABYLON {
  67216. /** @hidden */
  67217. export class _DevTools {
  67218. static WarnImport(name: string): string;
  67219. }
  67220. }
  67221. declare module BABYLON {
  67222. /**
  67223. * Interface used to define the mechanism to get data from the network
  67224. */
  67225. export interface IWebRequest {
  67226. /**
  67227. * Returns client's response url
  67228. */
  67229. responseURL: string;
  67230. /**
  67231. * Returns client's status
  67232. */
  67233. status: number;
  67234. /**
  67235. * Returns client's status as a text
  67236. */
  67237. statusText: string;
  67238. }
  67239. }
  67240. declare module BABYLON {
  67241. /**
  67242. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67243. */
  67244. export class WebRequest implements IWebRequest {
  67245. private _xhr;
  67246. /**
  67247. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67248. * i.e. when loading files, where the server/service expects an Authorization header
  67249. */
  67250. static CustomRequestHeaders: {
  67251. [key: string]: string;
  67252. };
  67253. /**
  67254. * Add callback functions in this array to update all the requests before they get sent to the network
  67255. */
  67256. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67257. private _injectCustomRequestHeaders;
  67258. /**
  67259. * Gets or sets a function to be called when loading progress changes
  67260. */
  67261. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67262. /**
  67263. * Returns client's state
  67264. */
  67265. readonly readyState: number;
  67266. /**
  67267. * Returns client's status
  67268. */
  67269. readonly status: number;
  67270. /**
  67271. * Returns client's status as a text
  67272. */
  67273. readonly statusText: string;
  67274. /**
  67275. * Returns client's response
  67276. */
  67277. readonly response: any;
  67278. /**
  67279. * Returns client's response url
  67280. */
  67281. readonly responseURL: string;
  67282. /**
  67283. * Returns client's response as text
  67284. */
  67285. readonly responseText: string;
  67286. /**
  67287. * Gets or sets the expected response type
  67288. */
  67289. responseType: XMLHttpRequestResponseType;
  67290. /** @hidden */
  67291. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67292. /** @hidden */
  67293. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67294. /**
  67295. * Cancels any network activity
  67296. */
  67297. abort(): void;
  67298. /**
  67299. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67300. * @param body defines an optional request body
  67301. */
  67302. send(body?: Document | BodyInit | null): void;
  67303. /**
  67304. * Sets the request method, request URL
  67305. * @param method defines the method to use (GET, POST, etc..)
  67306. * @param url defines the url to connect with
  67307. */
  67308. open(method: string, url: string): void;
  67309. }
  67310. }
  67311. declare module BABYLON {
  67312. /**
  67313. * File request interface
  67314. */
  67315. export interface IFileRequest {
  67316. /**
  67317. * Raised when the request is complete (success or error).
  67318. */
  67319. onCompleteObservable: Observable<IFileRequest>;
  67320. /**
  67321. * Aborts the request for a file.
  67322. */
  67323. abort: () => void;
  67324. }
  67325. }
  67326. declare module BABYLON {
  67327. /**
  67328. * Define options used to create a render target texture
  67329. */
  67330. export class RenderTargetCreationOptions {
  67331. /**
  67332. * Specifies is mipmaps must be generated
  67333. */
  67334. generateMipMaps?: boolean;
  67335. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67336. generateDepthBuffer?: boolean;
  67337. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67338. generateStencilBuffer?: boolean;
  67339. /** Defines texture type (int by default) */
  67340. type?: number;
  67341. /** Defines sampling mode (trilinear by default) */
  67342. samplingMode?: number;
  67343. /** Defines format (RGBA by default) */
  67344. format?: number;
  67345. }
  67346. }
  67347. declare module BABYLON {
  67348. /**
  67349. * @hidden
  67350. **/
  67351. export class _TimeToken {
  67352. _startTimeQuery: Nullable<WebGLQuery>;
  67353. _endTimeQuery: Nullable<WebGLQuery>;
  67354. _timeElapsedQuery: Nullable<WebGLQuery>;
  67355. _timeElapsedQueryEnded: boolean;
  67356. }
  67357. }
  67358. declare module BABYLON {
  67359. /** Defines the cross module used constants to avoid circular dependncies */
  67360. export class Constants {
  67361. /** Defines that alpha blending is disabled */
  67362. static readonly ALPHA_DISABLE: number;
  67363. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67364. static readonly ALPHA_ADD: number;
  67365. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67366. static readonly ALPHA_COMBINE: number;
  67367. /** Defines that alpha blending to DEST - SRC * DEST */
  67368. static readonly ALPHA_SUBTRACT: number;
  67369. /** Defines that alpha blending to SRC * DEST */
  67370. static readonly ALPHA_MULTIPLY: number;
  67371. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67372. static readonly ALPHA_MAXIMIZED: number;
  67373. /** Defines that alpha blending to SRC + DEST */
  67374. static readonly ALPHA_ONEONE: number;
  67375. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67376. static readonly ALPHA_PREMULTIPLIED: number;
  67377. /**
  67378. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67379. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67380. */
  67381. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67382. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67383. static readonly ALPHA_INTERPOLATE: number;
  67384. /**
  67385. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67386. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67387. */
  67388. static readonly ALPHA_SCREENMODE: number;
  67389. /**
  67390. * Defines that alpha blending to SRC + DST
  67391. * Alpha will be set to SRC ALPHA + DST ALPHA
  67392. */
  67393. static readonly ALPHA_ONEONE_ONEONE: number;
  67394. /**
  67395. * Defines that alpha blending to SRC * DST ALPHA + DST
  67396. * Alpha will be set to 0
  67397. */
  67398. static readonly ALPHA_ALPHATOCOLOR: number;
  67399. /**
  67400. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67401. */
  67402. static readonly ALPHA_REVERSEONEMINUS: number;
  67403. /**
  67404. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67405. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67406. */
  67407. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67408. /**
  67409. * Defines that alpha blending to SRC + DST
  67410. * Alpha will be set to SRC ALPHA
  67411. */
  67412. static readonly ALPHA_ONEONE_ONEZERO: number;
  67413. /** Defines that alpha blending equation a SUM */
  67414. static readonly ALPHA_EQUATION_ADD: number;
  67415. /** Defines that alpha blending equation a SUBSTRACTION */
  67416. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67417. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67418. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67419. /** Defines that alpha blending equation a MAX operation */
  67420. static readonly ALPHA_EQUATION_MAX: number;
  67421. /** Defines that alpha blending equation a MIN operation */
  67422. static readonly ALPHA_EQUATION_MIN: number;
  67423. /**
  67424. * Defines that alpha blending equation a DARKEN operation:
  67425. * It takes the min of the src and sums the alpha channels.
  67426. */
  67427. static readonly ALPHA_EQUATION_DARKEN: number;
  67428. /** Defines that the ressource is not delayed*/
  67429. static readonly DELAYLOADSTATE_NONE: number;
  67430. /** Defines that the ressource was successfully delay loaded */
  67431. static readonly DELAYLOADSTATE_LOADED: number;
  67432. /** Defines that the ressource is currently delay loading */
  67433. static readonly DELAYLOADSTATE_LOADING: number;
  67434. /** Defines that the ressource is delayed and has not started loading */
  67435. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67436. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67437. static readonly NEVER: number;
  67438. /** 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 */
  67439. static readonly ALWAYS: number;
  67440. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67441. static readonly LESS: number;
  67442. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67443. static readonly EQUAL: number;
  67444. /** 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 */
  67445. static readonly LEQUAL: number;
  67446. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67447. static readonly GREATER: number;
  67448. /** 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 */
  67449. static readonly GEQUAL: number;
  67450. /** 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 */
  67451. static readonly NOTEQUAL: number;
  67452. /** Passed to stencilOperation to specify that stencil value must be kept */
  67453. static readonly KEEP: number;
  67454. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67455. static readonly REPLACE: number;
  67456. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67457. static readonly INCR: number;
  67458. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67459. static readonly DECR: number;
  67460. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67461. static readonly INVERT: number;
  67462. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67463. static readonly INCR_WRAP: number;
  67464. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67465. static readonly DECR_WRAP: number;
  67466. /** Texture is not repeating outside of 0..1 UVs */
  67467. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67468. /** Texture is repeating outside of 0..1 UVs */
  67469. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67470. /** Texture is repeating and mirrored */
  67471. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67472. /** ALPHA */
  67473. static readonly TEXTUREFORMAT_ALPHA: number;
  67474. /** LUMINANCE */
  67475. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67476. /** LUMINANCE_ALPHA */
  67477. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67478. /** RGB */
  67479. static readonly TEXTUREFORMAT_RGB: number;
  67480. /** RGBA */
  67481. static readonly TEXTUREFORMAT_RGBA: number;
  67482. /** RED */
  67483. static readonly TEXTUREFORMAT_RED: number;
  67484. /** RED (2nd reference) */
  67485. static readonly TEXTUREFORMAT_R: number;
  67486. /** RG */
  67487. static readonly TEXTUREFORMAT_RG: number;
  67488. /** RED_INTEGER */
  67489. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67490. /** RED_INTEGER (2nd reference) */
  67491. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67492. /** RG_INTEGER */
  67493. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67494. /** RGB_INTEGER */
  67495. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67496. /** RGBA_INTEGER */
  67497. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67498. /** UNSIGNED_BYTE */
  67499. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67500. /** UNSIGNED_BYTE (2nd reference) */
  67501. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67502. /** FLOAT */
  67503. static readonly TEXTURETYPE_FLOAT: number;
  67504. /** HALF_FLOAT */
  67505. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67506. /** BYTE */
  67507. static readonly TEXTURETYPE_BYTE: number;
  67508. /** SHORT */
  67509. static readonly TEXTURETYPE_SHORT: number;
  67510. /** UNSIGNED_SHORT */
  67511. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67512. /** INT */
  67513. static readonly TEXTURETYPE_INT: number;
  67514. /** UNSIGNED_INT */
  67515. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67516. /** UNSIGNED_SHORT_4_4_4_4 */
  67517. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67518. /** UNSIGNED_SHORT_5_5_5_1 */
  67519. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67520. /** UNSIGNED_SHORT_5_6_5 */
  67521. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67522. /** UNSIGNED_INT_2_10_10_10_REV */
  67523. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67524. /** UNSIGNED_INT_24_8 */
  67525. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67526. /** UNSIGNED_INT_10F_11F_11F_REV */
  67527. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67528. /** UNSIGNED_INT_5_9_9_9_REV */
  67529. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67530. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67531. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67532. /** nearest is mag = nearest and min = nearest and mip = linear */
  67533. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67534. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67535. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67536. /** Trilinear is mag = linear and min = linear and mip = linear */
  67537. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67538. /** nearest is mag = nearest and min = nearest and mip = linear */
  67539. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67540. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67541. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67542. /** Trilinear is mag = linear and min = linear and mip = linear */
  67543. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67544. /** mag = nearest and min = nearest and mip = nearest */
  67545. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67546. /** mag = nearest and min = linear and mip = nearest */
  67547. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67548. /** mag = nearest and min = linear and mip = linear */
  67549. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67550. /** mag = nearest and min = linear and mip = none */
  67551. static readonly TEXTURE_NEAREST_LINEAR: number;
  67552. /** mag = nearest and min = nearest and mip = none */
  67553. static readonly TEXTURE_NEAREST_NEAREST: number;
  67554. /** mag = linear and min = nearest and mip = nearest */
  67555. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67556. /** mag = linear and min = nearest and mip = linear */
  67557. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67558. /** mag = linear and min = linear and mip = none */
  67559. static readonly TEXTURE_LINEAR_LINEAR: number;
  67560. /** mag = linear and min = nearest and mip = none */
  67561. static readonly TEXTURE_LINEAR_NEAREST: number;
  67562. /** Explicit coordinates mode */
  67563. static readonly TEXTURE_EXPLICIT_MODE: number;
  67564. /** Spherical coordinates mode */
  67565. static readonly TEXTURE_SPHERICAL_MODE: number;
  67566. /** Planar coordinates mode */
  67567. static readonly TEXTURE_PLANAR_MODE: number;
  67568. /** Cubic coordinates mode */
  67569. static readonly TEXTURE_CUBIC_MODE: number;
  67570. /** Projection coordinates mode */
  67571. static readonly TEXTURE_PROJECTION_MODE: number;
  67572. /** Skybox coordinates mode */
  67573. static readonly TEXTURE_SKYBOX_MODE: number;
  67574. /** Inverse Cubic coordinates mode */
  67575. static readonly TEXTURE_INVCUBIC_MODE: number;
  67576. /** Equirectangular coordinates mode */
  67577. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67578. /** Equirectangular Fixed coordinates mode */
  67579. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67580. /** Equirectangular Fixed Mirrored coordinates mode */
  67581. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67582. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67583. static readonly SCALEMODE_FLOOR: number;
  67584. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67585. static readonly SCALEMODE_NEAREST: number;
  67586. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67587. static readonly SCALEMODE_CEILING: number;
  67588. /**
  67589. * The dirty texture flag value
  67590. */
  67591. static readonly MATERIAL_TextureDirtyFlag: number;
  67592. /**
  67593. * The dirty light flag value
  67594. */
  67595. static readonly MATERIAL_LightDirtyFlag: number;
  67596. /**
  67597. * The dirty fresnel flag value
  67598. */
  67599. static readonly MATERIAL_FresnelDirtyFlag: number;
  67600. /**
  67601. * The dirty attribute flag value
  67602. */
  67603. static readonly MATERIAL_AttributesDirtyFlag: number;
  67604. /**
  67605. * The dirty misc flag value
  67606. */
  67607. static readonly MATERIAL_MiscDirtyFlag: number;
  67608. /**
  67609. * The all dirty flag value
  67610. */
  67611. static readonly MATERIAL_AllDirtyFlag: number;
  67612. /**
  67613. * Returns the triangle fill mode
  67614. */
  67615. static readonly MATERIAL_TriangleFillMode: number;
  67616. /**
  67617. * Returns the wireframe mode
  67618. */
  67619. static readonly MATERIAL_WireFrameFillMode: number;
  67620. /**
  67621. * Returns the point fill mode
  67622. */
  67623. static readonly MATERIAL_PointFillMode: number;
  67624. /**
  67625. * Returns the point list draw mode
  67626. */
  67627. static readonly MATERIAL_PointListDrawMode: number;
  67628. /**
  67629. * Returns the line list draw mode
  67630. */
  67631. static readonly MATERIAL_LineListDrawMode: number;
  67632. /**
  67633. * Returns the line loop draw mode
  67634. */
  67635. static readonly MATERIAL_LineLoopDrawMode: number;
  67636. /**
  67637. * Returns the line strip draw mode
  67638. */
  67639. static readonly MATERIAL_LineStripDrawMode: number;
  67640. /**
  67641. * Returns the triangle strip draw mode
  67642. */
  67643. static readonly MATERIAL_TriangleStripDrawMode: number;
  67644. /**
  67645. * Returns the triangle fan draw mode
  67646. */
  67647. static readonly MATERIAL_TriangleFanDrawMode: number;
  67648. /**
  67649. * Stores the clock-wise side orientation
  67650. */
  67651. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67652. /**
  67653. * Stores the counter clock-wise side orientation
  67654. */
  67655. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67656. /**
  67657. * Nothing
  67658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67659. */
  67660. static readonly ACTION_NothingTrigger: number;
  67661. /**
  67662. * On pick
  67663. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67664. */
  67665. static readonly ACTION_OnPickTrigger: number;
  67666. /**
  67667. * On left pick
  67668. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67669. */
  67670. static readonly ACTION_OnLeftPickTrigger: number;
  67671. /**
  67672. * On right pick
  67673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67674. */
  67675. static readonly ACTION_OnRightPickTrigger: number;
  67676. /**
  67677. * On center pick
  67678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67679. */
  67680. static readonly ACTION_OnCenterPickTrigger: number;
  67681. /**
  67682. * On pick down
  67683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67684. */
  67685. static readonly ACTION_OnPickDownTrigger: number;
  67686. /**
  67687. * On double pick
  67688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67689. */
  67690. static readonly ACTION_OnDoublePickTrigger: number;
  67691. /**
  67692. * On pick up
  67693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67694. */
  67695. static readonly ACTION_OnPickUpTrigger: number;
  67696. /**
  67697. * On pick out.
  67698. * This trigger will only be raised if you also declared a OnPickDown
  67699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67700. */
  67701. static readonly ACTION_OnPickOutTrigger: number;
  67702. /**
  67703. * On long press
  67704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67705. */
  67706. static readonly ACTION_OnLongPressTrigger: number;
  67707. /**
  67708. * On pointer over
  67709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67710. */
  67711. static readonly ACTION_OnPointerOverTrigger: number;
  67712. /**
  67713. * On pointer out
  67714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67715. */
  67716. static readonly ACTION_OnPointerOutTrigger: number;
  67717. /**
  67718. * On every frame
  67719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67720. */
  67721. static readonly ACTION_OnEveryFrameTrigger: number;
  67722. /**
  67723. * On intersection enter
  67724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67725. */
  67726. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67727. /**
  67728. * On intersection exit
  67729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67730. */
  67731. static readonly ACTION_OnIntersectionExitTrigger: number;
  67732. /**
  67733. * On key down
  67734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67735. */
  67736. static readonly ACTION_OnKeyDownTrigger: number;
  67737. /**
  67738. * On key up
  67739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67740. */
  67741. static readonly ACTION_OnKeyUpTrigger: number;
  67742. /**
  67743. * Billboard mode will only apply to Y axis
  67744. */
  67745. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67746. /**
  67747. * Billboard mode will apply to all axes
  67748. */
  67749. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67750. /**
  67751. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67752. */
  67753. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67754. /**
  67755. * Gets or sets base Assets URL
  67756. */
  67757. static PARTICLES_BaseAssetsUrl: string;
  67758. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67759. * Test order :
  67760. * Is the bounding sphere outside the frustum ?
  67761. * If not, are the bounding box vertices outside the frustum ?
  67762. * It not, then the cullable object is in the frustum.
  67763. */
  67764. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67765. /** Culling strategy : Bounding Sphere Only.
  67766. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67767. * It's also less accurate than the standard because some not visible objects can still be selected.
  67768. * Test : is the bounding sphere outside the frustum ?
  67769. * If not, then the cullable object is in the frustum.
  67770. */
  67771. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67772. /** Culling strategy : Optimistic Inclusion.
  67773. * This in an inclusion test first, then the standard exclusion test.
  67774. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67775. * 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.
  67776. * Anyway, it's as accurate as the standard strategy.
  67777. * Test :
  67778. * Is the cullable object bounding sphere center in the frustum ?
  67779. * If not, apply the default culling strategy.
  67780. */
  67781. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67782. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67783. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67784. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67785. * 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.
  67786. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67787. * Test :
  67788. * Is the cullable object bounding sphere center in the frustum ?
  67789. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67790. */
  67791. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67792. /**
  67793. * No logging while loading
  67794. */
  67795. static readonly SCENELOADER_NO_LOGGING: number;
  67796. /**
  67797. * Minimal logging while loading
  67798. */
  67799. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67800. /**
  67801. * Summary logging while loading
  67802. */
  67803. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67804. /**
  67805. * Detailled logging while loading
  67806. */
  67807. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67808. }
  67809. }
  67810. declare module BABYLON {
  67811. /**
  67812. * This represents the required contract to create a new type of texture loader.
  67813. */
  67814. export interface IInternalTextureLoader {
  67815. /**
  67816. * Defines wether the loader supports cascade loading the different faces.
  67817. */
  67818. supportCascades: boolean;
  67819. /**
  67820. * This returns if the loader support the current file information.
  67821. * @param extension defines the file extension of the file being loaded
  67822. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67823. * @param fallback defines the fallback internal texture if any
  67824. * @param isBase64 defines whether the texture is encoded as a base64
  67825. * @param isBuffer defines whether the texture data are stored as a buffer
  67826. * @returns true if the loader can load the specified file
  67827. */
  67828. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67829. /**
  67830. * Transform the url before loading if required.
  67831. * @param rootUrl the url of the texture
  67832. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67833. * @returns the transformed texture
  67834. */
  67835. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67836. /**
  67837. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67838. * @param rootUrl the url of the texture
  67839. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67840. * @returns the fallback texture
  67841. */
  67842. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67843. /**
  67844. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67845. * @param data contains the texture data
  67846. * @param texture defines the BabylonJS internal texture
  67847. * @param createPolynomials will be true if polynomials have been requested
  67848. * @param onLoad defines the callback to trigger once the texture is ready
  67849. * @param onError defines the callback to trigger in case of error
  67850. */
  67851. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67852. /**
  67853. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67854. * @param data contains the texture data
  67855. * @param texture defines the BabylonJS internal texture
  67856. * @param callback defines the method to call once ready to upload
  67857. */
  67858. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67859. }
  67860. }
  67861. declare module BABYLON {
  67862. /**
  67863. * Class used to store and describe the pipeline context associated with an effect
  67864. */
  67865. export interface IPipelineContext {
  67866. /**
  67867. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67868. */
  67869. isAsync: boolean;
  67870. /**
  67871. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67872. */
  67873. isReady: boolean;
  67874. /** @hidden */
  67875. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67876. }
  67877. }
  67878. declare module BABYLON {
  67879. /**
  67880. * Class used to store gfx data (like WebGLBuffer)
  67881. */
  67882. export class DataBuffer {
  67883. /**
  67884. * Gets or sets the number of objects referencing this buffer
  67885. */
  67886. references: number;
  67887. /** Gets or sets the size of the underlying buffer */
  67888. capacity: number;
  67889. /**
  67890. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67891. */
  67892. is32Bits: boolean;
  67893. /**
  67894. * Gets the underlying buffer
  67895. */
  67896. readonly underlyingResource: any;
  67897. }
  67898. }
  67899. declare module BABYLON {
  67900. /** @hidden */
  67901. export interface IShaderProcessor {
  67902. attributeProcessor?: (attribute: string) => string;
  67903. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67904. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67905. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67906. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67907. lineProcessor?: (line: string, isFragment: boolean) => string;
  67908. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67909. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67910. }
  67911. }
  67912. declare module BABYLON {
  67913. /** @hidden */
  67914. export interface ProcessingOptions {
  67915. defines: string[];
  67916. indexParameters: any;
  67917. isFragment: boolean;
  67918. shouldUseHighPrecisionShader: boolean;
  67919. supportsUniformBuffers: boolean;
  67920. shadersRepository: string;
  67921. includesShadersStore: {
  67922. [key: string]: string;
  67923. };
  67924. processor?: IShaderProcessor;
  67925. version: string;
  67926. platformName: string;
  67927. lookForClosingBracketForUniformBuffer?: boolean;
  67928. }
  67929. }
  67930. declare module BABYLON {
  67931. /**
  67932. * Helper to manipulate strings
  67933. */
  67934. export class StringTools {
  67935. /**
  67936. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67937. * @param str Source string
  67938. * @param suffix Suffix to search for in the source string
  67939. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67940. */
  67941. static EndsWith(str: string, suffix: string): boolean;
  67942. /**
  67943. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67944. * @param str Source string
  67945. * @param suffix Suffix to search for in the source string
  67946. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67947. */
  67948. static StartsWith(str: string, suffix: string): boolean;
  67949. }
  67950. }
  67951. declare module BABYLON {
  67952. /** @hidden */
  67953. export class ShaderCodeNode {
  67954. line: string;
  67955. children: ShaderCodeNode[];
  67956. additionalDefineKey?: string;
  67957. additionalDefineValue?: string;
  67958. isValid(preprocessors: {
  67959. [key: string]: string;
  67960. }): boolean;
  67961. process(preprocessors: {
  67962. [key: string]: string;
  67963. }, options: ProcessingOptions): string;
  67964. }
  67965. }
  67966. declare module BABYLON {
  67967. /** @hidden */
  67968. export class ShaderCodeCursor {
  67969. private _lines;
  67970. lineIndex: number;
  67971. readonly currentLine: string;
  67972. readonly canRead: boolean;
  67973. lines: string[];
  67974. }
  67975. }
  67976. declare module BABYLON {
  67977. /** @hidden */
  67978. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67979. process(preprocessors: {
  67980. [key: string]: string;
  67981. }, options: ProcessingOptions): string;
  67982. }
  67983. }
  67984. declare module BABYLON {
  67985. /** @hidden */
  67986. export class ShaderDefineExpression {
  67987. isTrue(preprocessors: {
  67988. [key: string]: string;
  67989. }): boolean;
  67990. }
  67991. }
  67992. declare module BABYLON {
  67993. /** @hidden */
  67994. export class ShaderCodeTestNode extends ShaderCodeNode {
  67995. testExpression: ShaderDefineExpression;
  67996. isValid(preprocessors: {
  67997. [key: string]: string;
  67998. }): boolean;
  67999. }
  68000. }
  68001. declare module BABYLON {
  68002. /** @hidden */
  68003. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68004. define: string;
  68005. not: boolean;
  68006. constructor(define: string, not?: boolean);
  68007. isTrue(preprocessors: {
  68008. [key: string]: string;
  68009. }): boolean;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68015. leftOperand: ShaderDefineExpression;
  68016. rightOperand: ShaderDefineExpression;
  68017. isTrue(preprocessors: {
  68018. [key: string]: string;
  68019. }): boolean;
  68020. }
  68021. }
  68022. declare module BABYLON {
  68023. /** @hidden */
  68024. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68025. leftOperand: ShaderDefineExpression;
  68026. rightOperand: ShaderDefineExpression;
  68027. isTrue(preprocessors: {
  68028. [key: string]: string;
  68029. }): boolean;
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /** @hidden */
  68034. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68035. define: string;
  68036. operand: string;
  68037. testValue: string;
  68038. constructor(define: string, operand: string, testValue: string);
  68039. isTrue(preprocessors: {
  68040. [key: string]: string;
  68041. }): boolean;
  68042. }
  68043. }
  68044. declare module BABYLON {
  68045. /**
  68046. * @ignore
  68047. * Application error to support additional information when loading a file
  68048. */
  68049. export class LoadFileError extends Error {
  68050. /** defines the optional web request */
  68051. request?: WebRequest | undefined;
  68052. private static _setPrototypeOf;
  68053. /**
  68054. * Creates a new LoadFileError
  68055. * @param message defines the message of the error
  68056. * @param request defines the optional web request
  68057. */
  68058. constructor(message: string,
  68059. /** defines the optional web request */
  68060. request?: WebRequest | undefined);
  68061. }
  68062. }
  68063. declare module BABYLON {
  68064. /**
  68065. * Class used to enable access to offline support
  68066. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68067. */
  68068. export interface IOfflineProvider {
  68069. /**
  68070. * Gets a boolean indicating if scene must be saved in the database
  68071. */
  68072. enableSceneOffline: boolean;
  68073. /**
  68074. * Gets a boolean indicating if textures must be saved in the database
  68075. */
  68076. enableTexturesOffline: boolean;
  68077. /**
  68078. * Open the offline support and make it available
  68079. * @param successCallback defines the callback to call on success
  68080. * @param errorCallback defines the callback to call on error
  68081. */
  68082. open(successCallback: () => void, errorCallback: () => void): void;
  68083. /**
  68084. * Loads an image from the offline support
  68085. * @param url defines the url to load from
  68086. * @param image defines the target DOM image
  68087. */
  68088. loadImage(url: string, image: HTMLImageElement): void;
  68089. /**
  68090. * Loads a file from offline support
  68091. * @param url defines the URL to load from
  68092. * @param sceneLoaded defines a callback to call on success
  68093. * @param progressCallBack defines a callback to call when progress changed
  68094. * @param errorCallback defines a callback to call on error
  68095. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68096. */
  68097. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68098. }
  68099. }
  68100. declare module BABYLON {
  68101. /**
  68102. * Class used to help managing file picking and drag'n'drop
  68103. * File Storage
  68104. */
  68105. export class FilesInputStore {
  68106. /**
  68107. * List of files ready to be loaded
  68108. */
  68109. static FilesToLoad: {
  68110. [key: string]: File;
  68111. };
  68112. }
  68113. }
  68114. declare module BABYLON {
  68115. /**
  68116. * Class used to define a retry strategy when error happens while loading assets
  68117. */
  68118. export class RetryStrategy {
  68119. /**
  68120. * Function used to defines an exponential back off strategy
  68121. * @param maxRetries defines the maximum number of retries (3 by default)
  68122. * @param baseInterval defines the interval between retries
  68123. * @returns the strategy function to use
  68124. */
  68125. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68126. }
  68127. }
  68128. declare module BABYLON {
  68129. /**
  68130. * @hidden
  68131. */
  68132. export class FileTools {
  68133. /**
  68134. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68135. */
  68136. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68137. /**
  68138. * Gets or sets the base URL to use to load assets
  68139. */
  68140. static BaseUrl: string;
  68141. /**
  68142. * Default behaviour for cors in the application.
  68143. * It can be a string if the expected behavior is identical in the entire app.
  68144. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68145. */
  68146. static CorsBehavior: string | ((url: string | string[]) => string);
  68147. /**
  68148. * Gets or sets a function used to pre-process url before using them to load assets
  68149. */
  68150. static PreprocessUrl: (url: string) => string;
  68151. /**
  68152. * Removes unwanted characters from an url
  68153. * @param url defines the url to clean
  68154. * @returns the cleaned url
  68155. */
  68156. private static _CleanUrl;
  68157. /**
  68158. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68159. * @param url define the url we are trying
  68160. * @param element define the dom element where to configure the cors policy
  68161. */
  68162. static SetCorsBehavior(url: string | string[], element: {
  68163. crossOrigin: string | null;
  68164. }): void;
  68165. /**
  68166. * Loads an image as an HTMLImageElement.
  68167. * @param input url string, ArrayBuffer, or Blob to load
  68168. * @param onLoad callback called when the image successfully loads
  68169. * @param onError callback called when the image fails to load
  68170. * @param offlineProvider offline provider for caching
  68171. * @returns the HTMLImageElement of the loaded image
  68172. */
  68173. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  68174. /**
  68175. * Loads a file
  68176. * @param fileToLoad defines the file to load
  68177. * @param callback defines the callback to call when data is loaded
  68178. * @param progressCallBack defines the callback to call during loading process
  68179. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68180. * @returns a file request object
  68181. */
  68182. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68183. /**
  68184. * Loads a file
  68185. * @param url url string, ArrayBuffer, or Blob to load
  68186. * @param onSuccess callback called when the file successfully loads
  68187. * @param onProgress callback called while file is loading (if the server supports this mode)
  68188. * @param offlineProvider defines the offline provider for caching
  68189. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68190. * @param onError callback called when the file fails to load
  68191. * @returns a file request object
  68192. */
  68193. 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;
  68194. /**
  68195. * Checks if the loaded document was accessed via `file:`-Protocol.
  68196. * @returns boolean
  68197. */
  68198. static IsFileURL(): boolean;
  68199. }
  68200. }
  68201. declare module BABYLON {
  68202. /** @hidden */
  68203. export class ShaderProcessor {
  68204. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68205. private static _ProcessPrecision;
  68206. private static _ExtractOperation;
  68207. private static _BuildSubExpression;
  68208. private static _BuildExpression;
  68209. private static _MoveCursorWithinIf;
  68210. private static _MoveCursor;
  68211. private static _EvaluatePreProcessors;
  68212. private static _PreparePreProcessors;
  68213. private static _ProcessShaderConversion;
  68214. private static _ProcessIncludes;
  68215. }
  68216. }
  68217. declare module BABYLON {
  68218. /**
  68219. * @hidden
  68220. */
  68221. export interface IColor4Like {
  68222. r: float;
  68223. g: float;
  68224. b: float;
  68225. a: float;
  68226. }
  68227. /**
  68228. * @hidden
  68229. */
  68230. export interface IColor3Like {
  68231. r: float;
  68232. g: float;
  68233. b: float;
  68234. }
  68235. /**
  68236. * @hidden
  68237. */
  68238. export interface IVector4Like {
  68239. x: float;
  68240. y: float;
  68241. z: float;
  68242. w: float;
  68243. }
  68244. /**
  68245. * @hidden
  68246. */
  68247. export interface IVector3Like {
  68248. x: float;
  68249. y: float;
  68250. z: float;
  68251. }
  68252. /**
  68253. * @hidden
  68254. */
  68255. export interface IVector2Like {
  68256. x: float;
  68257. y: float;
  68258. }
  68259. /**
  68260. * @hidden
  68261. */
  68262. export interface IMatrixLike {
  68263. toArray(): DeepImmutable<Float32Array>;
  68264. updateFlag: int;
  68265. }
  68266. /**
  68267. * @hidden
  68268. */
  68269. export interface IViewportLike {
  68270. x: float;
  68271. y: float;
  68272. width: float;
  68273. height: float;
  68274. }
  68275. /**
  68276. * @hidden
  68277. */
  68278. export interface IPlaneLike {
  68279. normal: IVector3Like;
  68280. d: float;
  68281. normalize(): void;
  68282. }
  68283. }
  68284. declare module BABYLON {
  68285. /**
  68286. * Interface used to define common properties for effect fallbacks
  68287. */
  68288. export interface IEffectFallbacks {
  68289. /**
  68290. * Removes the defines that should be removed when falling back.
  68291. * @param currentDefines defines the current define statements for the shader.
  68292. * @param effect defines the current effect we try to compile
  68293. * @returns The resulting defines with defines of the current rank removed.
  68294. */
  68295. reduce(currentDefines: string, effect: Effect): string;
  68296. /**
  68297. * Removes the fallback from the bound mesh.
  68298. */
  68299. unBindMesh(): void;
  68300. /**
  68301. * Checks to see if more fallbacks are still availible.
  68302. */
  68303. hasMoreFallbacks: boolean;
  68304. }
  68305. }
  68306. declare module BABYLON {
  68307. /**
  68308. * Class used to evalaute queries containing `and` and `or` operators
  68309. */
  68310. export class AndOrNotEvaluator {
  68311. /**
  68312. * Evaluate a query
  68313. * @param query defines the query to evaluate
  68314. * @param evaluateCallback defines the callback used to filter result
  68315. * @returns true if the query matches
  68316. */
  68317. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68318. private static _HandleParenthesisContent;
  68319. private static _SimplifyNegation;
  68320. }
  68321. }
  68322. declare module BABYLON {
  68323. /**
  68324. * Class used to store custom tags
  68325. */
  68326. export class Tags {
  68327. /**
  68328. * Adds support for tags on the given object
  68329. * @param obj defines the object to use
  68330. */
  68331. static EnableFor(obj: any): void;
  68332. /**
  68333. * Removes tags support
  68334. * @param obj defines the object to use
  68335. */
  68336. static DisableFor(obj: any): void;
  68337. /**
  68338. * Gets a boolean indicating if the given object has tags
  68339. * @param obj defines the object to use
  68340. * @returns a boolean
  68341. */
  68342. static HasTags(obj: any): boolean;
  68343. /**
  68344. * Gets the tags available on a given object
  68345. * @param obj defines the object to use
  68346. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68347. * @returns the tags
  68348. */
  68349. static GetTags(obj: any, asString?: boolean): any;
  68350. /**
  68351. * Adds tags to an object
  68352. * @param obj defines the object to use
  68353. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68354. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68355. */
  68356. static AddTagsTo(obj: any, tagsString: string): void;
  68357. /**
  68358. * @hidden
  68359. */
  68360. static _AddTagTo(obj: any, tag: string): void;
  68361. /**
  68362. * Removes specific tags from a specific object
  68363. * @param obj defines the object to use
  68364. * @param tagsString defines the tags to remove
  68365. */
  68366. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68367. /**
  68368. * @hidden
  68369. */
  68370. static _RemoveTagFrom(obj: any, tag: string): void;
  68371. /**
  68372. * Defines if tags hosted on an object match a given query
  68373. * @param obj defines the object to use
  68374. * @param tagsQuery defines the tag query
  68375. * @returns a boolean
  68376. */
  68377. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68378. }
  68379. }
  68380. declare module BABYLON {
  68381. /**
  68382. * Scalar computation library
  68383. */
  68384. export class Scalar {
  68385. /**
  68386. * Two pi constants convenient for computation.
  68387. */
  68388. static TwoPi: number;
  68389. /**
  68390. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68391. * @param a number
  68392. * @param b number
  68393. * @param epsilon (default = 1.401298E-45)
  68394. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68395. */
  68396. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68397. /**
  68398. * Returns a string : the upper case translation of the number i to hexadecimal.
  68399. * @param i number
  68400. * @returns the upper case translation of the number i to hexadecimal.
  68401. */
  68402. static ToHex(i: number): string;
  68403. /**
  68404. * Returns -1 if value is negative and +1 is value is positive.
  68405. * @param value the value
  68406. * @returns the value itself if it's equal to zero.
  68407. */
  68408. static Sign(value: number): number;
  68409. /**
  68410. * Returns the value itself if it's between min and max.
  68411. * Returns min if the value is lower than min.
  68412. * Returns max if the value is greater than max.
  68413. * @param value the value to clmap
  68414. * @param min the min value to clamp to (default: 0)
  68415. * @param max the max value to clamp to (default: 1)
  68416. * @returns the clamped value
  68417. */
  68418. static Clamp(value: number, min?: number, max?: number): number;
  68419. /**
  68420. * the log2 of value.
  68421. * @param value the value to compute log2 of
  68422. * @returns the log2 of value.
  68423. */
  68424. static Log2(value: number): number;
  68425. /**
  68426. * Loops the value, so that it is never larger than length and never smaller than 0.
  68427. *
  68428. * This is similar to the modulo operator but it works with floating point numbers.
  68429. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68430. * With t = 5 and length = 2.5, the result would be 0.0.
  68431. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68432. * @param value the value
  68433. * @param length the length
  68434. * @returns the looped value
  68435. */
  68436. static Repeat(value: number, length: number): number;
  68437. /**
  68438. * Normalize the value between 0.0 and 1.0 using min and max values
  68439. * @param value value to normalize
  68440. * @param min max to normalize between
  68441. * @param max min to normalize between
  68442. * @returns the normalized value
  68443. */
  68444. static Normalize(value: number, min: number, max: number): number;
  68445. /**
  68446. * Denormalize the value from 0.0 and 1.0 using min and max values
  68447. * @param normalized value to denormalize
  68448. * @param min max to denormalize between
  68449. * @param max min to denormalize between
  68450. * @returns the denormalized value
  68451. */
  68452. static Denormalize(normalized: number, min: number, max: number): number;
  68453. /**
  68454. * Calculates the shortest difference between two given angles given in degrees.
  68455. * @param current current angle in degrees
  68456. * @param target target angle in degrees
  68457. * @returns the delta
  68458. */
  68459. static DeltaAngle(current: number, target: number): number;
  68460. /**
  68461. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68462. * @param tx value
  68463. * @param length length
  68464. * @returns The returned value will move back and forth between 0 and length
  68465. */
  68466. static PingPong(tx: number, length: number): number;
  68467. /**
  68468. * Interpolates between min and max with smoothing at the limits.
  68469. *
  68470. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68471. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68472. * @param from from
  68473. * @param to to
  68474. * @param tx value
  68475. * @returns the smooth stepped value
  68476. */
  68477. static SmoothStep(from: number, to: number, tx: number): number;
  68478. /**
  68479. * Moves a value current towards target.
  68480. *
  68481. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68482. * Negative values of maxDelta pushes the value away from target.
  68483. * @param current current value
  68484. * @param target target value
  68485. * @param maxDelta max distance to move
  68486. * @returns resulting value
  68487. */
  68488. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68489. /**
  68490. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68491. *
  68492. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68493. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68494. * @param current current value
  68495. * @param target target value
  68496. * @param maxDelta max distance to move
  68497. * @returns resulting angle
  68498. */
  68499. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68500. /**
  68501. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68502. * @param start start value
  68503. * @param end target value
  68504. * @param amount amount to lerp between
  68505. * @returns the lerped value
  68506. */
  68507. static Lerp(start: number, end: number, amount: number): number;
  68508. /**
  68509. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68510. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68511. * @param start start value
  68512. * @param end target value
  68513. * @param amount amount to lerp between
  68514. * @returns the lerped value
  68515. */
  68516. static LerpAngle(start: number, end: number, amount: number): number;
  68517. /**
  68518. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68519. * @param a start value
  68520. * @param b target value
  68521. * @param value value between a and b
  68522. * @returns the inverseLerp value
  68523. */
  68524. static InverseLerp(a: number, b: number, value: number): number;
  68525. /**
  68526. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68527. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68528. * @param value1 spline value
  68529. * @param tangent1 spline value
  68530. * @param value2 spline value
  68531. * @param tangent2 spline value
  68532. * @param amount input value
  68533. * @returns hermite result
  68534. */
  68535. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68536. /**
  68537. * Returns a random float number between and min and max values
  68538. * @param min min value of random
  68539. * @param max max value of random
  68540. * @returns random value
  68541. */
  68542. static RandomRange(min: number, max: number): number;
  68543. /**
  68544. * This function returns percentage of a number in a given range.
  68545. *
  68546. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68547. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68548. * @param number to convert to percentage
  68549. * @param min min range
  68550. * @param max max range
  68551. * @returns the percentage
  68552. */
  68553. static RangeToPercent(number: number, min: number, max: number): number;
  68554. /**
  68555. * This function returns number that corresponds to the percentage in a given range.
  68556. *
  68557. * PercentToRange(0.34,0,100) will return 34.
  68558. * @param percent to convert to number
  68559. * @param min min range
  68560. * @param max max range
  68561. * @returns the number
  68562. */
  68563. static PercentToRange(percent: number, min: number, max: number): number;
  68564. /**
  68565. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68566. * @param angle The angle to normalize in radian.
  68567. * @return The converted angle.
  68568. */
  68569. static NormalizeRadians(angle: number): number;
  68570. }
  68571. }
  68572. declare module BABYLON {
  68573. /**
  68574. * Constant used to convert a value to gamma space
  68575. * @ignorenaming
  68576. */
  68577. export const ToGammaSpace: number;
  68578. /**
  68579. * Constant used to convert a value to linear space
  68580. * @ignorenaming
  68581. */
  68582. export const ToLinearSpace = 2.2;
  68583. /**
  68584. * Constant used to define the minimal number value in Babylon.js
  68585. * @ignorenaming
  68586. */
  68587. let Epsilon: number;
  68588. }
  68589. declare module BABYLON {
  68590. /**
  68591. * Class used to represent a viewport on screen
  68592. */
  68593. export class Viewport {
  68594. /** viewport left coordinate */
  68595. x: number;
  68596. /** viewport top coordinate */
  68597. y: number;
  68598. /**viewport width */
  68599. width: number;
  68600. /** viewport height */
  68601. height: number;
  68602. /**
  68603. * Creates a Viewport object located at (x, y) and sized (width, height)
  68604. * @param x defines viewport left coordinate
  68605. * @param y defines viewport top coordinate
  68606. * @param width defines the viewport width
  68607. * @param height defines the viewport height
  68608. */
  68609. constructor(
  68610. /** viewport left coordinate */
  68611. x: number,
  68612. /** viewport top coordinate */
  68613. y: number,
  68614. /**viewport width */
  68615. width: number,
  68616. /** viewport height */
  68617. height: number);
  68618. /**
  68619. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68620. * @param renderWidth defines the rendering width
  68621. * @param renderHeight defines the rendering height
  68622. * @returns a new Viewport
  68623. */
  68624. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68625. /**
  68626. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68627. * @param renderWidth defines the rendering width
  68628. * @param renderHeight defines the rendering height
  68629. * @param ref defines the target viewport
  68630. * @returns the current viewport
  68631. */
  68632. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68633. /**
  68634. * Returns a new Viewport copied from the current one
  68635. * @returns a new Viewport
  68636. */
  68637. clone(): Viewport;
  68638. }
  68639. }
  68640. declare module BABYLON {
  68641. /**
  68642. * Class containing a set of static utilities functions for arrays.
  68643. */
  68644. export class ArrayTools {
  68645. /**
  68646. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68647. * @param size the number of element to construct and put in the array
  68648. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68649. * @returns a new array filled with new objects
  68650. */
  68651. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68652. }
  68653. }
  68654. declare module BABYLON {
  68655. /**
  68656. * Class representing a vector containing 2 coordinates
  68657. */
  68658. export class Vector2 {
  68659. /** defines the first coordinate */
  68660. x: number;
  68661. /** defines the second coordinate */
  68662. y: number;
  68663. /**
  68664. * Creates a new Vector2 from the given x and y coordinates
  68665. * @param x defines the first coordinate
  68666. * @param y defines the second coordinate
  68667. */
  68668. constructor(
  68669. /** defines the first coordinate */
  68670. x?: number,
  68671. /** defines the second coordinate */
  68672. y?: number);
  68673. /**
  68674. * Gets a string with the Vector2 coordinates
  68675. * @returns a string with the Vector2 coordinates
  68676. */
  68677. toString(): string;
  68678. /**
  68679. * Gets class name
  68680. * @returns the string "Vector2"
  68681. */
  68682. getClassName(): string;
  68683. /**
  68684. * Gets current vector hash code
  68685. * @returns the Vector2 hash code as a number
  68686. */
  68687. getHashCode(): number;
  68688. /**
  68689. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68690. * @param array defines the source array
  68691. * @param index defines the offset in source array
  68692. * @returns the current Vector2
  68693. */
  68694. toArray(array: FloatArray, index?: number): Vector2;
  68695. /**
  68696. * Copy the current vector to an array
  68697. * @returns a new array with 2 elements: the Vector2 coordinates.
  68698. */
  68699. asArray(): number[];
  68700. /**
  68701. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68702. * @param source defines the source Vector2
  68703. * @returns the current updated Vector2
  68704. */
  68705. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68706. /**
  68707. * Sets the Vector2 coordinates with the given floats
  68708. * @param x defines the first coordinate
  68709. * @param y defines the second coordinate
  68710. * @returns the current updated Vector2
  68711. */
  68712. copyFromFloats(x: number, y: number): Vector2;
  68713. /**
  68714. * Sets the Vector2 coordinates with the given floats
  68715. * @param x defines the first coordinate
  68716. * @param y defines the second coordinate
  68717. * @returns the current updated Vector2
  68718. */
  68719. set(x: number, y: number): Vector2;
  68720. /**
  68721. * Add another vector with the current one
  68722. * @param otherVector defines the other vector
  68723. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68724. */
  68725. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68726. /**
  68727. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68728. * @param otherVector defines the other vector
  68729. * @param result defines the target vector
  68730. * @returns the unmodified current Vector2
  68731. */
  68732. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68733. /**
  68734. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68735. * @param otherVector defines the other vector
  68736. * @returns the current updated Vector2
  68737. */
  68738. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68739. /**
  68740. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68741. * @param otherVector defines the other vector
  68742. * @returns a new Vector2
  68743. */
  68744. addVector3(otherVector: Vector3): Vector2;
  68745. /**
  68746. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68747. * @param otherVector defines the other vector
  68748. * @returns a new Vector2
  68749. */
  68750. subtract(otherVector: Vector2): Vector2;
  68751. /**
  68752. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68753. * @param otherVector defines the other vector
  68754. * @param result defines the target vector
  68755. * @returns the unmodified current Vector2
  68756. */
  68757. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68758. /**
  68759. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68760. * @param otherVector defines the other vector
  68761. * @returns the current updated Vector2
  68762. */
  68763. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68764. /**
  68765. * Multiplies in place the current Vector2 coordinates by the given ones
  68766. * @param otherVector defines the other vector
  68767. * @returns the current updated Vector2
  68768. */
  68769. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68770. /**
  68771. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68772. * @param otherVector defines the other vector
  68773. * @returns a new Vector2
  68774. */
  68775. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68776. /**
  68777. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68778. * @param otherVector defines the other vector
  68779. * @param result defines the target vector
  68780. * @returns the unmodified current Vector2
  68781. */
  68782. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68783. /**
  68784. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68785. * @param x defines the first coordinate
  68786. * @param y defines the second coordinate
  68787. * @returns a new Vector2
  68788. */
  68789. multiplyByFloats(x: number, y: number): Vector2;
  68790. /**
  68791. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68792. * @param otherVector defines the other vector
  68793. * @returns a new Vector2
  68794. */
  68795. divide(otherVector: Vector2): Vector2;
  68796. /**
  68797. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68798. * @param otherVector defines the other vector
  68799. * @param result defines the target vector
  68800. * @returns the unmodified current Vector2
  68801. */
  68802. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68803. /**
  68804. * Divides the current Vector2 coordinates by the given ones
  68805. * @param otherVector defines the other vector
  68806. * @returns the current updated Vector2
  68807. */
  68808. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68809. /**
  68810. * Gets a new Vector2 with current Vector2 negated coordinates
  68811. * @returns a new Vector2
  68812. */
  68813. negate(): Vector2;
  68814. /**
  68815. * Multiply the Vector2 coordinates by scale
  68816. * @param scale defines the scaling factor
  68817. * @returns the current updated Vector2
  68818. */
  68819. scaleInPlace(scale: number): Vector2;
  68820. /**
  68821. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68822. * @param scale defines the scaling factor
  68823. * @returns a new Vector2
  68824. */
  68825. scale(scale: number): Vector2;
  68826. /**
  68827. * Scale the current Vector2 values by a factor to a given Vector2
  68828. * @param scale defines the scale factor
  68829. * @param result defines the Vector2 object where to store the result
  68830. * @returns the unmodified current Vector2
  68831. */
  68832. scaleToRef(scale: number, result: Vector2): Vector2;
  68833. /**
  68834. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68835. * @param scale defines the scale factor
  68836. * @param result defines the Vector2 object where to store the result
  68837. * @returns the unmodified current Vector2
  68838. */
  68839. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68840. /**
  68841. * Gets a boolean if two vectors are equals
  68842. * @param otherVector defines the other vector
  68843. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68844. */
  68845. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68846. /**
  68847. * Gets a boolean if two vectors are equals (using an epsilon value)
  68848. * @param otherVector defines the other vector
  68849. * @param epsilon defines the minimal distance to consider equality
  68850. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68851. */
  68852. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68853. /**
  68854. * Gets a new Vector2 from current Vector2 floored values
  68855. * @returns a new Vector2
  68856. */
  68857. floor(): Vector2;
  68858. /**
  68859. * Gets a new Vector2 from current Vector2 floored values
  68860. * @returns a new Vector2
  68861. */
  68862. fract(): Vector2;
  68863. /**
  68864. * Gets the length of the vector
  68865. * @returns the vector length (float)
  68866. */
  68867. length(): number;
  68868. /**
  68869. * Gets the vector squared length
  68870. * @returns the vector squared length (float)
  68871. */
  68872. lengthSquared(): number;
  68873. /**
  68874. * Normalize the vector
  68875. * @returns the current updated Vector2
  68876. */
  68877. normalize(): Vector2;
  68878. /**
  68879. * Gets a new Vector2 copied from the Vector2
  68880. * @returns a new Vector2
  68881. */
  68882. clone(): Vector2;
  68883. /**
  68884. * Gets a new Vector2(0, 0)
  68885. * @returns a new Vector2
  68886. */
  68887. static Zero(): Vector2;
  68888. /**
  68889. * Gets a new Vector2(1, 1)
  68890. * @returns a new Vector2
  68891. */
  68892. static One(): Vector2;
  68893. /**
  68894. * Gets a new Vector2 set from the given index element of the given array
  68895. * @param array defines the data source
  68896. * @param offset defines the offset in the data source
  68897. * @returns a new Vector2
  68898. */
  68899. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68900. /**
  68901. * Sets "result" from the given index element of the given array
  68902. * @param array defines the data source
  68903. * @param offset defines the offset in the data source
  68904. * @param result defines the target vector
  68905. */
  68906. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68907. /**
  68908. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68909. * @param value1 defines 1st point of control
  68910. * @param value2 defines 2nd point of control
  68911. * @param value3 defines 3rd point of control
  68912. * @param value4 defines 4th point of control
  68913. * @param amount defines the interpolation factor
  68914. * @returns a new Vector2
  68915. */
  68916. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68917. /**
  68918. * 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".
  68919. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68920. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68921. * @param value defines the value to clamp
  68922. * @param min defines the lower limit
  68923. * @param max defines the upper limit
  68924. * @returns a new Vector2
  68925. */
  68926. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68927. /**
  68928. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68929. * @param value1 defines the 1st control point
  68930. * @param tangent1 defines the outgoing tangent
  68931. * @param value2 defines the 2nd control point
  68932. * @param tangent2 defines the incoming tangent
  68933. * @param amount defines the interpolation factor
  68934. * @returns a new Vector2
  68935. */
  68936. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68937. /**
  68938. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68939. * @param start defines the start vector
  68940. * @param end defines the end vector
  68941. * @param amount defines the interpolation factor
  68942. * @returns a new Vector2
  68943. */
  68944. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68945. /**
  68946. * Gets the dot product of the vector "left" and the vector "right"
  68947. * @param left defines first vector
  68948. * @param right defines second vector
  68949. * @returns the dot product (float)
  68950. */
  68951. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68952. /**
  68953. * Returns a new Vector2 equal to the normalized given vector
  68954. * @param vector defines the vector to normalize
  68955. * @returns a new Vector2
  68956. */
  68957. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68958. /**
  68959. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68960. * @param left defines 1st vector
  68961. * @param right defines 2nd vector
  68962. * @returns a new Vector2
  68963. */
  68964. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68965. /**
  68966. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68967. * @param left defines 1st vector
  68968. * @param right defines 2nd vector
  68969. * @returns a new Vector2
  68970. */
  68971. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68972. /**
  68973. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68974. * @param vector defines the vector to transform
  68975. * @param transformation defines the matrix to apply
  68976. * @returns a new Vector2
  68977. */
  68978. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  68979. /**
  68980. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  68981. * @param vector defines the vector to transform
  68982. * @param transformation defines the matrix to apply
  68983. * @param result defines the target vector
  68984. */
  68985. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  68986. /**
  68987. * Determines if a given vector is included in a triangle
  68988. * @param p defines the vector to test
  68989. * @param p0 defines 1st triangle point
  68990. * @param p1 defines 2nd triangle point
  68991. * @param p2 defines 3rd triangle point
  68992. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  68993. */
  68994. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  68995. /**
  68996. * Gets the distance between the vectors "value1" and "value2"
  68997. * @param value1 defines first vector
  68998. * @param value2 defines second vector
  68999. * @returns the distance between vectors
  69000. */
  69001. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69002. /**
  69003. * Returns the squared distance between the vectors "value1" and "value2"
  69004. * @param value1 defines first vector
  69005. * @param value2 defines second vector
  69006. * @returns the squared distance between vectors
  69007. */
  69008. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69009. /**
  69010. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69011. * @param value1 defines first vector
  69012. * @param value2 defines second vector
  69013. * @returns a new Vector2
  69014. */
  69015. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69016. /**
  69017. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69018. * @param p defines the middle point
  69019. * @param segA defines one point of the segment
  69020. * @param segB defines the other point of the segment
  69021. * @returns the shortest distance
  69022. */
  69023. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69024. }
  69025. /**
  69026. * Classed used to store (x,y,z) vector representation
  69027. * A Vector3 is the main object used in 3D geometry
  69028. * It can represent etiher the coordinates of a point the space, either a direction
  69029. * Reminder: js uses a left handed forward facing system
  69030. */
  69031. export class Vector3 {
  69032. /**
  69033. * Defines the first coordinates (on X axis)
  69034. */
  69035. x: number;
  69036. /**
  69037. * Defines the second coordinates (on Y axis)
  69038. */
  69039. y: number;
  69040. /**
  69041. * Defines the third coordinates (on Z axis)
  69042. */
  69043. z: number;
  69044. private static _UpReadOnly;
  69045. private static _ZeroReadOnly;
  69046. /**
  69047. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69048. * @param x defines the first coordinates (on X axis)
  69049. * @param y defines the second coordinates (on Y axis)
  69050. * @param z defines the third coordinates (on Z axis)
  69051. */
  69052. constructor(
  69053. /**
  69054. * Defines the first coordinates (on X axis)
  69055. */
  69056. x?: number,
  69057. /**
  69058. * Defines the second coordinates (on Y axis)
  69059. */
  69060. y?: number,
  69061. /**
  69062. * Defines the third coordinates (on Z axis)
  69063. */
  69064. z?: number);
  69065. /**
  69066. * Creates a string representation of the Vector3
  69067. * @returns a string with the Vector3 coordinates.
  69068. */
  69069. toString(): string;
  69070. /**
  69071. * Gets the class name
  69072. * @returns the string "Vector3"
  69073. */
  69074. getClassName(): string;
  69075. /**
  69076. * Creates the Vector3 hash code
  69077. * @returns a number which tends to be unique between Vector3 instances
  69078. */
  69079. getHashCode(): number;
  69080. /**
  69081. * Creates an array containing three elements : the coordinates of the Vector3
  69082. * @returns a new array of numbers
  69083. */
  69084. asArray(): number[];
  69085. /**
  69086. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69087. * @param array defines the destination array
  69088. * @param index defines the offset in the destination array
  69089. * @returns the current Vector3
  69090. */
  69091. toArray(array: FloatArray, index?: number): Vector3;
  69092. /**
  69093. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69094. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69095. */
  69096. toQuaternion(): Quaternion;
  69097. /**
  69098. * Adds the given vector to the current Vector3
  69099. * @param otherVector defines the second operand
  69100. * @returns the current updated Vector3
  69101. */
  69102. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69103. /**
  69104. * Adds the given coordinates to the current Vector3
  69105. * @param x defines the x coordinate of the operand
  69106. * @param y defines the y coordinate of the operand
  69107. * @param z defines the z coordinate of the operand
  69108. * @returns the current updated Vector3
  69109. */
  69110. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69111. /**
  69112. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69113. * @param otherVector defines the second operand
  69114. * @returns the resulting Vector3
  69115. */
  69116. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69117. /**
  69118. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69119. * @param otherVector defines the second operand
  69120. * @param result defines the Vector3 object where to store the result
  69121. * @returns the current Vector3
  69122. */
  69123. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69124. /**
  69125. * Subtract the given vector from the current Vector3
  69126. * @param otherVector defines the second operand
  69127. * @returns the current updated Vector3
  69128. */
  69129. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69130. /**
  69131. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69132. * @param otherVector defines the second operand
  69133. * @returns the resulting Vector3
  69134. */
  69135. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69136. /**
  69137. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69138. * @param otherVector defines the second operand
  69139. * @param result defines the Vector3 object where to store the result
  69140. * @returns the current Vector3
  69141. */
  69142. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69143. /**
  69144. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69145. * @param x defines the x coordinate of the operand
  69146. * @param y defines the y coordinate of the operand
  69147. * @param z defines the z coordinate of the operand
  69148. * @returns the resulting Vector3
  69149. */
  69150. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69151. /**
  69152. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69153. * @param x defines the x coordinate of the operand
  69154. * @param y defines the y coordinate of the operand
  69155. * @param z defines the z coordinate of the operand
  69156. * @param result defines the Vector3 object where to store the result
  69157. * @returns the current Vector3
  69158. */
  69159. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69160. /**
  69161. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69162. * @returns a new Vector3
  69163. */
  69164. negate(): Vector3;
  69165. /**
  69166. * Multiplies the Vector3 coordinates by the float "scale"
  69167. * @param scale defines the multiplier factor
  69168. * @returns the current updated Vector3
  69169. */
  69170. scaleInPlace(scale: number): Vector3;
  69171. /**
  69172. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69173. * @param scale defines the multiplier factor
  69174. * @returns a new Vector3
  69175. */
  69176. scale(scale: number): Vector3;
  69177. /**
  69178. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69179. * @param scale defines the multiplier factor
  69180. * @param result defines the Vector3 object where to store the result
  69181. * @returns the current Vector3
  69182. */
  69183. scaleToRef(scale: number, result: Vector3): Vector3;
  69184. /**
  69185. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69186. * @param scale defines the scale factor
  69187. * @param result defines the Vector3 object where to store the result
  69188. * @returns the unmodified current Vector3
  69189. */
  69190. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69191. /**
  69192. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69193. * @param otherVector defines the second operand
  69194. * @returns true if both vectors are equals
  69195. */
  69196. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69197. /**
  69198. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69199. * @param otherVector defines the second operand
  69200. * @param epsilon defines the minimal distance to define values as equals
  69201. * @returns true if both vectors are distant less than epsilon
  69202. */
  69203. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69204. /**
  69205. * Returns true if the current Vector3 coordinates equals the given floats
  69206. * @param x defines the x coordinate of the operand
  69207. * @param y defines the y coordinate of the operand
  69208. * @param z defines the z coordinate of the operand
  69209. * @returns true if both vectors are equals
  69210. */
  69211. equalsToFloats(x: number, y: number, z: number): boolean;
  69212. /**
  69213. * Multiplies the current Vector3 coordinates by the given ones
  69214. * @param otherVector defines the second operand
  69215. * @returns the current updated Vector3
  69216. */
  69217. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69218. /**
  69219. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69220. * @param otherVector defines the second operand
  69221. * @returns the new Vector3
  69222. */
  69223. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69224. /**
  69225. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69226. * @param otherVector defines the second operand
  69227. * @param result defines the Vector3 object where to store the result
  69228. * @returns the current Vector3
  69229. */
  69230. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69231. /**
  69232. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69233. * @param x defines the x coordinate of the operand
  69234. * @param y defines the y coordinate of the operand
  69235. * @param z defines the z coordinate of the operand
  69236. * @returns the new Vector3
  69237. */
  69238. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69239. /**
  69240. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69241. * @param otherVector defines the second operand
  69242. * @returns the new Vector3
  69243. */
  69244. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69245. /**
  69246. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69247. * @param otherVector defines the second operand
  69248. * @param result defines the Vector3 object where to store the result
  69249. * @returns the current Vector3
  69250. */
  69251. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69252. /**
  69253. * Divides the current Vector3 coordinates by the given ones.
  69254. * @param otherVector defines the second operand
  69255. * @returns the current updated Vector3
  69256. */
  69257. divideInPlace(otherVector: Vector3): Vector3;
  69258. /**
  69259. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69260. * @param other defines the second operand
  69261. * @returns the current updated Vector3
  69262. */
  69263. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69264. /**
  69265. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69266. * @param other defines the second operand
  69267. * @returns the current updated Vector3
  69268. */
  69269. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69270. /**
  69271. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69272. * @param x defines the x coordinate of the operand
  69273. * @param y defines the y coordinate of the operand
  69274. * @param z defines the z coordinate of the operand
  69275. * @returns the current updated Vector3
  69276. */
  69277. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69278. /**
  69279. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69280. * @param x defines the x coordinate of the operand
  69281. * @param y defines the y coordinate of the operand
  69282. * @param z defines the z coordinate of the operand
  69283. * @returns the current updated Vector3
  69284. */
  69285. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69286. /**
  69287. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69288. * Check if is non uniform within a certain amount of decimal places to account for this
  69289. * @param epsilon the amount the values can differ
  69290. * @returns if the the vector is non uniform to a certain number of decimal places
  69291. */
  69292. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69293. /**
  69294. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69295. */
  69296. readonly isNonUniform: boolean;
  69297. /**
  69298. * Gets a new Vector3 from current Vector3 floored values
  69299. * @returns a new Vector3
  69300. */
  69301. floor(): Vector3;
  69302. /**
  69303. * Gets a new Vector3 from current Vector3 floored values
  69304. * @returns a new Vector3
  69305. */
  69306. fract(): Vector3;
  69307. /**
  69308. * Gets the length of the Vector3
  69309. * @returns the length of the Vector3
  69310. */
  69311. length(): number;
  69312. /**
  69313. * Gets the squared length of the Vector3
  69314. * @returns squared length of the Vector3
  69315. */
  69316. lengthSquared(): number;
  69317. /**
  69318. * Normalize the current Vector3.
  69319. * Please note that this is an in place operation.
  69320. * @returns the current updated Vector3
  69321. */
  69322. normalize(): Vector3;
  69323. /**
  69324. * Reorders the x y z properties of the vector in place
  69325. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69326. * @returns the current updated vector
  69327. */
  69328. reorderInPlace(order: string): this;
  69329. /**
  69330. * Rotates the vector around 0,0,0 by a quaternion
  69331. * @param quaternion the rotation quaternion
  69332. * @param result vector to store the result
  69333. * @returns the resulting vector
  69334. */
  69335. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69336. /**
  69337. * Rotates a vector around a given point
  69338. * @param quaternion the rotation quaternion
  69339. * @param point the point to rotate around
  69340. * @param result vector to store the result
  69341. * @returns the resulting vector
  69342. */
  69343. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69344. /**
  69345. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69346. * The cross product is then orthogonal to both current and "other"
  69347. * @param other defines the right operand
  69348. * @returns the cross product
  69349. */
  69350. cross(other: Vector3): Vector3;
  69351. /**
  69352. * Normalize the current Vector3 with the given input length.
  69353. * Please note that this is an in place operation.
  69354. * @param len the length of the vector
  69355. * @returns the current updated Vector3
  69356. */
  69357. normalizeFromLength(len: number): Vector3;
  69358. /**
  69359. * Normalize the current Vector3 to a new vector
  69360. * @returns the new Vector3
  69361. */
  69362. normalizeToNew(): Vector3;
  69363. /**
  69364. * Normalize the current Vector3 to the reference
  69365. * @param reference define the Vector3 to update
  69366. * @returns the updated Vector3
  69367. */
  69368. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69369. /**
  69370. * Creates a new Vector3 copied from the current Vector3
  69371. * @returns the new Vector3
  69372. */
  69373. clone(): Vector3;
  69374. /**
  69375. * Copies the given vector coordinates to the current Vector3 ones
  69376. * @param source defines the source Vector3
  69377. * @returns the current updated Vector3
  69378. */
  69379. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69380. /**
  69381. * Copies the given floats to the current Vector3 coordinates
  69382. * @param x defines the x coordinate of the operand
  69383. * @param y defines the y coordinate of the operand
  69384. * @param z defines the z coordinate of the operand
  69385. * @returns the current updated Vector3
  69386. */
  69387. copyFromFloats(x: number, y: number, z: number): Vector3;
  69388. /**
  69389. * Copies the given floats to the current Vector3 coordinates
  69390. * @param x defines the x coordinate of the operand
  69391. * @param y defines the y coordinate of the operand
  69392. * @param z defines the z coordinate of the operand
  69393. * @returns the current updated Vector3
  69394. */
  69395. set(x: number, y: number, z: number): Vector3;
  69396. /**
  69397. * Copies the given float to the current Vector3 coordinates
  69398. * @param v defines the x, y and z coordinates of the operand
  69399. * @returns the current updated Vector3
  69400. */
  69401. setAll(v: number): Vector3;
  69402. /**
  69403. * Get the clip factor between two vectors
  69404. * @param vector0 defines the first operand
  69405. * @param vector1 defines the second operand
  69406. * @param axis defines the axis to use
  69407. * @param size defines the size along the axis
  69408. * @returns the clip factor
  69409. */
  69410. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69411. /**
  69412. * Get angle between two vectors
  69413. * @param vector0 angle between vector0 and vector1
  69414. * @param vector1 angle between vector0 and vector1
  69415. * @param normal direction of the normal
  69416. * @return the angle between vector0 and vector1
  69417. */
  69418. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69419. /**
  69420. * Returns a new Vector3 set from the index "offset" of the given array
  69421. * @param array defines the source array
  69422. * @param offset defines the offset in the source array
  69423. * @returns the new Vector3
  69424. */
  69425. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69426. /**
  69427. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69428. * This function is deprecated. Use FromArray instead
  69429. * @param array defines the source array
  69430. * @param offset defines the offset in the source array
  69431. * @returns the new Vector3
  69432. */
  69433. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69434. /**
  69435. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69436. * @param array defines the source array
  69437. * @param offset defines the offset in the source array
  69438. * @param result defines the Vector3 where to store the result
  69439. */
  69440. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69441. /**
  69442. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69443. * This function is deprecated. Use FromArrayToRef instead.
  69444. * @param array defines the source array
  69445. * @param offset defines the offset in the source array
  69446. * @param result defines the Vector3 where to store the result
  69447. */
  69448. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69449. /**
  69450. * Sets the given vector "result" with the given floats.
  69451. * @param x defines the x coordinate of the source
  69452. * @param y defines the y coordinate of the source
  69453. * @param z defines the z coordinate of the source
  69454. * @param result defines the Vector3 where to store the result
  69455. */
  69456. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69457. /**
  69458. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69459. * @returns a new empty Vector3
  69460. */
  69461. static Zero(): Vector3;
  69462. /**
  69463. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69464. * @returns a new unit Vector3
  69465. */
  69466. static One(): Vector3;
  69467. /**
  69468. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69469. * @returns a new up Vector3
  69470. */
  69471. static Up(): Vector3;
  69472. /**
  69473. * Gets a up Vector3 that must not be updated
  69474. */
  69475. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69476. /**
  69477. * Gets a zero Vector3 that must not be updated
  69478. */
  69479. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69480. /**
  69481. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69482. * @returns a new down Vector3
  69483. */
  69484. static Down(): Vector3;
  69485. /**
  69486. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69487. * @returns a new forward Vector3
  69488. */
  69489. static Forward(): Vector3;
  69490. /**
  69491. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69492. * @returns a new forward Vector3
  69493. */
  69494. static Backward(): Vector3;
  69495. /**
  69496. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69497. * @returns a new right Vector3
  69498. */
  69499. static Right(): Vector3;
  69500. /**
  69501. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69502. * @returns a new left Vector3
  69503. */
  69504. static Left(): Vector3;
  69505. /**
  69506. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69507. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69508. * @param vector defines the Vector3 to transform
  69509. * @param transformation defines the transformation matrix
  69510. * @returns the transformed Vector3
  69511. */
  69512. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69513. /**
  69514. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69515. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69516. * @param vector defines the Vector3 to transform
  69517. * @param transformation defines the transformation matrix
  69518. * @param result defines the Vector3 where to store the result
  69519. */
  69520. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69521. /**
  69522. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69523. * This method computes tranformed coordinates only, not transformed direction vectors
  69524. * @param x define the x coordinate of the source vector
  69525. * @param y define the y coordinate of the source vector
  69526. * @param z define the z coordinate of the source vector
  69527. * @param transformation defines the transformation matrix
  69528. * @param result defines the Vector3 where to store the result
  69529. */
  69530. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69531. /**
  69532. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69533. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69534. * @param vector defines the Vector3 to transform
  69535. * @param transformation defines the transformation matrix
  69536. * @returns the new Vector3
  69537. */
  69538. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69539. /**
  69540. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69541. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69542. * @param vector defines the Vector3 to transform
  69543. * @param transformation defines the transformation matrix
  69544. * @param result defines the Vector3 where to store the result
  69545. */
  69546. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69547. /**
  69548. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69549. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69550. * @param x define the x coordinate of the source vector
  69551. * @param y define the y coordinate of the source vector
  69552. * @param z define the z coordinate of the source vector
  69553. * @param transformation defines the transformation matrix
  69554. * @param result defines the Vector3 where to store the result
  69555. */
  69556. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69557. /**
  69558. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69559. * @param value1 defines the first control point
  69560. * @param value2 defines the second control point
  69561. * @param value3 defines the third control point
  69562. * @param value4 defines the fourth control point
  69563. * @param amount defines the amount on the spline to use
  69564. * @returns the new Vector3
  69565. */
  69566. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69567. /**
  69568. * 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"
  69569. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69570. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69571. * @param value defines the current value
  69572. * @param min defines the lower range value
  69573. * @param max defines the upper range value
  69574. * @returns the new Vector3
  69575. */
  69576. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69577. /**
  69578. * 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"
  69579. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69580. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69581. * @param value defines the current value
  69582. * @param min defines the lower range value
  69583. * @param max defines the upper range value
  69584. * @param result defines the Vector3 where to store the result
  69585. */
  69586. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69587. /**
  69588. * Checks if a given vector is inside a specific range
  69589. * @param v defines the vector to test
  69590. * @param min defines the minimum range
  69591. * @param max defines the maximum range
  69592. */
  69593. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69594. /**
  69595. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69596. * @param value1 defines the first control point
  69597. * @param tangent1 defines the first tangent vector
  69598. * @param value2 defines the second control point
  69599. * @param tangent2 defines the second tangent vector
  69600. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69601. * @returns the new Vector3
  69602. */
  69603. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69604. /**
  69605. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69606. * @param start defines the start value
  69607. * @param end defines the end value
  69608. * @param amount max defines amount between both (between 0 and 1)
  69609. * @returns the new Vector3
  69610. */
  69611. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69612. /**
  69613. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69614. * @param start defines the start value
  69615. * @param end defines the end value
  69616. * @param amount max defines amount between both (between 0 and 1)
  69617. * @param result defines the Vector3 where to store the result
  69618. */
  69619. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69620. /**
  69621. * Returns the dot product (float) between the vectors "left" and "right"
  69622. * @param left defines the left operand
  69623. * @param right defines the right operand
  69624. * @returns the dot product
  69625. */
  69626. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69627. /**
  69628. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69629. * The cross product is then orthogonal to both "left" and "right"
  69630. * @param left defines the left operand
  69631. * @param right defines the right operand
  69632. * @returns the cross product
  69633. */
  69634. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69635. /**
  69636. * Sets the given vector "result" with the cross product of "left" and "right"
  69637. * The cross product is then orthogonal to both "left" and "right"
  69638. * @param left defines the left operand
  69639. * @param right defines the right operand
  69640. * @param result defines the Vector3 where to store the result
  69641. */
  69642. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69643. /**
  69644. * Returns a new Vector3 as the normalization of the given vector
  69645. * @param vector defines the Vector3 to normalize
  69646. * @returns the new Vector3
  69647. */
  69648. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69649. /**
  69650. * Sets the given vector "result" with the normalization of the given first vector
  69651. * @param vector defines the Vector3 to normalize
  69652. * @param result defines the Vector3 where to store the result
  69653. */
  69654. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69655. /**
  69656. * Project a Vector3 onto screen space
  69657. * @param vector defines the Vector3 to project
  69658. * @param world defines the world matrix to use
  69659. * @param transform defines the transform (view x projection) matrix to use
  69660. * @param viewport defines the screen viewport to use
  69661. * @returns the new Vector3
  69662. */
  69663. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69664. /** @hidden */
  69665. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69666. /**
  69667. * Unproject from screen space to object space
  69668. * @param source defines the screen space Vector3 to use
  69669. * @param viewportWidth defines the current width of the viewport
  69670. * @param viewportHeight defines the current height of the viewport
  69671. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69672. * @param transform defines the transform (view x projection) matrix to use
  69673. * @returns the new Vector3
  69674. */
  69675. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69676. /**
  69677. * Unproject from screen space to object space
  69678. * @param source defines the screen space Vector3 to use
  69679. * @param viewportWidth defines the current width of the viewport
  69680. * @param viewportHeight defines the current height of the viewport
  69681. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69682. * @param view defines the view matrix to use
  69683. * @param projection defines the projection matrix to use
  69684. * @returns the new Vector3
  69685. */
  69686. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69687. /**
  69688. * Unproject from screen space to object space
  69689. * @param source defines the screen space Vector3 to use
  69690. * @param viewportWidth defines the current width of the viewport
  69691. * @param viewportHeight defines the current height of the viewport
  69692. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69693. * @param view defines the view matrix to use
  69694. * @param projection defines the projection matrix to use
  69695. * @param result defines the Vector3 where to store the result
  69696. */
  69697. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69698. /**
  69699. * Unproject from screen space to object space
  69700. * @param sourceX defines the screen space x coordinate to use
  69701. * @param sourceY defines the screen space y coordinate to use
  69702. * @param sourceZ defines the screen space z coordinate to use
  69703. * @param viewportWidth defines the current width of the viewport
  69704. * @param viewportHeight defines the current height of the viewport
  69705. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69706. * @param view defines the view matrix to use
  69707. * @param projection defines the projection matrix to use
  69708. * @param result defines the Vector3 where to store the result
  69709. */
  69710. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69711. /**
  69712. * Gets the minimal coordinate values between two Vector3
  69713. * @param left defines the first operand
  69714. * @param right defines the second operand
  69715. * @returns the new Vector3
  69716. */
  69717. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69718. /**
  69719. * Gets the maximal coordinate values between two Vector3
  69720. * @param left defines the first operand
  69721. * @param right defines the second operand
  69722. * @returns the new Vector3
  69723. */
  69724. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69725. /**
  69726. * Returns the distance between the vectors "value1" and "value2"
  69727. * @param value1 defines the first operand
  69728. * @param value2 defines the second operand
  69729. * @returns the distance
  69730. */
  69731. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69732. /**
  69733. * Returns the squared distance between the vectors "value1" and "value2"
  69734. * @param value1 defines the first operand
  69735. * @param value2 defines the second operand
  69736. * @returns the squared distance
  69737. */
  69738. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69739. /**
  69740. * Returns a new Vector3 located at the center between "value1" and "value2"
  69741. * @param value1 defines the first operand
  69742. * @param value2 defines the second operand
  69743. * @returns the new Vector3
  69744. */
  69745. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69746. /**
  69747. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69748. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69749. * to something in order to rotate it from its local system to the given target system
  69750. * Note: axis1, axis2 and axis3 are normalized during this operation
  69751. * @param axis1 defines the first axis
  69752. * @param axis2 defines the second axis
  69753. * @param axis3 defines the third axis
  69754. * @returns a new Vector3
  69755. */
  69756. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69757. /**
  69758. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69759. * @param axis1 defines the first axis
  69760. * @param axis2 defines the second axis
  69761. * @param axis3 defines the third axis
  69762. * @param ref defines the Vector3 where to store the result
  69763. */
  69764. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69765. }
  69766. /**
  69767. * Vector4 class created for EulerAngle class conversion to Quaternion
  69768. */
  69769. export class Vector4 {
  69770. /** x value of the vector */
  69771. x: number;
  69772. /** y value of the vector */
  69773. y: number;
  69774. /** z value of the vector */
  69775. z: number;
  69776. /** w value of the vector */
  69777. w: number;
  69778. /**
  69779. * Creates a Vector4 object from the given floats.
  69780. * @param x x value of the vector
  69781. * @param y y value of the vector
  69782. * @param z z value of the vector
  69783. * @param w w value of the vector
  69784. */
  69785. constructor(
  69786. /** x value of the vector */
  69787. x: number,
  69788. /** y value of the vector */
  69789. y: number,
  69790. /** z value of the vector */
  69791. z: number,
  69792. /** w value of the vector */
  69793. w: number);
  69794. /**
  69795. * Returns the string with the Vector4 coordinates.
  69796. * @returns a string containing all the vector values
  69797. */
  69798. toString(): string;
  69799. /**
  69800. * Returns the string "Vector4".
  69801. * @returns "Vector4"
  69802. */
  69803. getClassName(): string;
  69804. /**
  69805. * Returns the Vector4 hash code.
  69806. * @returns a unique hash code
  69807. */
  69808. getHashCode(): number;
  69809. /**
  69810. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69811. * @returns the resulting array
  69812. */
  69813. asArray(): number[];
  69814. /**
  69815. * Populates the given array from the given index with the Vector4 coordinates.
  69816. * @param array array to populate
  69817. * @param index index of the array to start at (default: 0)
  69818. * @returns the Vector4.
  69819. */
  69820. toArray(array: FloatArray, index?: number): Vector4;
  69821. /**
  69822. * Adds the given vector to the current Vector4.
  69823. * @param otherVector the vector to add
  69824. * @returns the updated Vector4.
  69825. */
  69826. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69827. /**
  69828. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69829. * @param otherVector the vector to add
  69830. * @returns the resulting vector
  69831. */
  69832. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69833. /**
  69834. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69835. * @param otherVector the vector to add
  69836. * @param result the vector to store the result
  69837. * @returns the current Vector4.
  69838. */
  69839. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69840. /**
  69841. * Subtract in place the given vector from the current Vector4.
  69842. * @param otherVector the vector to subtract
  69843. * @returns the updated Vector4.
  69844. */
  69845. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69846. /**
  69847. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69848. * @param otherVector the vector to add
  69849. * @returns the new vector with the result
  69850. */
  69851. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69852. /**
  69853. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69854. * @param otherVector the vector to subtract
  69855. * @param result the vector to store the result
  69856. * @returns the current Vector4.
  69857. */
  69858. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69859. /**
  69860. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69861. */
  69862. /**
  69863. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69864. * @param x value to subtract
  69865. * @param y value to subtract
  69866. * @param z value to subtract
  69867. * @param w value to subtract
  69868. * @returns new vector containing the result
  69869. */
  69870. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69871. /**
  69872. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69873. * @param x value to subtract
  69874. * @param y value to subtract
  69875. * @param z value to subtract
  69876. * @param w value to subtract
  69877. * @param result the vector to store the result in
  69878. * @returns the current Vector4.
  69879. */
  69880. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69881. /**
  69882. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69883. * @returns a new vector with the negated values
  69884. */
  69885. negate(): Vector4;
  69886. /**
  69887. * Multiplies the current Vector4 coordinates by scale (float).
  69888. * @param scale the number to scale with
  69889. * @returns the updated Vector4.
  69890. */
  69891. scaleInPlace(scale: number): Vector4;
  69892. /**
  69893. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69894. * @param scale the number to scale with
  69895. * @returns a new vector with the result
  69896. */
  69897. scale(scale: number): Vector4;
  69898. /**
  69899. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69900. * @param scale the number to scale with
  69901. * @param result a vector to store the result in
  69902. * @returns the current Vector4.
  69903. */
  69904. scaleToRef(scale: number, result: Vector4): Vector4;
  69905. /**
  69906. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69907. * @param scale defines the scale factor
  69908. * @param result defines the Vector4 object where to store the result
  69909. * @returns the unmodified current Vector4
  69910. */
  69911. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69912. /**
  69913. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69914. * @param otherVector the vector to compare against
  69915. * @returns true if they are equal
  69916. */
  69917. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69918. /**
  69919. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69920. * @param otherVector vector to compare against
  69921. * @param epsilon (Default: very small number)
  69922. * @returns true if they are equal
  69923. */
  69924. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69925. /**
  69926. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69927. * @param x x value to compare against
  69928. * @param y y value to compare against
  69929. * @param z z value to compare against
  69930. * @param w w value to compare against
  69931. * @returns true if equal
  69932. */
  69933. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69934. /**
  69935. * Multiplies in place the current Vector4 by the given one.
  69936. * @param otherVector vector to multiple with
  69937. * @returns the updated Vector4.
  69938. */
  69939. multiplyInPlace(otherVector: Vector4): Vector4;
  69940. /**
  69941. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69942. * @param otherVector vector to multiple with
  69943. * @returns resulting new vector
  69944. */
  69945. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69946. /**
  69947. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69948. * @param otherVector vector to multiple with
  69949. * @param result vector to store the result
  69950. * @returns the current Vector4.
  69951. */
  69952. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69953. /**
  69954. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69955. * @param x x value multiply with
  69956. * @param y y value multiply with
  69957. * @param z z value multiply with
  69958. * @param w w value multiply with
  69959. * @returns resulting new vector
  69960. */
  69961. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69962. /**
  69963. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69964. * @param otherVector vector to devide with
  69965. * @returns resulting new vector
  69966. */
  69967. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69968. /**
  69969. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69970. * @param otherVector vector to devide with
  69971. * @param result vector to store the result
  69972. * @returns the current Vector4.
  69973. */
  69974. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69975. /**
  69976. * Divides the current Vector3 coordinates by the given ones.
  69977. * @param otherVector vector to devide with
  69978. * @returns the updated Vector3.
  69979. */
  69980. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69981. /**
  69982. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  69983. * @param other defines the second operand
  69984. * @returns the current updated Vector4
  69985. */
  69986. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  69987. /**
  69988. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  69989. * @param other defines the second operand
  69990. * @returns the current updated Vector4
  69991. */
  69992. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  69993. /**
  69994. * Gets a new Vector4 from current Vector4 floored values
  69995. * @returns a new Vector4
  69996. */
  69997. floor(): Vector4;
  69998. /**
  69999. * Gets a new Vector4 from current Vector3 floored values
  70000. * @returns a new Vector4
  70001. */
  70002. fract(): Vector4;
  70003. /**
  70004. * Returns the Vector4 length (float).
  70005. * @returns the length
  70006. */
  70007. length(): number;
  70008. /**
  70009. * Returns the Vector4 squared length (float).
  70010. * @returns the length squared
  70011. */
  70012. lengthSquared(): number;
  70013. /**
  70014. * Normalizes in place the Vector4.
  70015. * @returns the updated Vector4.
  70016. */
  70017. normalize(): Vector4;
  70018. /**
  70019. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70020. * @returns this converted to a new vector3
  70021. */
  70022. toVector3(): Vector3;
  70023. /**
  70024. * Returns a new Vector4 copied from the current one.
  70025. * @returns the new cloned vector
  70026. */
  70027. clone(): Vector4;
  70028. /**
  70029. * Updates the current Vector4 with the given one coordinates.
  70030. * @param source the source vector to copy from
  70031. * @returns the updated Vector4.
  70032. */
  70033. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70034. /**
  70035. * Updates the current Vector4 coordinates with the given floats.
  70036. * @param x float to copy from
  70037. * @param y float to copy from
  70038. * @param z float to copy from
  70039. * @param w float to copy from
  70040. * @returns the updated Vector4.
  70041. */
  70042. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70043. /**
  70044. * Updates the current Vector4 coordinates with the given floats.
  70045. * @param x float to set from
  70046. * @param y float to set from
  70047. * @param z float to set from
  70048. * @param w float to set from
  70049. * @returns the updated Vector4.
  70050. */
  70051. set(x: number, y: number, z: number, w: number): Vector4;
  70052. /**
  70053. * Copies the given float to the current Vector3 coordinates
  70054. * @param v defines the x, y, z and w coordinates of the operand
  70055. * @returns the current updated Vector3
  70056. */
  70057. setAll(v: number): Vector4;
  70058. /**
  70059. * Returns a new Vector4 set from the starting index of the given array.
  70060. * @param array the array to pull values from
  70061. * @param offset the offset into the array to start at
  70062. * @returns the new vector
  70063. */
  70064. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70065. /**
  70066. * Updates the given vector "result" from the starting index of the given array.
  70067. * @param array the array to pull values from
  70068. * @param offset the offset into the array to start at
  70069. * @param result the vector to store the result in
  70070. */
  70071. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70072. /**
  70073. * Updates the given vector "result" from the starting index of the given Float32Array.
  70074. * @param array the array to pull values from
  70075. * @param offset the offset into the array to start at
  70076. * @param result the vector to store the result in
  70077. */
  70078. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70079. /**
  70080. * Updates the given vector "result" coordinates from the given floats.
  70081. * @param x float to set from
  70082. * @param y float to set from
  70083. * @param z float to set from
  70084. * @param w float to set from
  70085. * @param result the vector to the floats in
  70086. */
  70087. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70088. /**
  70089. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70090. * @returns the new vector
  70091. */
  70092. static Zero(): Vector4;
  70093. /**
  70094. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70095. * @returns the new vector
  70096. */
  70097. static One(): Vector4;
  70098. /**
  70099. * Returns a new normalized Vector4 from the given one.
  70100. * @param vector the vector to normalize
  70101. * @returns the vector
  70102. */
  70103. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70104. /**
  70105. * Updates the given vector "result" from the normalization of the given one.
  70106. * @param vector the vector to normalize
  70107. * @param result the vector to store the result in
  70108. */
  70109. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70110. /**
  70111. * Returns a vector with the minimum values from the left and right vectors
  70112. * @param left left vector to minimize
  70113. * @param right right vector to minimize
  70114. * @returns a new vector with the minimum of the left and right vector values
  70115. */
  70116. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70117. /**
  70118. * Returns a vector with the maximum values from the left and right vectors
  70119. * @param left left vector to maximize
  70120. * @param right right vector to maximize
  70121. * @returns a new vector with the maximum of the left and right vector values
  70122. */
  70123. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70124. /**
  70125. * Returns the distance (float) between the vectors "value1" and "value2".
  70126. * @param value1 value to calulate the distance between
  70127. * @param value2 value to calulate the distance between
  70128. * @return the distance between the two vectors
  70129. */
  70130. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70131. /**
  70132. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70133. * @param value1 value to calulate the distance between
  70134. * @param value2 value to calulate the distance between
  70135. * @return the distance between the two vectors squared
  70136. */
  70137. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70138. /**
  70139. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70140. * @param value1 value to calulate the center between
  70141. * @param value2 value to calulate the center between
  70142. * @return the center between the two vectors
  70143. */
  70144. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70145. /**
  70146. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70147. * This methods computes transformed normalized direction vectors only.
  70148. * @param vector the vector to transform
  70149. * @param transformation the transformation matrix to apply
  70150. * @returns the new vector
  70151. */
  70152. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70153. /**
  70154. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70155. * This methods computes transformed normalized direction vectors only.
  70156. * @param vector the vector to transform
  70157. * @param transformation the transformation matrix to apply
  70158. * @param result the vector to store the result in
  70159. */
  70160. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70161. /**
  70162. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70163. * This methods computes transformed normalized direction vectors only.
  70164. * @param x value to transform
  70165. * @param y value to transform
  70166. * @param z value to transform
  70167. * @param w value to transform
  70168. * @param transformation the transformation matrix to apply
  70169. * @param result the vector to store the results in
  70170. */
  70171. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70172. /**
  70173. * Creates a new Vector4 from a Vector3
  70174. * @param source defines the source data
  70175. * @param w defines the 4th component (default is 0)
  70176. * @returns a new Vector4
  70177. */
  70178. static FromVector3(source: Vector3, w?: number): Vector4;
  70179. }
  70180. /**
  70181. * Class used to store quaternion data
  70182. * @see https://en.wikipedia.org/wiki/Quaternion
  70183. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70184. */
  70185. export class Quaternion {
  70186. /** defines the first component (0 by default) */
  70187. x: number;
  70188. /** defines the second component (0 by default) */
  70189. y: number;
  70190. /** defines the third component (0 by default) */
  70191. z: number;
  70192. /** defines the fourth component (1.0 by default) */
  70193. w: number;
  70194. /**
  70195. * Creates a new Quaternion from the given floats
  70196. * @param x defines the first component (0 by default)
  70197. * @param y defines the second component (0 by default)
  70198. * @param z defines the third component (0 by default)
  70199. * @param w defines the fourth component (1.0 by default)
  70200. */
  70201. constructor(
  70202. /** defines the first component (0 by default) */
  70203. x?: number,
  70204. /** defines the second component (0 by default) */
  70205. y?: number,
  70206. /** defines the third component (0 by default) */
  70207. z?: number,
  70208. /** defines the fourth component (1.0 by default) */
  70209. w?: number);
  70210. /**
  70211. * Gets a string representation for the current quaternion
  70212. * @returns a string with the Quaternion coordinates
  70213. */
  70214. toString(): string;
  70215. /**
  70216. * Gets the class name of the quaternion
  70217. * @returns the string "Quaternion"
  70218. */
  70219. getClassName(): string;
  70220. /**
  70221. * Gets a hash code for this quaternion
  70222. * @returns the quaternion hash code
  70223. */
  70224. getHashCode(): number;
  70225. /**
  70226. * Copy the quaternion to an array
  70227. * @returns a new array populated with 4 elements from the quaternion coordinates
  70228. */
  70229. asArray(): number[];
  70230. /**
  70231. * Check if two quaternions are equals
  70232. * @param otherQuaternion defines the second operand
  70233. * @return true if the current quaternion and the given one coordinates are strictly equals
  70234. */
  70235. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70236. /**
  70237. * Clone the current quaternion
  70238. * @returns a new quaternion copied from the current one
  70239. */
  70240. clone(): Quaternion;
  70241. /**
  70242. * Copy a quaternion to the current one
  70243. * @param other defines the other quaternion
  70244. * @returns the updated current quaternion
  70245. */
  70246. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70247. /**
  70248. * Updates the current quaternion with the given float coordinates
  70249. * @param x defines the x coordinate
  70250. * @param y defines the y coordinate
  70251. * @param z defines the z coordinate
  70252. * @param w defines the w coordinate
  70253. * @returns the updated current quaternion
  70254. */
  70255. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70256. /**
  70257. * Updates the current quaternion from the given float coordinates
  70258. * @param x defines the x coordinate
  70259. * @param y defines the y coordinate
  70260. * @param z defines the z coordinate
  70261. * @param w defines the w coordinate
  70262. * @returns the updated current quaternion
  70263. */
  70264. set(x: number, y: number, z: number, w: number): Quaternion;
  70265. /**
  70266. * Adds two quaternions
  70267. * @param other defines the second operand
  70268. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70269. */
  70270. add(other: DeepImmutable<Quaternion>): Quaternion;
  70271. /**
  70272. * Add a quaternion to the current one
  70273. * @param other defines the quaternion to add
  70274. * @returns the current quaternion
  70275. */
  70276. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70277. /**
  70278. * Subtract two quaternions
  70279. * @param other defines the second operand
  70280. * @returns a new quaternion as the subtraction result of the given one from the current one
  70281. */
  70282. subtract(other: Quaternion): Quaternion;
  70283. /**
  70284. * Multiplies the current quaternion by a scale factor
  70285. * @param value defines the scale factor
  70286. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70287. */
  70288. scale(value: number): Quaternion;
  70289. /**
  70290. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70291. * @param scale defines the scale factor
  70292. * @param result defines the Quaternion object where to store the result
  70293. * @returns the unmodified current quaternion
  70294. */
  70295. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70296. /**
  70297. * Multiplies in place the current quaternion by a scale factor
  70298. * @param value defines the scale factor
  70299. * @returns the current modified quaternion
  70300. */
  70301. scaleInPlace(value: number): Quaternion;
  70302. /**
  70303. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70304. * @param scale defines the scale factor
  70305. * @param result defines the Quaternion object where to store the result
  70306. * @returns the unmodified current quaternion
  70307. */
  70308. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70309. /**
  70310. * Multiplies two quaternions
  70311. * @param q1 defines the second operand
  70312. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70313. */
  70314. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70315. /**
  70316. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70317. * @param q1 defines the second operand
  70318. * @param result defines the target quaternion
  70319. * @returns the current quaternion
  70320. */
  70321. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70322. /**
  70323. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70324. * @param q1 defines the second operand
  70325. * @returns the currentupdated quaternion
  70326. */
  70327. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70328. /**
  70329. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70330. * @param ref defines the target quaternion
  70331. * @returns the current quaternion
  70332. */
  70333. conjugateToRef(ref: Quaternion): Quaternion;
  70334. /**
  70335. * Conjugates in place (1-q) the current quaternion
  70336. * @returns the current updated quaternion
  70337. */
  70338. conjugateInPlace(): Quaternion;
  70339. /**
  70340. * Conjugates in place (1-q) the current quaternion
  70341. * @returns a new quaternion
  70342. */
  70343. conjugate(): Quaternion;
  70344. /**
  70345. * Gets length of current quaternion
  70346. * @returns the quaternion length (float)
  70347. */
  70348. length(): number;
  70349. /**
  70350. * Normalize in place the current quaternion
  70351. * @returns the current updated quaternion
  70352. */
  70353. normalize(): Quaternion;
  70354. /**
  70355. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70356. * @param order is a reserved parameter and is ignore for now
  70357. * @returns a new Vector3 containing the Euler angles
  70358. */
  70359. toEulerAngles(order?: string): Vector3;
  70360. /**
  70361. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70362. * @param result defines the vector which will be filled with the Euler angles
  70363. * @param order is a reserved parameter and is ignore for now
  70364. * @returns the current unchanged quaternion
  70365. */
  70366. toEulerAnglesToRef(result: Vector3): Quaternion;
  70367. /**
  70368. * Updates the given rotation matrix with the current quaternion values
  70369. * @param result defines the target matrix
  70370. * @returns the current unchanged quaternion
  70371. */
  70372. toRotationMatrix(result: Matrix): Quaternion;
  70373. /**
  70374. * Updates the current quaternion from the given rotation matrix values
  70375. * @param matrix defines the source matrix
  70376. * @returns the current updated quaternion
  70377. */
  70378. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70379. /**
  70380. * Creates a new quaternion from a rotation matrix
  70381. * @param matrix defines the source matrix
  70382. * @returns a new quaternion created from the given rotation matrix values
  70383. */
  70384. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70385. /**
  70386. * Updates the given quaternion with the given rotation matrix values
  70387. * @param matrix defines the source matrix
  70388. * @param result defines the target quaternion
  70389. */
  70390. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70391. /**
  70392. * Returns the dot product (float) between the quaternions "left" and "right"
  70393. * @param left defines the left operand
  70394. * @param right defines the right operand
  70395. * @returns the dot product
  70396. */
  70397. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70398. /**
  70399. * Checks if the two quaternions are close to each other
  70400. * @param quat0 defines the first quaternion to check
  70401. * @param quat1 defines the second quaternion to check
  70402. * @returns true if the two quaternions are close to each other
  70403. */
  70404. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70405. /**
  70406. * Creates an empty quaternion
  70407. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70408. */
  70409. static Zero(): Quaternion;
  70410. /**
  70411. * Inverse a given quaternion
  70412. * @param q defines the source quaternion
  70413. * @returns a new quaternion as the inverted current quaternion
  70414. */
  70415. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70416. /**
  70417. * Inverse a given quaternion
  70418. * @param q defines the source quaternion
  70419. * @param result the quaternion the result will be stored in
  70420. * @returns the result quaternion
  70421. */
  70422. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70423. /**
  70424. * Creates an identity quaternion
  70425. * @returns the identity quaternion
  70426. */
  70427. static Identity(): Quaternion;
  70428. /**
  70429. * Gets a boolean indicating if the given quaternion is identity
  70430. * @param quaternion defines the quaternion to check
  70431. * @returns true if the quaternion is identity
  70432. */
  70433. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70434. /**
  70435. * Creates a quaternion from a rotation around an axis
  70436. * @param axis defines the axis to use
  70437. * @param angle defines the angle to use
  70438. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70439. */
  70440. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70441. /**
  70442. * Creates a rotation around an axis and stores it into the given quaternion
  70443. * @param axis defines the axis to use
  70444. * @param angle defines the angle to use
  70445. * @param result defines the target quaternion
  70446. * @returns the target quaternion
  70447. */
  70448. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70449. /**
  70450. * Creates a new quaternion from data stored into an array
  70451. * @param array defines the data source
  70452. * @param offset defines the offset in the source array where the data starts
  70453. * @returns a new quaternion
  70454. */
  70455. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70456. /**
  70457. * Create a quaternion from Euler rotation angles
  70458. * @param x Pitch
  70459. * @param y Yaw
  70460. * @param z Roll
  70461. * @returns the new Quaternion
  70462. */
  70463. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70464. /**
  70465. * Updates a quaternion from Euler rotation angles
  70466. * @param x Pitch
  70467. * @param y Yaw
  70468. * @param z Roll
  70469. * @param result the quaternion to store the result
  70470. * @returns the updated quaternion
  70471. */
  70472. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70473. /**
  70474. * Create a quaternion from Euler rotation vector
  70475. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70476. * @returns the new Quaternion
  70477. */
  70478. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70479. /**
  70480. * Updates a quaternion from Euler rotation vector
  70481. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70482. * @param result the quaternion to store the result
  70483. * @returns the updated quaternion
  70484. */
  70485. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70486. /**
  70487. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70488. * @param yaw defines the rotation around Y axis
  70489. * @param pitch defines the rotation around X axis
  70490. * @param roll defines the rotation around Z axis
  70491. * @returns the new quaternion
  70492. */
  70493. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70494. /**
  70495. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70496. * @param yaw defines the rotation around Y axis
  70497. * @param pitch defines the rotation around X axis
  70498. * @param roll defines the rotation around Z axis
  70499. * @param result defines the target quaternion
  70500. */
  70501. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70502. /**
  70503. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70504. * @param alpha defines the rotation around first axis
  70505. * @param beta defines the rotation around second axis
  70506. * @param gamma defines the rotation around third axis
  70507. * @returns the new quaternion
  70508. */
  70509. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70510. /**
  70511. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70512. * @param alpha defines the rotation around first axis
  70513. * @param beta defines the rotation around second axis
  70514. * @param gamma defines the rotation around third axis
  70515. * @param result defines the target quaternion
  70516. */
  70517. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70518. /**
  70519. * 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)
  70520. * @param axis1 defines the first axis
  70521. * @param axis2 defines the second axis
  70522. * @param axis3 defines the third axis
  70523. * @returns the new quaternion
  70524. */
  70525. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70526. /**
  70527. * 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
  70528. * @param axis1 defines the first axis
  70529. * @param axis2 defines the second axis
  70530. * @param axis3 defines the third axis
  70531. * @param ref defines the target quaternion
  70532. */
  70533. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70534. /**
  70535. * Interpolates between two quaternions
  70536. * @param left defines first quaternion
  70537. * @param right defines second quaternion
  70538. * @param amount defines the gradient to use
  70539. * @returns the new interpolated quaternion
  70540. */
  70541. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70542. /**
  70543. * Interpolates between two quaternions and stores it into a target quaternion
  70544. * @param left defines first quaternion
  70545. * @param right defines second quaternion
  70546. * @param amount defines the gradient to use
  70547. * @param result defines the target quaternion
  70548. */
  70549. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70550. /**
  70551. * Interpolate between two quaternions using Hermite interpolation
  70552. * @param value1 defines first quaternion
  70553. * @param tangent1 defines the incoming tangent
  70554. * @param value2 defines second quaternion
  70555. * @param tangent2 defines the outgoing tangent
  70556. * @param amount defines the target quaternion
  70557. * @returns the new interpolated quaternion
  70558. */
  70559. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70560. }
  70561. /**
  70562. * Class used to store matrix data (4x4)
  70563. */
  70564. export class Matrix {
  70565. private static _updateFlagSeed;
  70566. private static _identityReadOnly;
  70567. private _isIdentity;
  70568. private _isIdentityDirty;
  70569. private _isIdentity3x2;
  70570. private _isIdentity3x2Dirty;
  70571. /**
  70572. * Gets the update flag of the matrix which is an unique number for the matrix.
  70573. * It will be incremented every time the matrix data change.
  70574. * You can use it to speed the comparison between two versions of the same matrix.
  70575. */
  70576. updateFlag: number;
  70577. private readonly _m;
  70578. /**
  70579. * Gets the internal data of the matrix
  70580. */
  70581. readonly m: DeepImmutable<Float32Array>;
  70582. /** @hidden */
  70583. _markAsUpdated(): void;
  70584. /** @hidden */
  70585. private _updateIdentityStatus;
  70586. /**
  70587. * Creates an empty matrix (filled with zeros)
  70588. */
  70589. constructor();
  70590. /**
  70591. * Check if the current matrix is identity
  70592. * @returns true is the matrix is the identity matrix
  70593. */
  70594. isIdentity(): boolean;
  70595. /**
  70596. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70597. * @returns true is the matrix is the identity matrix
  70598. */
  70599. isIdentityAs3x2(): boolean;
  70600. /**
  70601. * Gets the determinant of the matrix
  70602. * @returns the matrix determinant
  70603. */
  70604. determinant(): number;
  70605. /**
  70606. * Returns the matrix as a Float32Array
  70607. * @returns the matrix underlying array
  70608. */
  70609. toArray(): DeepImmutable<Float32Array>;
  70610. /**
  70611. * Returns the matrix as a Float32Array
  70612. * @returns the matrix underlying array.
  70613. */
  70614. asArray(): DeepImmutable<Float32Array>;
  70615. /**
  70616. * Inverts the current matrix in place
  70617. * @returns the current inverted matrix
  70618. */
  70619. invert(): Matrix;
  70620. /**
  70621. * Sets all the matrix elements to zero
  70622. * @returns the current matrix
  70623. */
  70624. reset(): Matrix;
  70625. /**
  70626. * Adds the current matrix with a second one
  70627. * @param other defines the matrix to add
  70628. * @returns a new matrix as the addition of the current matrix and the given one
  70629. */
  70630. add(other: DeepImmutable<Matrix>): Matrix;
  70631. /**
  70632. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70633. * @param other defines the matrix to add
  70634. * @param result defines the target matrix
  70635. * @returns the current matrix
  70636. */
  70637. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70638. /**
  70639. * Adds in place the given matrix to the current matrix
  70640. * @param other defines the second operand
  70641. * @returns the current updated matrix
  70642. */
  70643. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70644. /**
  70645. * Sets the given matrix to the current inverted Matrix
  70646. * @param other defines the target matrix
  70647. * @returns the unmodified current matrix
  70648. */
  70649. invertToRef(other: Matrix): Matrix;
  70650. /**
  70651. * add a value at the specified position in the current Matrix
  70652. * @param index the index of the value within the matrix. between 0 and 15.
  70653. * @param value the value to be added
  70654. * @returns the current updated matrix
  70655. */
  70656. addAtIndex(index: number, value: number): Matrix;
  70657. /**
  70658. * mutiply the specified position in the current Matrix by a value
  70659. * @param index the index of the value within the matrix. between 0 and 15.
  70660. * @param value the value to be added
  70661. * @returns the current updated matrix
  70662. */
  70663. multiplyAtIndex(index: number, value: number): Matrix;
  70664. /**
  70665. * Inserts the translation vector (using 3 floats) in the current matrix
  70666. * @param x defines the 1st component of the translation
  70667. * @param y defines the 2nd component of the translation
  70668. * @param z defines the 3rd component of the translation
  70669. * @returns the current updated matrix
  70670. */
  70671. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70672. /**
  70673. * Adds the translation vector (using 3 floats) in the current matrix
  70674. * @param x defines the 1st component of the translation
  70675. * @param y defines the 2nd component of the translation
  70676. * @param z defines the 3rd component of the translation
  70677. * @returns the current updated matrix
  70678. */
  70679. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70680. /**
  70681. * Inserts the translation vector in the current matrix
  70682. * @param vector3 defines the translation to insert
  70683. * @returns the current updated matrix
  70684. */
  70685. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70686. /**
  70687. * Gets the translation value of the current matrix
  70688. * @returns a new Vector3 as the extracted translation from the matrix
  70689. */
  70690. getTranslation(): Vector3;
  70691. /**
  70692. * Fill a Vector3 with the extracted translation from the matrix
  70693. * @param result defines the Vector3 where to store the translation
  70694. * @returns the current matrix
  70695. */
  70696. getTranslationToRef(result: Vector3): Matrix;
  70697. /**
  70698. * Remove rotation and scaling part from the matrix
  70699. * @returns the updated matrix
  70700. */
  70701. removeRotationAndScaling(): Matrix;
  70702. /**
  70703. * Multiply two matrices
  70704. * @param other defines the second operand
  70705. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70706. */
  70707. multiply(other: DeepImmutable<Matrix>): Matrix;
  70708. /**
  70709. * Copy the current matrix from the given one
  70710. * @param other defines the source matrix
  70711. * @returns the current updated matrix
  70712. */
  70713. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70714. /**
  70715. * Populates the given array from the starting index with the current matrix values
  70716. * @param array defines the target array
  70717. * @param offset defines the offset in the target array where to start storing values
  70718. * @returns the current matrix
  70719. */
  70720. copyToArray(array: Float32Array, offset?: number): Matrix;
  70721. /**
  70722. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70723. * @param other defines the second operand
  70724. * @param result defines the matrix where to store the multiplication
  70725. * @returns the current matrix
  70726. */
  70727. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70728. /**
  70729. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70730. * @param other defines the second operand
  70731. * @param result defines the array where to store the multiplication
  70732. * @param offset defines the offset in the target array where to start storing values
  70733. * @returns the current matrix
  70734. */
  70735. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70736. /**
  70737. * Check equality between this matrix and a second one
  70738. * @param value defines the second matrix to compare
  70739. * @returns true is the current matrix and the given one values are strictly equal
  70740. */
  70741. equals(value: DeepImmutable<Matrix>): boolean;
  70742. /**
  70743. * Clone the current matrix
  70744. * @returns a new matrix from the current matrix
  70745. */
  70746. clone(): Matrix;
  70747. /**
  70748. * Returns the name of the current matrix class
  70749. * @returns the string "Matrix"
  70750. */
  70751. getClassName(): string;
  70752. /**
  70753. * Gets the hash code of the current matrix
  70754. * @returns the hash code
  70755. */
  70756. getHashCode(): number;
  70757. /**
  70758. * Decomposes the current Matrix into a translation, rotation and scaling components
  70759. * @param scale defines the scale vector3 given as a reference to update
  70760. * @param rotation defines the rotation quaternion given as a reference to update
  70761. * @param translation defines the translation vector3 given as a reference to update
  70762. * @returns true if operation was successful
  70763. */
  70764. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70765. /**
  70766. * Gets specific row of the matrix
  70767. * @param index defines the number of the row to get
  70768. * @returns the index-th row of the current matrix as a new Vector4
  70769. */
  70770. getRow(index: number): Nullable<Vector4>;
  70771. /**
  70772. * Sets the index-th row of the current matrix to the vector4 values
  70773. * @param index defines the number of the row to set
  70774. * @param row defines the target vector4
  70775. * @returns the updated current matrix
  70776. */
  70777. setRow(index: number, row: Vector4): Matrix;
  70778. /**
  70779. * Compute the transpose of the matrix
  70780. * @returns the new transposed matrix
  70781. */
  70782. transpose(): Matrix;
  70783. /**
  70784. * Compute the transpose of the matrix and store it in a given matrix
  70785. * @param result defines the target matrix
  70786. * @returns the current matrix
  70787. */
  70788. transposeToRef(result: Matrix): Matrix;
  70789. /**
  70790. * Sets the index-th row of the current matrix with the given 4 x float values
  70791. * @param index defines the row index
  70792. * @param x defines the x component to set
  70793. * @param y defines the y component to set
  70794. * @param z defines the z component to set
  70795. * @param w defines the w component to set
  70796. * @returns the updated current matrix
  70797. */
  70798. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70799. /**
  70800. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70801. * @param scale defines the scale factor
  70802. * @returns a new matrix
  70803. */
  70804. scale(scale: number): Matrix;
  70805. /**
  70806. * Scale the current matrix values by a factor to a given result matrix
  70807. * @param scale defines the scale factor
  70808. * @param result defines the matrix to store the result
  70809. * @returns the current matrix
  70810. */
  70811. scaleToRef(scale: number, result: Matrix): Matrix;
  70812. /**
  70813. * Scale the current matrix values by a factor and add the result to a given matrix
  70814. * @param scale defines the scale factor
  70815. * @param result defines the Matrix to store the result
  70816. * @returns the current matrix
  70817. */
  70818. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70819. /**
  70820. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70821. * @param ref matrix to store the result
  70822. */
  70823. toNormalMatrix(ref: Matrix): void;
  70824. /**
  70825. * Gets only rotation part of the current matrix
  70826. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70827. */
  70828. getRotationMatrix(): Matrix;
  70829. /**
  70830. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70831. * @param result defines the target matrix to store data to
  70832. * @returns the current matrix
  70833. */
  70834. getRotationMatrixToRef(result: Matrix): Matrix;
  70835. /**
  70836. * Toggles model matrix from being right handed to left handed in place and vice versa
  70837. */
  70838. toggleModelMatrixHandInPlace(): void;
  70839. /**
  70840. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70841. */
  70842. toggleProjectionMatrixHandInPlace(): void;
  70843. /**
  70844. * Creates a matrix from an array
  70845. * @param array defines the source array
  70846. * @param offset defines an offset in the source array
  70847. * @returns a new Matrix set from the starting index of the given array
  70848. */
  70849. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70850. /**
  70851. * Copy the content of an array into a given matrix
  70852. * @param array defines the source array
  70853. * @param offset defines an offset in the source array
  70854. * @param result defines the target matrix
  70855. */
  70856. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70857. /**
  70858. * Stores an array into a matrix after having multiplied each component by a given factor
  70859. * @param array defines the source array
  70860. * @param offset defines the offset in the source array
  70861. * @param scale defines the scaling factor
  70862. * @param result defines the target matrix
  70863. */
  70864. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70865. /**
  70866. * Gets an identity matrix that must not be updated
  70867. */
  70868. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70869. /**
  70870. * Stores a list of values (16) inside a given matrix
  70871. * @param initialM11 defines 1st value of 1st row
  70872. * @param initialM12 defines 2nd value of 1st row
  70873. * @param initialM13 defines 3rd value of 1st row
  70874. * @param initialM14 defines 4th value of 1st row
  70875. * @param initialM21 defines 1st value of 2nd row
  70876. * @param initialM22 defines 2nd value of 2nd row
  70877. * @param initialM23 defines 3rd value of 2nd row
  70878. * @param initialM24 defines 4th value of 2nd row
  70879. * @param initialM31 defines 1st value of 3rd row
  70880. * @param initialM32 defines 2nd value of 3rd row
  70881. * @param initialM33 defines 3rd value of 3rd row
  70882. * @param initialM34 defines 4th value of 3rd row
  70883. * @param initialM41 defines 1st value of 4th row
  70884. * @param initialM42 defines 2nd value of 4th row
  70885. * @param initialM43 defines 3rd value of 4th row
  70886. * @param initialM44 defines 4th value of 4th row
  70887. * @param result defines the target matrix
  70888. */
  70889. 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;
  70890. /**
  70891. * Creates new matrix from a list of values (16)
  70892. * @param initialM11 defines 1st value of 1st row
  70893. * @param initialM12 defines 2nd value of 1st row
  70894. * @param initialM13 defines 3rd value of 1st row
  70895. * @param initialM14 defines 4th value of 1st row
  70896. * @param initialM21 defines 1st value of 2nd row
  70897. * @param initialM22 defines 2nd value of 2nd row
  70898. * @param initialM23 defines 3rd value of 2nd row
  70899. * @param initialM24 defines 4th value of 2nd row
  70900. * @param initialM31 defines 1st value of 3rd row
  70901. * @param initialM32 defines 2nd value of 3rd row
  70902. * @param initialM33 defines 3rd value of 3rd row
  70903. * @param initialM34 defines 4th value of 3rd row
  70904. * @param initialM41 defines 1st value of 4th row
  70905. * @param initialM42 defines 2nd value of 4th row
  70906. * @param initialM43 defines 3rd value of 4th row
  70907. * @param initialM44 defines 4th value of 4th row
  70908. * @returns the new matrix
  70909. */
  70910. 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;
  70911. /**
  70912. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70913. * @param scale defines the scale vector3
  70914. * @param rotation defines the rotation quaternion
  70915. * @param translation defines the translation vector3
  70916. * @returns a new matrix
  70917. */
  70918. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70919. /**
  70920. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70921. * @param scale defines the scale vector3
  70922. * @param rotation defines the rotation quaternion
  70923. * @param translation defines the translation vector3
  70924. * @param result defines the target matrix
  70925. */
  70926. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70927. /**
  70928. * Creates a new identity matrix
  70929. * @returns a new identity matrix
  70930. */
  70931. static Identity(): Matrix;
  70932. /**
  70933. * Creates a new identity matrix and stores the result in a given matrix
  70934. * @param result defines the target matrix
  70935. */
  70936. static IdentityToRef(result: Matrix): void;
  70937. /**
  70938. * Creates a new zero matrix
  70939. * @returns a new zero matrix
  70940. */
  70941. static Zero(): Matrix;
  70942. /**
  70943. * Creates a new rotation matrix for "angle" radians around the X axis
  70944. * @param angle defines the angle (in radians) to use
  70945. * @return the new matrix
  70946. */
  70947. static RotationX(angle: number): Matrix;
  70948. /**
  70949. * Creates a new matrix as the invert of a given matrix
  70950. * @param source defines the source matrix
  70951. * @returns the new matrix
  70952. */
  70953. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70954. /**
  70955. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70956. * @param angle defines the angle (in radians) to use
  70957. * @param result defines the target matrix
  70958. */
  70959. static RotationXToRef(angle: number, result: Matrix): void;
  70960. /**
  70961. * Creates a new rotation matrix for "angle" radians around the Y axis
  70962. * @param angle defines the angle (in radians) to use
  70963. * @return the new matrix
  70964. */
  70965. static RotationY(angle: number): Matrix;
  70966. /**
  70967. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70968. * @param angle defines the angle (in radians) to use
  70969. * @param result defines the target matrix
  70970. */
  70971. static RotationYToRef(angle: number, result: Matrix): void;
  70972. /**
  70973. * Creates a new rotation matrix for "angle" radians around the Z axis
  70974. * @param angle defines the angle (in radians) to use
  70975. * @return the new matrix
  70976. */
  70977. static RotationZ(angle: number): Matrix;
  70978. /**
  70979. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  70980. * @param angle defines the angle (in radians) to use
  70981. * @param result defines the target matrix
  70982. */
  70983. static RotationZToRef(angle: number, result: Matrix): void;
  70984. /**
  70985. * Creates a new rotation matrix for "angle" radians around the given axis
  70986. * @param axis defines the axis to use
  70987. * @param angle defines the angle (in radians) to use
  70988. * @return the new matrix
  70989. */
  70990. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  70991. /**
  70992. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  70993. * @param axis defines the axis to use
  70994. * @param angle defines the angle (in radians) to use
  70995. * @param result defines the target matrix
  70996. */
  70997. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  70998. /**
  70999. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71000. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71001. * @param from defines the vector to align
  71002. * @param to defines the vector to align to
  71003. * @param result defines the target matrix
  71004. */
  71005. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71006. /**
  71007. * Creates a rotation matrix
  71008. * @param yaw defines the yaw angle in radians (Y axis)
  71009. * @param pitch defines the pitch angle in radians (X axis)
  71010. * @param roll defines the roll angle in radians (X axis)
  71011. * @returns the new rotation matrix
  71012. */
  71013. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71014. /**
  71015. * Creates a rotation matrix and stores it in a given matrix
  71016. * @param yaw defines the yaw angle in radians (Y axis)
  71017. * @param pitch defines the pitch angle in radians (X axis)
  71018. * @param roll defines the roll angle in radians (X axis)
  71019. * @param result defines the target matrix
  71020. */
  71021. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71022. /**
  71023. * Creates a scaling matrix
  71024. * @param x defines the scale factor on X axis
  71025. * @param y defines the scale factor on Y axis
  71026. * @param z defines the scale factor on Z axis
  71027. * @returns the new matrix
  71028. */
  71029. static Scaling(x: number, y: number, z: number): Matrix;
  71030. /**
  71031. * Creates a scaling matrix and stores it in a given matrix
  71032. * @param x defines the scale factor on X axis
  71033. * @param y defines the scale factor on Y axis
  71034. * @param z defines the scale factor on Z axis
  71035. * @param result defines the target matrix
  71036. */
  71037. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71038. /**
  71039. * Creates a translation matrix
  71040. * @param x defines the translation on X axis
  71041. * @param y defines the translation on Y axis
  71042. * @param z defines the translationon Z axis
  71043. * @returns the new matrix
  71044. */
  71045. static Translation(x: number, y: number, z: number): Matrix;
  71046. /**
  71047. * Creates a translation matrix and stores it in a given matrix
  71048. * @param x defines the translation on X axis
  71049. * @param y defines the translation on Y axis
  71050. * @param z defines the translationon Z axis
  71051. * @param result defines the target matrix
  71052. */
  71053. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71054. /**
  71055. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71056. * @param startValue defines the start value
  71057. * @param endValue defines the end value
  71058. * @param gradient defines the gradient factor
  71059. * @returns the new matrix
  71060. */
  71061. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71062. /**
  71063. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71064. * @param startValue defines the start value
  71065. * @param endValue defines the end value
  71066. * @param gradient defines the gradient factor
  71067. * @param result defines the Matrix object where to store data
  71068. */
  71069. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71070. /**
  71071. * Builds a new matrix whose values are computed by:
  71072. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71073. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71074. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71075. * @param startValue defines the first matrix
  71076. * @param endValue defines the second matrix
  71077. * @param gradient defines the gradient between the two matrices
  71078. * @returns the new matrix
  71079. */
  71080. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71081. /**
  71082. * Update a matrix to values which are computed by:
  71083. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71084. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71085. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71086. * @param startValue defines the first matrix
  71087. * @param endValue defines the second matrix
  71088. * @param gradient defines the gradient between the two matrices
  71089. * @param result defines the target matrix
  71090. */
  71091. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71092. /**
  71093. * 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"
  71094. * This function works in left handed mode
  71095. * @param eye defines the final position of the entity
  71096. * @param target defines where the entity should look at
  71097. * @param up defines the up vector for the entity
  71098. * @returns the new matrix
  71099. */
  71100. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71101. /**
  71102. * 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".
  71103. * This function works in left handed mode
  71104. * @param eye defines the final position of the entity
  71105. * @param target defines where the entity should look at
  71106. * @param up defines the up vector for the entity
  71107. * @param result defines the target matrix
  71108. */
  71109. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71110. /**
  71111. * 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"
  71112. * This function works in right handed mode
  71113. * @param eye defines the final position of the entity
  71114. * @param target defines where the entity should look at
  71115. * @param up defines the up vector for the entity
  71116. * @returns the new matrix
  71117. */
  71118. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71119. /**
  71120. * 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".
  71121. * This function works in right handed mode
  71122. * @param eye defines the final position of the entity
  71123. * @param target defines where the entity should look at
  71124. * @param up defines the up vector for the entity
  71125. * @param result defines the target matrix
  71126. */
  71127. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71128. /**
  71129. * Create a left-handed orthographic projection matrix
  71130. * @param width defines the viewport width
  71131. * @param height defines the viewport height
  71132. * @param znear defines the near clip plane
  71133. * @param zfar defines the far clip plane
  71134. * @returns a new matrix as a left-handed orthographic projection matrix
  71135. */
  71136. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71137. /**
  71138. * Store a left-handed orthographic projection to a given matrix
  71139. * @param width defines the viewport width
  71140. * @param height defines the viewport height
  71141. * @param znear defines the near clip plane
  71142. * @param zfar defines the far clip plane
  71143. * @param result defines the target matrix
  71144. */
  71145. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71146. /**
  71147. * Create a left-handed orthographic projection matrix
  71148. * @param left defines the viewport left coordinate
  71149. * @param right defines the viewport right coordinate
  71150. * @param bottom defines the viewport bottom coordinate
  71151. * @param top defines the viewport top coordinate
  71152. * @param znear defines the near clip plane
  71153. * @param zfar defines the far clip plane
  71154. * @returns a new matrix as a left-handed orthographic projection matrix
  71155. */
  71156. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71157. /**
  71158. * Stores a left-handed orthographic projection into a given matrix
  71159. * @param left defines the viewport left coordinate
  71160. * @param right defines the viewport right coordinate
  71161. * @param bottom defines the viewport bottom coordinate
  71162. * @param top defines the viewport top coordinate
  71163. * @param znear defines the near clip plane
  71164. * @param zfar defines the far clip plane
  71165. * @param result defines the target matrix
  71166. */
  71167. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71168. /**
  71169. * Creates a right-handed orthographic projection matrix
  71170. * @param left defines the viewport left coordinate
  71171. * @param right defines the viewport right coordinate
  71172. * @param bottom defines the viewport bottom coordinate
  71173. * @param top defines the viewport top coordinate
  71174. * @param znear defines the near clip plane
  71175. * @param zfar defines the far clip plane
  71176. * @returns a new matrix as a right-handed orthographic projection matrix
  71177. */
  71178. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71179. /**
  71180. * Stores a right-handed orthographic projection into a given matrix
  71181. * @param left defines the viewport left coordinate
  71182. * @param right defines the viewport right coordinate
  71183. * @param bottom defines the viewport bottom coordinate
  71184. * @param top defines the viewport top coordinate
  71185. * @param znear defines the near clip plane
  71186. * @param zfar defines the far clip plane
  71187. * @param result defines the target matrix
  71188. */
  71189. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71190. /**
  71191. * Creates a left-handed perspective projection matrix
  71192. * @param width defines the viewport width
  71193. * @param height defines the viewport height
  71194. * @param znear defines the near clip plane
  71195. * @param zfar defines the far clip plane
  71196. * @returns a new matrix as a left-handed perspective projection matrix
  71197. */
  71198. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71199. /**
  71200. * Creates a left-handed perspective projection matrix
  71201. * @param fov defines the horizontal field of view
  71202. * @param aspect defines the aspect ratio
  71203. * @param znear defines the near clip plane
  71204. * @param zfar defines the far clip plane
  71205. * @returns a new matrix as a left-handed perspective projection matrix
  71206. */
  71207. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71208. /**
  71209. * Stores a left-handed perspective projection into a given matrix
  71210. * @param fov defines the horizontal field of view
  71211. * @param aspect defines the aspect ratio
  71212. * @param znear defines the near clip plane
  71213. * @param zfar defines the far clip plane
  71214. * @param result defines the target matrix
  71215. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71216. */
  71217. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71218. /**
  71219. * Creates a right-handed perspective projection matrix
  71220. * @param fov defines the horizontal field of view
  71221. * @param aspect defines the aspect ratio
  71222. * @param znear defines the near clip plane
  71223. * @param zfar defines the far clip plane
  71224. * @returns a new matrix as a right-handed perspective projection matrix
  71225. */
  71226. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71227. /**
  71228. * Stores a right-handed perspective projection into a given matrix
  71229. * @param fov defines the horizontal field of view
  71230. * @param aspect defines the aspect ratio
  71231. * @param znear defines the near clip plane
  71232. * @param zfar defines the far clip plane
  71233. * @param result defines the target matrix
  71234. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71235. */
  71236. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71237. /**
  71238. * Stores a perspective projection for WebVR info a given matrix
  71239. * @param fov defines the field of view
  71240. * @param znear defines the near clip plane
  71241. * @param zfar defines the far clip plane
  71242. * @param result defines the target matrix
  71243. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71244. */
  71245. static PerspectiveFovWebVRToRef(fov: {
  71246. upDegrees: number;
  71247. downDegrees: number;
  71248. leftDegrees: number;
  71249. rightDegrees: number;
  71250. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71251. /**
  71252. * Computes a complete transformation matrix
  71253. * @param viewport defines the viewport to use
  71254. * @param world defines the world matrix
  71255. * @param view defines the view matrix
  71256. * @param projection defines the projection matrix
  71257. * @param zmin defines the near clip plane
  71258. * @param zmax defines the far clip plane
  71259. * @returns the transformation matrix
  71260. */
  71261. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71262. /**
  71263. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71264. * @param matrix defines the matrix to use
  71265. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71266. */
  71267. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71268. /**
  71269. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71270. * @param matrix defines the matrix to use
  71271. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71272. */
  71273. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71274. /**
  71275. * Compute the transpose of a given matrix
  71276. * @param matrix defines the matrix to transpose
  71277. * @returns the new matrix
  71278. */
  71279. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71280. /**
  71281. * Compute the transpose of a matrix and store it in a target matrix
  71282. * @param matrix defines the matrix to transpose
  71283. * @param result defines the target matrix
  71284. */
  71285. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71286. /**
  71287. * Computes a reflection matrix from a plane
  71288. * @param plane defines the reflection plane
  71289. * @returns a new matrix
  71290. */
  71291. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71292. /**
  71293. * Computes a reflection matrix from a plane
  71294. * @param plane defines the reflection plane
  71295. * @param result defines the target matrix
  71296. */
  71297. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71298. /**
  71299. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71300. * @param xaxis defines the value of the 1st axis
  71301. * @param yaxis defines the value of the 2nd axis
  71302. * @param zaxis defines the value of the 3rd axis
  71303. * @param result defines the target matrix
  71304. */
  71305. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71306. /**
  71307. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71308. * @param quat defines the quaternion to use
  71309. * @param result defines the target matrix
  71310. */
  71311. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71312. }
  71313. /**
  71314. * @hidden
  71315. */
  71316. export class TmpVectors {
  71317. static Vector2: Vector2[];
  71318. static Vector3: Vector3[];
  71319. static Vector4: Vector4[];
  71320. static Quaternion: Quaternion[];
  71321. static Matrix: Matrix[];
  71322. }
  71323. }
  71324. declare module BABYLON {
  71325. /**
  71326. * Defines potential orientation for back face culling
  71327. */
  71328. export enum Orientation {
  71329. /**
  71330. * Clockwise
  71331. */
  71332. CW = 0,
  71333. /** Counter clockwise */
  71334. CCW = 1
  71335. }
  71336. /** Class used to represent a Bezier curve */
  71337. export class BezierCurve {
  71338. /**
  71339. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71340. * @param t defines the time
  71341. * @param x1 defines the left coordinate on X axis
  71342. * @param y1 defines the left coordinate on Y axis
  71343. * @param x2 defines the right coordinate on X axis
  71344. * @param y2 defines the right coordinate on Y axis
  71345. * @returns the interpolated value
  71346. */
  71347. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71348. }
  71349. /**
  71350. * Defines angle representation
  71351. */
  71352. export class Angle {
  71353. private _radians;
  71354. /**
  71355. * Creates an Angle object of "radians" radians (float).
  71356. * @param radians the angle in radians
  71357. */
  71358. constructor(radians: number);
  71359. /**
  71360. * Get value in degrees
  71361. * @returns the Angle value in degrees (float)
  71362. */
  71363. degrees(): number;
  71364. /**
  71365. * Get value in radians
  71366. * @returns the Angle value in radians (float)
  71367. */
  71368. radians(): number;
  71369. /**
  71370. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71371. * @param a defines first vector
  71372. * @param b defines second vector
  71373. * @returns a new Angle
  71374. */
  71375. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71376. /**
  71377. * Gets a new Angle object from the given float in radians
  71378. * @param radians defines the angle value in radians
  71379. * @returns a new Angle
  71380. */
  71381. static FromRadians(radians: number): Angle;
  71382. /**
  71383. * Gets a new Angle object from the given float in degrees
  71384. * @param degrees defines the angle value in degrees
  71385. * @returns a new Angle
  71386. */
  71387. static FromDegrees(degrees: number): Angle;
  71388. }
  71389. /**
  71390. * This represents an arc in a 2d space.
  71391. */
  71392. export class Arc2 {
  71393. /** Defines the start point of the arc */
  71394. startPoint: Vector2;
  71395. /** Defines the mid point of the arc */
  71396. midPoint: Vector2;
  71397. /** Defines the end point of the arc */
  71398. endPoint: Vector2;
  71399. /**
  71400. * Defines the center point of the arc.
  71401. */
  71402. centerPoint: Vector2;
  71403. /**
  71404. * Defines the radius of the arc.
  71405. */
  71406. radius: number;
  71407. /**
  71408. * Defines the angle of the arc (from mid point to end point).
  71409. */
  71410. angle: Angle;
  71411. /**
  71412. * Defines the start angle of the arc (from start point to middle point).
  71413. */
  71414. startAngle: Angle;
  71415. /**
  71416. * Defines the orientation of the arc (clock wise/counter clock wise).
  71417. */
  71418. orientation: Orientation;
  71419. /**
  71420. * Creates an Arc object from the three given points : start, middle and end.
  71421. * @param startPoint Defines the start point of the arc
  71422. * @param midPoint Defines the midlle point of the arc
  71423. * @param endPoint Defines the end point of the arc
  71424. */
  71425. constructor(
  71426. /** Defines the start point of the arc */
  71427. startPoint: Vector2,
  71428. /** Defines the mid point of the arc */
  71429. midPoint: Vector2,
  71430. /** Defines the end point of the arc */
  71431. endPoint: Vector2);
  71432. }
  71433. /**
  71434. * Represents a 2D path made up of multiple 2D points
  71435. */
  71436. export class Path2 {
  71437. private _points;
  71438. private _length;
  71439. /**
  71440. * If the path start and end point are the same
  71441. */
  71442. closed: boolean;
  71443. /**
  71444. * Creates a Path2 object from the starting 2D coordinates x and y.
  71445. * @param x the starting points x value
  71446. * @param y the starting points y value
  71447. */
  71448. constructor(x: number, y: number);
  71449. /**
  71450. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71451. * @param x the added points x value
  71452. * @param y the added points y value
  71453. * @returns the updated Path2.
  71454. */
  71455. addLineTo(x: number, y: number): Path2;
  71456. /**
  71457. * 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.
  71458. * @param midX middle point x value
  71459. * @param midY middle point y value
  71460. * @param endX end point x value
  71461. * @param endY end point y value
  71462. * @param numberOfSegments (default: 36)
  71463. * @returns the updated Path2.
  71464. */
  71465. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71466. /**
  71467. * Closes the Path2.
  71468. * @returns the Path2.
  71469. */
  71470. close(): Path2;
  71471. /**
  71472. * Gets the sum of the distance between each sequential point in the path
  71473. * @returns the Path2 total length (float).
  71474. */
  71475. length(): number;
  71476. /**
  71477. * Gets the points which construct the path
  71478. * @returns the Path2 internal array of points.
  71479. */
  71480. getPoints(): Vector2[];
  71481. /**
  71482. * Retreives the point at the distance aways from the starting point
  71483. * @param normalizedLengthPosition the length along the path to retreive the point from
  71484. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71485. */
  71486. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71487. /**
  71488. * Creates a new path starting from an x and y position
  71489. * @param x starting x value
  71490. * @param y starting y value
  71491. * @returns a new Path2 starting at the coordinates (x, y).
  71492. */
  71493. static StartingAt(x: number, y: number): Path2;
  71494. }
  71495. /**
  71496. * Represents a 3D path made up of multiple 3D points
  71497. */
  71498. export class Path3D {
  71499. /**
  71500. * an array of Vector3, the curve axis of the Path3D
  71501. */
  71502. path: Vector3[];
  71503. private _curve;
  71504. private _distances;
  71505. private _tangents;
  71506. private _normals;
  71507. private _binormals;
  71508. private _raw;
  71509. /**
  71510. * new Path3D(path, normal, raw)
  71511. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71512. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71513. * @param path an array of Vector3, the curve axis of the Path3D
  71514. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71515. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71516. */
  71517. constructor(
  71518. /**
  71519. * an array of Vector3, the curve axis of the Path3D
  71520. */
  71521. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71522. /**
  71523. * Returns the Path3D array of successive Vector3 designing its curve.
  71524. * @returns the Path3D array of successive Vector3 designing its curve.
  71525. */
  71526. getCurve(): Vector3[];
  71527. /**
  71528. * Returns an array populated with tangent vectors on each Path3D curve point.
  71529. * @returns an array populated with tangent vectors on each Path3D curve point.
  71530. */
  71531. getTangents(): Vector3[];
  71532. /**
  71533. * Returns an array populated with normal vectors on each Path3D curve point.
  71534. * @returns an array populated with normal vectors on each Path3D curve point.
  71535. */
  71536. getNormals(): Vector3[];
  71537. /**
  71538. * Returns an array populated with binormal vectors on each Path3D curve point.
  71539. * @returns an array populated with binormal vectors on each Path3D curve point.
  71540. */
  71541. getBinormals(): Vector3[];
  71542. /**
  71543. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71544. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71545. */
  71546. getDistances(): number[];
  71547. /**
  71548. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71549. * @param path path which all values are copied into the curves points
  71550. * @param firstNormal which should be projected onto the curve
  71551. * @returns the same object updated.
  71552. */
  71553. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71554. private _compute;
  71555. private _getFirstNonNullVector;
  71556. private _getLastNonNullVector;
  71557. private _normalVector;
  71558. }
  71559. /**
  71560. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71561. * A Curve3 is designed from a series of successive Vector3.
  71562. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71563. */
  71564. export class Curve3 {
  71565. private _points;
  71566. private _length;
  71567. /**
  71568. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71569. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71570. * @param v1 (Vector3) the control point
  71571. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71572. * @param nbPoints (integer) the wanted number of points in the curve
  71573. * @returns the created Curve3
  71574. */
  71575. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71576. /**
  71577. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71578. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71579. * @param v1 (Vector3) the first control point
  71580. * @param v2 (Vector3) the second control point
  71581. * @param v3 (Vector3) the end point of the Cubic Bezier
  71582. * @param nbPoints (integer) the wanted number of points in the curve
  71583. * @returns the created Curve3
  71584. */
  71585. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71586. /**
  71587. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71588. * @param p1 (Vector3) the origin point of the Hermite Spline
  71589. * @param t1 (Vector3) the tangent vector at the origin point
  71590. * @param p2 (Vector3) the end point of the Hermite Spline
  71591. * @param t2 (Vector3) the tangent vector at the end point
  71592. * @param nbPoints (integer) the wanted number of points in the curve
  71593. * @returns the created Curve3
  71594. */
  71595. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71596. /**
  71597. * Returns a Curve3 object along a CatmullRom Spline curve :
  71598. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71599. * @param nbPoints (integer) the wanted number of points between each curve control points
  71600. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71601. * @returns the created Curve3
  71602. */
  71603. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71604. /**
  71605. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71606. * A Curve3 is designed from a series of successive Vector3.
  71607. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71608. * @param points points which make up the curve
  71609. */
  71610. constructor(points: Vector3[]);
  71611. /**
  71612. * @returns the Curve3 stored array of successive Vector3
  71613. */
  71614. getPoints(): Vector3[];
  71615. /**
  71616. * @returns the computed length (float) of the curve.
  71617. */
  71618. length(): number;
  71619. /**
  71620. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71621. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71622. * curveA and curveB keep unchanged.
  71623. * @param curve the curve to continue from this curve
  71624. * @returns the newly constructed curve
  71625. */
  71626. continue(curve: DeepImmutable<Curve3>): Curve3;
  71627. private _computeLength;
  71628. }
  71629. }
  71630. declare module BABYLON {
  71631. /**
  71632. * This represents the main contract an easing function should follow.
  71633. * Easing functions are used throughout the animation system.
  71634. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71635. */
  71636. export interface IEasingFunction {
  71637. /**
  71638. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71639. * of the easing function.
  71640. * The link below provides some of the most common examples of easing functions.
  71641. * @see https://easings.net/
  71642. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71643. * @returns the corresponding value on the curve defined by the easing function
  71644. */
  71645. ease(gradient: number): number;
  71646. }
  71647. /**
  71648. * Base class used for every default easing function.
  71649. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71650. */
  71651. export class EasingFunction implements IEasingFunction {
  71652. /**
  71653. * Interpolation follows the mathematical formula associated with the easing function.
  71654. */
  71655. static readonly EASINGMODE_EASEIN: number;
  71656. /**
  71657. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71658. */
  71659. static readonly EASINGMODE_EASEOUT: number;
  71660. /**
  71661. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71662. */
  71663. static readonly EASINGMODE_EASEINOUT: number;
  71664. private _easingMode;
  71665. /**
  71666. * Sets the easing mode of the current function.
  71667. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71668. */
  71669. setEasingMode(easingMode: number): void;
  71670. /**
  71671. * Gets the current easing mode.
  71672. * @returns the easing mode
  71673. */
  71674. getEasingMode(): number;
  71675. /**
  71676. * @hidden
  71677. */
  71678. easeInCore(gradient: number): number;
  71679. /**
  71680. * Given an input gradient between 0 and 1, this returns the corresponding value
  71681. * of the easing function.
  71682. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71683. * @returns the corresponding value on the curve defined by the easing function
  71684. */
  71685. ease(gradient: number): number;
  71686. }
  71687. /**
  71688. * Easing function with a circle shape (see link below).
  71689. * @see https://easings.net/#easeInCirc
  71690. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71691. */
  71692. export class CircleEase extends EasingFunction implements IEasingFunction {
  71693. /** @hidden */
  71694. easeInCore(gradient: number): number;
  71695. }
  71696. /**
  71697. * Easing function with a ease back shape (see link below).
  71698. * @see https://easings.net/#easeInBack
  71699. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71700. */
  71701. export class BackEase extends EasingFunction implements IEasingFunction {
  71702. /** Defines the amplitude of the function */
  71703. amplitude: number;
  71704. /**
  71705. * Instantiates a back ease easing
  71706. * @see https://easings.net/#easeInBack
  71707. * @param amplitude Defines the amplitude of the function
  71708. */
  71709. constructor(
  71710. /** Defines the amplitude of the function */
  71711. amplitude?: number);
  71712. /** @hidden */
  71713. easeInCore(gradient: number): number;
  71714. }
  71715. /**
  71716. * Easing function with a bouncing shape (see link below).
  71717. * @see https://easings.net/#easeInBounce
  71718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71719. */
  71720. export class BounceEase extends EasingFunction implements IEasingFunction {
  71721. /** Defines the number of bounces */
  71722. bounces: number;
  71723. /** Defines the amplitude of the bounce */
  71724. bounciness: number;
  71725. /**
  71726. * Instantiates a bounce easing
  71727. * @see https://easings.net/#easeInBounce
  71728. * @param bounces Defines the number of bounces
  71729. * @param bounciness Defines the amplitude of the bounce
  71730. */
  71731. constructor(
  71732. /** Defines the number of bounces */
  71733. bounces?: number,
  71734. /** Defines the amplitude of the bounce */
  71735. bounciness?: number);
  71736. /** @hidden */
  71737. easeInCore(gradient: number): number;
  71738. }
  71739. /**
  71740. * Easing function with a power of 3 shape (see link below).
  71741. * @see https://easings.net/#easeInCubic
  71742. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71743. */
  71744. export class CubicEase extends EasingFunction implements IEasingFunction {
  71745. /** @hidden */
  71746. easeInCore(gradient: number): number;
  71747. }
  71748. /**
  71749. * Easing function with an elastic shape (see link below).
  71750. * @see https://easings.net/#easeInElastic
  71751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71752. */
  71753. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71754. /** Defines the number of oscillations*/
  71755. oscillations: number;
  71756. /** Defines the amplitude of the oscillations*/
  71757. springiness: number;
  71758. /**
  71759. * Instantiates an elastic easing function
  71760. * @see https://easings.net/#easeInElastic
  71761. * @param oscillations Defines the number of oscillations
  71762. * @param springiness Defines the amplitude of the oscillations
  71763. */
  71764. constructor(
  71765. /** Defines the number of oscillations*/
  71766. oscillations?: number,
  71767. /** Defines the amplitude of the oscillations*/
  71768. springiness?: number);
  71769. /** @hidden */
  71770. easeInCore(gradient: number): number;
  71771. }
  71772. /**
  71773. * Easing function with an exponential shape (see link below).
  71774. * @see https://easings.net/#easeInExpo
  71775. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71776. */
  71777. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71778. /** Defines the exponent of the function */
  71779. exponent: number;
  71780. /**
  71781. * Instantiates an exponential easing function
  71782. * @see https://easings.net/#easeInExpo
  71783. * @param exponent Defines the exponent of the function
  71784. */
  71785. constructor(
  71786. /** Defines the exponent of the function */
  71787. exponent?: number);
  71788. /** @hidden */
  71789. easeInCore(gradient: number): number;
  71790. }
  71791. /**
  71792. * Easing function with a power shape (see link below).
  71793. * @see https://easings.net/#easeInQuad
  71794. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71795. */
  71796. export class PowerEase extends EasingFunction implements IEasingFunction {
  71797. /** Defines the power of the function */
  71798. power: number;
  71799. /**
  71800. * Instantiates an power base easing function
  71801. * @see https://easings.net/#easeInQuad
  71802. * @param power Defines the power of the function
  71803. */
  71804. constructor(
  71805. /** Defines the power of the function */
  71806. power?: number);
  71807. /** @hidden */
  71808. easeInCore(gradient: number): number;
  71809. }
  71810. /**
  71811. * Easing function with a power of 2 shape (see link below).
  71812. * @see https://easings.net/#easeInQuad
  71813. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71814. */
  71815. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71816. /** @hidden */
  71817. easeInCore(gradient: number): number;
  71818. }
  71819. /**
  71820. * Easing function with a power of 4 shape (see link below).
  71821. * @see https://easings.net/#easeInQuart
  71822. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71823. */
  71824. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71825. /** @hidden */
  71826. easeInCore(gradient: number): number;
  71827. }
  71828. /**
  71829. * Easing function with a power of 5 shape (see link below).
  71830. * @see https://easings.net/#easeInQuint
  71831. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71832. */
  71833. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71834. /** @hidden */
  71835. easeInCore(gradient: number): number;
  71836. }
  71837. /**
  71838. * Easing function with a sin shape (see link below).
  71839. * @see https://easings.net/#easeInSine
  71840. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71841. */
  71842. export class SineEase extends EasingFunction implements IEasingFunction {
  71843. /** @hidden */
  71844. easeInCore(gradient: number): number;
  71845. }
  71846. /**
  71847. * Easing function with a bezier shape (see link below).
  71848. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71850. */
  71851. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71852. /** Defines the x component of the start tangent in the bezier curve */
  71853. x1: number;
  71854. /** Defines the y component of the start tangent in the bezier curve */
  71855. y1: number;
  71856. /** Defines the x component of the end tangent in the bezier curve */
  71857. x2: number;
  71858. /** Defines the y component of the end tangent in the bezier curve */
  71859. y2: number;
  71860. /**
  71861. * Instantiates a bezier function
  71862. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71863. * @param x1 Defines the x component of the start tangent in the bezier curve
  71864. * @param y1 Defines the y component of the start tangent in the bezier curve
  71865. * @param x2 Defines the x component of the end tangent in the bezier curve
  71866. * @param y2 Defines the y component of the end tangent in the bezier curve
  71867. */
  71868. constructor(
  71869. /** Defines the x component of the start tangent in the bezier curve */
  71870. x1?: number,
  71871. /** Defines the y component of the start tangent in the bezier curve */
  71872. y1?: number,
  71873. /** Defines the x component of the end tangent in the bezier curve */
  71874. x2?: number,
  71875. /** Defines the y component of the end tangent in the bezier curve */
  71876. y2?: number);
  71877. /** @hidden */
  71878. easeInCore(gradient: number): number;
  71879. }
  71880. }
  71881. declare module BABYLON {
  71882. /**
  71883. * Class used to hold a RBG color
  71884. */
  71885. export class Color3 {
  71886. /**
  71887. * Defines the red component (between 0 and 1, default is 0)
  71888. */
  71889. r: number;
  71890. /**
  71891. * Defines the green component (between 0 and 1, default is 0)
  71892. */
  71893. g: number;
  71894. /**
  71895. * Defines the blue component (between 0 and 1, default is 0)
  71896. */
  71897. b: number;
  71898. /**
  71899. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71900. * @param r defines the red component (between 0 and 1, default is 0)
  71901. * @param g defines the green component (between 0 and 1, default is 0)
  71902. * @param b defines the blue component (between 0 and 1, default is 0)
  71903. */
  71904. constructor(
  71905. /**
  71906. * Defines the red component (between 0 and 1, default is 0)
  71907. */
  71908. r?: number,
  71909. /**
  71910. * Defines the green component (between 0 and 1, default is 0)
  71911. */
  71912. g?: number,
  71913. /**
  71914. * Defines the blue component (between 0 and 1, default is 0)
  71915. */
  71916. b?: number);
  71917. /**
  71918. * Creates a string with the Color3 current values
  71919. * @returns the string representation of the Color3 object
  71920. */
  71921. toString(): string;
  71922. /**
  71923. * Returns the string "Color3"
  71924. * @returns "Color3"
  71925. */
  71926. getClassName(): string;
  71927. /**
  71928. * Compute the Color3 hash code
  71929. * @returns an unique number that can be used to hash Color3 objects
  71930. */
  71931. getHashCode(): number;
  71932. /**
  71933. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71934. * @param array defines the array where to store the r,g,b components
  71935. * @param index defines an optional index in the target array to define where to start storing values
  71936. * @returns the current Color3 object
  71937. */
  71938. toArray(array: FloatArray, index?: number): Color3;
  71939. /**
  71940. * Returns a new Color4 object from the current Color3 and the given alpha
  71941. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71942. * @returns a new Color4 object
  71943. */
  71944. toColor4(alpha?: number): Color4;
  71945. /**
  71946. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71947. * @returns the new array
  71948. */
  71949. asArray(): number[];
  71950. /**
  71951. * Returns the luminance value
  71952. * @returns a float value
  71953. */
  71954. toLuminance(): number;
  71955. /**
  71956. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71957. * @param otherColor defines the second operand
  71958. * @returns the new Color3 object
  71959. */
  71960. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71961. /**
  71962. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71963. * @param otherColor defines the second operand
  71964. * @param result defines the Color3 object where to store the result
  71965. * @returns the current Color3
  71966. */
  71967. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71968. /**
  71969. * Determines equality between Color3 objects
  71970. * @param otherColor defines the second operand
  71971. * @returns true if the rgb values are equal to the given ones
  71972. */
  71973. equals(otherColor: DeepImmutable<Color3>): boolean;
  71974. /**
  71975. * Determines equality between the current Color3 object and a set of r,b,g values
  71976. * @param r defines the red component to check
  71977. * @param g defines the green component to check
  71978. * @param b defines the blue component to check
  71979. * @returns true if the rgb values are equal to the given ones
  71980. */
  71981. equalsFloats(r: number, g: number, b: number): boolean;
  71982. /**
  71983. * Multiplies in place each rgb value by scale
  71984. * @param scale defines the scaling factor
  71985. * @returns the updated Color3
  71986. */
  71987. scale(scale: number): Color3;
  71988. /**
  71989. * Multiplies the rgb values by scale and stores the result into "result"
  71990. * @param scale defines the scaling factor
  71991. * @param result defines the Color3 object where to store the result
  71992. * @returns the unmodified current Color3
  71993. */
  71994. scaleToRef(scale: number, result: Color3): Color3;
  71995. /**
  71996. * Scale the current Color3 values by a factor and add the result to a given Color3
  71997. * @param scale defines the scale factor
  71998. * @param result defines color to store the result into
  71999. * @returns the unmodified current Color3
  72000. */
  72001. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72002. /**
  72003. * Clamps the rgb values by the min and max values and stores the result into "result"
  72004. * @param min defines minimum clamping value (default is 0)
  72005. * @param max defines maximum clamping value (default is 1)
  72006. * @param result defines color to store the result into
  72007. * @returns the original Color3
  72008. */
  72009. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72010. /**
  72011. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72012. * @param otherColor defines the second operand
  72013. * @returns the new Color3
  72014. */
  72015. add(otherColor: DeepImmutable<Color3>): Color3;
  72016. /**
  72017. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72018. * @param otherColor defines the second operand
  72019. * @param result defines Color3 object to store the result into
  72020. * @returns the unmodified current Color3
  72021. */
  72022. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72023. /**
  72024. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72025. * @param otherColor defines the second operand
  72026. * @returns the new Color3
  72027. */
  72028. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72029. /**
  72030. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72031. * @param otherColor defines the second operand
  72032. * @param result defines Color3 object to store the result into
  72033. * @returns the unmodified current Color3
  72034. */
  72035. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72036. /**
  72037. * Copy the current object
  72038. * @returns a new Color3 copied the current one
  72039. */
  72040. clone(): Color3;
  72041. /**
  72042. * Copies the rgb values from the source in the current Color3
  72043. * @param source defines the source Color3 object
  72044. * @returns the updated Color3 object
  72045. */
  72046. copyFrom(source: DeepImmutable<Color3>): Color3;
  72047. /**
  72048. * Updates the Color3 rgb values from the given floats
  72049. * @param r defines the red component to read from
  72050. * @param g defines the green component to read from
  72051. * @param b defines the blue component to read from
  72052. * @returns the current Color3 object
  72053. */
  72054. copyFromFloats(r: number, g: number, b: number): Color3;
  72055. /**
  72056. * Updates the Color3 rgb values from the given floats
  72057. * @param r defines the red component to read from
  72058. * @param g defines the green component to read from
  72059. * @param b defines the blue component to read from
  72060. * @returns the current Color3 object
  72061. */
  72062. set(r: number, g: number, b: number): Color3;
  72063. /**
  72064. * Compute the Color3 hexadecimal code as a string
  72065. * @returns a string containing the hexadecimal representation of the Color3 object
  72066. */
  72067. toHexString(): string;
  72068. /**
  72069. * Computes a new Color3 converted from the current one to linear space
  72070. * @returns a new Color3 object
  72071. */
  72072. toLinearSpace(): Color3;
  72073. /**
  72074. * Converts current color in rgb space to HSV values
  72075. * @returns a new color3 representing the HSV values
  72076. */
  72077. toHSV(): Color3;
  72078. /**
  72079. * Converts current color in rgb space to HSV values
  72080. * @param result defines the Color3 where to store the HSV values
  72081. */
  72082. toHSVToRef(result: Color3): void;
  72083. /**
  72084. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72085. * @param convertedColor defines the Color3 object where to store the linear space version
  72086. * @returns the unmodified Color3
  72087. */
  72088. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72089. /**
  72090. * Computes a new Color3 converted from the current one to gamma space
  72091. * @returns a new Color3 object
  72092. */
  72093. toGammaSpace(): Color3;
  72094. /**
  72095. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72096. * @param convertedColor defines the Color3 object where to store the gamma space version
  72097. * @returns the unmodified Color3
  72098. */
  72099. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72100. private static _BlackReadOnly;
  72101. /**
  72102. * Convert Hue, saturation and value to a Color3 (RGB)
  72103. * @param hue defines the hue
  72104. * @param saturation defines the saturation
  72105. * @param value defines the value
  72106. * @param result defines the Color3 where to store the RGB values
  72107. */
  72108. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72109. /**
  72110. * Creates a new Color3 from the string containing valid hexadecimal values
  72111. * @param hex defines a string containing valid hexadecimal values
  72112. * @returns a new Color3 object
  72113. */
  72114. static FromHexString(hex: string): Color3;
  72115. /**
  72116. * Creates a new Color3 from the starting index of the given array
  72117. * @param array defines the source array
  72118. * @param offset defines an offset in the source array
  72119. * @returns a new Color3 object
  72120. */
  72121. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72122. /**
  72123. * Creates a new Color3 from integer values (< 256)
  72124. * @param r defines the red component to read from (value between 0 and 255)
  72125. * @param g defines the green component to read from (value between 0 and 255)
  72126. * @param b defines the blue component to read from (value between 0 and 255)
  72127. * @returns a new Color3 object
  72128. */
  72129. static FromInts(r: number, g: number, b: number): Color3;
  72130. /**
  72131. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72132. * @param start defines the start Color3 value
  72133. * @param end defines the end Color3 value
  72134. * @param amount defines the gradient value between start and end
  72135. * @returns a new Color3 object
  72136. */
  72137. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72138. /**
  72139. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72140. * @param left defines the start value
  72141. * @param right defines the end value
  72142. * @param amount defines the gradient factor
  72143. * @param result defines the Color3 object where to store the result
  72144. */
  72145. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72146. /**
  72147. * Returns a Color3 value containing a red color
  72148. * @returns a new Color3 object
  72149. */
  72150. static Red(): Color3;
  72151. /**
  72152. * Returns a Color3 value containing a green color
  72153. * @returns a new Color3 object
  72154. */
  72155. static Green(): Color3;
  72156. /**
  72157. * Returns a Color3 value containing a blue color
  72158. * @returns a new Color3 object
  72159. */
  72160. static Blue(): Color3;
  72161. /**
  72162. * Returns a Color3 value containing a black color
  72163. * @returns a new Color3 object
  72164. */
  72165. static Black(): Color3;
  72166. /**
  72167. * Gets a Color3 value containing a black color that must not be updated
  72168. */
  72169. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72170. /**
  72171. * Returns a Color3 value containing a white color
  72172. * @returns a new Color3 object
  72173. */
  72174. static White(): Color3;
  72175. /**
  72176. * Returns a Color3 value containing a purple color
  72177. * @returns a new Color3 object
  72178. */
  72179. static Purple(): Color3;
  72180. /**
  72181. * Returns a Color3 value containing a magenta color
  72182. * @returns a new Color3 object
  72183. */
  72184. static Magenta(): Color3;
  72185. /**
  72186. * Returns a Color3 value containing a yellow color
  72187. * @returns a new Color3 object
  72188. */
  72189. static Yellow(): Color3;
  72190. /**
  72191. * Returns a Color3 value containing a gray color
  72192. * @returns a new Color3 object
  72193. */
  72194. static Gray(): Color3;
  72195. /**
  72196. * Returns a Color3 value containing a teal color
  72197. * @returns a new Color3 object
  72198. */
  72199. static Teal(): Color3;
  72200. /**
  72201. * Returns a Color3 value containing a random color
  72202. * @returns a new Color3 object
  72203. */
  72204. static Random(): Color3;
  72205. }
  72206. /**
  72207. * Class used to hold a RBGA color
  72208. */
  72209. export class Color4 {
  72210. /**
  72211. * Defines the red component (between 0 and 1, default is 0)
  72212. */
  72213. r: number;
  72214. /**
  72215. * Defines the green component (between 0 and 1, default is 0)
  72216. */
  72217. g: number;
  72218. /**
  72219. * Defines the blue component (between 0 and 1, default is 0)
  72220. */
  72221. b: number;
  72222. /**
  72223. * Defines the alpha component (between 0 and 1, default is 1)
  72224. */
  72225. a: number;
  72226. /**
  72227. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72228. * @param r defines the red component (between 0 and 1, default is 0)
  72229. * @param g defines the green component (between 0 and 1, default is 0)
  72230. * @param b defines the blue component (between 0 and 1, default is 0)
  72231. * @param a defines the alpha component (between 0 and 1, default is 1)
  72232. */
  72233. constructor(
  72234. /**
  72235. * Defines the red component (between 0 and 1, default is 0)
  72236. */
  72237. r?: number,
  72238. /**
  72239. * Defines the green component (between 0 and 1, default is 0)
  72240. */
  72241. g?: number,
  72242. /**
  72243. * Defines the blue component (between 0 and 1, default is 0)
  72244. */
  72245. b?: number,
  72246. /**
  72247. * Defines the alpha component (between 0 and 1, default is 1)
  72248. */
  72249. a?: number);
  72250. /**
  72251. * Adds in place the given Color4 values to the current Color4 object
  72252. * @param right defines the second operand
  72253. * @returns the current updated Color4 object
  72254. */
  72255. addInPlace(right: DeepImmutable<Color4>): Color4;
  72256. /**
  72257. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72258. * @returns the new array
  72259. */
  72260. asArray(): number[];
  72261. /**
  72262. * Stores from the starting index in the given array the Color4 successive values
  72263. * @param array defines the array where to store the r,g,b components
  72264. * @param index defines an optional index in the target array to define where to start storing values
  72265. * @returns the current Color4 object
  72266. */
  72267. toArray(array: number[], index?: number): Color4;
  72268. /**
  72269. * Determines equality between Color4 objects
  72270. * @param otherColor defines the second operand
  72271. * @returns true if the rgba values are equal to the given ones
  72272. */
  72273. equals(otherColor: DeepImmutable<Color4>): boolean;
  72274. /**
  72275. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72276. * @param right defines the second operand
  72277. * @returns a new Color4 object
  72278. */
  72279. add(right: DeepImmutable<Color4>): Color4;
  72280. /**
  72281. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72282. * @param right defines the second operand
  72283. * @returns a new Color4 object
  72284. */
  72285. subtract(right: DeepImmutable<Color4>): Color4;
  72286. /**
  72287. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72288. * @param right defines the second operand
  72289. * @param result defines the Color4 object where to store the result
  72290. * @returns the current Color4 object
  72291. */
  72292. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72293. /**
  72294. * Creates a new Color4 with the current Color4 values multiplied by scale
  72295. * @param scale defines the scaling factor to apply
  72296. * @returns a new Color4 object
  72297. */
  72298. scale(scale: number): Color4;
  72299. /**
  72300. * Multiplies the current Color4 values by scale and stores the result in "result"
  72301. * @param scale defines the scaling factor to apply
  72302. * @param result defines the Color4 object where to store the result
  72303. * @returns the current unmodified Color4
  72304. */
  72305. scaleToRef(scale: number, result: Color4): Color4;
  72306. /**
  72307. * Scale the current Color4 values by a factor and add the result to a given Color4
  72308. * @param scale defines the scale factor
  72309. * @param result defines the Color4 object where to store the result
  72310. * @returns the unmodified current Color4
  72311. */
  72312. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72313. /**
  72314. * Clamps the rgb values by the min and max values and stores the result into "result"
  72315. * @param min defines minimum clamping value (default is 0)
  72316. * @param max defines maximum clamping value (default is 1)
  72317. * @param result defines color to store the result into.
  72318. * @returns the cuurent Color4
  72319. */
  72320. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72321. /**
  72322. * Multipy an Color4 value by another and return a new Color4 object
  72323. * @param color defines the Color4 value to multiply by
  72324. * @returns a new Color4 object
  72325. */
  72326. multiply(color: Color4): Color4;
  72327. /**
  72328. * Multipy a Color4 value by another and push the result in a reference value
  72329. * @param color defines the Color4 value to multiply by
  72330. * @param result defines the Color4 to fill the result in
  72331. * @returns the result Color4
  72332. */
  72333. multiplyToRef(color: Color4, result: Color4): Color4;
  72334. /**
  72335. * Creates a string with the Color4 current values
  72336. * @returns the string representation of the Color4 object
  72337. */
  72338. toString(): string;
  72339. /**
  72340. * Returns the string "Color4"
  72341. * @returns "Color4"
  72342. */
  72343. getClassName(): string;
  72344. /**
  72345. * Compute the Color4 hash code
  72346. * @returns an unique number that can be used to hash Color4 objects
  72347. */
  72348. getHashCode(): number;
  72349. /**
  72350. * Creates a new Color4 copied from the current one
  72351. * @returns a new Color4 object
  72352. */
  72353. clone(): Color4;
  72354. /**
  72355. * Copies the given Color4 values into the current one
  72356. * @param source defines the source Color4 object
  72357. * @returns the current updated Color4 object
  72358. */
  72359. copyFrom(source: Color4): Color4;
  72360. /**
  72361. * Copies the given float values into the current one
  72362. * @param r defines the red component to read from
  72363. * @param g defines the green component to read from
  72364. * @param b defines the blue component to read from
  72365. * @param a defines the alpha component to read from
  72366. * @returns the current updated Color4 object
  72367. */
  72368. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72369. /**
  72370. * Copies the given float values into the current one
  72371. * @param r defines the red component to read from
  72372. * @param g defines the green component to read from
  72373. * @param b defines the blue component to read from
  72374. * @param a defines the alpha component to read from
  72375. * @returns the current updated Color4 object
  72376. */
  72377. set(r: number, g: number, b: number, a: number): Color4;
  72378. /**
  72379. * Compute the Color4 hexadecimal code as a string
  72380. * @returns a string containing the hexadecimal representation of the Color4 object
  72381. */
  72382. toHexString(): string;
  72383. /**
  72384. * Computes a new Color4 converted from the current one to linear space
  72385. * @returns a new Color4 object
  72386. */
  72387. toLinearSpace(): Color4;
  72388. /**
  72389. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72390. * @param convertedColor defines the Color4 object where to store the linear space version
  72391. * @returns the unmodified Color4
  72392. */
  72393. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72394. /**
  72395. * Computes a new Color4 converted from the current one to gamma space
  72396. * @returns a new Color4 object
  72397. */
  72398. toGammaSpace(): Color4;
  72399. /**
  72400. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72401. * @param convertedColor defines the Color4 object where to store the gamma space version
  72402. * @returns the unmodified Color4
  72403. */
  72404. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72405. /**
  72406. * Creates a new Color4 from the string containing valid hexadecimal values
  72407. * @param hex defines a string containing valid hexadecimal values
  72408. * @returns a new Color4 object
  72409. */
  72410. static FromHexString(hex: string): Color4;
  72411. /**
  72412. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72413. * @param left defines the start value
  72414. * @param right defines the end value
  72415. * @param amount defines the gradient factor
  72416. * @returns a new Color4 object
  72417. */
  72418. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72419. /**
  72420. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72421. * @param left defines the start value
  72422. * @param right defines the end value
  72423. * @param amount defines the gradient factor
  72424. * @param result defines the Color4 object where to store data
  72425. */
  72426. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72427. /**
  72428. * Creates a new Color4 from a Color3 and an alpha value
  72429. * @param color3 defines the source Color3 to read from
  72430. * @param alpha defines the alpha component (1.0 by default)
  72431. * @returns a new Color4 object
  72432. */
  72433. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72434. /**
  72435. * Creates a new Color4 from the starting index element of the given array
  72436. * @param array defines the source array to read from
  72437. * @param offset defines the offset in the source array
  72438. * @returns a new Color4 object
  72439. */
  72440. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72441. /**
  72442. * Creates a new Color3 from integer values (< 256)
  72443. * @param r defines the red component to read from (value between 0 and 255)
  72444. * @param g defines the green component to read from (value between 0 and 255)
  72445. * @param b defines the blue component to read from (value between 0 and 255)
  72446. * @param a defines the alpha component to read from (value between 0 and 255)
  72447. * @returns a new Color3 object
  72448. */
  72449. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72450. /**
  72451. * Check the content of a given array and convert it to an array containing RGBA data
  72452. * If the original array was already containing count * 4 values then it is returned directly
  72453. * @param colors defines the array to check
  72454. * @param count defines the number of RGBA data to expect
  72455. * @returns an array containing count * 4 values (RGBA)
  72456. */
  72457. static CheckColors4(colors: number[], count: number): number[];
  72458. }
  72459. /**
  72460. * @hidden
  72461. */
  72462. export class TmpColors {
  72463. static Color3: Color3[];
  72464. static Color4: Color4[];
  72465. }
  72466. }
  72467. declare module BABYLON {
  72468. /**
  72469. * Defines an interface which represents an animation key frame
  72470. */
  72471. export interface IAnimationKey {
  72472. /**
  72473. * Frame of the key frame
  72474. */
  72475. frame: number;
  72476. /**
  72477. * Value at the specifies key frame
  72478. */
  72479. value: any;
  72480. /**
  72481. * The input tangent for the cubic hermite spline
  72482. */
  72483. inTangent?: any;
  72484. /**
  72485. * The output tangent for the cubic hermite spline
  72486. */
  72487. outTangent?: any;
  72488. /**
  72489. * The animation interpolation type
  72490. */
  72491. interpolation?: AnimationKeyInterpolation;
  72492. }
  72493. /**
  72494. * Enum for the animation key frame interpolation type
  72495. */
  72496. export enum AnimationKeyInterpolation {
  72497. /**
  72498. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72499. */
  72500. STEP = 1
  72501. }
  72502. }
  72503. declare module BABYLON {
  72504. /**
  72505. * Represents the range of an animation
  72506. */
  72507. export class AnimationRange {
  72508. /**The name of the animation range**/
  72509. name: string;
  72510. /**The starting frame of the animation */
  72511. from: number;
  72512. /**The ending frame of the animation*/
  72513. to: number;
  72514. /**
  72515. * Initializes the range of an animation
  72516. * @param name The name of the animation range
  72517. * @param from The starting frame of the animation
  72518. * @param to The ending frame of the animation
  72519. */
  72520. constructor(
  72521. /**The name of the animation range**/
  72522. name: string,
  72523. /**The starting frame of the animation */
  72524. from: number,
  72525. /**The ending frame of the animation*/
  72526. to: number);
  72527. /**
  72528. * Makes a copy of the animation range
  72529. * @returns A copy of the animation range
  72530. */
  72531. clone(): AnimationRange;
  72532. }
  72533. }
  72534. declare module BABYLON {
  72535. /**
  72536. * Composed of a frame, and an action function
  72537. */
  72538. export class AnimationEvent {
  72539. /** The frame for which the event is triggered **/
  72540. frame: number;
  72541. /** The event to perform when triggered **/
  72542. action: (currentFrame: number) => void;
  72543. /** Specifies if the event should be triggered only once**/
  72544. onlyOnce?: boolean | undefined;
  72545. /**
  72546. * Specifies if the animation event is done
  72547. */
  72548. isDone: boolean;
  72549. /**
  72550. * Initializes the animation event
  72551. * @param frame The frame for which the event is triggered
  72552. * @param action The event to perform when triggered
  72553. * @param onlyOnce Specifies if the event should be triggered only once
  72554. */
  72555. constructor(
  72556. /** The frame for which the event is triggered **/
  72557. frame: number,
  72558. /** The event to perform when triggered **/
  72559. action: (currentFrame: number) => void,
  72560. /** Specifies if the event should be triggered only once**/
  72561. onlyOnce?: boolean | undefined);
  72562. /** @hidden */
  72563. _clone(): AnimationEvent;
  72564. }
  72565. }
  72566. declare module BABYLON {
  72567. /**
  72568. * Interface used to define a behavior
  72569. */
  72570. export interface Behavior<T> {
  72571. /** gets or sets behavior's name */
  72572. name: string;
  72573. /**
  72574. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72575. */
  72576. init(): void;
  72577. /**
  72578. * Called when the behavior is attached to a target
  72579. * @param target defines the target where the behavior is attached to
  72580. */
  72581. attach(target: T): void;
  72582. /**
  72583. * Called when the behavior is detached from its target
  72584. */
  72585. detach(): void;
  72586. }
  72587. /**
  72588. * Interface implemented by classes supporting behaviors
  72589. */
  72590. export interface IBehaviorAware<T> {
  72591. /**
  72592. * Attach a behavior
  72593. * @param behavior defines the behavior to attach
  72594. * @returns the current host
  72595. */
  72596. addBehavior(behavior: Behavior<T>): T;
  72597. /**
  72598. * Remove a behavior from the current object
  72599. * @param behavior defines the behavior to detach
  72600. * @returns the current host
  72601. */
  72602. removeBehavior(behavior: Behavior<T>): T;
  72603. /**
  72604. * Gets a behavior using its name to search
  72605. * @param name defines the name to search
  72606. * @returns the behavior or null if not found
  72607. */
  72608. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72609. }
  72610. }
  72611. declare module BABYLON {
  72612. /**
  72613. * Defines an array and its length.
  72614. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72615. */
  72616. export interface ISmartArrayLike<T> {
  72617. /**
  72618. * The data of the array.
  72619. */
  72620. data: Array<T>;
  72621. /**
  72622. * The active length of the array.
  72623. */
  72624. length: number;
  72625. }
  72626. /**
  72627. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72628. */
  72629. export class SmartArray<T> implements ISmartArrayLike<T> {
  72630. /**
  72631. * The full set of data from the array.
  72632. */
  72633. data: Array<T>;
  72634. /**
  72635. * The active length of the array.
  72636. */
  72637. length: number;
  72638. protected _id: number;
  72639. /**
  72640. * Instantiates a Smart Array.
  72641. * @param capacity defines the default capacity of the array.
  72642. */
  72643. constructor(capacity: number);
  72644. /**
  72645. * Pushes a value at the end of the active data.
  72646. * @param value defines the object to push in the array.
  72647. */
  72648. push(value: T): void;
  72649. /**
  72650. * Iterates over the active data and apply the lambda to them.
  72651. * @param func defines the action to apply on each value.
  72652. */
  72653. forEach(func: (content: T) => void): void;
  72654. /**
  72655. * Sorts the full sets of data.
  72656. * @param compareFn defines the comparison function to apply.
  72657. */
  72658. sort(compareFn: (a: T, b: T) => number): void;
  72659. /**
  72660. * Resets the active data to an empty array.
  72661. */
  72662. reset(): void;
  72663. /**
  72664. * Releases all the data from the array as well as the array.
  72665. */
  72666. dispose(): void;
  72667. /**
  72668. * Concats the active data with a given array.
  72669. * @param array defines the data to concatenate with.
  72670. */
  72671. concat(array: any): void;
  72672. /**
  72673. * Returns the position of a value in the active data.
  72674. * @param value defines the value to find the index for
  72675. * @returns the index if found in the active data otherwise -1
  72676. */
  72677. indexOf(value: T): number;
  72678. /**
  72679. * Returns whether an element is part of the active data.
  72680. * @param value defines the value to look for
  72681. * @returns true if found in the active data otherwise false
  72682. */
  72683. contains(value: T): boolean;
  72684. private static _GlobalId;
  72685. }
  72686. /**
  72687. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72688. * The data in this array can only be present once
  72689. */
  72690. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72691. private _duplicateId;
  72692. /**
  72693. * Pushes a value at the end of the active data.
  72694. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72695. * @param value defines the object to push in the array.
  72696. */
  72697. push(value: T): void;
  72698. /**
  72699. * Pushes a value at the end of the active data.
  72700. * If the data is already present, it won t be added again
  72701. * @param value defines the object to push in the array.
  72702. * @returns true if added false if it was already present
  72703. */
  72704. pushNoDuplicate(value: T): boolean;
  72705. /**
  72706. * Resets the active data to an empty array.
  72707. */
  72708. reset(): void;
  72709. /**
  72710. * Concats the active data with a given array.
  72711. * This ensures no dupplicate will be present in the result.
  72712. * @param array defines the data to concatenate with.
  72713. */
  72714. concatWithNoDuplicate(array: any): void;
  72715. }
  72716. }
  72717. declare module BABYLON {
  72718. /**
  72719. * @ignore
  72720. * This is a list of all the different input types that are available in the application.
  72721. * Fo instance: ArcRotateCameraGamepadInput...
  72722. */
  72723. export var CameraInputTypes: {};
  72724. /**
  72725. * This is the contract to implement in order to create a new input class.
  72726. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72727. */
  72728. export interface ICameraInput<TCamera extends Camera> {
  72729. /**
  72730. * Defines the camera the input is attached to.
  72731. */
  72732. camera: Nullable<TCamera>;
  72733. /**
  72734. * Gets the class name of the current intput.
  72735. * @returns the class name
  72736. */
  72737. getClassName(): string;
  72738. /**
  72739. * Get the friendly name associated with the input class.
  72740. * @returns the input friendly name
  72741. */
  72742. getSimpleName(): string;
  72743. /**
  72744. * Attach the input controls to a specific dom element to get the input from.
  72745. * @param element Defines the element the controls should be listened from
  72746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72747. */
  72748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72749. /**
  72750. * Detach the current controls from the specified dom element.
  72751. * @param element Defines the element to stop listening the inputs from
  72752. */
  72753. detachControl(element: Nullable<HTMLElement>): void;
  72754. /**
  72755. * Update the current camera state depending on the inputs that have been used this frame.
  72756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72757. */
  72758. checkInputs?: () => void;
  72759. }
  72760. /**
  72761. * Represents a map of input types to input instance or input index to input instance.
  72762. */
  72763. export interface CameraInputsMap<TCamera extends Camera> {
  72764. /**
  72765. * Accessor to the input by input type.
  72766. */
  72767. [name: string]: ICameraInput<TCamera>;
  72768. /**
  72769. * Accessor to the input by input index.
  72770. */
  72771. [idx: number]: ICameraInput<TCamera>;
  72772. }
  72773. /**
  72774. * This represents the input manager used within a camera.
  72775. * It helps dealing with all the different kind of input attached to a camera.
  72776. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72777. */
  72778. export class CameraInputsManager<TCamera extends Camera> {
  72779. /**
  72780. * Defines the list of inputs attahed to the camera.
  72781. */
  72782. attached: CameraInputsMap<TCamera>;
  72783. /**
  72784. * Defines the dom element the camera is collecting inputs from.
  72785. * This is null if the controls have not been attached.
  72786. */
  72787. attachedElement: Nullable<HTMLElement>;
  72788. /**
  72789. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72790. */
  72791. noPreventDefault: boolean;
  72792. /**
  72793. * Defined the camera the input manager belongs to.
  72794. */
  72795. camera: TCamera;
  72796. /**
  72797. * Update the current camera state depending on the inputs that have been used this frame.
  72798. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72799. */
  72800. checkInputs: () => void;
  72801. /**
  72802. * Instantiate a new Camera Input Manager.
  72803. * @param camera Defines the camera the input manager blongs to
  72804. */
  72805. constructor(camera: TCamera);
  72806. /**
  72807. * Add an input method to a camera
  72808. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72809. * @param input camera input method
  72810. */
  72811. add(input: ICameraInput<TCamera>): void;
  72812. /**
  72813. * Remove a specific input method from a camera
  72814. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72815. * @param inputToRemove camera input method
  72816. */
  72817. remove(inputToRemove: ICameraInput<TCamera>): void;
  72818. /**
  72819. * Remove a specific input type from a camera
  72820. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72821. * @param inputType the type of the input to remove
  72822. */
  72823. removeByType(inputType: string): void;
  72824. private _addCheckInputs;
  72825. /**
  72826. * Attach the input controls to the currently attached dom element to listen the events from.
  72827. * @param input Defines the input to attach
  72828. */
  72829. attachInput(input: ICameraInput<TCamera>): void;
  72830. /**
  72831. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72832. * @param element Defines the dom element to collect the events from
  72833. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72834. */
  72835. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72836. /**
  72837. * Detach the current manager inputs controls from a specific dom element.
  72838. * @param element Defines the dom element to collect the events from
  72839. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72840. */
  72841. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72842. /**
  72843. * Rebuild the dynamic inputCheck function from the current list of
  72844. * defined inputs in the manager.
  72845. */
  72846. rebuildInputCheck(): void;
  72847. /**
  72848. * Remove all attached input methods from a camera
  72849. */
  72850. clear(): void;
  72851. /**
  72852. * Serialize the current input manager attached to a camera.
  72853. * This ensures than once parsed,
  72854. * the input associated to the camera will be identical to the current ones
  72855. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72856. */
  72857. serialize(serializedCamera: any): void;
  72858. /**
  72859. * Parses an input manager serialized JSON to restore the previous list of inputs
  72860. * and states associated to a camera.
  72861. * @param parsedCamera Defines the JSON to parse
  72862. */
  72863. parse(parsedCamera: any): void;
  72864. }
  72865. }
  72866. declare module BABYLON {
  72867. /**
  72868. * Class used to store data that will be store in GPU memory
  72869. */
  72870. export class Buffer {
  72871. private _engine;
  72872. private _buffer;
  72873. /** @hidden */
  72874. _data: Nullable<DataArray>;
  72875. private _updatable;
  72876. private _instanced;
  72877. /**
  72878. * Gets the byte stride.
  72879. */
  72880. readonly byteStride: number;
  72881. /**
  72882. * Constructor
  72883. * @param engine the engine
  72884. * @param data the data to use for this buffer
  72885. * @param updatable whether the data is updatable
  72886. * @param stride the stride (optional)
  72887. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72888. * @param instanced whether the buffer is instanced (optional)
  72889. * @param useBytes set to true if the stride in in bytes (optional)
  72890. */
  72891. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72892. /**
  72893. * Create a new VertexBuffer based on the current buffer
  72894. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72895. * @param offset defines offset in the buffer (0 by default)
  72896. * @param size defines the size in floats of attributes (position is 3 for instance)
  72897. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72898. * @param instanced defines if the vertex buffer contains indexed data
  72899. * @param useBytes defines if the offset and stride are in bytes
  72900. * @returns the new vertex buffer
  72901. */
  72902. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72903. /**
  72904. * Gets a boolean indicating if the Buffer is updatable?
  72905. * @returns true if the buffer is updatable
  72906. */
  72907. isUpdatable(): boolean;
  72908. /**
  72909. * Gets current buffer's data
  72910. * @returns a DataArray or null
  72911. */
  72912. getData(): Nullable<DataArray>;
  72913. /**
  72914. * Gets underlying native buffer
  72915. * @returns underlying native buffer
  72916. */
  72917. getBuffer(): Nullable<DataBuffer>;
  72918. /**
  72919. * Gets the stride in float32 units (i.e. byte stride / 4).
  72920. * May not be an integer if the byte stride is not divisible by 4.
  72921. * DEPRECATED. Use byteStride instead.
  72922. * @returns the stride in float32 units
  72923. */
  72924. getStrideSize(): number;
  72925. /**
  72926. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72927. * @param data defines the data to store
  72928. */
  72929. create(data?: Nullable<DataArray>): void;
  72930. /** @hidden */
  72931. _rebuild(): void;
  72932. /**
  72933. * Update current buffer data
  72934. * @param data defines the data to store
  72935. */
  72936. update(data: DataArray): void;
  72937. /**
  72938. * Updates the data directly.
  72939. * @param data the new data
  72940. * @param offset the new offset
  72941. * @param vertexCount the vertex count (optional)
  72942. * @param useBytes set to true if the offset is in bytes
  72943. */
  72944. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72945. /**
  72946. * Release all resources
  72947. */
  72948. dispose(): void;
  72949. }
  72950. /**
  72951. * Specialized buffer used to store vertex data
  72952. */
  72953. export class VertexBuffer {
  72954. /** @hidden */
  72955. _buffer: Buffer;
  72956. private _kind;
  72957. private _size;
  72958. private _ownsBuffer;
  72959. private _instanced;
  72960. private _instanceDivisor;
  72961. /**
  72962. * The byte type.
  72963. */
  72964. static readonly BYTE: number;
  72965. /**
  72966. * The unsigned byte type.
  72967. */
  72968. static readonly UNSIGNED_BYTE: number;
  72969. /**
  72970. * The short type.
  72971. */
  72972. static readonly SHORT: number;
  72973. /**
  72974. * The unsigned short type.
  72975. */
  72976. static readonly UNSIGNED_SHORT: number;
  72977. /**
  72978. * The integer type.
  72979. */
  72980. static readonly INT: number;
  72981. /**
  72982. * The unsigned integer type.
  72983. */
  72984. static readonly UNSIGNED_INT: number;
  72985. /**
  72986. * The float type.
  72987. */
  72988. static readonly FLOAT: number;
  72989. /**
  72990. * Gets or sets the instance divisor when in instanced mode
  72991. */
  72992. instanceDivisor: number;
  72993. /**
  72994. * Gets the byte stride.
  72995. */
  72996. readonly byteStride: number;
  72997. /**
  72998. * Gets the byte offset.
  72999. */
  73000. readonly byteOffset: number;
  73001. /**
  73002. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73003. */
  73004. readonly normalized: boolean;
  73005. /**
  73006. * Gets the data type of each component in the array.
  73007. */
  73008. readonly type: number;
  73009. /**
  73010. * Constructor
  73011. * @param engine the engine
  73012. * @param data the data to use for this vertex buffer
  73013. * @param kind the vertex buffer kind
  73014. * @param updatable whether the data is updatable
  73015. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73016. * @param stride the stride (optional)
  73017. * @param instanced whether the buffer is instanced (optional)
  73018. * @param offset the offset of the data (optional)
  73019. * @param size the number of components (optional)
  73020. * @param type the type of the component (optional)
  73021. * @param normalized whether the data contains normalized data (optional)
  73022. * @param useBytes set to true if stride and offset are in bytes (optional)
  73023. */
  73024. 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);
  73025. /** @hidden */
  73026. _rebuild(): void;
  73027. /**
  73028. * Returns the kind of the VertexBuffer (string)
  73029. * @returns a string
  73030. */
  73031. getKind(): string;
  73032. /**
  73033. * Gets a boolean indicating if the VertexBuffer is updatable?
  73034. * @returns true if the buffer is updatable
  73035. */
  73036. isUpdatable(): boolean;
  73037. /**
  73038. * Gets current buffer's data
  73039. * @returns a DataArray or null
  73040. */
  73041. getData(): Nullable<DataArray>;
  73042. /**
  73043. * Gets underlying native buffer
  73044. * @returns underlying native buffer
  73045. */
  73046. getBuffer(): Nullable<DataBuffer>;
  73047. /**
  73048. * Gets the stride in float32 units (i.e. byte stride / 4).
  73049. * May not be an integer if the byte stride is not divisible by 4.
  73050. * DEPRECATED. Use byteStride instead.
  73051. * @returns the stride in float32 units
  73052. */
  73053. getStrideSize(): number;
  73054. /**
  73055. * Returns the offset as a multiple of the type byte length.
  73056. * DEPRECATED. Use byteOffset instead.
  73057. * @returns the offset in bytes
  73058. */
  73059. getOffset(): number;
  73060. /**
  73061. * Returns the number of components per vertex attribute (integer)
  73062. * @returns the size in float
  73063. */
  73064. getSize(): number;
  73065. /**
  73066. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73067. * @returns true if this buffer is instanced
  73068. */
  73069. getIsInstanced(): boolean;
  73070. /**
  73071. * Returns the instancing divisor, zero for non-instanced (integer).
  73072. * @returns a number
  73073. */
  73074. getInstanceDivisor(): number;
  73075. /**
  73076. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73077. * @param data defines the data to store
  73078. */
  73079. create(data?: DataArray): void;
  73080. /**
  73081. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73082. * This function will create a new buffer if the current one is not updatable
  73083. * @param data defines the data to store
  73084. */
  73085. update(data: DataArray): void;
  73086. /**
  73087. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73088. * Returns the directly updated WebGLBuffer.
  73089. * @param data the new data
  73090. * @param offset the new offset
  73091. * @param useBytes set to true if the offset is in bytes
  73092. */
  73093. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73094. /**
  73095. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73096. */
  73097. dispose(): void;
  73098. /**
  73099. * Enumerates each value of this vertex buffer as numbers.
  73100. * @param count the number of values to enumerate
  73101. * @param callback the callback function called for each value
  73102. */
  73103. forEach(count: number, callback: (value: number, index: number) => void): void;
  73104. /**
  73105. * Positions
  73106. */
  73107. static readonly PositionKind: string;
  73108. /**
  73109. * Normals
  73110. */
  73111. static readonly NormalKind: string;
  73112. /**
  73113. * Tangents
  73114. */
  73115. static readonly TangentKind: string;
  73116. /**
  73117. * Texture coordinates
  73118. */
  73119. static readonly UVKind: string;
  73120. /**
  73121. * Texture coordinates 2
  73122. */
  73123. static readonly UV2Kind: string;
  73124. /**
  73125. * Texture coordinates 3
  73126. */
  73127. static readonly UV3Kind: string;
  73128. /**
  73129. * Texture coordinates 4
  73130. */
  73131. static readonly UV4Kind: string;
  73132. /**
  73133. * Texture coordinates 5
  73134. */
  73135. static readonly UV5Kind: string;
  73136. /**
  73137. * Texture coordinates 6
  73138. */
  73139. static readonly UV6Kind: string;
  73140. /**
  73141. * Colors
  73142. */
  73143. static readonly ColorKind: string;
  73144. /**
  73145. * Matrix indices (for bones)
  73146. */
  73147. static readonly MatricesIndicesKind: string;
  73148. /**
  73149. * Matrix weights (for bones)
  73150. */
  73151. static readonly MatricesWeightsKind: string;
  73152. /**
  73153. * Additional matrix indices (for bones)
  73154. */
  73155. static readonly MatricesIndicesExtraKind: string;
  73156. /**
  73157. * Additional matrix weights (for bones)
  73158. */
  73159. static readonly MatricesWeightsExtraKind: string;
  73160. /**
  73161. * Deduces the stride given a kind.
  73162. * @param kind The kind string to deduce
  73163. * @returns The deduced stride
  73164. */
  73165. static DeduceStride(kind: string): number;
  73166. /**
  73167. * Gets the byte length of the given type.
  73168. * @param type the type
  73169. * @returns the number of bytes
  73170. */
  73171. static GetTypeByteLength(type: number): number;
  73172. /**
  73173. * Enumerates each value of the given parameters as numbers.
  73174. * @param data the data to enumerate
  73175. * @param byteOffset the byte offset of the data
  73176. * @param byteStride the byte stride of the data
  73177. * @param componentCount the number of components per element
  73178. * @param componentType the type of the component
  73179. * @param count the number of values to enumerate
  73180. * @param normalized whether the data is normalized
  73181. * @param callback the callback function called for each value
  73182. */
  73183. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73184. private static _GetFloatValue;
  73185. }
  73186. }
  73187. declare module BABYLON {
  73188. /**
  73189. * @hidden
  73190. */
  73191. export class IntersectionInfo {
  73192. bu: Nullable<number>;
  73193. bv: Nullable<number>;
  73194. distance: number;
  73195. faceId: number;
  73196. subMeshId: number;
  73197. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73198. }
  73199. }
  73200. declare module BABYLON {
  73201. /**
  73202. * Represens a plane by the equation ax + by + cz + d = 0
  73203. */
  73204. export class Plane {
  73205. private static _TmpMatrix;
  73206. /**
  73207. * Normal of the plane (a,b,c)
  73208. */
  73209. normal: Vector3;
  73210. /**
  73211. * d component of the plane
  73212. */
  73213. d: number;
  73214. /**
  73215. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73216. * @param a a component of the plane
  73217. * @param b b component of the plane
  73218. * @param c c component of the plane
  73219. * @param d d component of the plane
  73220. */
  73221. constructor(a: number, b: number, c: number, d: number);
  73222. /**
  73223. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73224. */
  73225. asArray(): number[];
  73226. /**
  73227. * @returns a new plane copied from the current Plane.
  73228. */
  73229. clone(): Plane;
  73230. /**
  73231. * @returns the string "Plane".
  73232. */
  73233. getClassName(): string;
  73234. /**
  73235. * @returns the Plane hash code.
  73236. */
  73237. getHashCode(): number;
  73238. /**
  73239. * Normalize the current Plane in place.
  73240. * @returns the updated Plane.
  73241. */
  73242. normalize(): Plane;
  73243. /**
  73244. * Applies a transformation the plane and returns the result
  73245. * @param transformation the transformation matrix to be applied to the plane
  73246. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73247. */
  73248. transform(transformation: DeepImmutable<Matrix>): Plane;
  73249. /**
  73250. * Calcualtte the dot product between the point and the plane normal
  73251. * @param point point to calculate the dot product with
  73252. * @returns the dot product (float) of the point coordinates and the plane normal.
  73253. */
  73254. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73255. /**
  73256. * Updates the current Plane from the plane defined by the three given points.
  73257. * @param point1 one of the points used to contruct the plane
  73258. * @param point2 one of the points used to contruct the plane
  73259. * @param point3 one of the points used to contruct the plane
  73260. * @returns the updated Plane.
  73261. */
  73262. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73263. /**
  73264. * Checks if the plane is facing a given direction
  73265. * @param direction the direction to check if the plane is facing
  73266. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73267. * @returns True is the vector "direction" is the same side than the plane normal.
  73268. */
  73269. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73270. /**
  73271. * Calculates the distance to a point
  73272. * @param point point to calculate distance to
  73273. * @returns the signed distance (float) from the given point to the Plane.
  73274. */
  73275. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73276. /**
  73277. * Creates a plane from an array
  73278. * @param array the array to create a plane from
  73279. * @returns a new Plane from the given array.
  73280. */
  73281. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73282. /**
  73283. * Creates a plane from three points
  73284. * @param point1 point used to create the plane
  73285. * @param point2 point used to create the plane
  73286. * @param point3 point used to create the plane
  73287. * @returns a new Plane defined by the three given points.
  73288. */
  73289. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73290. /**
  73291. * Creates a plane from an origin point and a normal
  73292. * @param origin origin of the plane to be constructed
  73293. * @param normal normal of the plane to be constructed
  73294. * @returns a new Plane the normal vector to this plane at the given origin point.
  73295. * Note : the vector "normal" is updated because normalized.
  73296. */
  73297. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73298. /**
  73299. * Calculates the distance from a plane and a point
  73300. * @param origin origin of the plane to be constructed
  73301. * @param normal normal of the plane to be constructed
  73302. * @param point point to calculate distance to
  73303. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73304. */
  73305. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73306. }
  73307. }
  73308. declare module BABYLON {
  73309. /**
  73310. * Class used to store bounding sphere information
  73311. */
  73312. export class BoundingSphere {
  73313. /**
  73314. * Gets the center of the bounding sphere in local space
  73315. */
  73316. readonly center: Vector3;
  73317. /**
  73318. * Radius of the bounding sphere in local space
  73319. */
  73320. radius: number;
  73321. /**
  73322. * Gets the center of the bounding sphere in world space
  73323. */
  73324. readonly centerWorld: Vector3;
  73325. /**
  73326. * Radius of the bounding sphere in world space
  73327. */
  73328. radiusWorld: number;
  73329. /**
  73330. * Gets the minimum vector in local space
  73331. */
  73332. readonly minimum: Vector3;
  73333. /**
  73334. * Gets the maximum vector in local space
  73335. */
  73336. readonly maximum: Vector3;
  73337. private _worldMatrix;
  73338. private static readonly TmpVector3;
  73339. /**
  73340. * Creates a new bounding sphere
  73341. * @param min defines the minimum vector (in local space)
  73342. * @param max defines the maximum vector (in local space)
  73343. * @param worldMatrix defines the new world matrix
  73344. */
  73345. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73346. /**
  73347. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73348. * @param min defines the new minimum vector (in local space)
  73349. * @param max defines the new maximum vector (in local space)
  73350. * @param worldMatrix defines the new world matrix
  73351. */
  73352. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73353. /**
  73354. * Scale the current bounding sphere by applying a scale factor
  73355. * @param factor defines the scale factor to apply
  73356. * @returns the current bounding box
  73357. */
  73358. scale(factor: number): BoundingSphere;
  73359. /**
  73360. * Gets the world matrix of the bounding box
  73361. * @returns a matrix
  73362. */
  73363. getWorldMatrix(): DeepImmutable<Matrix>;
  73364. /** @hidden */
  73365. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73366. /**
  73367. * Tests if the bounding sphere is intersecting the frustum planes
  73368. * @param frustumPlanes defines the frustum planes to test
  73369. * @returns true if there is an intersection
  73370. */
  73371. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73372. /**
  73373. * Tests if the bounding sphere center is in between the frustum planes.
  73374. * Used for optimistic fast inclusion.
  73375. * @param frustumPlanes defines the frustum planes to test
  73376. * @returns true if the sphere center is in between the frustum planes
  73377. */
  73378. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73379. /**
  73380. * Tests if a point is inside the bounding sphere
  73381. * @param point defines the point to test
  73382. * @returns true if the point is inside the bounding sphere
  73383. */
  73384. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73385. /**
  73386. * Checks if two sphere intersct
  73387. * @param sphere0 sphere 0
  73388. * @param sphere1 sphere 1
  73389. * @returns true if the speres intersect
  73390. */
  73391. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73392. }
  73393. }
  73394. declare module BABYLON {
  73395. /**
  73396. * Class used to store bounding box information
  73397. */
  73398. export class BoundingBox implements ICullable {
  73399. /**
  73400. * Gets the 8 vectors representing the bounding box in local space
  73401. */
  73402. readonly vectors: Vector3[];
  73403. /**
  73404. * Gets the center of the bounding box in local space
  73405. */
  73406. readonly center: Vector3;
  73407. /**
  73408. * Gets the center of the bounding box in world space
  73409. */
  73410. readonly centerWorld: Vector3;
  73411. /**
  73412. * Gets the extend size in local space
  73413. */
  73414. readonly extendSize: Vector3;
  73415. /**
  73416. * Gets the extend size in world space
  73417. */
  73418. readonly extendSizeWorld: Vector3;
  73419. /**
  73420. * Gets the OBB (object bounding box) directions
  73421. */
  73422. readonly directions: Vector3[];
  73423. /**
  73424. * Gets the 8 vectors representing the bounding box in world space
  73425. */
  73426. readonly vectorsWorld: Vector3[];
  73427. /**
  73428. * Gets the minimum vector in world space
  73429. */
  73430. readonly minimumWorld: Vector3;
  73431. /**
  73432. * Gets the maximum vector in world space
  73433. */
  73434. readonly maximumWorld: Vector3;
  73435. /**
  73436. * Gets the minimum vector in local space
  73437. */
  73438. readonly minimum: Vector3;
  73439. /**
  73440. * Gets the maximum vector in local space
  73441. */
  73442. readonly maximum: Vector3;
  73443. private _worldMatrix;
  73444. private static readonly TmpVector3;
  73445. /**
  73446. * @hidden
  73447. */
  73448. _tag: number;
  73449. /**
  73450. * Creates a new bounding box
  73451. * @param min defines the minimum vector (in local space)
  73452. * @param max defines the maximum vector (in local space)
  73453. * @param worldMatrix defines the new world matrix
  73454. */
  73455. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73456. /**
  73457. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73458. * @param min defines the new minimum vector (in local space)
  73459. * @param max defines the new maximum vector (in local space)
  73460. * @param worldMatrix defines the new world matrix
  73461. */
  73462. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73463. /**
  73464. * Scale the current bounding box by applying a scale factor
  73465. * @param factor defines the scale factor to apply
  73466. * @returns the current bounding box
  73467. */
  73468. scale(factor: number): BoundingBox;
  73469. /**
  73470. * Gets the world matrix of the bounding box
  73471. * @returns a matrix
  73472. */
  73473. getWorldMatrix(): DeepImmutable<Matrix>;
  73474. /** @hidden */
  73475. _update(world: DeepImmutable<Matrix>): void;
  73476. /**
  73477. * Tests if the bounding box is intersecting the frustum planes
  73478. * @param frustumPlanes defines the frustum planes to test
  73479. * @returns true if there is an intersection
  73480. */
  73481. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73482. /**
  73483. * Tests if the bounding box is entirely inside the frustum planes
  73484. * @param frustumPlanes defines the frustum planes to test
  73485. * @returns true if there is an inclusion
  73486. */
  73487. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73488. /**
  73489. * Tests if a point is inside the bounding box
  73490. * @param point defines the point to test
  73491. * @returns true if the point is inside the bounding box
  73492. */
  73493. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73494. /**
  73495. * Tests if the bounding box intersects with a bounding sphere
  73496. * @param sphere defines the sphere to test
  73497. * @returns true if there is an intersection
  73498. */
  73499. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73500. /**
  73501. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73502. * @param min defines the min vector to use
  73503. * @param max defines the max vector to use
  73504. * @returns true if there is an intersection
  73505. */
  73506. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73507. /**
  73508. * Tests if two bounding boxes are intersections
  73509. * @param box0 defines the first box to test
  73510. * @param box1 defines the second box to test
  73511. * @returns true if there is an intersection
  73512. */
  73513. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73514. /**
  73515. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73516. * @param minPoint defines the minimum vector of the bounding box
  73517. * @param maxPoint defines the maximum vector of the bounding box
  73518. * @param sphereCenter defines the sphere center
  73519. * @param sphereRadius defines the sphere radius
  73520. * @returns true if there is an intersection
  73521. */
  73522. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73523. /**
  73524. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73525. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73526. * @param frustumPlanes defines the frustum planes to test
  73527. * @return true if there is an inclusion
  73528. */
  73529. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73530. /**
  73531. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73532. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73533. * @param frustumPlanes defines the frustum planes to test
  73534. * @return true if there is an intersection
  73535. */
  73536. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73537. }
  73538. }
  73539. declare module BABYLON {
  73540. /** @hidden */
  73541. export class Collider {
  73542. /** Define if a collision was found */
  73543. collisionFound: boolean;
  73544. /**
  73545. * Define last intersection point in local space
  73546. */
  73547. intersectionPoint: Vector3;
  73548. /**
  73549. * Define last collided mesh
  73550. */
  73551. collidedMesh: Nullable<AbstractMesh>;
  73552. private _collisionPoint;
  73553. private _planeIntersectionPoint;
  73554. private _tempVector;
  73555. private _tempVector2;
  73556. private _tempVector3;
  73557. private _tempVector4;
  73558. private _edge;
  73559. private _baseToVertex;
  73560. private _destinationPoint;
  73561. private _slidePlaneNormal;
  73562. private _displacementVector;
  73563. /** @hidden */
  73564. _radius: Vector3;
  73565. /** @hidden */
  73566. _retry: number;
  73567. private _velocity;
  73568. private _basePoint;
  73569. private _epsilon;
  73570. /** @hidden */
  73571. _velocityWorldLength: number;
  73572. /** @hidden */
  73573. _basePointWorld: Vector3;
  73574. private _velocityWorld;
  73575. private _normalizedVelocity;
  73576. /** @hidden */
  73577. _initialVelocity: Vector3;
  73578. /** @hidden */
  73579. _initialPosition: Vector3;
  73580. private _nearestDistance;
  73581. private _collisionMask;
  73582. collisionMask: number;
  73583. /**
  73584. * Gets the plane normal used to compute the sliding response (in local space)
  73585. */
  73586. readonly slidePlaneNormal: Vector3;
  73587. /** @hidden */
  73588. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73589. /** @hidden */
  73590. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73591. /** @hidden */
  73592. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73593. /** @hidden */
  73594. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73595. /** @hidden */
  73596. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73597. /** @hidden */
  73598. _getResponse(pos: Vector3, vel: Vector3): void;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Interface for cullable objects
  73604. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73605. */
  73606. export interface ICullable {
  73607. /**
  73608. * Checks if the object or part of the object is in the frustum
  73609. * @param frustumPlanes Camera near/planes
  73610. * @returns true if the object is in frustum otherwise false
  73611. */
  73612. isInFrustum(frustumPlanes: Plane[]): boolean;
  73613. /**
  73614. * Checks if a cullable object (mesh...) is in the camera frustum
  73615. * Unlike isInFrustum this cheks the full bounding box
  73616. * @param frustumPlanes Camera near/planes
  73617. * @returns true if the object is in frustum otherwise false
  73618. */
  73619. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73620. }
  73621. /**
  73622. * Info for a bounding data of a mesh
  73623. */
  73624. export class BoundingInfo implements ICullable {
  73625. /**
  73626. * Bounding box for the mesh
  73627. */
  73628. readonly boundingBox: BoundingBox;
  73629. /**
  73630. * Bounding sphere for the mesh
  73631. */
  73632. readonly boundingSphere: BoundingSphere;
  73633. private _isLocked;
  73634. private static readonly TmpVector3;
  73635. /**
  73636. * Constructs bounding info
  73637. * @param minimum min vector of the bounding box/sphere
  73638. * @param maximum max vector of the bounding box/sphere
  73639. * @param worldMatrix defines the new world matrix
  73640. */
  73641. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73642. /**
  73643. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73644. * @param min defines the new minimum vector (in local space)
  73645. * @param max defines the new maximum vector (in local space)
  73646. * @param worldMatrix defines the new world matrix
  73647. */
  73648. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73649. /**
  73650. * min vector of the bounding box/sphere
  73651. */
  73652. readonly minimum: Vector3;
  73653. /**
  73654. * max vector of the bounding box/sphere
  73655. */
  73656. readonly maximum: Vector3;
  73657. /**
  73658. * If the info is locked and won't be updated to avoid perf overhead
  73659. */
  73660. isLocked: boolean;
  73661. /**
  73662. * Updates the bounding sphere and box
  73663. * @param world world matrix to be used to update
  73664. */
  73665. update(world: DeepImmutable<Matrix>): void;
  73666. /**
  73667. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73668. * @param center New center of the bounding info
  73669. * @param extend New extend of the bounding info
  73670. * @returns the current bounding info
  73671. */
  73672. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73673. /**
  73674. * Scale the current bounding info by applying a scale factor
  73675. * @param factor defines the scale factor to apply
  73676. * @returns the current bounding info
  73677. */
  73678. scale(factor: number): BoundingInfo;
  73679. /**
  73680. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73681. * @param frustumPlanes defines the frustum to test
  73682. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73683. * @returns true if the bounding info is in the frustum planes
  73684. */
  73685. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73686. /**
  73687. * Gets the world distance between the min and max points of the bounding box
  73688. */
  73689. readonly diagonalLength: number;
  73690. /**
  73691. * Checks if a cullable object (mesh...) is in the camera frustum
  73692. * Unlike isInFrustum this cheks the full bounding box
  73693. * @param frustumPlanes Camera near/planes
  73694. * @returns true if the object is in frustum otherwise false
  73695. */
  73696. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73697. /** @hidden */
  73698. _checkCollision(collider: Collider): boolean;
  73699. /**
  73700. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73701. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73702. * @param point the point to check intersection with
  73703. * @returns if the point intersects
  73704. */
  73705. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73706. /**
  73707. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73708. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73709. * @param boundingInfo the bounding info to check intersection with
  73710. * @param precise if the intersection should be done using OBB
  73711. * @returns if the bounding info intersects
  73712. */
  73713. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73714. }
  73715. }
  73716. declare module BABYLON {
  73717. /**
  73718. * Extracts minimum and maximum values from a list of indexed positions
  73719. * @param positions defines the positions to use
  73720. * @param indices defines the indices to the positions
  73721. * @param indexStart defines the start index
  73722. * @param indexCount defines the end index
  73723. * @param bias defines bias value to add to the result
  73724. * @return minimum and maximum values
  73725. */
  73726. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73727. minimum: Vector3;
  73728. maximum: Vector3;
  73729. };
  73730. /**
  73731. * Extracts minimum and maximum values from a list of positions
  73732. * @param positions defines the positions to use
  73733. * @param start defines the start index in the positions array
  73734. * @param count defines the number of positions to handle
  73735. * @param bias defines bias value to add to the result
  73736. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73737. * @return minimum and maximum values
  73738. */
  73739. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73740. minimum: Vector3;
  73741. maximum: Vector3;
  73742. };
  73743. }
  73744. declare module BABYLON {
  73745. /** @hidden */
  73746. export class WebGLDataBuffer extends DataBuffer {
  73747. private _buffer;
  73748. constructor(resource: WebGLBuffer);
  73749. readonly underlyingResource: any;
  73750. }
  73751. }
  73752. declare module BABYLON {
  73753. /** @hidden */
  73754. export class WebGLPipelineContext implements IPipelineContext {
  73755. engine: ThinEngine;
  73756. program: Nullable<WebGLProgram>;
  73757. context?: WebGLRenderingContext;
  73758. vertexShader?: WebGLShader;
  73759. fragmentShader?: WebGLShader;
  73760. isParallelCompiled: boolean;
  73761. onCompiled?: () => void;
  73762. transformFeedback?: WebGLTransformFeedback | null;
  73763. readonly isAsync: boolean;
  73764. readonly isReady: boolean;
  73765. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73766. }
  73767. }
  73768. declare module BABYLON {
  73769. interface ThinEngine {
  73770. /**
  73771. * Create an uniform buffer
  73772. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73773. * @param elements defines the content of the uniform buffer
  73774. * @returns the webGL uniform buffer
  73775. */
  73776. createUniformBuffer(elements: FloatArray): DataBuffer;
  73777. /**
  73778. * Create a dynamic uniform buffer
  73779. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73780. * @param elements defines the content of the uniform buffer
  73781. * @returns the webGL uniform buffer
  73782. */
  73783. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73784. /**
  73785. * Update an existing uniform buffer
  73786. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73787. * @param uniformBuffer defines the target uniform buffer
  73788. * @param elements defines the content to update
  73789. * @param offset defines the offset in the uniform buffer where update should start
  73790. * @param count defines the size of the data to update
  73791. */
  73792. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73793. /**
  73794. * Bind an uniform buffer to the current webGL context
  73795. * @param buffer defines the buffer to bind
  73796. */
  73797. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73798. /**
  73799. * Bind a buffer to the current webGL context at a given location
  73800. * @param buffer defines the buffer to bind
  73801. * @param location defines the index where to bind the buffer
  73802. */
  73803. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73804. /**
  73805. * Bind a specific block at a given index in a specific shader program
  73806. * @param pipelineContext defines the pipeline context to use
  73807. * @param blockName defines the block name
  73808. * @param index defines the index where to bind the block
  73809. */
  73810. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73811. }
  73812. }
  73813. declare module BABYLON {
  73814. /**
  73815. * Uniform buffer objects.
  73816. *
  73817. * Handles blocks of uniform on the GPU.
  73818. *
  73819. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73820. *
  73821. * For more information, please refer to :
  73822. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73823. */
  73824. export class UniformBuffer {
  73825. private _engine;
  73826. private _buffer;
  73827. private _data;
  73828. private _bufferData;
  73829. private _dynamic?;
  73830. private _uniformLocations;
  73831. private _uniformSizes;
  73832. private _uniformLocationPointer;
  73833. private _needSync;
  73834. private _noUBO;
  73835. private _currentEffect;
  73836. private static _MAX_UNIFORM_SIZE;
  73837. private static _tempBuffer;
  73838. /**
  73839. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73840. * This is dynamic to allow compat with webgl 1 and 2.
  73841. * You will need to pass the name of the uniform as well as the value.
  73842. */
  73843. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73844. /**
  73845. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73846. * This is dynamic to allow compat with webgl 1 and 2.
  73847. * You will need to pass the name of the uniform as well as the value.
  73848. */
  73849. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73850. /**
  73851. * Lambda to Update a single float in a uniform buffer.
  73852. * This is dynamic to allow compat with webgl 1 and 2.
  73853. * You will need to pass the name of the uniform as well as the value.
  73854. */
  73855. updateFloat: (name: string, x: number) => void;
  73856. /**
  73857. * Lambda to Update a vec2 of float in a uniform buffer.
  73858. * This is dynamic to allow compat with webgl 1 and 2.
  73859. * You will need to pass the name of the uniform as well as the value.
  73860. */
  73861. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73862. /**
  73863. * Lambda to Update a vec3 of float in a uniform buffer.
  73864. * This is dynamic to allow compat with webgl 1 and 2.
  73865. * You will need to pass the name of the uniform as well as the value.
  73866. */
  73867. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73868. /**
  73869. * Lambda to Update a vec4 of float in a uniform buffer.
  73870. * This is dynamic to allow compat with webgl 1 and 2.
  73871. * You will need to pass the name of the uniform as well as the value.
  73872. */
  73873. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73874. /**
  73875. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73876. * This is dynamic to allow compat with webgl 1 and 2.
  73877. * You will need to pass the name of the uniform as well as the value.
  73878. */
  73879. updateMatrix: (name: string, mat: Matrix) => void;
  73880. /**
  73881. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73882. * This is dynamic to allow compat with webgl 1 and 2.
  73883. * You will need to pass the name of the uniform as well as the value.
  73884. */
  73885. updateVector3: (name: string, vector: Vector3) => void;
  73886. /**
  73887. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73888. * This is dynamic to allow compat with webgl 1 and 2.
  73889. * You will need to pass the name of the uniform as well as the value.
  73890. */
  73891. updateVector4: (name: string, vector: Vector4) => void;
  73892. /**
  73893. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73894. * This is dynamic to allow compat with webgl 1 and 2.
  73895. * You will need to pass the name of the uniform as well as the value.
  73896. */
  73897. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73898. /**
  73899. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73900. * This is dynamic to allow compat with webgl 1 and 2.
  73901. * You will need to pass the name of the uniform as well as the value.
  73902. */
  73903. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73904. /**
  73905. * Instantiates a new Uniform buffer objects.
  73906. *
  73907. * Handles blocks of uniform on the GPU.
  73908. *
  73909. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73910. *
  73911. * For more information, please refer to :
  73912. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73913. * @param engine Define the engine the buffer is associated with
  73914. * @param data Define the data contained in the buffer
  73915. * @param dynamic Define if the buffer is updatable
  73916. */
  73917. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73918. /**
  73919. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73920. * or just falling back on setUniformXXX calls.
  73921. */
  73922. readonly useUbo: boolean;
  73923. /**
  73924. * Indicates if the WebGL underlying uniform buffer is in sync
  73925. * with the javascript cache data.
  73926. */
  73927. readonly isSync: boolean;
  73928. /**
  73929. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73930. * Also, a dynamic UniformBuffer will disable cache verification and always
  73931. * update the underlying WebGL uniform buffer to the GPU.
  73932. * @returns if Dynamic, otherwise false
  73933. */
  73934. isDynamic(): boolean;
  73935. /**
  73936. * The data cache on JS side.
  73937. * @returns the underlying data as a float array
  73938. */
  73939. getData(): Float32Array;
  73940. /**
  73941. * The underlying WebGL Uniform buffer.
  73942. * @returns the webgl buffer
  73943. */
  73944. getBuffer(): Nullable<DataBuffer>;
  73945. /**
  73946. * std140 layout specifies how to align data within an UBO structure.
  73947. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73948. * for specs.
  73949. */
  73950. private _fillAlignment;
  73951. /**
  73952. * Adds an uniform in the buffer.
  73953. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73954. * for the layout to be correct !
  73955. * @param name Name of the uniform, as used in the uniform block in the shader.
  73956. * @param size Data size, or data directly.
  73957. */
  73958. addUniform(name: string, size: number | number[]): void;
  73959. /**
  73960. * Adds a Matrix 4x4 to the uniform buffer.
  73961. * @param name Name of the uniform, as used in the uniform block in the shader.
  73962. * @param mat A 4x4 matrix.
  73963. */
  73964. addMatrix(name: string, mat: Matrix): void;
  73965. /**
  73966. * Adds a vec2 to the uniform buffer.
  73967. * @param name Name of the uniform, as used in the uniform block in the shader.
  73968. * @param x Define the x component value of the vec2
  73969. * @param y Define the y component value of the vec2
  73970. */
  73971. addFloat2(name: string, x: number, y: number): void;
  73972. /**
  73973. * Adds a vec3 to the uniform buffer.
  73974. * @param name Name of the uniform, as used in the uniform block in the shader.
  73975. * @param x Define the x component value of the vec3
  73976. * @param y Define the y component value of the vec3
  73977. * @param z Define the z component value of the vec3
  73978. */
  73979. addFloat3(name: string, x: number, y: number, z: number): void;
  73980. /**
  73981. * Adds a vec3 to the uniform buffer.
  73982. * @param name Name of the uniform, as used in the uniform block in the shader.
  73983. * @param color Define the vec3 from a Color
  73984. */
  73985. addColor3(name: string, color: Color3): void;
  73986. /**
  73987. * Adds a vec4 to the uniform buffer.
  73988. * @param name Name of the uniform, as used in the uniform block in the shader.
  73989. * @param color Define the rgb components from a Color
  73990. * @param alpha Define the a component of the vec4
  73991. */
  73992. addColor4(name: string, color: Color3, alpha: number): void;
  73993. /**
  73994. * Adds a vec3 to the uniform buffer.
  73995. * @param name Name of the uniform, as used in the uniform block in the shader.
  73996. * @param vector Define the vec3 components from a Vector
  73997. */
  73998. addVector3(name: string, vector: Vector3): void;
  73999. /**
  74000. * Adds a Matrix 3x3 to the uniform buffer.
  74001. * @param name Name of the uniform, as used in the uniform block in the shader.
  74002. */
  74003. addMatrix3x3(name: string): void;
  74004. /**
  74005. * Adds a Matrix 2x2 to the uniform buffer.
  74006. * @param name Name of the uniform, as used in the uniform block in the shader.
  74007. */
  74008. addMatrix2x2(name: string): void;
  74009. /**
  74010. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74011. */
  74012. create(): void;
  74013. /** @hidden */
  74014. _rebuild(): void;
  74015. /**
  74016. * Updates the WebGL Uniform Buffer on the GPU.
  74017. * If the `dynamic` flag is set to true, no cache comparison is done.
  74018. * Otherwise, the buffer will be updated only if the cache differs.
  74019. */
  74020. update(): void;
  74021. /**
  74022. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74023. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74024. * @param data Define the flattened data
  74025. * @param size Define the size of the data.
  74026. */
  74027. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74028. private _valueCache;
  74029. private _cacheMatrix;
  74030. private _updateMatrix3x3ForUniform;
  74031. private _updateMatrix3x3ForEffect;
  74032. private _updateMatrix2x2ForEffect;
  74033. private _updateMatrix2x2ForUniform;
  74034. private _updateFloatForEffect;
  74035. private _updateFloatForUniform;
  74036. private _updateFloat2ForEffect;
  74037. private _updateFloat2ForUniform;
  74038. private _updateFloat3ForEffect;
  74039. private _updateFloat3ForUniform;
  74040. private _updateFloat4ForEffect;
  74041. private _updateFloat4ForUniform;
  74042. private _updateMatrixForEffect;
  74043. private _updateMatrixForUniform;
  74044. private _updateVector3ForEffect;
  74045. private _updateVector3ForUniform;
  74046. private _updateVector4ForEffect;
  74047. private _updateVector4ForUniform;
  74048. private _updateColor3ForEffect;
  74049. private _updateColor3ForUniform;
  74050. private _updateColor4ForEffect;
  74051. private _updateColor4ForUniform;
  74052. /**
  74053. * Sets a sampler uniform on the effect.
  74054. * @param name Define the name of the sampler.
  74055. * @param texture Define the texture to set in the sampler
  74056. */
  74057. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74058. /**
  74059. * Directly updates the value of the uniform in the cache AND on the GPU.
  74060. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74061. * @param data Define the flattened data
  74062. */
  74063. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74064. /**
  74065. * Binds this uniform buffer to an effect.
  74066. * @param effect Define the effect to bind the buffer to
  74067. * @param name Name of the uniform block in the shader.
  74068. */
  74069. bindToEffect(effect: Effect, name: string): void;
  74070. /**
  74071. * Disposes the uniform buffer.
  74072. */
  74073. dispose(): void;
  74074. }
  74075. }
  74076. declare module BABYLON {
  74077. /**
  74078. * Enum that determines the text-wrapping mode to use.
  74079. */
  74080. export enum InspectableType {
  74081. /**
  74082. * Checkbox for booleans
  74083. */
  74084. Checkbox = 0,
  74085. /**
  74086. * Sliders for numbers
  74087. */
  74088. Slider = 1,
  74089. /**
  74090. * Vector3
  74091. */
  74092. Vector3 = 2,
  74093. /**
  74094. * Quaternions
  74095. */
  74096. Quaternion = 3,
  74097. /**
  74098. * Color3
  74099. */
  74100. Color3 = 4,
  74101. /**
  74102. * String
  74103. */
  74104. String = 5
  74105. }
  74106. /**
  74107. * Interface used to define custom inspectable properties.
  74108. * This interface is used by the inspector to display custom property grids
  74109. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74110. */
  74111. export interface IInspectable {
  74112. /**
  74113. * Gets the label to display
  74114. */
  74115. label: string;
  74116. /**
  74117. * Gets the name of the property to edit
  74118. */
  74119. propertyName: string;
  74120. /**
  74121. * Gets the type of the editor to use
  74122. */
  74123. type: InspectableType;
  74124. /**
  74125. * Gets the minimum value of the property when using in "slider" mode
  74126. */
  74127. min?: number;
  74128. /**
  74129. * Gets the maximum value of the property when using in "slider" mode
  74130. */
  74131. max?: number;
  74132. /**
  74133. * Gets the setp to use when using in "slider" mode
  74134. */
  74135. step?: number;
  74136. }
  74137. }
  74138. declare module BABYLON {
  74139. /**
  74140. * Class used to provide helper for timing
  74141. */
  74142. export class TimingTools {
  74143. /**
  74144. * Polyfill for setImmediate
  74145. * @param action defines the action to execute after the current execution block
  74146. */
  74147. static SetImmediate(action: () => void): void;
  74148. }
  74149. }
  74150. declare module BABYLON {
  74151. /**
  74152. * Class used to enable instatition of objects by class name
  74153. */
  74154. export class InstantiationTools {
  74155. /**
  74156. * Use this object to register external classes like custom textures or material
  74157. * to allow the laoders to instantiate them
  74158. */
  74159. static RegisteredExternalClasses: {
  74160. [key: string]: Object;
  74161. };
  74162. /**
  74163. * Tries to instantiate a new object from a given class name
  74164. * @param className defines the class name to instantiate
  74165. * @returns the new object or null if the system was not able to do the instantiation
  74166. */
  74167. static Instantiate(className: string): any;
  74168. }
  74169. }
  74170. declare module BABYLON {
  74171. /**
  74172. * Define options used to create a depth texture
  74173. */
  74174. export class DepthTextureCreationOptions {
  74175. /** Specifies whether or not a stencil should be allocated in the texture */
  74176. generateStencil?: boolean;
  74177. /** Specifies whether or not bilinear filtering is enable on the texture */
  74178. bilinearFiltering?: boolean;
  74179. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74180. comparisonFunction?: number;
  74181. /** Specifies if the created texture is a cube texture */
  74182. isCube?: boolean;
  74183. }
  74184. }
  74185. declare module BABYLON {
  74186. interface ThinEngine {
  74187. /**
  74188. * Creates a depth stencil cube texture.
  74189. * This is only available in WebGL 2.
  74190. * @param size The size of face edge in the cube texture.
  74191. * @param options The options defining the cube texture.
  74192. * @returns The cube texture
  74193. */
  74194. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74195. /**
  74196. * Creates a cube texture
  74197. * @param rootUrl defines the url where the files to load is located
  74198. * @param scene defines the current scene
  74199. * @param files defines the list of files to load (1 per face)
  74200. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74201. * @param onLoad defines an optional callback raised when the texture is loaded
  74202. * @param onError defines an optional callback raised if there is an issue to load the texture
  74203. * @param format defines the format of the data
  74204. * @param forcedExtension defines the extension to use to pick the right loader
  74205. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74206. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74207. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74208. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74209. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74210. * @returns the cube texture as an InternalTexture
  74211. */
  74212. 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;
  74213. /**
  74214. * Creates a cube texture
  74215. * @param rootUrl defines the url where the files to load is located
  74216. * @param scene defines the current scene
  74217. * @param files defines the list of files to load (1 per face)
  74218. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74219. * @param onLoad defines an optional callback raised when the texture is loaded
  74220. * @param onError defines an optional callback raised if there is an issue to load the texture
  74221. * @param format defines the format of the data
  74222. * @param forcedExtension defines the extension to use to pick the right loader
  74223. * @returns the cube texture as an InternalTexture
  74224. */
  74225. 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;
  74226. /**
  74227. * Creates a cube texture
  74228. * @param rootUrl defines the url where the files to load is located
  74229. * @param scene defines the current scene
  74230. * @param files defines the list of files to load (1 per face)
  74231. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74232. * @param onLoad defines an optional callback raised when the texture is loaded
  74233. * @param onError defines an optional callback raised if there is an issue to load the texture
  74234. * @param format defines the format of the data
  74235. * @param forcedExtension defines the extension to use to pick the right loader
  74236. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74237. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74238. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74239. * @returns the cube texture as an InternalTexture
  74240. */
  74241. 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;
  74242. /** @hidden */
  74243. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74244. /** @hidden */
  74245. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74246. /** @hidden */
  74247. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74248. /** @hidden */
  74249. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74250. }
  74251. }
  74252. declare module BABYLON {
  74253. /**
  74254. * Class for creating a cube texture
  74255. */
  74256. export class CubeTexture extends BaseTexture {
  74257. private _delayedOnLoad;
  74258. /**
  74259. * The url of the texture
  74260. */
  74261. url: string;
  74262. /**
  74263. * Gets or sets the center of the bounding box associated with the cube texture.
  74264. * It must define where the camera used to render the texture was set
  74265. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74266. */
  74267. boundingBoxPosition: Vector3;
  74268. private _boundingBoxSize;
  74269. /**
  74270. * Gets or sets the size of the bounding box associated with the cube texture
  74271. * When defined, the cubemap will switch to local mode
  74272. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74273. * @example https://www.babylonjs-playground.com/#RNASML
  74274. */
  74275. /**
  74276. * Returns the bounding box size
  74277. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74278. */
  74279. boundingBoxSize: Vector3;
  74280. protected _rotationY: number;
  74281. /**
  74282. * Sets texture matrix rotation angle around Y axis in radians.
  74283. */
  74284. /**
  74285. * Gets texture matrix rotation angle around Y axis radians.
  74286. */
  74287. rotationY: number;
  74288. /**
  74289. * Are mip maps generated for this texture or not.
  74290. */
  74291. readonly noMipmap: boolean;
  74292. private _noMipmap;
  74293. private _files;
  74294. protected _forcedExtension: Nullable<string>;
  74295. private _extensions;
  74296. private _textureMatrix;
  74297. private _format;
  74298. private _createPolynomials;
  74299. /** @hidden */
  74300. _prefiltered: boolean;
  74301. /**
  74302. * Creates a cube texture from an array of image urls
  74303. * @param files defines an array of image urls
  74304. * @param scene defines the hosting scene
  74305. * @param noMipmap specifies if mip maps are not used
  74306. * @returns a cube texture
  74307. */
  74308. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74309. /**
  74310. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74311. * @param url defines the url of the prefiltered texture
  74312. * @param scene defines the scene the texture is attached to
  74313. * @param forcedExtension defines the extension of the file if different from the url
  74314. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74315. * @return the prefiltered texture
  74316. */
  74317. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74318. /**
  74319. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74320. * as prefiltered data.
  74321. * @param rootUrl defines the url of the texture or the root name of the six images
  74322. * @param scene defines the scene the texture is attached to
  74323. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74324. * @param noMipmap defines if mipmaps should be created or not
  74325. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74326. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74327. * @param onError defines a callback triggered in case of error during load
  74328. * @param format defines the internal format to use for the texture once loaded
  74329. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74330. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74331. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74332. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74333. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74334. * @return the cube texture
  74335. */
  74336. 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);
  74337. /**
  74338. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74339. */
  74340. readonly isPrefiltered: boolean;
  74341. /**
  74342. * Get the current class name of the texture useful for serialization or dynamic coding.
  74343. * @returns "CubeTexture"
  74344. */
  74345. getClassName(): string;
  74346. /**
  74347. * Update the url (and optional buffer) of this texture if url was null during construction.
  74348. * @param url the url of the texture
  74349. * @param forcedExtension defines the extension to use
  74350. * @param onLoad callback called when the texture is loaded (defaults to null)
  74351. */
  74352. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74353. /**
  74354. * Delays loading of the cube texture
  74355. * @param forcedExtension defines the extension to use
  74356. */
  74357. delayLoad(forcedExtension?: string): void;
  74358. /**
  74359. * Returns the reflection texture matrix
  74360. * @returns the reflection texture matrix
  74361. */
  74362. getReflectionTextureMatrix(): Matrix;
  74363. /**
  74364. * Sets the reflection texture matrix
  74365. * @param value Reflection texture matrix
  74366. */
  74367. setReflectionTextureMatrix(value: Matrix): void;
  74368. /**
  74369. * Parses text to create a cube texture
  74370. * @param parsedTexture define the serialized text to read from
  74371. * @param scene defines the hosting scene
  74372. * @param rootUrl defines the root url of the cube texture
  74373. * @returns a cube texture
  74374. */
  74375. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74376. /**
  74377. * Makes a clone, or deep copy, of the cube texture
  74378. * @returns a new cube texture
  74379. */
  74380. clone(): CubeTexture;
  74381. }
  74382. }
  74383. declare module BABYLON {
  74384. /**
  74385. * Manages the defines for the Material
  74386. */
  74387. export class MaterialDefines {
  74388. /** @hidden */
  74389. protected _keys: string[];
  74390. private _isDirty;
  74391. /** @hidden */
  74392. _renderId: number;
  74393. /** @hidden */
  74394. _areLightsDirty: boolean;
  74395. /** @hidden */
  74396. _areLightsDisposed: boolean;
  74397. /** @hidden */
  74398. _areAttributesDirty: boolean;
  74399. /** @hidden */
  74400. _areTexturesDirty: boolean;
  74401. /** @hidden */
  74402. _areFresnelDirty: boolean;
  74403. /** @hidden */
  74404. _areMiscDirty: boolean;
  74405. /** @hidden */
  74406. _areImageProcessingDirty: boolean;
  74407. /** @hidden */
  74408. _normals: boolean;
  74409. /** @hidden */
  74410. _uvs: boolean;
  74411. /** @hidden */
  74412. _needNormals: boolean;
  74413. /** @hidden */
  74414. _needUVs: boolean;
  74415. [id: string]: any;
  74416. /**
  74417. * Specifies if the material needs to be re-calculated
  74418. */
  74419. readonly isDirty: boolean;
  74420. /**
  74421. * Marks the material to indicate that it has been re-calculated
  74422. */
  74423. markAsProcessed(): void;
  74424. /**
  74425. * Marks the material to indicate that it needs to be re-calculated
  74426. */
  74427. markAsUnprocessed(): void;
  74428. /**
  74429. * Marks the material to indicate all of its defines need to be re-calculated
  74430. */
  74431. markAllAsDirty(): void;
  74432. /**
  74433. * Marks the material to indicate that image processing needs to be re-calculated
  74434. */
  74435. markAsImageProcessingDirty(): void;
  74436. /**
  74437. * Marks the material to indicate the lights need to be re-calculated
  74438. * @param disposed Defines whether the light is dirty due to dispose or not
  74439. */
  74440. markAsLightDirty(disposed?: boolean): void;
  74441. /**
  74442. * Marks the attribute state as changed
  74443. */
  74444. markAsAttributesDirty(): void;
  74445. /**
  74446. * Marks the texture state as changed
  74447. */
  74448. markAsTexturesDirty(): void;
  74449. /**
  74450. * Marks the fresnel state as changed
  74451. */
  74452. markAsFresnelDirty(): void;
  74453. /**
  74454. * Marks the misc state as changed
  74455. */
  74456. markAsMiscDirty(): void;
  74457. /**
  74458. * Rebuilds the material defines
  74459. */
  74460. rebuild(): void;
  74461. /**
  74462. * Specifies if two material defines are equal
  74463. * @param other - A material define instance to compare to
  74464. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74465. */
  74466. isEqual(other: MaterialDefines): boolean;
  74467. /**
  74468. * Clones this instance's defines to another instance
  74469. * @param other - material defines to clone values to
  74470. */
  74471. cloneTo(other: MaterialDefines): void;
  74472. /**
  74473. * Resets the material define values
  74474. */
  74475. reset(): void;
  74476. /**
  74477. * Converts the material define values to a string
  74478. * @returns - String of material define information
  74479. */
  74480. toString(): string;
  74481. }
  74482. }
  74483. declare module BABYLON {
  74484. /**
  74485. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74486. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74487. * 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;
  74488. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74489. */
  74490. export class ColorCurves {
  74491. private _dirty;
  74492. private _tempColor;
  74493. private _globalCurve;
  74494. private _highlightsCurve;
  74495. private _midtonesCurve;
  74496. private _shadowsCurve;
  74497. private _positiveCurve;
  74498. private _negativeCurve;
  74499. private _globalHue;
  74500. private _globalDensity;
  74501. private _globalSaturation;
  74502. private _globalExposure;
  74503. /**
  74504. * Gets the global Hue value.
  74505. * 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).
  74506. */
  74507. /**
  74508. * Sets the global Hue value.
  74509. * 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).
  74510. */
  74511. globalHue: number;
  74512. /**
  74513. * Gets the global Density value.
  74514. * 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.
  74515. * Values less than zero provide a filter of opposite hue.
  74516. */
  74517. /**
  74518. * Sets the global Density value.
  74519. * 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.
  74520. * Values less than zero provide a filter of opposite hue.
  74521. */
  74522. globalDensity: number;
  74523. /**
  74524. * Gets the global Saturation value.
  74525. * 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.
  74526. */
  74527. /**
  74528. * Sets the global Saturation value.
  74529. * 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.
  74530. */
  74531. globalSaturation: number;
  74532. /**
  74533. * Gets the global Exposure value.
  74534. * 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.
  74535. */
  74536. /**
  74537. * Sets the global Exposure value.
  74538. * 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.
  74539. */
  74540. globalExposure: number;
  74541. private _highlightsHue;
  74542. private _highlightsDensity;
  74543. private _highlightsSaturation;
  74544. private _highlightsExposure;
  74545. /**
  74546. * Gets the highlights Hue value.
  74547. * 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).
  74548. */
  74549. /**
  74550. * Sets the highlights Hue value.
  74551. * 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).
  74552. */
  74553. highlightsHue: number;
  74554. /**
  74555. * Gets the highlights Density value.
  74556. * 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.
  74557. * Values less than zero provide a filter of opposite hue.
  74558. */
  74559. /**
  74560. * Sets the highlights Density value.
  74561. * 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.
  74562. * Values less than zero provide a filter of opposite hue.
  74563. */
  74564. highlightsDensity: number;
  74565. /**
  74566. * Gets the highlights Saturation value.
  74567. * 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.
  74568. */
  74569. /**
  74570. * Sets the highlights Saturation value.
  74571. * 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.
  74572. */
  74573. highlightsSaturation: number;
  74574. /**
  74575. * Gets the highlights Exposure value.
  74576. * 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.
  74577. */
  74578. /**
  74579. * Sets the highlights Exposure value.
  74580. * 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.
  74581. */
  74582. highlightsExposure: number;
  74583. private _midtonesHue;
  74584. private _midtonesDensity;
  74585. private _midtonesSaturation;
  74586. private _midtonesExposure;
  74587. /**
  74588. * Gets the midtones Hue value.
  74589. * 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).
  74590. */
  74591. /**
  74592. * Sets the midtones Hue value.
  74593. * 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).
  74594. */
  74595. midtonesHue: number;
  74596. /**
  74597. * Gets the midtones Density value.
  74598. * 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.
  74599. * Values less than zero provide a filter of opposite hue.
  74600. */
  74601. /**
  74602. * Sets the midtones 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. midtonesDensity: number;
  74607. /**
  74608. * Gets the midtones Saturation value.
  74609. * 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.
  74610. */
  74611. /**
  74612. * Sets the midtones Saturation value.
  74613. * 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.
  74614. */
  74615. midtonesSaturation: number;
  74616. /**
  74617. * Gets the midtones Exposure 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 exposure and negative values decrease exposure.
  74619. */
  74620. /**
  74621. * Sets the midtones Exposure value.
  74622. * 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.
  74623. */
  74624. midtonesExposure: number;
  74625. private _shadowsHue;
  74626. private _shadowsDensity;
  74627. private _shadowsSaturation;
  74628. private _shadowsExposure;
  74629. /**
  74630. * Gets the shadows Hue value.
  74631. * 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).
  74632. */
  74633. /**
  74634. * Sets the shadows Hue value.
  74635. * 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).
  74636. */
  74637. shadowsHue: number;
  74638. /**
  74639. * Gets the shadows Density value.
  74640. * 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.
  74641. * Values less than zero provide a filter of opposite hue.
  74642. */
  74643. /**
  74644. * Sets the shadows 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. shadowsDensity: number;
  74649. /**
  74650. * Gets the shadows Saturation value.
  74651. * 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.
  74652. */
  74653. /**
  74654. * Sets the shadows Saturation value.
  74655. * 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.
  74656. */
  74657. shadowsSaturation: number;
  74658. /**
  74659. * Gets the shadows Exposure 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 exposure and negative values decrease exposure.
  74661. */
  74662. /**
  74663. * Sets the shadows Exposure value.
  74664. * 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.
  74665. */
  74666. shadowsExposure: number;
  74667. /**
  74668. * Returns the class name
  74669. * @returns The class name
  74670. */
  74671. getClassName(): string;
  74672. /**
  74673. * Binds the color curves to the shader.
  74674. * @param colorCurves The color curve to bind
  74675. * @param effect The effect to bind to
  74676. * @param positiveUniform The positive uniform shader parameter
  74677. * @param neutralUniform The neutral uniform shader parameter
  74678. * @param negativeUniform The negative uniform shader parameter
  74679. */
  74680. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74681. /**
  74682. * Prepare the list of uniforms associated with the ColorCurves effects.
  74683. * @param uniformsList The list of uniforms used in the effect
  74684. */
  74685. static PrepareUniforms(uniformsList: string[]): void;
  74686. /**
  74687. * Returns color grading data based on a hue, density, saturation and exposure value.
  74688. * @param filterHue The hue of the color filter.
  74689. * @param filterDensity The density of the color filter.
  74690. * @param saturation The saturation.
  74691. * @param exposure The exposure.
  74692. * @param result The result data container.
  74693. */
  74694. private getColorGradingDataToRef;
  74695. /**
  74696. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74697. * @param value The input slider value in range [-100,100].
  74698. * @returns Adjusted value.
  74699. */
  74700. private static applyColorGradingSliderNonlinear;
  74701. /**
  74702. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74703. * @param hue The hue (H) input.
  74704. * @param saturation The saturation (S) input.
  74705. * @param brightness The brightness (B) input.
  74706. * @result An RGBA color represented as Vector4.
  74707. */
  74708. private static fromHSBToRef;
  74709. /**
  74710. * Returns a value clamped between min and max
  74711. * @param value The value to clamp
  74712. * @param min The minimum of value
  74713. * @param max The maximum of value
  74714. * @returns The clamped value.
  74715. */
  74716. private static clamp;
  74717. /**
  74718. * Clones the current color curve instance.
  74719. * @return The cloned curves
  74720. */
  74721. clone(): ColorCurves;
  74722. /**
  74723. * Serializes the current color curve instance to a json representation.
  74724. * @return a JSON representation
  74725. */
  74726. serialize(): any;
  74727. /**
  74728. * Parses the color curve from a json representation.
  74729. * @param source the JSON source to parse
  74730. * @return The parsed curves
  74731. */
  74732. static Parse(source: any): ColorCurves;
  74733. }
  74734. }
  74735. declare module BABYLON {
  74736. /**
  74737. * Interface to follow in your material defines to integrate easily the
  74738. * Image proccessing functions.
  74739. * @hidden
  74740. */
  74741. export interface IImageProcessingConfigurationDefines {
  74742. IMAGEPROCESSING: boolean;
  74743. VIGNETTE: boolean;
  74744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74745. VIGNETTEBLENDMODEOPAQUE: boolean;
  74746. TONEMAPPING: boolean;
  74747. TONEMAPPING_ACES: boolean;
  74748. CONTRAST: boolean;
  74749. EXPOSURE: boolean;
  74750. COLORCURVES: boolean;
  74751. COLORGRADING: boolean;
  74752. COLORGRADING3D: boolean;
  74753. SAMPLER3DGREENDEPTH: boolean;
  74754. SAMPLER3DBGRMAP: boolean;
  74755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74756. }
  74757. /**
  74758. * @hidden
  74759. */
  74760. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74761. IMAGEPROCESSING: boolean;
  74762. VIGNETTE: boolean;
  74763. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74764. VIGNETTEBLENDMODEOPAQUE: boolean;
  74765. TONEMAPPING: boolean;
  74766. TONEMAPPING_ACES: boolean;
  74767. CONTRAST: boolean;
  74768. COLORCURVES: boolean;
  74769. COLORGRADING: boolean;
  74770. COLORGRADING3D: boolean;
  74771. SAMPLER3DGREENDEPTH: boolean;
  74772. SAMPLER3DBGRMAP: boolean;
  74773. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74774. EXPOSURE: boolean;
  74775. constructor();
  74776. }
  74777. /**
  74778. * This groups together the common properties used for image processing either in direct forward pass
  74779. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74780. * or not.
  74781. */
  74782. export class ImageProcessingConfiguration {
  74783. /**
  74784. * Default tone mapping applied in BabylonJS.
  74785. */
  74786. static readonly TONEMAPPING_STANDARD: number;
  74787. /**
  74788. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74789. * to other engines rendering to increase portability.
  74790. */
  74791. static readonly TONEMAPPING_ACES: number;
  74792. /**
  74793. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74794. */
  74795. colorCurves: Nullable<ColorCurves>;
  74796. private _colorCurvesEnabled;
  74797. /**
  74798. * Gets wether the color curves effect is enabled.
  74799. */
  74800. /**
  74801. * Sets wether the color curves effect is enabled.
  74802. */
  74803. colorCurvesEnabled: boolean;
  74804. private _colorGradingTexture;
  74805. /**
  74806. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74807. */
  74808. /**
  74809. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74810. */
  74811. colorGradingTexture: Nullable<BaseTexture>;
  74812. private _colorGradingEnabled;
  74813. /**
  74814. * Gets wether the color grading effect is enabled.
  74815. */
  74816. /**
  74817. * Sets wether the color grading effect is enabled.
  74818. */
  74819. colorGradingEnabled: boolean;
  74820. private _colorGradingWithGreenDepth;
  74821. /**
  74822. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74823. */
  74824. /**
  74825. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74826. */
  74827. colorGradingWithGreenDepth: boolean;
  74828. private _colorGradingBGR;
  74829. /**
  74830. * Gets wether the color grading texture contains BGR values.
  74831. */
  74832. /**
  74833. * Sets wether the color grading texture contains BGR values.
  74834. */
  74835. colorGradingBGR: boolean;
  74836. /** @hidden */
  74837. _exposure: number;
  74838. /**
  74839. * Gets the Exposure used in the effect.
  74840. */
  74841. /**
  74842. * Sets the Exposure used in the effect.
  74843. */
  74844. exposure: number;
  74845. private _toneMappingEnabled;
  74846. /**
  74847. * Gets wether the tone mapping effect is enabled.
  74848. */
  74849. /**
  74850. * Sets wether the tone mapping effect is enabled.
  74851. */
  74852. toneMappingEnabled: boolean;
  74853. private _toneMappingType;
  74854. /**
  74855. * Gets the type of tone mapping effect.
  74856. */
  74857. /**
  74858. * Sets the type of tone mapping effect used in BabylonJS.
  74859. */
  74860. toneMappingType: number;
  74861. protected _contrast: number;
  74862. /**
  74863. * Gets the contrast used in the effect.
  74864. */
  74865. /**
  74866. * Sets the contrast used in the effect.
  74867. */
  74868. contrast: number;
  74869. /**
  74870. * Vignette stretch size.
  74871. */
  74872. vignetteStretch: number;
  74873. /**
  74874. * Vignette centre X Offset.
  74875. */
  74876. vignetteCentreX: number;
  74877. /**
  74878. * Vignette centre Y Offset.
  74879. */
  74880. vignetteCentreY: number;
  74881. /**
  74882. * Vignette weight or intensity of the vignette effect.
  74883. */
  74884. vignetteWeight: number;
  74885. /**
  74886. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74887. * if vignetteEnabled is set to true.
  74888. */
  74889. vignetteColor: Color4;
  74890. /**
  74891. * Camera field of view used by the Vignette effect.
  74892. */
  74893. vignetteCameraFov: number;
  74894. private _vignetteBlendMode;
  74895. /**
  74896. * Gets the vignette blend mode allowing different kind of effect.
  74897. */
  74898. /**
  74899. * Sets the vignette blend mode allowing different kind of effect.
  74900. */
  74901. vignetteBlendMode: number;
  74902. private _vignetteEnabled;
  74903. /**
  74904. * Gets wether the vignette effect is enabled.
  74905. */
  74906. /**
  74907. * Sets wether the vignette effect is enabled.
  74908. */
  74909. vignetteEnabled: boolean;
  74910. private _applyByPostProcess;
  74911. /**
  74912. * Gets wether the image processing is applied through a post process or not.
  74913. */
  74914. /**
  74915. * Sets wether the image processing is applied through a post process or not.
  74916. */
  74917. applyByPostProcess: boolean;
  74918. private _isEnabled;
  74919. /**
  74920. * Gets wether the image processing is enabled or not.
  74921. */
  74922. /**
  74923. * Sets wether the image processing is enabled or not.
  74924. */
  74925. isEnabled: boolean;
  74926. /**
  74927. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74928. */
  74929. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74930. /**
  74931. * Method called each time the image processing information changes requires to recompile the effect.
  74932. */
  74933. protected _updateParameters(): void;
  74934. /**
  74935. * Gets the current class name.
  74936. * @return "ImageProcessingConfiguration"
  74937. */
  74938. getClassName(): string;
  74939. /**
  74940. * Prepare the list of uniforms associated with the Image Processing effects.
  74941. * @param uniforms The list of uniforms used in the effect
  74942. * @param defines the list of defines currently in use
  74943. */
  74944. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74945. /**
  74946. * Prepare the list of samplers associated with the Image Processing effects.
  74947. * @param samplersList The list of uniforms used in the effect
  74948. * @param defines the list of defines currently in use
  74949. */
  74950. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74951. /**
  74952. * Prepare the list of defines associated to the shader.
  74953. * @param defines the list of defines to complete
  74954. * @param forPostProcess Define if we are currently in post process mode or not
  74955. */
  74956. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74957. /**
  74958. * Returns true if all the image processing information are ready.
  74959. * @returns True if ready, otherwise, false
  74960. */
  74961. isReady(): boolean;
  74962. /**
  74963. * Binds the image processing to the shader.
  74964. * @param effect The effect to bind to
  74965. * @param aspectRatio Define the current aspect ratio of the effect
  74966. */
  74967. bind(effect: Effect, aspectRatio?: number): void;
  74968. /**
  74969. * Clones the current image processing instance.
  74970. * @return The cloned image processing
  74971. */
  74972. clone(): ImageProcessingConfiguration;
  74973. /**
  74974. * Serializes the current image processing instance to a json representation.
  74975. * @return a JSON representation
  74976. */
  74977. serialize(): any;
  74978. /**
  74979. * Parses the image processing from a json representation.
  74980. * @param source the JSON source to parse
  74981. * @return The parsed image processing
  74982. */
  74983. static Parse(source: any): ImageProcessingConfiguration;
  74984. private static _VIGNETTEMODE_MULTIPLY;
  74985. private static _VIGNETTEMODE_OPAQUE;
  74986. /**
  74987. * Used to apply the vignette as a mix with the pixel color.
  74988. */
  74989. static readonly VIGNETTEMODE_MULTIPLY: number;
  74990. /**
  74991. * Used to apply the vignette as a replacement of the pixel color.
  74992. */
  74993. static readonly VIGNETTEMODE_OPAQUE: number;
  74994. }
  74995. }
  74996. declare module BABYLON {
  74997. /** @hidden */
  74998. export var postprocessVertexShader: {
  74999. name: string;
  75000. shader: string;
  75001. };
  75002. }
  75003. declare module BABYLON {
  75004. interface ThinEngine {
  75005. /**
  75006. * Creates a new render target texture
  75007. * @param size defines the size of the texture
  75008. * @param options defines the options used to create the texture
  75009. * @returns a new render target texture stored in an InternalTexture
  75010. */
  75011. createRenderTargetTexture(size: number | {
  75012. width: number;
  75013. height: number;
  75014. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75015. }
  75016. }
  75017. declare module BABYLON {
  75018. /** Defines supported spaces */
  75019. export enum Space {
  75020. /** Local (object) space */
  75021. LOCAL = 0,
  75022. /** World space */
  75023. WORLD = 1,
  75024. /** Bone space */
  75025. BONE = 2
  75026. }
  75027. /** Defines the 3 main axes */
  75028. export class Axis {
  75029. /** X axis */
  75030. static X: Vector3;
  75031. /** Y axis */
  75032. static Y: Vector3;
  75033. /** Z axis */
  75034. static Z: Vector3;
  75035. }
  75036. }
  75037. declare module BABYLON {
  75038. /**
  75039. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75040. * This is the base of the follow, arc rotate cameras and Free camera
  75041. * @see http://doc.babylonjs.com/features/cameras
  75042. */
  75043. export class TargetCamera extends Camera {
  75044. private static _RigCamTransformMatrix;
  75045. private static _TargetTransformMatrix;
  75046. private static _TargetFocalPoint;
  75047. /**
  75048. * Define the current direction the camera is moving to
  75049. */
  75050. cameraDirection: Vector3;
  75051. /**
  75052. * Define the current rotation the camera is rotating to
  75053. */
  75054. cameraRotation: Vector2;
  75055. /**
  75056. * When set, the up vector of the camera will be updated by the rotation of the camera
  75057. */
  75058. updateUpVectorFromRotation: boolean;
  75059. private _tmpQuaternion;
  75060. /**
  75061. * Define the current rotation of the camera
  75062. */
  75063. rotation: Vector3;
  75064. /**
  75065. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75066. */
  75067. rotationQuaternion: Quaternion;
  75068. /**
  75069. * Define the current speed of the camera
  75070. */
  75071. speed: number;
  75072. /**
  75073. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75074. * around all axis.
  75075. */
  75076. noRotationConstraint: boolean;
  75077. /**
  75078. * Define the current target of the camera as an object or a position.
  75079. */
  75080. lockedTarget: any;
  75081. /** @hidden */
  75082. _currentTarget: Vector3;
  75083. /** @hidden */
  75084. _initialFocalDistance: number;
  75085. /** @hidden */
  75086. _viewMatrix: Matrix;
  75087. /** @hidden */
  75088. _camMatrix: Matrix;
  75089. /** @hidden */
  75090. _cameraTransformMatrix: Matrix;
  75091. /** @hidden */
  75092. _cameraRotationMatrix: Matrix;
  75093. /** @hidden */
  75094. _referencePoint: Vector3;
  75095. /** @hidden */
  75096. _transformedReferencePoint: Vector3;
  75097. protected _globalCurrentTarget: Vector3;
  75098. protected _globalCurrentUpVector: Vector3;
  75099. /** @hidden */
  75100. _reset: () => void;
  75101. private _defaultUp;
  75102. /**
  75103. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75104. * This is the base of the follow, arc rotate cameras and Free camera
  75105. * @see http://doc.babylonjs.com/features/cameras
  75106. * @param name Defines the name of the camera in the scene
  75107. * @param position Defines the start position of the camera in the scene
  75108. * @param scene Defines the scene the camera belongs to
  75109. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75110. */
  75111. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75112. /**
  75113. * Gets the position in front of the camera at a given distance.
  75114. * @param distance The distance from the camera we want the position to be
  75115. * @returns the position
  75116. */
  75117. getFrontPosition(distance: number): Vector3;
  75118. /** @hidden */
  75119. _getLockedTargetPosition(): Nullable<Vector3>;
  75120. private _storedPosition;
  75121. private _storedRotation;
  75122. private _storedRotationQuaternion;
  75123. /**
  75124. * Store current camera state of the camera (fov, position, rotation, etc..)
  75125. * @returns the camera
  75126. */
  75127. storeState(): Camera;
  75128. /**
  75129. * Restored camera state. You must call storeState() first
  75130. * @returns whether it was successful or not
  75131. * @hidden
  75132. */
  75133. _restoreStateValues(): boolean;
  75134. /** @hidden */
  75135. _initCache(): void;
  75136. /** @hidden */
  75137. _updateCache(ignoreParentClass?: boolean): void;
  75138. /** @hidden */
  75139. _isSynchronizedViewMatrix(): boolean;
  75140. /** @hidden */
  75141. _computeLocalCameraSpeed(): number;
  75142. /**
  75143. * Defines the target the camera should look at.
  75144. * @param target Defines the new target as a Vector or a mesh
  75145. */
  75146. setTarget(target: Vector3): void;
  75147. /**
  75148. * Return the current target position of the camera. This value is expressed in local space.
  75149. * @returns the target position
  75150. */
  75151. getTarget(): Vector3;
  75152. /** @hidden */
  75153. _decideIfNeedsToMove(): boolean;
  75154. /** @hidden */
  75155. _updatePosition(): void;
  75156. /** @hidden */
  75157. _checkInputs(): void;
  75158. protected _updateCameraRotationMatrix(): void;
  75159. /**
  75160. * 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)
  75161. * @returns the current camera
  75162. */
  75163. private _rotateUpVectorWithCameraRotationMatrix;
  75164. private _cachedRotationZ;
  75165. private _cachedQuaternionRotationZ;
  75166. /** @hidden */
  75167. _getViewMatrix(): Matrix;
  75168. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75169. /**
  75170. * @hidden
  75171. */
  75172. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75173. /**
  75174. * @hidden
  75175. */
  75176. _updateRigCameras(): void;
  75177. private _getRigCamPositionAndTarget;
  75178. /**
  75179. * Gets the current object class name.
  75180. * @return the class name
  75181. */
  75182. getClassName(): string;
  75183. }
  75184. }
  75185. declare module BABYLON {
  75186. /**
  75187. * Gather the list of keyboard event types as constants.
  75188. */
  75189. export class KeyboardEventTypes {
  75190. /**
  75191. * The keydown event is fired when a key becomes active (pressed).
  75192. */
  75193. static readonly KEYDOWN: number;
  75194. /**
  75195. * The keyup event is fired when a key has been released.
  75196. */
  75197. static readonly KEYUP: number;
  75198. }
  75199. /**
  75200. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75201. */
  75202. export class KeyboardInfo {
  75203. /**
  75204. * Defines the type of event (KeyboardEventTypes)
  75205. */
  75206. type: number;
  75207. /**
  75208. * Defines the related dom event
  75209. */
  75210. event: KeyboardEvent;
  75211. /**
  75212. * Instantiates a new keyboard info.
  75213. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75214. * @param type Defines the type of event (KeyboardEventTypes)
  75215. * @param event Defines the related dom event
  75216. */
  75217. constructor(
  75218. /**
  75219. * Defines the type of event (KeyboardEventTypes)
  75220. */
  75221. type: number,
  75222. /**
  75223. * Defines the related dom event
  75224. */
  75225. event: KeyboardEvent);
  75226. }
  75227. /**
  75228. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75229. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75230. */
  75231. export class KeyboardInfoPre extends KeyboardInfo {
  75232. /**
  75233. * Defines the type of event (KeyboardEventTypes)
  75234. */
  75235. type: number;
  75236. /**
  75237. * Defines the related dom event
  75238. */
  75239. event: KeyboardEvent;
  75240. /**
  75241. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75242. */
  75243. skipOnPointerObservable: boolean;
  75244. /**
  75245. * Instantiates a new keyboard pre info.
  75246. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75247. * @param type Defines the type of event (KeyboardEventTypes)
  75248. * @param event Defines the related dom event
  75249. */
  75250. constructor(
  75251. /**
  75252. * Defines the type of event (KeyboardEventTypes)
  75253. */
  75254. type: number,
  75255. /**
  75256. * Defines the related dom event
  75257. */
  75258. event: KeyboardEvent);
  75259. }
  75260. }
  75261. declare module BABYLON {
  75262. /**
  75263. * Manage the keyboard inputs to control the movement of a free camera.
  75264. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75265. */
  75266. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75267. /**
  75268. * Defines the camera the input is attached to.
  75269. */
  75270. camera: FreeCamera;
  75271. /**
  75272. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75273. */
  75274. keysUp: number[];
  75275. /**
  75276. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75277. */
  75278. keysDown: number[];
  75279. /**
  75280. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75281. */
  75282. keysLeft: number[];
  75283. /**
  75284. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75285. */
  75286. keysRight: number[];
  75287. private _keys;
  75288. private _onCanvasBlurObserver;
  75289. private _onKeyboardObserver;
  75290. private _engine;
  75291. private _scene;
  75292. /**
  75293. * Attach the input controls to a specific dom element to get the input from.
  75294. * @param element Defines the element the controls should be listened from
  75295. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75296. */
  75297. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75298. /**
  75299. * Detach the current controls from the specified dom element.
  75300. * @param element Defines the element to stop listening the inputs from
  75301. */
  75302. detachControl(element: Nullable<HTMLElement>): void;
  75303. /**
  75304. * Update the current camera state depending on the inputs that have been used this frame.
  75305. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75306. */
  75307. checkInputs(): void;
  75308. /**
  75309. * Gets the class name of the current intput.
  75310. * @returns the class name
  75311. */
  75312. getClassName(): string;
  75313. /** @hidden */
  75314. _onLostFocus(): void;
  75315. /**
  75316. * Get the friendly name associated with the input class.
  75317. * @returns the input friendly name
  75318. */
  75319. getSimpleName(): string;
  75320. }
  75321. }
  75322. declare module BABYLON {
  75323. /**
  75324. * Interface describing all the common properties and methods a shadow light needs to implement.
  75325. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75326. * as well as binding the different shadow properties to the effects.
  75327. */
  75328. export interface IShadowLight extends Light {
  75329. /**
  75330. * The light id in the scene (used in scene.findLighById for instance)
  75331. */
  75332. id: string;
  75333. /**
  75334. * The position the shdow will be casted from.
  75335. */
  75336. position: Vector3;
  75337. /**
  75338. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75339. */
  75340. direction: Vector3;
  75341. /**
  75342. * The transformed position. Position of the light in world space taking parenting in account.
  75343. */
  75344. transformedPosition: Vector3;
  75345. /**
  75346. * The transformed direction. Direction of the light in world space taking parenting in account.
  75347. */
  75348. transformedDirection: Vector3;
  75349. /**
  75350. * The friendly name of the light in the scene.
  75351. */
  75352. name: string;
  75353. /**
  75354. * Defines the shadow projection clipping minimum z value.
  75355. */
  75356. shadowMinZ: number;
  75357. /**
  75358. * Defines the shadow projection clipping maximum z value.
  75359. */
  75360. shadowMaxZ: number;
  75361. /**
  75362. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75363. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75364. */
  75365. computeTransformedInformation(): boolean;
  75366. /**
  75367. * Gets the scene the light belongs to.
  75368. * @returns The scene
  75369. */
  75370. getScene(): Scene;
  75371. /**
  75372. * Callback defining a custom Projection Matrix Builder.
  75373. * This can be used to override the default projection matrix computation.
  75374. */
  75375. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75376. /**
  75377. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75378. * @param matrix The materix to updated with the projection information
  75379. * @param viewMatrix The transform matrix of the light
  75380. * @param renderList The list of mesh to render in the map
  75381. * @returns The current light
  75382. */
  75383. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75384. /**
  75385. * Gets the current depth scale used in ESM.
  75386. * @returns The scale
  75387. */
  75388. getDepthScale(): number;
  75389. /**
  75390. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75391. * @returns true if a cube texture needs to be use
  75392. */
  75393. needCube(): boolean;
  75394. /**
  75395. * Detects if the projection matrix requires to be recomputed this frame.
  75396. * @returns true if it requires to be recomputed otherwise, false.
  75397. */
  75398. needProjectionMatrixCompute(): boolean;
  75399. /**
  75400. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75401. */
  75402. forceProjectionMatrixCompute(): void;
  75403. /**
  75404. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75405. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75406. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75407. */
  75408. getShadowDirection(faceIndex?: number): Vector3;
  75409. /**
  75410. * Gets the minZ used for shadow according to both the scene and the light.
  75411. * @param activeCamera The camera we are returning the min for
  75412. * @returns the depth min z
  75413. */
  75414. getDepthMinZ(activeCamera: Camera): number;
  75415. /**
  75416. * Gets the maxZ used for shadow according to both the scene and the light.
  75417. * @param activeCamera The camera we are returning the max for
  75418. * @returns the depth max z
  75419. */
  75420. getDepthMaxZ(activeCamera: Camera): number;
  75421. }
  75422. /**
  75423. * Base implementation IShadowLight
  75424. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75425. */
  75426. export abstract class ShadowLight extends Light implements IShadowLight {
  75427. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75428. protected _position: Vector3;
  75429. protected _setPosition(value: Vector3): void;
  75430. /**
  75431. * Sets the position the shadow will be casted from. Also use as the light position for both
  75432. * point and spot lights.
  75433. */
  75434. /**
  75435. * Sets the position the shadow will be casted from. Also use as the light position for both
  75436. * point and spot lights.
  75437. */
  75438. position: Vector3;
  75439. protected _direction: Vector3;
  75440. protected _setDirection(value: Vector3): void;
  75441. /**
  75442. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75443. * Also use as the light direction on spot and directional lights.
  75444. */
  75445. /**
  75446. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75447. * Also use as the light direction on spot and directional lights.
  75448. */
  75449. direction: Vector3;
  75450. private _shadowMinZ;
  75451. /**
  75452. * Gets the shadow projection clipping minimum z value.
  75453. */
  75454. /**
  75455. * Sets the shadow projection clipping minimum z value.
  75456. */
  75457. shadowMinZ: number;
  75458. private _shadowMaxZ;
  75459. /**
  75460. * Sets the shadow projection clipping maximum z value.
  75461. */
  75462. /**
  75463. * Gets the shadow projection clipping maximum z value.
  75464. */
  75465. shadowMaxZ: number;
  75466. /**
  75467. * Callback defining a custom Projection Matrix Builder.
  75468. * This can be used to override the default projection matrix computation.
  75469. */
  75470. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75471. /**
  75472. * The transformed position. Position of the light in world space taking parenting in account.
  75473. */
  75474. transformedPosition: Vector3;
  75475. /**
  75476. * The transformed direction. Direction of the light in world space taking parenting in account.
  75477. */
  75478. transformedDirection: Vector3;
  75479. private _needProjectionMatrixCompute;
  75480. /**
  75481. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75482. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75483. */
  75484. computeTransformedInformation(): boolean;
  75485. /**
  75486. * Return the depth scale used for the shadow map.
  75487. * @returns the depth scale.
  75488. */
  75489. getDepthScale(): number;
  75490. /**
  75491. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75492. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75493. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75494. */
  75495. getShadowDirection(faceIndex?: number): Vector3;
  75496. /**
  75497. * Returns the ShadowLight absolute position in the World.
  75498. * @returns the position vector in world space
  75499. */
  75500. getAbsolutePosition(): Vector3;
  75501. /**
  75502. * Sets the ShadowLight direction toward the passed target.
  75503. * @param target The point to target in local space
  75504. * @returns the updated ShadowLight direction
  75505. */
  75506. setDirectionToTarget(target: Vector3): Vector3;
  75507. /**
  75508. * Returns the light rotation in euler definition.
  75509. * @returns the x y z rotation in local space.
  75510. */
  75511. getRotation(): Vector3;
  75512. /**
  75513. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75514. * @returns true if a cube texture needs to be use
  75515. */
  75516. needCube(): boolean;
  75517. /**
  75518. * Detects if the projection matrix requires to be recomputed this frame.
  75519. * @returns true if it requires to be recomputed otherwise, false.
  75520. */
  75521. needProjectionMatrixCompute(): boolean;
  75522. /**
  75523. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75524. */
  75525. forceProjectionMatrixCompute(): void;
  75526. /** @hidden */
  75527. _initCache(): void;
  75528. /** @hidden */
  75529. _isSynchronized(): boolean;
  75530. /**
  75531. * Computes the world matrix of the node
  75532. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75533. * @returns the world matrix
  75534. */
  75535. computeWorldMatrix(force?: boolean): Matrix;
  75536. /**
  75537. * Gets the minZ used for shadow according to both the scene and the light.
  75538. * @param activeCamera The camera we are returning the min for
  75539. * @returns the depth min z
  75540. */
  75541. getDepthMinZ(activeCamera: Camera): number;
  75542. /**
  75543. * Gets the maxZ used for shadow according to both the scene and the light.
  75544. * @param activeCamera The camera we are returning the max for
  75545. * @returns the depth max z
  75546. */
  75547. getDepthMaxZ(activeCamera: Camera): number;
  75548. /**
  75549. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75550. * @param matrix The materix to updated with the projection information
  75551. * @param viewMatrix The transform matrix of the light
  75552. * @param renderList The list of mesh to render in the map
  75553. * @returns The current light
  75554. */
  75555. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75556. }
  75557. }
  75558. declare module BABYLON {
  75559. /**
  75560. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75561. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75562. */
  75563. export class EffectFallbacks implements IEffectFallbacks {
  75564. private _defines;
  75565. private _currentRank;
  75566. private _maxRank;
  75567. private _mesh;
  75568. /**
  75569. * Removes the fallback from the bound mesh.
  75570. */
  75571. unBindMesh(): void;
  75572. /**
  75573. * Adds a fallback on the specified property.
  75574. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75575. * @param define The name of the define in the shader
  75576. */
  75577. addFallback(rank: number, define: string): void;
  75578. /**
  75579. * Sets the mesh to use CPU skinning when needing to fallback.
  75580. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75581. * @param mesh The mesh to use the fallbacks.
  75582. */
  75583. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75584. /**
  75585. * Checks to see if more fallbacks are still availible.
  75586. */
  75587. readonly hasMoreFallbacks: boolean;
  75588. /**
  75589. * Removes the defines that should be removed when falling back.
  75590. * @param currentDefines defines the current define statements for the shader.
  75591. * @param effect defines the current effect we try to compile
  75592. * @returns The resulting defines with defines of the current rank removed.
  75593. */
  75594. reduce(currentDefines: string, effect: Effect): string;
  75595. }
  75596. }
  75597. declare module BABYLON {
  75598. /**
  75599. * "Static Class" containing the most commonly used helper while dealing with material for
  75600. * rendering purpose.
  75601. *
  75602. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75603. *
  75604. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75605. */
  75606. export class MaterialHelper {
  75607. /**
  75608. * Bind the current view position to an effect.
  75609. * @param effect The effect to be bound
  75610. * @param scene The scene the eyes position is used from
  75611. */
  75612. static BindEyePosition(effect: Effect, scene: Scene): void;
  75613. /**
  75614. * Helps preparing the defines values about the UVs in used in the effect.
  75615. * UVs are shared as much as we can accross channels in the shaders.
  75616. * @param texture The texture we are preparing the UVs for
  75617. * @param defines The defines to update
  75618. * @param key The channel key "diffuse", "specular"... used in the shader
  75619. */
  75620. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75621. /**
  75622. * Binds a texture matrix value to its corrsponding uniform
  75623. * @param texture The texture to bind the matrix for
  75624. * @param uniformBuffer The uniform buffer receivin the data
  75625. * @param key The channel key "diffuse", "specular"... used in the shader
  75626. */
  75627. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75628. /**
  75629. * Gets the current status of the fog (should it be enabled?)
  75630. * @param mesh defines the mesh to evaluate for fog support
  75631. * @param scene defines the hosting scene
  75632. * @returns true if fog must be enabled
  75633. */
  75634. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75635. /**
  75636. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75637. * @param mesh defines the current mesh
  75638. * @param scene defines the current scene
  75639. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75640. * @param pointsCloud defines if point cloud rendering has to be turned on
  75641. * @param fogEnabled defines if fog has to be turned on
  75642. * @param alphaTest defines if alpha testing has to be turned on
  75643. * @param defines defines the current list of defines
  75644. */
  75645. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75646. /**
  75647. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75648. * @param scene defines the current scene
  75649. * @param engine defines the current engine
  75650. * @param defines specifies the list of active defines
  75651. * @param useInstances defines if instances have to be turned on
  75652. * @param useClipPlane defines if clip plane have to be turned on
  75653. */
  75654. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75655. /**
  75656. * Prepares the defines for bones
  75657. * @param mesh The mesh containing the geometry data we will draw
  75658. * @param defines The defines to update
  75659. */
  75660. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75661. /**
  75662. * Prepares the defines for morph targets
  75663. * @param mesh The mesh containing the geometry data we will draw
  75664. * @param defines The defines to update
  75665. */
  75666. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75667. /**
  75668. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75669. * @param mesh The mesh containing the geometry data we will draw
  75670. * @param defines The defines to update
  75671. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75672. * @param useBones Precise whether bones should be used or not (override mesh info)
  75673. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75674. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75675. * @returns false if defines are considered not dirty and have not been checked
  75676. */
  75677. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75678. /**
  75679. * Prepares the defines related to multiview
  75680. * @param scene The scene we are intending to draw
  75681. * @param defines The defines to update
  75682. */
  75683. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75684. /**
  75685. * Prepares the defines related to the light information passed in parameter
  75686. * @param scene The scene we are intending to draw
  75687. * @param mesh The mesh the effect is compiling for
  75688. * @param light The light the effect is compiling for
  75689. * @param lightIndex The index of the light
  75690. * @param defines The defines to update
  75691. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75692. * @param state Defines the current state regarding what is needed (normals, etc...)
  75693. */
  75694. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75695. needNormals: boolean;
  75696. needRebuild: boolean;
  75697. shadowEnabled: boolean;
  75698. specularEnabled: boolean;
  75699. lightmapMode: boolean;
  75700. }): void;
  75701. /**
  75702. * Prepares the defines related to the light information passed in parameter
  75703. * @param scene The scene we are intending to draw
  75704. * @param mesh The mesh the effect is compiling for
  75705. * @param defines The defines to update
  75706. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75707. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75708. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75709. * @returns true if normals will be required for the rest of the effect
  75710. */
  75711. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75712. /**
  75713. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75714. * @param lightIndex defines the light index
  75715. * @param uniformsList The uniform list
  75716. * @param samplersList The sampler list
  75717. * @param projectedLightTexture defines if projected texture must be used
  75718. * @param uniformBuffersList defines an optional list of uniform buffers
  75719. */
  75720. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75721. /**
  75722. * Prepares the uniforms and samplers list to be used in the effect
  75723. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75724. * @param samplersList The sampler list
  75725. * @param defines The defines helping in the list generation
  75726. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75727. */
  75728. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75729. /**
  75730. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75731. * @param defines The defines to update while falling back
  75732. * @param fallbacks The authorized effect fallbacks
  75733. * @param maxSimultaneousLights The maximum number of lights allowed
  75734. * @param rank the current rank of the Effect
  75735. * @returns The newly affected rank
  75736. */
  75737. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75738. private static _TmpMorphInfluencers;
  75739. /**
  75740. * Prepares the list of attributes required for morph targets according to the effect defines.
  75741. * @param attribs The current list of supported attribs
  75742. * @param mesh The mesh to prepare the morph targets attributes for
  75743. * @param influencers The number of influencers
  75744. */
  75745. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75746. /**
  75747. * Prepares the list of attributes required for morph targets according to the effect defines.
  75748. * @param attribs The current list of supported attribs
  75749. * @param mesh The mesh to prepare the morph targets attributes for
  75750. * @param defines The current Defines of the effect
  75751. */
  75752. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75753. /**
  75754. * Prepares the list of attributes required for bones according to the effect defines.
  75755. * @param attribs The current list of supported attribs
  75756. * @param mesh The mesh to prepare the bones attributes for
  75757. * @param defines The current Defines of the effect
  75758. * @param fallbacks The current efffect fallback strategy
  75759. */
  75760. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75761. /**
  75762. * Check and prepare the list of attributes required for instances according to the effect defines.
  75763. * @param attribs The current list of supported attribs
  75764. * @param defines The current MaterialDefines of the effect
  75765. */
  75766. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75767. /**
  75768. * Add the list of attributes required for instances to the attribs array.
  75769. * @param attribs The current list of supported attribs
  75770. */
  75771. static PushAttributesForInstances(attribs: string[]): void;
  75772. /**
  75773. * Binds the light shadow information to the effect for the given mesh.
  75774. * @param light The light containing the generator
  75775. * @param scene The scene the lights belongs to
  75776. * @param mesh The mesh we are binding the information to render
  75777. * @param lightIndex The light index in the effect used to render the mesh
  75778. * @param effect The effect we are binding the data to
  75779. */
  75780. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75781. /**
  75782. * Binds the light information to the effect.
  75783. * @param light The light containing the generator
  75784. * @param effect The effect we are binding the data to
  75785. * @param lightIndex The light index in the effect used to render
  75786. */
  75787. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75788. /**
  75789. * Binds the lights information from the scene to the effect for the given mesh.
  75790. * @param light Light to bind
  75791. * @param lightIndex Light index
  75792. * @param scene The scene where the light belongs to
  75793. * @param mesh The mesh we are binding the information to render
  75794. * @param effect The effect we are binding the data to
  75795. * @param useSpecular Defines if specular is supported
  75796. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75797. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75798. */
  75799. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75800. /**
  75801. * Binds the lights information from the scene to the effect for the given mesh.
  75802. * @param scene The scene the lights belongs to
  75803. * @param mesh The mesh we are binding the information to render
  75804. * @param effect The effect we are binding the data to
  75805. * @param defines The generated defines for the effect
  75806. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75807. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75808. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75809. */
  75810. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75811. private static _tempFogColor;
  75812. /**
  75813. * Binds the fog information from the scene to the effect for the given mesh.
  75814. * @param scene The scene the lights belongs to
  75815. * @param mesh The mesh we are binding the information to render
  75816. * @param effect The effect we are binding the data to
  75817. * @param linearSpace Defines if the fog effect is applied in linear space
  75818. */
  75819. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75820. /**
  75821. * Binds the bones information from the mesh to the effect.
  75822. * @param mesh The mesh we are binding the information to render
  75823. * @param effect The effect we are binding the data to
  75824. */
  75825. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75826. /**
  75827. * Binds the morph targets information from the mesh to the effect.
  75828. * @param abstractMesh The mesh we are binding the information to render
  75829. * @param effect The effect we are binding the data to
  75830. */
  75831. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75832. /**
  75833. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75834. * @param defines The generated defines used in the effect
  75835. * @param effect The effect we are binding the data to
  75836. * @param scene The scene we are willing to render with logarithmic scale for
  75837. */
  75838. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75839. /**
  75840. * Binds the clip plane information from the scene to the effect.
  75841. * @param scene The scene the clip plane information are extracted from
  75842. * @param effect The effect we are binding the data to
  75843. */
  75844. static BindClipPlane(effect: Effect, scene: Scene): void;
  75845. }
  75846. }
  75847. declare module BABYLON {
  75848. /** @hidden */
  75849. export var packingFunctions: {
  75850. name: string;
  75851. shader: string;
  75852. };
  75853. }
  75854. declare module BABYLON {
  75855. /** @hidden */
  75856. export var shadowMapPixelShader: {
  75857. name: string;
  75858. shader: string;
  75859. };
  75860. }
  75861. declare module BABYLON {
  75862. /** @hidden */
  75863. export var bonesDeclaration: {
  75864. name: string;
  75865. shader: string;
  75866. };
  75867. }
  75868. declare module BABYLON {
  75869. /** @hidden */
  75870. export var morphTargetsVertexGlobalDeclaration: {
  75871. name: string;
  75872. shader: string;
  75873. };
  75874. }
  75875. declare module BABYLON {
  75876. /** @hidden */
  75877. export var morphTargetsVertexDeclaration: {
  75878. name: string;
  75879. shader: string;
  75880. };
  75881. }
  75882. declare module BABYLON {
  75883. /** @hidden */
  75884. export var instancesDeclaration: {
  75885. name: string;
  75886. shader: string;
  75887. };
  75888. }
  75889. declare module BABYLON {
  75890. /** @hidden */
  75891. export var helperFunctions: {
  75892. name: string;
  75893. shader: string;
  75894. };
  75895. }
  75896. declare module BABYLON {
  75897. /** @hidden */
  75898. export var morphTargetsVertex: {
  75899. name: string;
  75900. shader: string;
  75901. };
  75902. }
  75903. declare module BABYLON {
  75904. /** @hidden */
  75905. export var instancesVertex: {
  75906. name: string;
  75907. shader: string;
  75908. };
  75909. }
  75910. declare module BABYLON {
  75911. /** @hidden */
  75912. export var bonesVertex: {
  75913. name: string;
  75914. shader: string;
  75915. };
  75916. }
  75917. declare module BABYLON {
  75918. /** @hidden */
  75919. export var shadowMapVertexShader: {
  75920. name: string;
  75921. shader: string;
  75922. };
  75923. }
  75924. declare module BABYLON {
  75925. /** @hidden */
  75926. export var depthBoxBlurPixelShader: {
  75927. name: string;
  75928. shader: string;
  75929. };
  75930. }
  75931. declare module BABYLON {
  75932. /**
  75933. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75934. */
  75935. export interface ICustomShaderOptions {
  75936. /**
  75937. * Gets or sets the custom shader name to use
  75938. */
  75939. shaderName: string;
  75940. /**
  75941. * The list of attribute names used in the shader
  75942. */
  75943. attributes?: string[];
  75944. /**
  75945. * The list of unifrom names used in the shader
  75946. */
  75947. uniforms?: string[];
  75948. /**
  75949. * The list of sampler names used in the shader
  75950. */
  75951. samplers?: string[];
  75952. /**
  75953. * The list of defines used in the shader
  75954. */
  75955. defines?: string[];
  75956. }
  75957. /**
  75958. * Interface to implement to create a shadow generator compatible with BJS.
  75959. */
  75960. export interface IShadowGenerator {
  75961. /**
  75962. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75963. * @returns The render target texture if present otherwise, null
  75964. */
  75965. getShadowMap(): Nullable<RenderTargetTexture>;
  75966. /**
  75967. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75968. * @returns The render target texture if the shadow map is present otherwise, null
  75969. */
  75970. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75971. /**
  75972. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75973. * @param subMesh The submesh we want to render in the shadow map
  75974. * @param useInstances Defines wether will draw in the map using instances
  75975. * @returns true if ready otherwise, false
  75976. */
  75977. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75978. /**
  75979. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  75980. * @param defines Defines of the material we want to update
  75981. * @param lightIndex Index of the light in the enabled light list of the material
  75982. */
  75983. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  75984. /**
  75985. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  75986. * defined in the generator but impacting the effect).
  75987. * It implies the unifroms available on the materials are the standard BJS ones.
  75988. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  75989. * @param effect The effect we are binfing the information for
  75990. */
  75991. bindShadowLight(lightIndex: string, effect: Effect): void;
  75992. /**
  75993. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  75994. * (eq to shadow prjection matrix * light transform matrix)
  75995. * @returns The transform matrix used to create the shadow map
  75996. */
  75997. getTransformMatrix(): Matrix;
  75998. /**
  75999. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76000. * Cube and 2D textures for instance.
  76001. */
  76002. recreateShadowMap(): void;
  76003. /**
  76004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76005. * @param onCompiled Callback triggered at the and of the effects compilation
  76006. * @param options Sets of optional options forcing the compilation with different modes
  76007. */
  76008. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76009. useInstances: boolean;
  76010. }>): void;
  76011. /**
  76012. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76013. * @param options Sets of optional options forcing the compilation with different modes
  76014. * @returns A promise that resolves when the compilation completes
  76015. */
  76016. forceCompilationAsync(options?: Partial<{
  76017. useInstances: boolean;
  76018. }>): Promise<void>;
  76019. /**
  76020. * Serializes the shadow generator setup to a json object.
  76021. * @returns The serialized JSON object
  76022. */
  76023. serialize(): any;
  76024. /**
  76025. * Disposes the Shadow map and related Textures and effects.
  76026. */
  76027. dispose(): void;
  76028. }
  76029. /**
  76030. * Default implementation IShadowGenerator.
  76031. * This is the main object responsible of generating shadows in the framework.
  76032. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76033. */
  76034. export class ShadowGenerator implements IShadowGenerator {
  76035. /**
  76036. * Shadow generator mode None: no filtering applied.
  76037. */
  76038. static readonly FILTER_NONE: number;
  76039. /**
  76040. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76041. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76042. */
  76043. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76044. /**
  76045. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76046. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76047. */
  76048. static readonly FILTER_POISSONSAMPLING: number;
  76049. /**
  76050. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76051. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76052. */
  76053. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76054. /**
  76055. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76056. * edge artifacts on steep falloff.
  76057. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76058. */
  76059. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76060. /**
  76061. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76062. * edge artifacts on steep falloff.
  76063. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76064. */
  76065. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76066. /**
  76067. * Shadow generator mode PCF: Percentage Closer Filtering
  76068. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76069. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76070. */
  76071. static readonly FILTER_PCF: number;
  76072. /**
  76073. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76074. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76075. * Contact Hardening
  76076. */
  76077. static readonly FILTER_PCSS: number;
  76078. /**
  76079. * Reserved for PCF and PCSS
  76080. * Highest Quality.
  76081. *
  76082. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76083. *
  76084. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76085. */
  76086. static readonly QUALITY_HIGH: number;
  76087. /**
  76088. * Reserved for PCF and PCSS
  76089. * Good tradeoff for quality/perf cross devices
  76090. *
  76091. * Execute PCF on a 3*3 kernel.
  76092. *
  76093. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76094. */
  76095. static readonly QUALITY_MEDIUM: number;
  76096. /**
  76097. * Reserved for PCF and PCSS
  76098. * The lowest quality but the fastest.
  76099. *
  76100. * Execute PCF on a 1*1 kernel.
  76101. *
  76102. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76103. */
  76104. static readonly QUALITY_LOW: number;
  76105. /** Gets or sets the custom shader name to use */
  76106. customShaderOptions: ICustomShaderOptions;
  76107. /**
  76108. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76109. */
  76110. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76111. /**
  76112. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76113. */
  76114. onAfterShadowMapRenderObservable: Observable<Effect>;
  76115. /**
  76116. * Observable triggered before a mesh is rendered in the shadow map.
  76117. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76118. */
  76119. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76120. /**
  76121. * Observable triggered after a mesh is rendered in the shadow map.
  76122. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76123. */
  76124. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76125. private _bias;
  76126. /**
  76127. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76128. */
  76129. /**
  76130. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76131. */
  76132. bias: number;
  76133. private _normalBias;
  76134. /**
  76135. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76136. */
  76137. /**
  76138. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76139. */
  76140. normalBias: number;
  76141. private _blurBoxOffset;
  76142. /**
  76143. * Gets the blur box offset: offset applied during the blur pass.
  76144. * Only useful if useKernelBlur = false
  76145. */
  76146. /**
  76147. * Sets the blur box offset: offset applied during the blur pass.
  76148. * Only useful if useKernelBlur = false
  76149. */
  76150. blurBoxOffset: number;
  76151. private _blurScale;
  76152. /**
  76153. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76154. * 2 means half of the size.
  76155. */
  76156. /**
  76157. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76158. * 2 means half of the size.
  76159. */
  76160. blurScale: number;
  76161. private _blurKernel;
  76162. /**
  76163. * Gets the blur kernel: kernel size of the blur pass.
  76164. * Only useful if useKernelBlur = true
  76165. */
  76166. /**
  76167. * Sets the blur kernel: kernel size of the blur pass.
  76168. * Only useful if useKernelBlur = true
  76169. */
  76170. blurKernel: number;
  76171. private _useKernelBlur;
  76172. /**
  76173. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76174. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76175. */
  76176. /**
  76177. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76178. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76179. */
  76180. useKernelBlur: boolean;
  76181. private _depthScale;
  76182. /**
  76183. * Gets the depth scale used in ESM mode.
  76184. */
  76185. /**
  76186. * Sets the depth scale used in ESM mode.
  76187. * This can override the scale stored on the light.
  76188. */
  76189. depthScale: number;
  76190. private _filter;
  76191. /**
  76192. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76193. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76194. */
  76195. /**
  76196. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76197. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76198. */
  76199. filter: number;
  76200. /**
  76201. * Gets if the current filter is set to Poisson Sampling.
  76202. */
  76203. /**
  76204. * Sets the current filter to Poisson Sampling.
  76205. */
  76206. usePoissonSampling: boolean;
  76207. /**
  76208. * Gets if the current filter is set to ESM.
  76209. */
  76210. /**
  76211. * Sets the current filter is to ESM.
  76212. */
  76213. useExponentialShadowMap: boolean;
  76214. /**
  76215. * Gets if the current filter is set to filtered ESM.
  76216. */
  76217. /**
  76218. * Gets if the current filter is set to filtered ESM.
  76219. */
  76220. useBlurExponentialShadowMap: boolean;
  76221. /**
  76222. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76223. * exponential to prevent steep falloff artifacts).
  76224. */
  76225. /**
  76226. * Sets the current filter to "close ESM" (using the inverse of the
  76227. * exponential to prevent steep falloff artifacts).
  76228. */
  76229. useCloseExponentialShadowMap: boolean;
  76230. /**
  76231. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76232. * exponential to prevent steep falloff artifacts).
  76233. */
  76234. /**
  76235. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76236. * exponential to prevent steep falloff artifacts).
  76237. */
  76238. useBlurCloseExponentialShadowMap: boolean;
  76239. /**
  76240. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76241. */
  76242. /**
  76243. * Sets the current filter to "PCF" (percentage closer filtering).
  76244. */
  76245. usePercentageCloserFiltering: boolean;
  76246. private _filteringQuality;
  76247. /**
  76248. * Gets the PCF or PCSS Quality.
  76249. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76250. */
  76251. /**
  76252. * Sets the PCF or PCSS Quality.
  76253. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76254. */
  76255. filteringQuality: number;
  76256. /**
  76257. * Gets if the current filter is set to "PCSS" (contact hardening).
  76258. */
  76259. /**
  76260. * Sets the current filter to "PCSS" (contact hardening).
  76261. */
  76262. useContactHardeningShadow: boolean;
  76263. private _contactHardeningLightSizeUVRatio;
  76264. /**
  76265. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76266. * Using a ratio helps keeping shape stability independently of the map size.
  76267. *
  76268. * It does not account for the light projection as it was having too much
  76269. * instability during the light setup or during light position changes.
  76270. *
  76271. * Only valid if useContactHardeningShadow is true.
  76272. */
  76273. /**
  76274. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76275. * Using a ratio helps keeping shape stability independently of the map size.
  76276. *
  76277. * It does not account for the light projection as it was having too much
  76278. * instability during the light setup or during light position changes.
  76279. *
  76280. * Only valid if useContactHardeningShadow is true.
  76281. */
  76282. contactHardeningLightSizeUVRatio: number;
  76283. private _darkness;
  76284. /** Gets or sets the actual darkness of a shadow */
  76285. darkness: number;
  76286. /**
  76287. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76288. * 0 means strongest and 1 would means no shadow.
  76289. * @returns the darkness.
  76290. */
  76291. getDarkness(): number;
  76292. /**
  76293. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76294. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76295. * @returns the shadow generator allowing fluent coding.
  76296. */
  76297. setDarkness(darkness: number): ShadowGenerator;
  76298. private _transparencyShadow;
  76299. /** Gets or sets the ability to have transparent shadow */
  76300. transparencyShadow: boolean;
  76301. /**
  76302. * Sets the ability to have transparent shadow (boolean).
  76303. * @param transparent True if transparent else False
  76304. * @returns the shadow generator allowing fluent coding
  76305. */
  76306. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76307. private _shadowMap;
  76308. private _shadowMap2;
  76309. /**
  76310. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76311. * @returns The render target texture if present otherwise, null
  76312. */
  76313. getShadowMap(): Nullable<RenderTargetTexture>;
  76314. /**
  76315. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76316. * @returns The render target texture if the shadow map is present otherwise, null
  76317. */
  76318. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76319. /**
  76320. * Gets the class name of that object
  76321. * @returns "ShadowGenerator"
  76322. */
  76323. getClassName(): string;
  76324. /**
  76325. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76326. * @param mesh Mesh to add
  76327. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76328. * @returns the Shadow Generator itself
  76329. */
  76330. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76331. /**
  76332. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76333. * @param mesh Mesh to remove
  76334. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76335. * @returns the Shadow Generator itself
  76336. */
  76337. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76338. /**
  76339. * Controls the extent to which the shadows fade out at the edge of the frustum
  76340. * Used only by directionals and spots
  76341. */
  76342. frustumEdgeFalloff: number;
  76343. private _light;
  76344. /**
  76345. * Returns the associated light object.
  76346. * @returns the light generating the shadow
  76347. */
  76348. getLight(): IShadowLight;
  76349. /**
  76350. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76351. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76352. * It might on the other hand introduce peter panning.
  76353. */
  76354. forceBackFacesOnly: boolean;
  76355. private _scene;
  76356. private _lightDirection;
  76357. private _effect;
  76358. private _viewMatrix;
  76359. private _projectionMatrix;
  76360. private _transformMatrix;
  76361. private _cachedPosition;
  76362. private _cachedDirection;
  76363. private _cachedDefines;
  76364. private _currentRenderID;
  76365. private _boxBlurPostprocess;
  76366. private _kernelBlurXPostprocess;
  76367. private _kernelBlurYPostprocess;
  76368. private _blurPostProcesses;
  76369. private _mapSize;
  76370. private _currentFaceIndex;
  76371. private _currentFaceIndexCache;
  76372. private _textureType;
  76373. private _defaultTextureMatrix;
  76374. private _storedUniqueId;
  76375. /** @hidden */
  76376. static _SceneComponentInitialization: (scene: Scene) => void;
  76377. /**
  76378. * Creates a ShadowGenerator object.
  76379. * A ShadowGenerator is the required tool to use the shadows.
  76380. * Each light casting shadows needs to use its own ShadowGenerator.
  76381. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76382. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76383. * @param light The light object generating the shadows.
  76384. * @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.
  76385. */
  76386. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76387. private _initializeGenerator;
  76388. private _initializeShadowMap;
  76389. private _initializeBlurRTTAndPostProcesses;
  76390. private _renderForShadowMap;
  76391. private _renderSubMeshForShadowMap;
  76392. private _applyFilterValues;
  76393. /**
  76394. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76395. * @param onCompiled Callback triggered at the and of the effects compilation
  76396. * @param options Sets of optional options forcing the compilation with different modes
  76397. */
  76398. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76399. useInstances: boolean;
  76400. }>): void;
  76401. /**
  76402. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76403. * @param options Sets of optional options forcing the compilation with different modes
  76404. * @returns A promise that resolves when the compilation completes
  76405. */
  76406. forceCompilationAsync(options?: Partial<{
  76407. useInstances: boolean;
  76408. }>): Promise<void>;
  76409. /**
  76410. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76411. * @param subMesh The submesh we want to render in the shadow map
  76412. * @param useInstances Defines wether will draw in the map using instances
  76413. * @returns true if ready otherwise, false
  76414. */
  76415. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76416. /**
  76417. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76418. * @param defines Defines of the material we want to update
  76419. * @param lightIndex Index of the light in the enabled light list of the material
  76420. */
  76421. prepareDefines(defines: any, lightIndex: number): void;
  76422. /**
  76423. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76424. * defined in the generator but impacting the effect).
  76425. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76426. * @param effect The effect we are binfing the information for
  76427. */
  76428. bindShadowLight(lightIndex: string, effect: Effect): void;
  76429. /**
  76430. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76431. * (eq to shadow prjection matrix * light transform matrix)
  76432. * @returns The transform matrix used to create the shadow map
  76433. */
  76434. getTransformMatrix(): Matrix;
  76435. /**
  76436. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76437. * Cube and 2D textures for instance.
  76438. */
  76439. recreateShadowMap(): void;
  76440. private _disposeBlurPostProcesses;
  76441. private _disposeRTTandPostProcesses;
  76442. /**
  76443. * Disposes the ShadowGenerator.
  76444. * Returns nothing.
  76445. */
  76446. dispose(): void;
  76447. /**
  76448. * Serializes the shadow generator setup to a json object.
  76449. * @returns The serialized JSON object
  76450. */
  76451. serialize(): any;
  76452. /**
  76453. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76454. * @param parsedShadowGenerator The JSON object to parse
  76455. * @param scene The scene to create the shadow map for
  76456. * @returns The parsed shadow generator
  76457. */
  76458. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76459. }
  76460. }
  76461. declare module BABYLON {
  76462. /**
  76463. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76464. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76465. * 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.
  76466. */
  76467. export abstract class Light extends Node {
  76468. /**
  76469. * Falloff Default: light is falling off following the material specification:
  76470. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76471. */
  76472. static readonly FALLOFF_DEFAULT: number;
  76473. /**
  76474. * Falloff Physical: light is falling off following the inverse squared distance law.
  76475. */
  76476. static readonly FALLOFF_PHYSICAL: number;
  76477. /**
  76478. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76479. * to enhance interoperability with other engines.
  76480. */
  76481. static readonly FALLOFF_GLTF: number;
  76482. /**
  76483. * Falloff Standard: light is falling off like in the standard material
  76484. * to enhance interoperability with other materials.
  76485. */
  76486. static readonly FALLOFF_STANDARD: number;
  76487. /**
  76488. * If every light affecting the material is in this lightmapMode,
  76489. * material.lightmapTexture adds or multiplies
  76490. * (depends on material.useLightmapAsShadowmap)
  76491. * after every other light calculations.
  76492. */
  76493. static readonly LIGHTMAP_DEFAULT: number;
  76494. /**
  76495. * material.lightmapTexture as only diffuse lighting from this light
  76496. * adds only specular lighting from this light
  76497. * adds dynamic shadows
  76498. */
  76499. static readonly LIGHTMAP_SPECULAR: number;
  76500. /**
  76501. * material.lightmapTexture as only lighting
  76502. * no light calculation from this light
  76503. * only adds dynamic shadows from this light
  76504. */
  76505. static readonly LIGHTMAP_SHADOWSONLY: number;
  76506. /**
  76507. * Each light type uses the default quantity according to its type:
  76508. * point/spot lights use luminous intensity
  76509. * directional lights use illuminance
  76510. */
  76511. static readonly INTENSITYMODE_AUTOMATIC: number;
  76512. /**
  76513. * lumen (lm)
  76514. */
  76515. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76516. /**
  76517. * candela (lm/sr)
  76518. */
  76519. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76520. /**
  76521. * lux (lm/m^2)
  76522. */
  76523. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76524. /**
  76525. * nit (cd/m^2)
  76526. */
  76527. static readonly INTENSITYMODE_LUMINANCE: number;
  76528. /**
  76529. * Light type const id of the point light.
  76530. */
  76531. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76532. /**
  76533. * Light type const id of the directional light.
  76534. */
  76535. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76536. /**
  76537. * Light type const id of the spot light.
  76538. */
  76539. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76540. /**
  76541. * Light type const id of the hemispheric light.
  76542. */
  76543. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76544. /**
  76545. * Diffuse gives the basic color to an object.
  76546. */
  76547. diffuse: Color3;
  76548. /**
  76549. * Specular produces a highlight color on an object.
  76550. * Note: This is note affecting PBR materials.
  76551. */
  76552. specular: Color3;
  76553. /**
  76554. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76555. * falling off base on range or angle.
  76556. * This can be set to any values in Light.FALLOFF_x.
  76557. *
  76558. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76559. * other types of materials.
  76560. */
  76561. falloffType: number;
  76562. /**
  76563. * Strength of the light.
  76564. * Note: By default it is define in the framework own unit.
  76565. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76566. */
  76567. intensity: number;
  76568. private _range;
  76569. protected _inverseSquaredRange: number;
  76570. /**
  76571. * Defines how far from the source the light is impacting in scene units.
  76572. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76573. */
  76574. /**
  76575. * Defines how far from the source the light is impacting in scene units.
  76576. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76577. */
  76578. range: number;
  76579. /**
  76580. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76581. * of light.
  76582. */
  76583. private _photometricScale;
  76584. private _intensityMode;
  76585. /**
  76586. * Gets the photometric scale used to interpret the intensity.
  76587. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76588. */
  76589. /**
  76590. * Sets the photometric scale used to interpret the intensity.
  76591. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76592. */
  76593. intensityMode: number;
  76594. private _radius;
  76595. /**
  76596. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76597. */
  76598. /**
  76599. * sets the light radius used by PBR Materials to simulate soft area lights.
  76600. */
  76601. radius: number;
  76602. private _renderPriority;
  76603. /**
  76604. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76605. * exceeding the number allowed of the materials.
  76606. */
  76607. renderPriority: number;
  76608. private _shadowEnabled;
  76609. /**
  76610. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76611. * the current shadow generator.
  76612. */
  76613. /**
  76614. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76615. * the current shadow generator.
  76616. */
  76617. shadowEnabled: boolean;
  76618. private _includedOnlyMeshes;
  76619. /**
  76620. * Gets the only meshes impacted by this light.
  76621. */
  76622. /**
  76623. * Sets the only meshes impacted by this light.
  76624. */
  76625. includedOnlyMeshes: AbstractMesh[];
  76626. private _excludedMeshes;
  76627. /**
  76628. * Gets the meshes not impacted by this light.
  76629. */
  76630. /**
  76631. * Sets the meshes not impacted by this light.
  76632. */
  76633. excludedMeshes: AbstractMesh[];
  76634. private _excludeWithLayerMask;
  76635. /**
  76636. * Gets the layer id use to find what meshes are not impacted by the light.
  76637. * Inactive if 0
  76638. */
  76639. /**
  76640. * Sets the layer id use to find what meshes are not impacted by the light.
  76641. * Inactive if 0
  76642. */
  76643. excludeWithLayerMask: number;
  76644. private _includeOnlyWithLayerMask;
  76645. /**
  76646. * Gets the layer id use to find what meshes are impacted by the light.
  76647. * Inactive if 0
  76648. */
  76649. /**
  76650. * Sets the layer id use to find what meshes are impacted by the light.
  76651. * Inactive if 0
  76652. */
  76653. includeOnlyWithLayerMask: number;
  76654. private _lightmapMode;
  76655. /**
  76656. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76657. */
  76658. /**
  76659. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76660. */
  76661. lightmapMode: number;
  76662. /**
  76663. * Shadow generator associted to the light.
  76664. * @hidden Internal use only.
  76665. */
  76666. _shadowGenerator: Nullable<IShadowGenerator>;
  76667. /**
  76668. * @hidden Internal use only.
  76669. */
  76670. _excludedMeshesIds: string[];
  76671. /**
  76672. * @hidden Internal use only.
  76673. */
  76674. _includedOnlyMeshesIds: string[];
  76675. /**
  76676. * The current light unifom buffer.
  76677. * @hidden Internal use only.
  76678. */
  76679. _uniformBuffer: UniformBuffer;
  76680. /**
  76681. * Creates a Light object in the scene.
  76682. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76683. * @param name The firendly name of the light
  76684. * @param scene The scene the light belongs too
  76685. */
  76686. constructor(name: string, scene: Scene);
  76687. protected abstract _buildUniformLayout(): void;
  76688. /**
  76689. * Sets the passed Effect "effect" with the Light information.
  76690. * @param effect The effect to update
  76691. * @param lightIndex The index of the light in the effect to update
  76692. * @returns The light
  76693. */
  76694. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76695. /**
  76696. * Sets the passed Effect "effect" with the Light information.
  76697. * @param effect The effect to update
  76698. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76699. * @returns The light
  76700. */
  76701. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76702. /**
  76703. * Returns the string "Light".
  76704. * @returns the class name
  76705. */
  76706. getClassName(): string;
  76707. /** @hidden */
  76708. readonly _isLight: boolean;
  76709. /**
  76710. * Converts the light information to a readable string for debug purpose.
  76711. * @param fullDetails Supports for multiple levels of logging within scene loading
  76712. * @returns the human readable light info
  76713. */
  76714. toString(fullDetails?: boolean): string;
  76715. /** @hidden */
  76716. protected _syncParentEnabledState(): void;
  76717. /**
  76718. * Set the enabled state of this node.
  76719. * @param value - the new enabled state
  76720. */
  76721. setEnabled(value: boolean): void;
  76722. /**
  76723. * Returns the Light associated shadow generator if any.
  76724. * @return the associated shadow generator.
  76725. */
  76726. getShadowGenerator(): Nullable<IShadowGenerator>;
  76727. /**
  76728. * Returns a Vector3, the absolute light position in the World.
  76729. * @returns the world space position of the light
  76730. */
  76731. getAbsolutePosition(): Vector3;
  76732. /**
  76733. * Specifies if the light will affect the passed mesh.
  76734. * @param mesh The mesh to test against the light
  76735. * @return true the mesh is affected otherwise, false.
  76736. */
  76737. canAffectMesh(mesh: AbstractMesh): boolean;
  76738. /**
  76739. * Sort function to order lights for rendering.
  76740. * @param a First Light object to compare to second.
  76741. * @param b Second Light object to compare first.
  76742. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76743. */
  76744. static CompareLightsPriority(a: Light, b: Light): number;
  76745. /**
  76746. * Releases resources associated with this node.
  76747. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76748. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76749. */
  76750. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76751. /**
  76752. * Returns the light type ID (integer).
  76753. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76754. */
  76755. getTypeID(): number;
  76756. /**
  76757. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76758. * @returns the scaled intensity in intensity mode unit
  76759. */
  76760. getScaledIntensity(): number;
  76761. /**
  76762. * Returns a new Light object, named "name", from the current one.
  76763. * @param name The name of the cloned light
  76764. * @returns the new created light
  76765. */
  76766. clone(name: string): Nullable<Light>;
  76767. /**
  76768. * Serializes the current light into a Serialization object.
  76769. * @returns the serialized object.
  76770. */
  76771. serialize(): any;
  76772. /**
  76773. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76774. * This new light is named "name" and added to the passed scene.
  76775. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76776. * @param name The friendly name of the light
  76777. * @param scene The scene the new light will belong to
  76778. * @returns the constructor function
  76779. */
  76780. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76781. /**
  76782. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76783. * @param parsedLight The JSON representation of the light
  76784. * @param scene The scene to create the parsed light in
  76785. * @returns the created light after parsing
  76786. */
  76787. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76788. private _hookArrayForExcluded;
  76789. private _hookArrayForIncludedOnly;
  76790. private _resyncMeshes;
  76791. /**
  76792. * Forces the meshes to update their light related information in their rendering used effects
  76793. * @hidden Internal Use Only
  76794. */
  76795. _markMeshesAsLightDirty(): void;
  76796. /**
  76797. * Recomputes the cached photometric scale if needed.
  76798. */
  76799. private _computePhotometricScale;
  76800. /**
  76801. * Returns the Photometric Scale according to the light type and intensity mode.
  76802. */
  76803. private _getPhotometricScale;
  76804. /**
  76805. * Reorder the light in the scene according to their defined priority.
  76806. * @hidden Internal Use Only
  76807. */
  76808. _reorderLightsInScene(): void;
  76809. /**
  76810. * Prepares the list of defines specific to the light type.
  76811. * @param defines the list of defines
  76812. * @param lightIndex defines the index of the light for the effect
  76813. */
  76814. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76815. }
  76816. }
  76817. declare module BABYLON {
  76818. /**
  76819. * Interface used to define Action
  76820. */
  76821. export interface IAction {
  76822. /**
  76823. * Trigger for the action
  76824. */
  76825. trigger: number;
  76826. /** Options of the trigger */
  76827. triggerOptions: any;
  76828. /**
  76829. * Gets the trigger parameters
  76830. * @returns the trigger parameters
  76831. */
  76832. getTriggerParameter(): any;
  76833. /**
  76834. * Internal only - executes current action event
  76835. * @hidden
  76836. */
  76837. _executeCurrent(evt?: ActionEvent): void;
  76838. /**
  76839. * Serialize placeholder for child classes
  76840. * @param parent of child
  76841. * @returns the serialized object
  76842. */
  76843. serialize(parent: any): any;
  76844. /**
  76845. * Internal only
  76846. * @hidden
  76847. */
  76848. _prepare(): void;
  76849. /**
  76850. * Internal only - manager for action
  76851. * @hidden
  76852. */
  76853. _actionManager: AbstractActionManager;
  76854. /**
  76855. * Adds action to chain of actions, may be a DoNothingAction
  76856. * @param action defines the next action to execute
  76857. * @returns The action passed in
  76858. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76859. */
  76860. then(action: IAction): IAction;
  76861. }
  76862. /**
  76863. * The action to be carried out following a trigger
  76864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76865. */
  76866. export class Action implements IAction {
  76867. /** the trigger, with or without parameters, for the action */
  76868. triggerOptions: any;
  76869. /**
  76870. * Trigger for the action
  76871. */
  76872. trigger: number;
  76873. /**
  76874. * Internal only - manager for action
  76875. * @hidden
  76876. */
  76877. _actionManager: ActionManager;
  76878. private _nextActiveAction;
  76879. private _child;
  76880. private _condition?;
  76881. private _triggerParameter;
  76882. /**
  76883. * An event triggered prior to action being executed.
  76884. */
  76885. onBeforeExecuteObservable: Observable<Action>;
  76886. /**
  76887. * Creates a new Action
  76888. * @param triggerOptions the trigger, with or without parameters, for the action
  76889. * @param condition an optional determinant of action
  76890. */
  76891. constructor(
  76892. /** the trigger, with or without parameters, for the action */
  76893. triggerOptions: any, condition?: Condition);
  76894. /**
  76895. * Internal only
  76896. * @hidden
  76897. */
  76898. _prepare(): void;
  76899. /**
  76900. * Gets the trigger parameters
  76901. * @returns the trigger parameters
  76902. */
  76903. getTriggerParameter(): any;
  76904. /**
  76905. * Internal only - executes current action event
  76906. * @hidden
  76907. */
  76908. _executeCurrent(evt?: ActionEvent): void;
  76909. /**
  76910. * Execute placeholder for child classes
  76911. * @param evt optional action event
  76912. */
  76913. execute(evt?: ActionEvent): void;
  76914. /**
  76915. * Skips to next active action
  76916. */
  76917. skipToNextActiveAction(): void;
  76918. /**
  76919. * Adds action to chain of actions, may be a DoNothingAction
  76920. * @param action defines the next action to execute
  76921. * @returns The action passed in
  76922. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76923. */
  76924. then(action: Action): Action;
  76925. /**
  76926. * Internal only
  76927. * @hidden
  76928. */
  76929. _getProperty(propertyPath: string): string;
  76930. /**
  76931. * Internal only
  76932. * @hidden
  76933. */
  76934. _getEffectiveTarget(target: any, propertyPath: string): any;
  76935. /**
  76936. * Serialize placeholder for child classes
  76937. * @param parent of child
  76938. * @returns the serialized object
  76939. */
  76940. serialize(parent: any): any;
  76941. /**
  76942. * Internal only called by serialize
  76943. * @hidden
  76944. */
  76945. protected _serialize(serializedAction: any, parent?: any): any;
  76946. /**
  76947. * Internal only
  76948. * @hidden
  76949. */
  76950. static _SerializeValueAsString: (value: any) => string;
  76951. /**
  76952. * Internal only
  76953. * @hidden
  76954. */
  76955. static _GetTargetProperty: (target: Node | Scene) => {
  76956. name: string;
  76957. targetType: string;
  76958. value: string;
  76959. };
  76960. }
  76961. }
  76962. declare module BABYLON {
  76963. /**
  76964. * A Condition applied to an Action
  76965. */
  76966. export class Condition {
  76967. /**
  76968. * Internal only - manager for action
  76969. * @hidden
  76970. */
  76971. _actionManager: ActionManager;
  76972. /**
  76973. * Internal only
  76974. * @hidden
  76975. */
  76976. _evaluationId: number;
  76977. /**
  76978. * Internal only
  76979. * @hidden
  76980. */
  76981. _currentResult: boolean;
  76982. /**
  76983. * Creates a new Condition
  76984. * @param actionManager the manager of the action the condition is applied to
  76985. */
  76986. constructor(actionManager: ActionManager);
  76987. /**
  76988. * Check if the current condition is valid
  76989. * @returns a boolean
  76990. */
  76991. isValid(): boolean;
  76992. /**
  76993. * Internal only
  76994. * @hidden
  76995. */
  76996. _getProperty(propertyPath: string): string;
  76997. /**
  76998. * Internal only
  76999. * @hidden
  77000. */
  77001. _getEffectiveTarget(target: any, propertyPath: string): any;
  77002. /**
  77003. * Serialize placeholder for child classes
  77004. * @returns the serialized object
  77005. */
  77006. serialize(): any;
  77007. /**
  77008. * Internal only
  77009. * @hidden
  77010. */
  77011. protected _serialize(serializedCondition: any): any;
  77012. }
  77013. /**
  77014. * Defines specific conditional operators as extensions of Condition
  77015. */
  77016. export class ValueCondition extends Condition {
  77017. /** path to specify the property of the target the conditional operator uses */
  77018. propertyPath: string;
  77019. /** the value compared by the conditional operator against the current value of the property */
  77020. value: any;
  77021. /** the conditional operator, default ValueCondition.IsEqual */
  77022. operator: number;
  77023. /**
  77024. * Internal only
  77025. * @hidden
  77026. */
  77027. private static _IsEqual;
  77028. /**
  77029. * Internal only
  77030. * @hidden
  77031. */
  77032. private static _IsDifferent;
  77033. /**
  77034. * Internal only
  77035. * @hidden
  77036. */
  77037. private static _IsGreater;
  77038. /**
  77039. * Internal only
  77040. * @hidden
  77041. */
  77042. private static _IsLesser;
  77043. /**
  77044. * returns the number for IsEqual
  77045. */
  77046. static readonly IsEqual: number;
  77047. /**
  77048. * Returns the number for IsDifferent
  77049. */
  77050. static readonly IsDifferent: number;
  77051. /**
  77052. * Returns the number for IsGreater
  77053. */
  77054. static readonly IsGreater: number;
  77055. /**
  77056. * Returns the number for IsLesser
  77057. */
  77058. static readonly IsLesser: number;
  77059. /**
  77060. * Internal only The action manager for the condition
  77061. * @hidden
  77062. */
  77063. _actionManager: ActionManager;
  77064. /**
  77065. * Internal only
  77066. * @hidden
  77067. */
  77068. private _target;
  77069. /**
  77070. * Internal only
  77071. * @hidden
  77072. */
  77073. private _effectiveTarget;
  77074. /**
  77075. * Internal only
  77076. * @hidden
  77077. */
  77078. private _property;
  77079. /**
  77080. * Creates a new ValueCondition
  77081. * @param actionManager manager for the action the condition applies to
  77082. * @param target for the action
  77083. * @param propertyPath path to specify the property of the target the conditional operator uses
  77084. * @param value the value compared by the conditional operator against the current value of the property
  77085. * @param operator the conditional operator, default ValueCondition.IsEqual
  77086. */
  77087. constructor(actionManager: ActionManager, target: any,
  77088. /** path to specify the property of the target the conditional operator uses */
  77089. propertyPath: string,
  77090. /** the value compared by the conditional operator against the current value of the property */
  77091. value: any,
  77092. /** the conditional operator, default ValueCondition.IsEqual */
  77093. operator?: number);
  77094. /**
  77095. * Compares the given value with the property value for the specified conditional operator
  77096. * @returns the result of the comparison
  77097. */
  77098. isValid(): boolean;
  77099. /**
  77100. * Serialize the ValueCondition into a JSON compatible object
  77101. * @returns serialization object
  77102. */
  77103. serialize(): any;
  77104. /**
  77105. * Gets the name of the conditional operator for the ValueCondition
  77106. * @param operator the conditional operator
  77107. * @returns the name
  77108. */
  77109. static GetOperatorName(operator: number): string;
  77110. }
  77111. /**
  77112. * Defines a predicate condition as an extension of Condition
  77113. */
  77114. export class PredicateCondition extends Condition {
  77115. /** defines the predicate function used to validate the condition */
  77116. predicate: () => boolean;
  77117. /**
  77118. * Internal only - manager for action
  77119. * @hidden
  77120. */
  77121. _actionManager: ActionManager;
  77122. /**
  77123. * Creates a new PredicateCondition
  77124. * @param actionManager manager for the action the condition applies to
  77125. * @param predicate defines the predicate function used to validate the condition
  77126. */
  77127. constructor(actionManager: ActionManager,
  77128. /** defines the predicate function used to validate the condition */
  77129. predicate: () => boolean);
  77130. /**
  77131. * @returns the validity of the predicate condition
  77132. */
  77133. isValid(): boolean;
  77134. }
  77135. /**
  77136. * Defines a state condition as an extension of Condition
  77137. */
  77138. export class StateCondition extends Condition {
  77139. /** Value to compare with target state */
  77140. value: string;
  77141. /**
  77142. * Internal only - manager for action
  77143. * @hidden
  77144. */
  77145. _actionManager: ActionManager;
  77146. /**
  77147. * Internal only
  77148. * @hidden
  77149. */
  77150. private _target;
  77151. /**
  77152. * Creates a new StateCondition
  77153. * @param actionManager manager for the action the condition applies to
  77154. * @param target of the condition
  77155. * @param value to compare with target state
  77156. */
  77157. constructor(actionManager: ActionManager, target: any,
  77158. /** Value to compare with target state */
  77159. value: string);
  77160. /**
  77161. * Gets a boolean indicating if the current condition is met
  77162. * @returns the validity of the state
  77163. */
  77164. isValid(): boolean;
  77165. /**
  77166. * Serialize the StateCondition into a JSON compatible object
  77167. * @returns serialization object
  77168. */
  77169. serialize(): any;
  77170. }
  77171. }
  77172. declare module BABYLON {
  77173. /**
  77174. * This defines an action responsible to toggle a boolean once triggered.
  77175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77176. */
  77177. export class SwitchBooleanAction extends Action {
  77178. /**
  77179. * The path to the boolean property in the target object
  77180. */
  77181. propertyPath: string;
  77182. private _target;
  77183. private _effectiveTarget;
  77184. private _property;
  77185. /**
  77186. * Instantiate the action
  77187. * @param triggerOptions defines the trigger options
  77188. * @param target defines the object containing the boolean
  77189. * @param propertyPath defines the path to the boolean property in the target object
  77190. * @param condition defines the trigger related conditions
  77191. */
  77192. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77193. /** @hidden */
  77194. _prepare(): void;
  77195. /**
  77196. * Execute the action toggle the boolean value.
  77197. */
  77198. execute(): void;
  77199. /**
  77200. * Serializes the actions and its related information.
  77201. * @param parent defines the object to serialize in
  77202. * @returns the serialized object
  77203. */
  77204. serialize(parent: any): any;
  77205. }
  77206. /**
  77207. * This defines an action responsible to set a the state field of the target
  77208. * to a desired value once triggered.
  77209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77210. */
  77211. export class SetStateAction extends Action {
  77212. /**
  77213. * The value to store in the state field.
  77214. */
  77215. value: string;
  77216. private _target;
  77217. /**
  77218. * Instantiate the action
  77219. * @param triggerOptions defines the trigger options
  77220. * @param target defines the object containing the state property
  77221. * @param value defines the value to store in the state field
  77222. * @param condition defines the trigger related conditions
  77223. */
  77224. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77225. /**
  77226. * Execute the action and store the value on the target state property.
  77227. */
  77228. execute(): void;
  77229. /**
  77230. * Serializes the actions and its related information.
  77231. * @param parent defines the object to serialize in
  77232. * @returns the serialized object
  77233. */
  77234. serialize(parent: any): any;
  77235. }
  77236. /**
  77237. * This defines an action responsible to set a property of the target
  77238. * to a desired value once triggered.
  77239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77240. */
  77241. export class SetValueAction extends Action {
  77242. /**
  77243. * The path of the property to set in the target.
  77244. */
  77245. propertyPath: string;
  77246. /**
  77247. * The value to set in the property
  77248. */
  77249. value: any;
  77250. private _target;
  77251. private _effectiveTarget;
  77252. private _property;
  77253. /**
  77254. * Instantiate the action
  77255. * @param triggerOptions defines the trigger options
  77256. * @param target defines the object containing the property
  77257. * @param propertyPath defines the path of the property to set in the target
  77258. * @param value defines the value to set in the property
  77259. * @param condition defines the trigger related conditions
  77260. */
  77261. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77262. /** @hidden */
  77263. _prepare(): void;
  77264. /**
  77265. * Execute the action and set the targetted property to the desired value.
  77266. */
  77267. execute(): void;
  77268. /**
  77269. * Serializes the actions and its related information.
  77270. * @param parent defines the object to serialize in
  77271. * @returns the serialized object
  77272. */
  77273. serialize(parent: any): any;
  77274. }
  77275. /**
  77276. * This defines an action responsible to increment the target value
  77277. * to a desired value once triggered.
  77278. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77279. */
  77280. export class IncrementValueAction extends Action {
  77281. /**
  77282. * The path of the property to increment in the target.
  77283. */
  77284. propertyPath: string;
  77285. /**
  77286. * The value we should increment the property by.
  77287. */
  77288. value: any;
  77289. private _target;
  77290. private _effectiveTarget;
  77291. private _property;
  77292. /**
  77293. * Instantiate the action
  77294. * @param triggerOptions defines the trigger options
  77295. * @param target defines the object containing the property
  77296. * @param propertyPath defines the path of the property to increment in the target
  77297. * @param value defines the value value we should increment the property by
  77298. * @param condition defines the trigger related conditions
  77299. */
  77300. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77301. /** @hidden */
  77302. _prepare(): void;
  77303. /**
  77304. * Execute the action and increment the target of the value amount.
  77305. */
  77306. execute(): void;
  77307. /**
  77308. * Serializes the actions and its related information.
  77309. * @param parent defines the object to serialize in
  77310. * @returns the serialized object
  77311. */
  77312. serialize(parent: any): any;
  77313. }
  77314. /**
  77315. * This defines an action responsible to start an animation once triggered.
  77316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77317. */
  77318. export class PlayAnimationAction extends Action {
  77319. /**
  77320. * Where the animation should start (animation frame)
  77321. */
  77322. from: number;
  77323. /**
  77324. * Where the animation should stop (animation frame)
  77325. */
  77326. to: number;
  77327. /**
  77328. * Define if the animation should loop or stop after the first play.
  77329. */
  77330. loop?: boolean;
  77331. private _target;
  77332. /**
  77333. * Instantiate the action
  77334. * @param triggerOptions defines the trigger options
  77335. * @param target defines the target animation or animation name
  77336. * @param from defines from where the animation should start (animation frame)
  77337. * @param end defines where the animation should stop (animation frame)
  77338. * @param loop defines if the animation should loop or stop after the first play
  77339. * @param condition defines the trigger related conditions
  77340. */
  77341. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77342. /** @hidden */
  77343. _prepare(): void;
  77344. /**
  77345. * Execute the action and play the animation.
  77346. */
  77347. execute(): void;
  77348. /**
  77349. * Serializes the actions and its related information.
  77350. * @param parent defines the object to serialize in
  77351. * @returns the serialized object
  77352. */
  77353. serialize(parent: any): any;
  77354. }
  77355. /**
  77356. * This defines an action responsible to stop an animation once triggered.
  77357. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77358. */
  77359. export class StopAnimationAction extends Action {
  77360. private _target;
  77361. /**
  77362. * Instantiate the action
  77363. * @param triggerOptions defines the trigger options
  77364. * @param target defines the target animation or animation name
  77365. * @param condition defines the trigger related conditions
  77366. */
  77367. constructor(triggerOptions: any, target: any, condition?: Condition);
  77368. /** @hidden */
  77369. _prepare(): void;
  77370. /**
  77371. * Execute the action and stop the animation.
  77372. */
  77373. execute(): void;
  77374. /**
  77375. * Serializes the actions and its related information.
  77376. * @param parent defines the object to serialize in
  77377. * @returns the serialized object
  77378. */
  77379. serialize(parent: any): any;
  77380. }
  77381. /**
  77382. * This defines an action responsible that does nothing once triggered.
  77383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77384. */
  77385. export class DoNothingAction extends Action {
  77386. /**
  77387. * Instantiate the action
  77388. * @param triggerOptions defines the trigger options
  77389. * @param condition defines the trigger related conditions
  77390. */
  77391. constructor(triggerOptions?: any, condition?: Condition);
  77392. /**
  77393. * Execute the action and do nothing.
  77394. */
  77395. execute(): void;
  77396. /**
  77397. * Serializes the actions and its related information.
  77398. * @param parent defines the object to serialize in
  77399. * @returns the serialized object
  77400. */
  77401. serialize(parent: any): any;
  77402. }
  77403. /**
  77404. * This defines an action responsible to trigger several actions once triggered.
  77405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77406. */
  77407. export class CombineAction extends Action {
  77408. /**
  77409. * The list of aggregated animations to run.
  77410. */
  77411. children: Action[];
  77412. /**
  77413. * Instantiate the action
  77414. * @param triggerOptions defines the trigger options
  77415. * @param children defines the list of aggregated animations to run
  77416. * @param condition defines the trigger related conditions
  77417. */
  77418. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77419. /** @hidden */
  77420. _prepare(): void;
  77421. /**
  77422. * Execute the action and executes all the aggregated actions.
  77423. */
  77424. execute(evt: ActionEvent): void;
  77425. /**
  77426. * Serializes the actions and its related information.
  77427. * @param parent defines the object to serialize in
  77428. * @returns the serialized object
  77429. */
  77430. serialize(parent: any): any;
  77431. }
  77432. /**
  77433. * This defines an action responsible to run code (external event) once triggered.
  77434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77435. */
  77436. export class ExecuteCodeAction extends Action {
  77437. /**
  77438. * The callback function to run.
  77439. */
  77440. func: (evt: ActionEvent) => void;
  77441. /**
  77442. * Instantiate the action
  77443. * @param triggerOptions defines the trigger options
  77444. * @param func defines the callback function to run
  77445. * @param condition defines the trigger related conditions
  77446. */
  77447. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77448. /**
  77449. * Execute the action and run the attached code.
  77450. */
  77451. execute(evt: ActionEvent): void;
  77452. }
  77453. /**
  77454. * This defines an action responsible to set the parent property of the target once triggered.
  77455. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77456. */
  77457. export class SetParentAction extends Action {
  77458. private _parent;
  77459. private _target;
  77460. /**
  77461. * Instantiate the action
  77462. * @param triggerOptions defines the trigger options
  77463. * @param target defines the target containing the parent property
  77464. * @param parent defines from where the animation should start (animation frame)
  77465. * @param condition defines the trigger related conditions
  77466. */
  77467. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77468. /** @hidden */
  77469. _prepare(): void;
  77470. /**
  77471. * Execute the action and set the parent property.
  77472. */
  77473. execute(): void;
  77474. /**
  77475. * Serializes the actions and its related information.
  77476. * @param parent defines the object to serialize in
  77477. * @returns the serialized object
  77478. */
  77479. serialize(parent: any): any;
  77480. }
  77481. }
  77482. declare module BABYLON {
  77483. /**
  77484. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77485. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77486. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77487. */
  77488. export class ActionManager extends AbstractActionManager {
  77489. /**
  77490. * Nothing
  77491. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77492. */
  77493. static readonly NothingTrigger: number;
  77494. /**
  77495. * On pick
  77496. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77497. */
  77498. static readonly OnPickTrigger: number;
  77499. /**
  77500. * On left pick
  77501. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77502. */
  77503. static readonly OnLeftPickTrigger: number;
  77504. /**
  77505. * On right pick
  77506. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77507. */
  77508. static readonly OnRightPickTrigger: number;
  77509. /**
  77510. * On center pick
  77511. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77512. */
  77513. static readonly OnCenterPickTrigger: number;
  77514. /**
  77515. * On pick down
  77516. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77517. */
  77518. static readonly OnPickDownTrigger: number;
  77519. /**
  77520. * On double pick
  77521. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77522. */
  77523. static readonly OnDoublePickTrigger: number;
  77524. /**
  77525. * On pick up
  77526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77527. */
  77528. static readonly OnPickUpTrigger: number;
  77529. /**
  77530. * On pick out.
  77531. * This trigger will only be raised if you also declared a OnPickDown
  77532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77533. */
  77534. static readonly OnPickOutTrigger: number;
  77535. /**
  77536. * On long press
  77537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77538. */
  77539. static readonly OnLongPressTrigger: number;
  77540. /**
  77541. * On pointer over
  77542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77543. */
  77544. static readonly OnPointerOverTrigger: number;
  77545. /**
  77546. * On pointer out
  77547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77548. */
  77549. static readonly OnPointerOutTrigger: number;
  77550. /**
  77551. * On every frame
  77552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77553. */
  77554. static readonly OnEveryFrameTrigger: number;
  77555. /**
  77556. * On intersection enter
  77557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77558. */
  77559. static readonly OnIntersectionEnterTrigger: number;
  77560. /**
  77561. * On intersection exit
  77562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77563. */
  77564. static readonly OnIntersectionExitTrigger: number;
  77565. /**
  77566. * On key down
  77567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77568. */
  77569. static readonly OnKeyDownTrigger: number;
  77570. /**
  77571. * On key up
  77572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77573. */
  77574. static readonly OnKeyUpTrigger: number;
  77575. private _scene;
  77576. /**
  77577. * Creates a new action manager
  77578. * @param scene defines the hosting scene
  77579. */
  77580. constructor(scene: Scene);
  77581. /**
  77582. * Releases all associated resources
  77583. */
  77584. dispose(): void;
  77585. /**
  77586. * Gets hosting scene
  77587. * @returns the hosting scene
  77588. */
  77589. getScene(): Scene;
  77590. /**
  77591. * Does this action manager handles actions of any of the given triggers
  77592. * @param triggers defines the triggers to be tested
  77593. * @return a boolean indicating whether one (or more) of the triggers is handled
  77594. */
  77595. hasSpecificTriggers(triggers: number[]): boolean;
  77596. /**
  77597. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77598. * speed.
  77599. * @param triggerA defines the trigger to be tested
  77600. * @param triggerB defines the trigger to be tested
  77601. * @return a boolean indicating whether one (or more) of the triggers is handled
  77602. */
  77603. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77604. /**
  77605. * Does this action manager handles actions of a given trigger
  77606. * @param trigger defines the trigger to be tested
  77607. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77608. * @return whether the trigger is handled
  77609. */
  77610. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77611. /**
  77612. * Does this action manager has pointer triggers
  77613. */
  77614. readonly hasPointerTriggers: boolean;
  77615. /**
  77616. * Does this action manager has pick triggers
  77617. */
  77618. readonly hasPickTriggers: boolean;
  77619. /**
  77620. * Registers an action to this action manager
  77621. * @param action defines the action to be registered
  77622. * @return the action amended (prepared) after registration
  77623. */
  77624. registerAction(action: IAction): Nullable<IAction>;
  77625. /**
  77626. * Unregisters an action to this action manager
  77627. * @param action defines the action to be unregistered
  77628. * @return a boolean indicating whether the action has been unregistered
  77629. */
  77630. unregisterAction(action: IAction): Boolean;
  77631. /**
  77632. * Process a specific trigger
  77633. * @param trigger defines the trigger to process
  77634. * @param evt defines the event details to be processed
  77635. */
  77636. processTrigger(trigger: number, evt?: IActionEvent): void;
  77637. /** @hidden */
  77638. _getEffectiveTarget(target: any, propertyPath: string): any;
  77639. /** @hidden */
  77640. _getProperty(propertyPath: string): string;
  77641. /**
  77642. * Serialize this manager to a JSON object
  77643. * @param name defines the property name to store this manager
  77644. * @returns a JSON representation of this manager
  77645. */
  77646. serialize(name: string): any;
  77647. /**
  77648. * Creates a new ActionManager from a JSON data
  77649. * @param parsedActions defines the JSON data to read from
  77650. * @param object defines the hosting mesh
  77651. * @param scene defines the hosting scene
  77652. */
  77653. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77654. /**
  77655. * Get a trigger name by index
  77656. * @param trigger defines the trigger index
  77657. * @returns a trigger name
  77658. */
  77659. static GetTriggerName(trigger: number): string;
  77660. }
  77661. }
  77662. declare module BABYLON {
  77663. /**
  77664. * Class representing a ray with position and direction
  77665. */
  77666. export class Ray {
  77667. /** origin point */
  77668. origin: Vector3;
  77669. /** direction */
  77670. direction: Vector3;
  77671. /** length of the ray */
  77672. length: number;
  77673. private static readonly TmpVector3;
  77674. private _tmpRay;
  77675. /**
  77676. * Creates a new ray
  77677. * @param origin origin point
  77678. * @param direction direction
  77679. * @param length length of the ray
  77680. */
  77681. constructor(
  77682. /** origin point */
  77683. origin: Vector3,
  77684. /** direction */
  77685. direction: Vector3,
  77686. /** length of the ray */
  77687. length?: number);
  77688. /**
  77689. * Checks if the ray intersects a box
  77690. * @param minimum bound of the box
  77691. * @param maximum bound of the box
  77692. * @param intersectionTreshold extra extend to be added to the box in all direction
  77693. * @returns if the box was hit
  77694. */
  77695. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77696. /**
  77697. * Checks if the ray intersects a box
  77698. * @param box the bounding box to check
  77699. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77700. * @returns if the box was hit
  77701. */
  77702. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77703. /**
  77704. * If the ray hits a sphere
  77705. * @param sphere the bounding sphere to check
  77706. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77707. * @returns true if it hits the sphere
  77708. */
  77709. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77710. /**
  77711. * If the ray hits a triange
  77712. * @param vertex0 triangle vertex
  77713. * @param vertex1 triangle vertex
  77714. * @param vertex2 triangle vertex
  77715. * @returns intersection information if hit
  77716. */
  77717. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77718. /**
  77719. * Checks if ray intersects a plane
  77720. * @param plane the plane to check
  77721. * @returns the distance away it was hit
  77722. */
  77723. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77724. /**
  77725. * Calculate the intercept of a ray on a given axis
  77726. * @param axis to check 'x' | 'y' | 'z'
  77727. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77728. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77729. */
  77730. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77731. /**
  77732. * Checks if ray intersects a mesh
  77733. * @param mesh the mesh to check
  77734. * @param fastCheck if only the bounding box should checked
  77735. * @returns picking info of the intersecton
  77736. */
  77737. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77738. /**
  77739. * Checks if ray intersects a mesh
  77740. * @param meshes the meshes to check
  77741. * @param fastCheck if only the bounding box should checked
  77742. * @param results array to store result in
  77743. * @returns Array of picking infos
  77744. */
  77745. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77746. private _comparePickingInfo;
  77747. private static smallnum;
  77748. private static rayl;
  77749. /**
  77750. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77751. * @param sega the first point of the segment to test the intersection against
  77752. * @param segb the second point of the segment to test the intersection against
  77753. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77754. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77755. */
  77756. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77757. /**
  77758. * Update the ray from viewport position
  77759. * @param x position
  77760. * @param y y position
  77761. * @param viewportWidth viewport width
  77762. * @param viewportHeight viewport height
  77763. * @param world world matrix
  77764. * @param view view matrix
  77765. * @param projection projection matrix
  77766. * @returns this ray updated
  77767. */
  77768. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77769. /**
  77770. * Creates a ray with origin and direction of 0,0,0
  77771. * @returns the new ray
  77772. */
  77773. static Zero(): Ray;
  77774. /**
  77775. * Creates a new ray from screen space and viewport
  77776. * @param x position
  77777. * @param y y position
  77778. * @param viewportWidth viewport width
  77779. * @param viewportHeight viewport height
  77780. * @param world world matrix
  77781. * @param view view matrix
  77782. * @param projection projection matrix
  77783. * @returns new ray
  77784. */
  77785. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77786. /**
  77787. * 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
  77788. * transformed to the given world matrix.
  77789. * @param origin The origin point
  77790. * @param end The end point
  77791. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77792. * @returns the new ray
  77793. */
  77794. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77795. /**
  77796. * Transforms a ray by a matrix
  77797. * @param ray ray to transform
  77798. * @param matrix matrix to apply
  77799. * @returns the resulting new ray
  77800. */
  77801. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77802. /**
  77803. * Transforms a ray by a matrix
  77804. * @param ray ray to transform
  77805. * @param matrix matrix to apply
  77806. * @param result ray to store result in
  77807. */
  77808. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77809. /**
  77810. * Unproject a ray from screen space to object space
  77811. * @param sourceX defines the screen space x coordinate to use
  77812. * @param sourceY defines the screen space y coordinate to use
  77813. * @param viewportWidth defines the current width of the viewport
  77814. * @param viewportHeight defines the current height of the viewport
  77815. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77816. * @param view defines the view matrix to use
  77817. * @param projection defines the projection matrix to use
  77818. */
  77819. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77820. }
  77821. /**
  77822. * Type used to define predicate used to select faces when a mesh intersection is detected
  77823. */
  77824. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77825. interface Scene {
  77826. /** @hidden */
  77827. _tempPickingRay: Nullable<Ray>;
  77828. /** @hidden */
  77829. _cachedRayForTransform: Ray;
  77830. /** @hidden */
  77831. _pickWithRayInverseMatrix: Matrix;
  77832. /** @hidden */
  77833. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77834. /** @hidden */
  77835. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77836. }
  77837. }
  77838. declare module BABYLON {
  77839. /**
  77840. * Groups all the scene component constants in one place to ease maintenance.
  77841. * @hidden
  77842. */
  77843. export class SceneComponentConstants {
  77844. static readonly NAME_EFFECTLAYER: string;
  77845. static readonly NAME_LAYER: string;
  77846. static readonly NAME_LENSFLARESYSTEM: string;
  77847. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77848. static readonly NAME_PARTICLESYSTEM: string;
  77849. static readonly NAME_GAMEPAD: string;
  77850. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77851. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77852. static readonly NAME_DEPTHRENDERER: string;
  77853. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77854. static readonly NAME_SPRITE: string;
  77855. static readonly NAME_OUTLINERENDERER: string;
  77856. static readonly NAME_PROCEDURALTEXTURE: string;
  77857. static readonly NAME_SHADOWGENERATOR: string;
  77858. static readonly NAME_OCTREE: string;
  77859. static readonly NAME_PHYSICSENGINE: string;
  77860. static readonly NAME_AUDIO: string;
  77861. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77862. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77863. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77864. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77865. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77866. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77867. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77868. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77869. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77870. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77871. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77872. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77873. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77874. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77875. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77876. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77877. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77878. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77879. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77880. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77881. static readonly STEP_AFTERRENDER_AUDIO: number;
  77882. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77883. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77884. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77885. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77886. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77887. static readonly STEP_POINTERMOVE_SPRITE: number;
  77888. static readonly STEP_POINTERDOWN_SPRITE: number;
  77889. static readonly STEP_POINTERUP_SPRITE: number;
  77890. }
  77891. /**
  77892. * This represents a scene component.
  77893. *
  77894. * This is used to decouple the dependency the scene is having on the different workloads like
  77895. * layers, post processes...
  77896. */
  77897. export interface ISceneComponent {
  77898. /**
  77899. * The name of the component. Each component must have a unique name.
  77900. */
  77901. name: string;
  77902. /**
  77903. * The scene the component belongs to.
  77904. */
  77905. scene: Scene;
  77906. /**
  77907. * Register the component to one instance of a scene.
  77908. */
  77909. register(): void;
  77910. /**
  77911. * Rebuilds the elements related to this component in case of
  77912. * context lost for instance.
  77913. */
  77914. rebuild(): void;
  77915. /**
  77916. * Disposes the component and the associated ressources.
  77917. */
  77918. dispose(): void;
  77919. }
  77920. /**
  77921. * This represents a SERIALIZABLE scene component.
  77922. *
  77923. * This extends Scene Component to add Serialization methods on top.
  77924. */
  77925. export interface ISceneSerializableComponent extends ISceneComponent {
  77926. /**
  77927. * Adds all the elements from the container to the scene
  77928. * @param container the container holding the elements
  77929. */
  77930. addFromContainer(container: AbstractScene): void;
  77931. /**
  77932. * Removes all the elements in the container from the scene
  77933. * @param container contains the elements to remove
  77934. * @param dispose if the removed element should be disposed (default: false)
  77935. */
  77936. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77937. /**
  77938. * Serializes the component data to the specified json object
  77939. * @param serializationObject The object to serialize to
  77940. */
  77941. serialize(serializationObject: any): void;
  77942. }
  77943. /**
  77944. * Strong typing of a Mesh related stage step action
  77945. */
  77946. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77947. /**
  77948. * Strong typing of a Evaluate Sub Mesh related stage step action
  77949. */
  77950. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77951. /**
  77952. * Strong typing of a Active Mesh related stage step action
  77953. */
  77954. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77955. /**
  77956. * Strong typing of a Camera related stage step action
  77957. */
  77958. export type CameraStageAction = (camera: Camera) => void;
  77959. /**
  77960. * Strong typing of a Camera Frame buffer related stage step action
  77961. */
  77962. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77963. /**
  77964. * Strong typing of a Render Target related stage step action
  77965. */
  77966. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77967. /**
  77968. * Strong typing of a RenderingGroup related stage step action
  77969. */
  77970. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77971. /**
  77972. * Strong typing of a Mesh Render related stage step action
  77973. */
  77974. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77975. /**
  77976. * Strong typing of a simple stage step action
  77977. */
  77978. export type SimpleStageAction = () => void;
  77979. /**
  77980. * Strong typing of a render target action.
  77981. */
  77982. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  77983. /**
  77984. * Strong typing of a pointer move action.
  77985. */
  77986. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  77987. /**
  77988. * Strong typing of a pointer up/down action.
  77989. */
  77990. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  77991. /**
  77992. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  77993. * @hidden
  77994. */
  77995. export class Stage<T extends Function> extends Array<{
  77996. index: number;
  77997. component: ISceneComponent;
  77998. action: T;
  77999. }> {
  78000. /**
  78001. * Hide ctor from the rest of the world.
  78002. * @param items The items to add.
  78003. */
  78004. private constructor();
  78005. /**
  78006. * Creates a new Stage.
  78007. * @returns A new instance of a Stage
  78008. */
  78009. static Create<T extends Function>(): Stage<T>;
  78010. /**
  78011. * Registers a step in an ordered way in the targeted stage.
  78012. * @param index Defines the position to register the step in
  78013. * @param component Defines the component attached to the step
  78014. * @param action Defines the action to launch during the step
  78015. */
  78016. registerStep(index: number, component: ISceneComponent, action: T): void;
  78017. /**
  78018. * Clears all the steps from the stage.
  78019. */
  78020. clear(): void;
  78021. }
  78022. }
  78023. declare module BABYLON {
  78024. interface Scene {
  78025. /** @hidden */
  78026. _pointerOverSprite: Nullable<Sprite>;
  78027. /** @hidden */
  78028. _pickedDownSprite: Nullable<Sprite>;
  78029. /** @hidden */
  78030. _tempSpritePickingRay: Nullable<Ray>;
  78031. /**
  78032. * All of the sprite managers added to this scene
  78033. * @see http://doc.babylonjs.com/babylon101/sprites
  78034. */
  78035. spriteManagers: Array<ISpriteManager>;
  78036. /**
  78037. * An event triggered when sprites rendering is about to start
  78038. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78039. */
  78040. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78041. /**
  78042. * An event triggered when sprites rendering is done
  78043. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78044. */
  78045. onAfterSpritesRenderingObservable: Observable<Scene>;
  78046. /** @hidden */
  78047. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78048. /** Launch a ray to try to pick a sprite in the scene
  78049. * @param x position on screen
  78050. * @param y position on screen
  78051. * @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
  78052. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78053. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78054. * @returns a PickingInfo
  78055. */
  78056. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78057. /** Use the given ray to pick a sprite in the scene
  78058. * @param ray The ray (in world space) to use to pick meshes
  78059. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  78060. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78061. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78062. * @returns a PickingInfo
  78063. */
  78064. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78065. /** @hidden */
  78066. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78067. /** Launch a ray to try to pick sprites in the scene
  78068. * @param x position on screen
  78069. * @param y position on screen
  78070. * @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
  78071. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78072. * @returns a PickingInfo array
  78073. */
  78074. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78075. /** Use the given ray to pick sprites in the scene
  78076. * @param ray The ray (in world space) to use to pick meshes
  78077. * @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
  78078. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78079. * @returns a PickingInfo array
  78080. */
  78081. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78082. /**
  78083. * Force the sprite under the pointer
  78084. * @param sprite defines the sprite to use
  78085. */
  78086. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78087. /**
  78088. * Gets the sprite under the pointer
  78089. * @returns a Sprite or null if no sprite is under the pointer
  78090. */
  78091. getPointerOverSprite(): Nullable<Sprite>;
  78092. }
  78093. /**
  78094. * Defines the sprite scene component responsible to manage sprites
  78095. * in a given scene.
  78096. */
  78097. export class SpriteSceneComponent implements ISceneComponent {
  78098. /**
  78099. * The component name helpfull to identify the component in the list of scene components.
  78100. */
  78101. readonly name: string;
  78102. /**
  78103. * The scene the component belongs to.
  78104. */
  78105. scene: Scene;
  78106. /** @hidden */
  78107. private _spritePredicate;
  78108. /**
  78109. * Creates a new instance of the component for the given scene
  78110. * @param scene Defines the scene to register the component in
  78111. */
  78112. constructor(scene: Scene);
  78113. /**
  78114. * Registers the component in a given scene
  78115. */
  78116. register(): void;
  78117. /**
  78118. * Rebuilds the elements related to this component in case of
  78119. * context lost for instance.
  78120. */
  78121. rebuild(): void;
  78122. /**
  78123. * Disposes the component and the associated ressources.
  78124. */
  78125. dispose(): void;
  78126. private _pickSpriteButKeepRay;
  78127. private _pointerMove;
  78128. private _pointerDown;
  78129. private _pointerUp;
  78130. }
  78131. }
  78132. declare module BABYLON {
  78133. /** @hidden */
  78134. export var fogFragmentDeclaration: {
  78135. name: string;
  78136. shader: string;
  78137. };
  78138. }
  78139. declare module BABYLON {
  78140. /** @hidden */
  78141. export var fogFragment: {
  78142. name: string;
  78143. shader: string;
  78144. };
  78145. }
  78146. declare module BABYLON {
  78147. /** @hidden */
  78148. export var spritesPixelShader: {
  78149. name: string;
  78150. shader: string;
  78151. };
  78152. }
  78153. declare module BABYLON {
  78154. /** @hidden */
  78155. export var fogVertexDeclaration: {
  78156. name: string;
  78157. shader: string;
  78158. };
  78159. }
  78160. declare module BABYLON {
  78161. /** @hidden */
  78162. export var spritesVertexShader: {
  78163. name: string;
  78164. shader: string;
  78165. };
  78166. }
  78167. declare module BABYLON {
  78168. /**
  78169. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78170. */
  78171. export interface ISpriteManager extends IDisposable {
  78172. /**
  78173. * Restricts the camera to viewing objects with the same layerMask.
  78174. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78175. */
  78176. layerMask: number;
  78177. /**
  78178. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78179. */
  78180. isPickable: boolean;
  78181. /**
  78182. * Specifies the rendering group id for this mesh (0 by default)
  78183. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78184. */
  78185. renderingGroupId: number;
  78186. /**
  78187. * Defines the list of sprites managed by the manager.
  78188. */
  78189. sprites: Array<Sprite>;
  78190. /**
  78191. * Tests the intersection of a sprite with a specific ray.
  78192. * @param ray The ray we are sending to test the collision
  78193. * @param camera The camera space we are sending rays in
  78194. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78195. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78196. * @returns picking info or null.
  78197. */
  78198. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78199. /**
  78200. * Intersects the sprites with a ray
  78201. * @param ray defines the ray to intersect with
  78202. * @param camera defines the current active camera
  78203. * @param predicate defines a predicate used to select candidate sprites
  78204. * @returns null if no hit or a PickingInfo array
  78205. */
  78206. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78207. /**
  78208. * Renders the list of sprites on screen.
  78209. */
  78210. render(): void;
  78211. }
  78212. /**
  78213. * Class used to manage multiple sprites on the same spritesheet
  78214. * @see http://doc.babylonjs.com/babylon101/sprites
  78215. */
  78216. export class SpriteManager implements ISpriteManager {
  78217. /** defines the manager's name */
  78218. name: string;
  78219. /** Gets the list of sprites */
  78220. sprites: Sprite[];
  78221. /** Gets or sets the rendering group id (0 by default) */
  78222. renderingGroupId: number;
  78223. /** Gets or sets camera layer mask */
  78224. layerMask: number;
  78225. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78226. fogEnabled: boolean;
  78227. /** Gets or sets a boolean indicating if the sprites are pickable */
  78228. isPickable: boolean;
  78229. /** Defines the default width of a cell in the spritesheet */
  78230. cellWidth: number;
  78231. /** Defines the default height of a cell in the spritesheet */
  78232. cellHeight: number;
  78233. /** Associative array from JSON sprite data file */
  78234. private _cellData;
  78235. /** Array of sprite names from JSON sprite data file */
  78236. private _spriteMap;
  78237. /** True when packed cell data from JSON file is ready*/
  78238. private _packedAndReady;
  78239. /**
  78240. * An event triggered when the manager is disposed.
  78241. */
  78242. onDisposeObservable: Observable<SpriteManager>;
  78243. private _onDisposeObserver;
  78244. /**
  78245. * Callback called when the manager is disposed
  78246. */
  78247. onDispose: () => void;
  78248. private _capacity;
  78249. private _fromPacked;
  78250. private _spriteTexture;
  78251. private _epsilon;
  78252. private _scene;
  78253. private _vertexData;
  78254. private _buffer;
  78255. private _vertexBuffers;
  78256. private _indexBuffer;
  78257. private _effectBase;
  78258. private _effectFog;
  78259. /**
  78260. * Gets or sets the spritesheet texture
  78261. */
  78262. texture: Texture;
  78263. /**
  78264. * Creates a new sprite manager
  78265. * @param name defines the manager's name
  78266. * @param imgUrl defines the sprite sheet url
  78267. * @param capacity defines the maximum allowed number of sprites
  78268. * @param cellSize defines the size of a sprite cell
  78269. * @param scene defines the hosting scene
  78270. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78271. * @param samplingMode defines the smapling mode to use with spritesheet
  78272. * @param fromPacked set to false; do not alter
  78273. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78274. */
  78275. constructor(
  78276. /** defines the manager's name */
  78277. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78278. private _makePacked;
  78279. private _appendSpriteVertex;
  78280. /**
  78281. * Intersects the sprites with a ray
  78282. * @param ray defines the ray to intersect with
  78283. * @param camera defines the current active camera
  78284. * @param predicate defines a predicate used to select candidate sprites
  78285. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78286. * @returns null if no hit or a PickingInfo
  78287. */
  78288. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78289. /**
  78290. * Intersects the sprites with a ray
  78291. * @param ray defines the ray to intersect with
  78292. * @param camera defines the current active camera
  78293. * @param predicate defines a predicate used to select candidate sprites
  78294. * @returns null if no hit or a PickingInfo array
  78295. */
  78296. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78297. /**
  78298. * Render all child sprites
  78299. */
  78300. render(): void;
  78301. /**
  78302. * Release associated resources
  78303. */
  78304. dispose(): void;
  78305. }
  78306. }
  78307. declare module BABYLON {
  78308. /**
  78309. * Class used to represent a sprite
  78310. * @see http://doc.babylonjs.com/babylon101/sprites
  78311. */
  78312. export class Sprite {
  78313. /** defines the name */
  78314. name: string;
  78315. /** Gets or sets the current world position */
  78316. position: Vector3;
  78317. /** Gets or sets the main color */
  78318. color: Color4;
  78319. /** Gets or sets the width */
  78320. width: number;
  78321. /** Gets or sets the height */
  78322. height: number;
  78323. /** Gets or sets rotation angle */
  78324. angle: number;
  78325. /** Gets or sets the cell index in the sprite sheet */
  78326. cellIndex: number;
  78327. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78328. cellRef: string;
  78329. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78330. invertU: number;
  78331. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78332. invertV: number;
  78333. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78334. disposeWhenFinishedAnimating: boolean;
  78335. /** Gets the list of attached animations */
  78336. animations: Animation[];
  78337. /** Gets or sets a boolean indicating if the sprite can be picked */
  78338. isPickable: boolean;
  78339. /**
  78340. * Gets or sets the associated action manager
  78341. */
  78342. actionManager: Nullable<ActionManager>;
  78343. private _animationStarted;
  78344. private _loopAnimation;
  78345. private _fromIndex;
  78346. private _toIndex;
  78347. private _delay;
  78348. private _direction;
  78349. private _manager;
  78350. private _time;
  78351. private _onAnimationEnd;
  78352. /**
  78353. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78354. */
  78355. isVisible: boolean;
  78356. /**
  78357. * Gets or sets the sprite size
  78358. */
  78359. size: number;
  78360. /**
  78361. * Creates a new Sprite
  78362. * @param name defines the name
  78363. * @param manager defines the manager
  78364. */
  78365. constructor(
  78366. /** defines the name */
  78367. name: string, manager: ISpriteManager);
  78368. /**
  78369. * Starts an animation
  78370. * @param from defines the initial key
  78371. * @param to defines the end key
  78372. * @param loop defines if the animation must loop
  78373. * @param delay defines the start delay (in ms)
  78374. * @param onAnimationEnd defines a callback to call when animation ends
  78375. */
  78376. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78377. /** Stops current animation (if any) */
  78378. stopAnimation(): void;
  78379. /** @hidden */
  78380. _animate(deltaTime: number): void;
  78381. /** Release associated resources */
  78382. dispose(): void;
  78383. }
  78384. }
  78385. declare module BABYLON {
  78386. /**
  78387. * Information about the result of picking within a scene
  78388. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78389. */
  78390. export class PickingInfo {
  78391. /** @hidden */
  78392. _pickingUnavailable: boolean;
  78393. /**
  78394. * If the pick collided with an object
  78395. */
  78396. hit: boolean;
  78397. /**
  78398. * Distance away where the pick collided
  78399. */
  78400. distance: number;
  78401. /**
  78402. * The location of pick collision
  78403. */
  78404. pickedPoint: Nullable<Vector3>;
  78405. /**
  78406. * The mesh corresponding the the pick collision
  78407. */
  78408. pickedMesh: Nullable<AbstractMesh>;
  78409. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78410. bu: number;
  78411. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78412. bv: number;
  78413. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78414. faceId: number;
  78415. /** Id of the the submesh that was picked */
  78416. subMeshId: number;
  78417. /** If a sprite was picked, this will be the sprite the pick collided with */
  78418. pickedSprite: Nullable<Sprite>;
  78419. /**
  78420. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78421. */
  78422. originMesh: Nullable<AbstractMesh>;
  78423. /**
  78424. * The ray that was used to perform the picking.
  78425. */
  78426. ray: Nullable<Ray>;
  78427. /**
  78428. * Gets the normal correspodning to the face the pick collided with
  78429. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78430. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78431. * @returns The normal correspodning to the face the pick collided with
  78432. */
  78433. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78434. /**
  78435. * Gets the texture coordinates of where the pick occured
  78436. * @returns the vector containing the coordnates of the texture
  78437. */
  78438. getTextureCoordinates(): Nullable<Vector2>;
  78439. }
  78440. }
  78441. declare module BABYLON {
  78442. /**
  78443. * Gather the list of pointer event types as constants.
  78444. */
  78445. export class PointerEventTypes {
  78446. /**
  78447. * 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.
  78448. */
  78449. static readonly POINTERDOWN: number;
  78450. /**
  78451. * The pointerup event is fired when a pointer is no longer active.
  78452. */
  78453. static readonly POINTERUP: number;
  78454. /**
  78455. * The pointermove event is fired when a pointer changes coordinates.
  78456. */
  78457. static readonly POINTERMOVE: number;
  78458. /**
  78459. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78460. */
  78461. static readonly POINTERWHEEL: number;
  78462. /**
  78463. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78464. */
  78465. static readonly POINTERPICK: number;
  78466. /**
  78467. * The pointertap event is fired when a the object has been touched and released without drag.
  78468. */
  78469. static readonly POINTERTAP: number;
  78470. /**
  78471. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78472. */
  78473. static readonly POINTERDOUBLETAP: number;
  78474. }
  78475. /**
  78476. * Base class of pointer info types.
  78477. */
  78478. export class PointerInfoBase {
  78479. /**
  78480. * Defines the type of event (PointerEventTypes)
  78481. */
  78482. type: number;
  78483. /**
  78484. * Defines the related dom event
  78485. */
  78486. event: PointerEvent | MouseWheelEvent;
  78487. /**
  78488. * Instantiates the base class of pointers info.
  78489. * @param type Defines the type of event (PointerEventTypes)
  78490. * @param event Defines the related dom event
  78491. */
  78492. constructor(
  78493. /**
  78494. * Defines the type of event (PointerEventTypes)
  78495. */
  78496. type: number,
  78497. /**
  78498. * Defines the related dom event
  78499. */
  78500. event: PointerEvent | MouseWheelEvent);
  78501. }
  78502. /**
  78503. * This class is used to store pointer related info for the onPrePointerObservable event.
  78504. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78505. */
  78506. export class PointerInfoPre extends PointerInfoBase {
  78507. /**
  78508. * Ray from a pointer if availible (eg. 6dof controller)
  78509. */
  78510. ray: Nullable<Ray>;
  78511. /**
  78512. * Defines the local position of the pointer on the canvas.
  78513. */
  78514. localPosition: Vector2;
  78515. /**
  78516. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78517. */
  78518. skipOnPointerObservable: boolean;
  78519. /**
  78520. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78521. * @param type Defines the type of event (PointerEventTypes)
  78522. * @param event Defines the related dom event
  78523. * @param localX Defines the local x coordinates of the pointer when the event occured
  78524. * @param localY Defines the local y coordinates of the pointer when the event occured
  78525. */
  78526. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78527. }
  78528. /**
  78529. * This type contains all the data related to a pointer event in Babylon.js.
  78530. * 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.
  78531. */
  78532. export class PointerInfo extends PointerInfoBase {
  78533. /**
  78534. * Defines the picking info associated to the info (if any)\
  78535. */
  78536. pickInfo: Nullable<PickingInfo>;
  78537. /**
  78538. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78539. * @param type Defines the type of event (PointerEventTypes)
  78540. * @param event Defines the related dom event
  78541. * @param pickInfo Defines the picking info associated to the info (if any)\
  78542. */
  78543. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78544. /**
  78545. * Defines the picking info associated to the info (if any)\
  78546. */
  78547. pickInfo: Nullable<PickingInfo>);
  78548. }
  78549. /**
  78550. * Data relating to a touch event on the screen.
  78551. */
  78552. export interface PointerTouch {
  78553. /**
  78554. * X coordinate of touch.
  78555. */
  78556. x: number;
  78557. /**
  78558. * Y coordinate of touch.
  78559. */
  78560. y: number;
  78561. /**
  78562. * Id of touch. Unique for each finger.
  78563. */
  78564. pointerId: number;
  78565. /**
  78566. * Event type passed from DOM.
  78567. */
  78568. type: any;
  78569. }
  78570. }
  78571. declare module BABYLON {
  78572. /**
  78573. * Manage the mouse inputs to control the movement of a free camera.
  78574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78575. */
  78576. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78577. /**
  78578. * Define if touch is enabled in the mouse input
  78579. */
  78580. touchEnabled: boolean;
  78581. /**
  78582. * Defines the camera the input is attached to.
  78583. */
  78584. camera: FreeCamera;
  78585. /**
  78586. * Defines the buttons associated with the input to handle camera move.
  78587. */
  78588. buttons: number[];
  78589. /**
  78590. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78591. */
  78592. angularSensibility: number;
  78593. private _pointerInput;
  78594. private _onMouseMove;
  78595. private _observer;
  78596. private previousPosition;
  78597. /**
  78598. * Observable for when a pointer move event occurs containing the move offset
  78599. */
  78600. onPointerMovedObservable: Observable<{
  78601. offsetX: number;
  78602. offsetY: number;
  78603. }>;
  78604. /**
  78605. * @hidden
  78606. * If the camera should be rotated automatically based on pointer movement
  78607. */
  78608. _allowCameraRotation: boolean;
  78609. /**
  78610. * Manage the mouse inputs to control the movement of a free camera.
  78611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78612. * @param touchEnabled Defines if touch is enabled or not
  78613. */
  78614. constructor(
  78615. /**
  78616. * Define if touch is enabled in the mouse input
  78617. */
  78618. touchEnabled?: boolean);
  78619. /**
  78620. * Attach the input controls to a specific dom element to get the input from.
  78621. * @param element Defines the element the controls should be listened from
  78622. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78623. */
  78624. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78625. /**
  78626. * Called on JS contextmenu event.
  78627. * Override this method to provide functionality.
  78628. */
  78629. protected onContextMenu(evt: PointerEvent): void;
  78630. /**
  78631. * Detach the current controls from the specified dom element.
  78632. * @param element Defines the element to stop listening the inputs from
  78633. */
  78634. detachControl(element: Nullable<HTMLElement>): void;
  78635. /**
  78636. * Gets the class name of the current intput.
  78637. * @returns the class name
  78638. */
  78639. getClassName(): string;
  78640. /**
  78641. * Get the friendly name associated with the input class.
  78642. * @returns the input friendly name
  78643. */
  78644. getSimpleName(): string;
  78645. }
  78646. }
  78647. declare module BABYLON {
  78648. /**
  78649. * Manage the touch inputs to control the movement of a free camera.
  78650. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78651. */
  78652. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78653. /**
  78654. * Defines the camera the input is attached to.
  78655. */
  78656. camera: FreeCamera;
  78657. /**
  78658. * Defines the touch sensibility for rotation.
  78659. * The higher the faster.
  78660. */
  78661. touchAngularSensibility: number;
  78662. /**
  78663. * Defines the touch sensibility for move.
  78664. * The higher the faster.
  78665. */
  78666. touchMoveSensibility: number;
  78667. private _offsetX;
  78668. private _offsetY;
  78669. private _pointerPressed;
  78670. private _pointerInput;
  78671. private _observer;
  78672. private _onLostFocus;
  78673. /**
  78674. * Attach the input controls to a specific dom element to get the input from.
  78675. * @param element Defines the element the controls should be listened from
  78676. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78677. */
  78678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78679. /**
  78680. * Detach the current controls from the specified dom element.
  78681. * @param element Defines the element to stop listening the inputs from
  78682. */
  78683. detachControl(element: Nullable<HTMLElement>): void;
  78684. /**
  78685. * Update the current camera state depending on the inputs that have been used this frame.
  78686. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78687. */
  78688. checkInputs(): void;
  78689. /**
  78690. * Gets the class name of the current intput.
  78691. * @returns the class name
  78692. */
  78693. getClassName(): string;
  78694. /**
  78695. * Get the friendly name associated with the input class.
  78696. * @returns the input friendly name
  78697. */
  78698. getSimpleName(): string;
  78699. }
  78700. }
  78701. declare module BABYLON {
  78702. /**
  78703. * Default Inputs manager for the FreeCamera.
  78704. * It groups all the default supported inputs for ease of use.
  78705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78706. */
  78707. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78708. /**
  78709. * @hidden
  78710. */
  78711. _mouseInput: Nullable<FreeCameraMouseInput>;
  78712. /**
  78713. * Instantiates a new FreeCameraInputsManager.
  78714. * @param camera Defines the camera the inputs belong to
  78715. */
  78716. constructor(camera: FreeCamera);
  78717. /**
  78718. * Add keyboard input support to the input manager.
  78719. * @returns the current input manager
  78720. */
  78721. addKeyboard(): FreeCameraInputsManager;
  78722. /**
  78723. * Add mouse input support to the input manager.
  78724. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78725. * @returns the current input manager
  78726. */
  78727. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78728. /**
  78729. * Removes the mouse input support from the manager
  78730. * @returns the current input manager
  78731. */
  78732. removeMouse(): FreeCameraInputsManager;
  78733. /**
  78734. * Add touch input support to the input manager.
  78735. * @returns the current input manager
  78736. */
  78737. addTouch(): FreeCameraInputsManager;
  78738. /**
  78739. * Remove all attached input methods from a camera
  78740. */
  78741. clear(): void;
  78742. }
  78743. }
  78744. declare module BABYLON {
  78745. /**
  78746. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78747. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78748. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78749. */
  78750. export class FreeCamera extends TargetCamera {
  78751. /**
  78752. * Define the collision ellipsoid of the camera.
  78753. * This is helpful to simulate a camera body like the player body around the camera
  78754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78755. */
  78756. ellipsoid: Vector3;
  78757. /**
  78758. * Define an offset for the position of the ellipsoid around the camera.
  78759. * This can be helpful to determine the center of the body near the gravity center of the body
  78760. * instead of its head.
  78761. */
  78762. ellipsoidOffset: Vector3;
  78763. /**
  78764. * Enable or disable collisions of the camera with the rest of the scene objects.
  78765. */
  78766. checkCollisions: boolean;
  78767. /**
  78768. * Enable or disable gravity on the camera.
  78769. */
  78770. applyGravity: boolean;
  78771. /**
  78772. * Define the input manager associated to the camera.
  78773. */
  78774. inputs: FreeCameraInputsManager;
  78775. /**
  78776. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78777. * Higher values reduce sensitivity.
  78778. */
  78779. /**
  78780. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78781. * Higher values reduce sensitivity.
  78782. */
  78783. angularSensibility: number;
  78784. /**
  78785. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78786. */
  78787. keysUp: number[];
  78788. /**
  78789. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78790. */
  78791. keysDown: number[];
  78792. /**
  78793. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78794. */
  78795. keysLeft: number[];
  78796. /**
  78797. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78798. */
  78799. keysRight: number[];
  78800. /**
  78801. * Event raised when the camera collide with a mesh in the scene.
  78802. */
  78803. onCollide: (collidedMesh: AbstractMesh) => void;
  78804. private _collider;
  78805. private _needMoveForGravity;
  78806. private _oldPosition;
  78807. private _diffPosition;
  78808. private _newPosition;
  78809. /** @hidden */
  78810. _localDirection: Vector3;
  78811. /** @hidden */
  78812. _transformedDirection: Vector3;
  78813. /**
  78814. * Instantiates a Free Camera.
  78815. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78816. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78817. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78818. * @param name Define the name of the camera in the scene
  78819. * @param position Define the start position of the camera in the scene
  78820. * @param scene Define the scene the camera belongs to
  78821. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78822. */
  78823. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78824. /**
  78825. * Attached controls to the current camera.
  78826. * @param element Defines the element the controls should be listened from
  78827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78828. */
  78829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78830. /**
  78831. * Detach the current controls from the camera.
  78832. * The camera will stop reacting to inputs.
  78833. * @param element Defines the element to stop listening the inputs from
  78834. */
  78835. detachControl(element: HTMLElement): void;
  78836. private _collisionMask;
  78837. /**
  78838. * Define a collision mask to limit the list of object the camera can collide with
  78839. */
  78840. collisionMask: number;
  78841. /** @hidden */
  78842. _collideWithWorld(displacement: Vector3): void;
  78843. private _onCollisionPositionChange;
  78844. /** @hidden */
  78845. _checkInputs(): void;
  78846. /** @hidden */
  78847. _decideIfNeedsToMove(): boolean;
  78848. /** @hidden */
  78849. _updatePosition(): void;
  78850. /**
  78851. * Destroy the camera and release the current resources hold by it.
  78852. */
  78853. dispose(): void;
  78854. /**
  78855. * Gets the current object class name.
  78856. * @return the class name
  78857. */
  78858. getClassName(): string;
  78859. }
  78860. }
  78861. declare module BABYLON {
  78862. /**
  78863. * Represents a gamepad control stick position
  78864. */
  78865. export class StickValues {
  78866. /**
  78867. * The x component of the control stick
  78868. */
  78869. x: number;
  78870. /**
  78871. * The y component of the control stick
  78872. */
  78873. y: number;
  78874. /**
  78875. * Initializes the gamepad x and y control stick values
  78876. * @param x The x component of the gamepad control stick value
  78877. * @param y The y component of the gamepad control stick value
  78878. */
  78879. constructor(
  78880. /**
  78881. * The x component of the control stick
  78882. */
  78883. x: number,
  78884. /**
  78885. * The y component of the control stick
  78886. */
  78887. y: number);
  78888. }
  78889. /**
  78890. * An interface which manages callbacks for gamepad button changes
  78891. */
  78892. export interface GamepadButtonChanges {
  78893. /**
  78894. * Called when a gamepad has been changed
  78895. */
  78896. changed: boolean;
  78897. /**
  78898. * Called when a gamepad press event has been triggered
  78899. */
  78900. pressChanged: boolean;
  78901. /**
  78902. * Called when a touch event has been triggered
  78903. */
  78904. touchChanged: boolean;
  78905. /**
  78906. * Called when a value has changed
  78907. */
  78908. valueChanged: boolean;
  78909. }
  78910. /**
  78911. * Represents a gamepad
  78912. */
  78913. export class Gamepad {
  78914. /**
  78915. * The id of the gamepad
  78916. */
  78917. id: string;
  78918. /**
  78919. * The index of the gamepad
  78920. */
  78921. index: number;
  78922. /**
  78923. * The browser gamepad
  78924. */
  78925. browserGamepad: any;
  78926. /**
  78927. * Specifies what type of gamepad this represents
  78928. */
  78929. type: number;
  78930. private _leftStick;
  78931. private _rightStick;
  78932. /** @hidden */
  78933. _isConnected: boolean;
  78934. private _leftStickAxisX;
  78935. private _leftStickAxisY;
  78936. private _rightStickAxisX;
  78937. private _rightStickAxisY;
  78938. /**
  78939. * Triggered when the left control stick has been changed
  78940. */
  78941. private _onleftstickchanged;
  78942. /**
  78943. * Triggered when the right control stick has been changed
  78944. */
  78945. private _onrightstickchanged;
  78946. /**
  78947. * Represents a gamepad controller
  78948. */
  78949. static GAMEPAD: number;
  78950. /**
  78951. * Represents a generic controller
  78952. */
  78953. static GENERIC: number;
  78954. /**
  78955. * Represents an XBox controller
  78956. */
  78957. static XBOX: number;
  78958. /**
  78959. * Represents a pose-enabled controller
  78960. */
  78961. static POSE_ENABLED: number;
  78962. /**
  78963. * Represents an Dual Shock controller
  78964. */
  78965. static DUALSHOCK: number;
  78966. /**
  78967. * Specifies whether the left control stick should be Y-inverted
  78968. */
  78969. protected _invertLeftStickY: boolean;
  78970. /**
  78971. * Specifies if the gamepad has been connected
  78972. */
  78973. readonly isConnected: boolean;
  78974. /**
  78975. * Initializes the gamepad
  78976. * @param id The id of the gamepad
  78977. * @param index The index of the gamepad
  78978. * @param browserGamepad The browser gamepad
  78979. * @param leftStickX The x component of the left joystick
  78980. * @param leftStickY The y component of the left joystick
  78981. * @param rightStickX The x component of the right joystick
  78982. * @param rightStickY The y component of the right joystick
  78983. */
  78984. constructor(
  78985. /**
  78986. * The id of the gamepad
  78987. */
  78988. id: string,
  78989. /**
  78990. * The index of the gamepad
  78991. */
  78992. index: number,
  78993. /**
  78994. * The browser gamepad
  78995. */
  78996. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  78997. /**
  78998. * Callback triggered when the left joystick has changed
  78999. * @param callback
  79000. */
  79001. onleftstickchanged(callback: (values: StickValues) => void): void;
  79002. /**
  79003. * Callback triggered when the right joystick has changed
  79004. * @param callback
  79005. */
  79006. onrightstickchanged(callback: (values: StickValues) => void): void;
  79007. /**
  79008. * Gets the left joystick
  79009. */
  79010. /**
  79011. * Sets the left joystick values
  79012. */
  79013. leftStick: StickValues;
  79014. /**
  79015. * Gets the right joystick
  79016. */
  79017. /**
  79018. * Sets the right joystick value
  79019. */
  79020. rightStick: StickValues;
  79021. /**
  79022. * Updates the gamepad joystick positions
  79023. */
  79024. update(): void;
  79025. /**
  79026. * Disposes the gamepad
  79027. */
  79028. dispose(): void;
  79029. }
  79030. /**
  79031. * Represents a generic gamepad
  79032. */
  79033. export class GenericPad extends Gamepad {
  79034. private _buttons;
  79035. private _onbuttondown;
  79036. private _onbuttonup;
  79037. /**
  79038. * Observable triggered when a button has been pressed
  79039. */
  79040. onButtonDownObservable: Observable<number>;
  79041. /**
  79042. * Observable triggered when a button has been released
  79043. */
  79044. onButtonUpObservable: Observable<number>;
  79045. /**
  79046. * Callback triggered when a button has been pressed
  79047. * @param callback Called when a button has been pressed
  79048. */
  79049. onbuttondown(callback: (buttonPressed: number) => void): void;
  79050. /**
  79051. * Callback triggered when a button has been released
  79052. * @param callback Called when a button has been released
  79053. */
  79054. onbuttonup(callback: (buttonReleased: number) => void): void;
  79055. /**
  79056. * Initializes the generic gamepad
  79057. * @param id The id of the generic gamepad
  79058. * @param index The index of the generic gamepad
  79059. * @param browserGamepad The browser gamepad
  79060. */
  79061. constructor(id: string, index: number, browserGamepad: any);
  79062. private _setButtonValue;
  79063. /**
  79064. * Updates the generic gamepad
  79065. */
  79066. update(): void;
  79067. /**
  79068. * Disposes the generic gamepad
  79069. */
  79070. dispose(): void;
  79071. }
  79072. }
  79073. declare module BABYLON {
  79074. interface Engine {
  79075. /**
  79076. * Creates a raw texture
  79077. * @param data defines the data to store in the texture
  79078. * @param width defines the width of the texture
  79079. * @param height defines the height of the texture
  79080. * @param format defines the format of the data
  79081. * @param generateMipMaps defines if the engine should generate the mip levels
  79082. * @param invertY defines if data must be stored with Y axis inverted
  79083. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79084. * @param compression defines the compression used (null by default)
  79085. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79086. * @returns the raw texture inside an InternalTexture
  79087. */
  79088. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79089. /**
  79090. * Update a raw texture
  79091. * @param texture defines the texture to update
  79092. * @param data defines the data to store in the texture
  79093. * @param format defines the format of the data
  79094. * @param invertY defines if data must be stored with Y axis inverted
  79095. */
  79096. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79097. /**
  79098. * Update a raw texture
  79099. * @param texture defines the texture to update
  79100. * @param data defines the data to store in the texture
  79101. * @param format defines the format of the data
  79102. * @param invertY defines if data must be stored with Y axis inverted
  79103. * @param compression defines the compression used (null by default)
  79104. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79105. */
  79106. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79107. /**
  79108. * Creates a new raw cube texture
  79109. * @param data defines the array of data to use to create each face
  79110. * @param size defines the size of the textures
  79111. * @param format defines the format of the data
  79112. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79113. * @param generateMipMaps defines if the engine should generate the mip levels
  79114. * @param invertY defines if data must be stored with Y axis inverted
  79115. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79116. * @param compression defines the compression used (null by default)
  79117. * @returns the cube texture as an InternalTexture
  79118. */
  79119. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79120. /**
  79121. * Update a raw cube texture
  79122. * @param texture defines the texture to udpdate
  79123. * @param data defines the data to store
  79124. * @param format defines the data format
  79125. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79126. * @param invertY defines if data must be stored with Y axis inverted
  79127. */
  79128. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79129. /**
  79130. * Update a raw cube texture
  79131. * @param texture defines the texture to udpdate
  79132. * @param data defines the data to store
  79133. * @param format defines the data format
  79134. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79135. * @param invertY defines if data must be stored with Y axis inverted
  79136. * @param compression defines the compression used (null by default)
  79137. */
  79138. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79139. /**
  79140. * Update a raw cube texture
  79141. * @param texture defines the texture to udpdate
  79142. * @param data defines the data to store
  79143. * @param format defines the data format
  79144. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79145. * @param invertY defines if data must be stored with Y axis inverted
  79146. * @param compression defines the compression used (null by default)
  79147. * @param level defines which level of the texture to update
  79148. */
  79149. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79150. /**
  79151. * Creates a new raw cube texture from a specified url
  79152. * @param url defines the url where the data is located
  79153. * @param scene defines the current scene
  79154. * @param size defines the size of the textures
  79155. * @param format defines the format of the data
  79156. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79157. * @param noMipmap defines if the engine should avoid generating the mip levels
  79158. * @param callback defines a callback used to extract texture data from loaded data
  79159. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79160. * @param onLoad defines a callback called when texture is loaded
  79161. * @param onError defines a callback called if there is an error
  79162. * @returns the cube texture as an InternalTexture
  79163. */
  79164. 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;
  79165. /**
  79166. * Creates a new raw cube texture from a specified url
  79167. * @param url defines the url where the data is located
  79168. * @param scene defines the current scene
  79169. * @param size defines the size of the textures
  79170. * @param format defines the format of the data
  79171. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79172. * @param noMipmap defines if the engine should avoid generating the mip levels
  79173. * @param callback defines a callback used to extract texture data from loaded data
  79174. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79175. * @param onLoad defines a callback called when texture is loaded
  79176. * @param onError defines a callback called if there is an error
  79177. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79178. * @param invertY defines if data must be stored with Y axis inverted
  79179. * @returns the cube texture as an InternalTexture
  79180. */
  79181. 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;
  79182. /**
  79183. * Creates a new raw 3D texture
  79184. * @param data defines the data used to create the texture
  79185. * @param width defines the width of the texture
  79186. * @param height defines the height of the texture
  79187. * @param depth defines the depth of the texture
  79188. * @param format defines the format of the texture
  79189. * @param generateMipMaps defines if the engine must generate mip levels
  79190. * @param invertY defines if data must be stored with Y axis inverted
  79191. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79192. * @param compression defines the compressed used (can be null)
  79193. * @param textureType defines the compressed used (can be null)
  79194. * @returns a new raw 3D texture (stored in an InternalTexture)
  79195. */
  79196. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79197. /**
  79198. * Update a raw 3D texture
  79199. * @param texture defines the texture to update
  79200. * @param data defines the data to store
  79201. * @param format defines the data format
  79202. * @param invertY defines if data must be stored with Y axis inverted
  79203. */
  79204. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79205. /**
  79206. * Update a raw 3D texture
  79207. * @param texture defines the texture to update
  79208. * @param data defines the data to store
  79209. * @param format defines the data format
  79210. * @param invertY defines if data must be stored with Y axis inverted
  79211. * @param compression defines the used compression (can be null)
  79212. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79213. */
  79214. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79215. }
  79216. }
  79217. declare module BABYLON {
  79218. /**
  79219. * Raw texture can help creating a texture directly from an array of data.
  79220. * This can be super useful if you either get the data from an uncompressed source or
  79221. * if you wish to create your texture pixel by pixel.
  79222. */
  79223. export class RawTexture extends Texture {
  79224. /**
  79225. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79226. */
  79227. format: number;
  79228. private _engine;
  79229. /**
  79230. * Instantiates a new RawTexture.
  79231. * Raw texture can help creating a texture directly from an array of data.
  79232. * This can be super useful if you either get the data from an uncompressed source or
  79233. * if you wish to create your texture pixel by pixel.
  79234. * @param data define the array of data to use to create the texture
  79235. * @param width define the width of the texture
  79236. * @param height define the height of the texture
  79237. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79238. * @param scene define the scene the texture belongs to
  79239. * @param generateMipMaps define whether mip maps should be generated or not
  79240. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79241. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79242. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79243. */
  79244. constructor(data: ArrayBufferView, width: number, height: number,
  79245. /**
  79246. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79247. */
  79248. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79249. /**
  79250. * Updates the texture underlying data.
  79251. * @param data Define the new data of the texture
  79252. */
  79253. update(data: ArrayBufferView): void;
  79254. /**
  79255. * Creates a luminance texture from some data.
  79256. * @param data Define the texture data
  79257. * @param width Define the width of the texture
  79258. * @param height Define the height of the texture
  79259. * @param scene Define the scene the texture belongs to
  79260. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79261. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79262. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79263. * @returns the luminance texture
  79264. */
  79265. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79266. /**
  79267. * Creates a luminance alpha texture from some data.
  79268. * @param data Define the texture data
  79269. * @param width Define the width of the texture
  79270. * @param height Define the height of the texture
  79271. * @param scene Define the scene the texture belongs to
  79272. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79273. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79274. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79275. * @returns the luminance alpha texture
  79276. */
  79277. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79278. /**
  79279. * Creates an alpha texture from some data.
  79280. * @param data Define the texture data
  79281. * @param width Define the width of the texture
  79282. * @param height Define the height of the texture
  79283. * @param scene Define the scene the texture belongs to
  79284. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79285. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79286. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79287. * @returns the alpha texture
  79288. */
  79289. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79290. /**
  79291. * Creates a RGB texture from some data.
  79292. * @param data Define the texture data
  79293. * @param width Define the width of the texture
  79294. * @param height Define the height of the texture
  79295. * @param scene Define the scene the texture belongs to
  79296. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79297. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79298. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79299. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79300. * @returns the RGB alpha texture
  79301. */
  79302. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79303. /**
  79304. * Creates a RGBA texture from some data.
  79305. * @param data Define the texture data
  79306. * @param width Define the width of the texture
  79307. * @param height Define the height of the texture
  79308. * @param scene Define the scene the texture belongs to
  79309. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79310. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79311. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79312. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79313. * @returns the RGBA texture
  79314. */
  79315. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79316. /**
  79317. * Creates a R texture from some data.
  79318. * @param data Define the texture data
  79319. * @param width Define the width of the texture
  79320. * @param height Define the height of the texture
  79321. * @param scene Define the scene the texture belongs to
  79322. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79323. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79324. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79325. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79326. * @returns the R texture
  79327. */
  79328. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79329. }
  79330. }
  79331. declare module BABYLON {
  79332. /**
  79333. * Interface for the size containing width and height
  79334. */
  79335. export interface ISize {
  79336. /**
  79337. * Width
  79338. */
  79339. width: number;
  79340. /**
  79341. * Heighht
  79342. */
  79343. height: number;
  79344. }
  79345. /**
  79346. * Size containing widht and height
  79347. */
  79348. export class Size implements ISize {
  79349. /**
  79350. * Width
  79351. */
  79352. width: number;
  79353. /**
  79354. * Height
  79355. */
  79356. height: number;
  79357. /**
  79358. * Creates a Size object from the given width and height (floats).
  79359. * @param width width of the new size
  79360. * @param height height of the new size
  79361. */
  79362. constructor(width: number, height: number);
  79363. /**
  79364. * Returns a string with the Size width and height
  79365. * @returns a string with the Size width and height
  79366. */
  79367. toString(): string;
  79368. /**
  79369. * "Size"
  79370. * @returns the string "Size"
  79371. */
  79372. getClassName(): string;
  79373. /**
  79374. * Returns the Size hash code.
  79375. * @returns a hash code for a unique width and height
  79376. */
  79377. getHashCode(): number;
  79378. /**
  79379. * Updates the current size from the given one.
  79380. * @param src the given size
  79381. */
  79382. copyFrom(src: Size): void;
  79383. /**
  79384. * Updates in place the current Size from the given floats.
  79385. * @param width width of the new size
  79386. * @param height height of the new size
  79387. * @returns the updated Size.
  79388. */
  79389. copyFromFloats(width: number, height: number): Size;
  79390. /**
  79391. * Updates in place the current Size from the given floats.
  79392. * @param width width to set
  79393. * @param height height to set
  79394. * @returns the updated Size.
  79395. */
  79396. set(width: number, height: number): Size;
  79397. /**
  79398. * Multiplies the width and height by numbers
  79399. * @param w factor to multiple the width by
  79400. * @param h factor to multiple the height by
  79401. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79402. */
  79403. multiplyByFloats(w: number, h: number): Size;
  79404. /**
  79405. * Clones the size
  79406. * @returns a new Size copied from the given one.
  79407. */
  79408. clone(): Size;
  79409. /**
  79410. * True if the current Size and the given one width and height are strictly equal.
  79411. * @param other the other size to compare against
  79412. * @returns True if the current Size and the given one width and height are strictly equal.
  79413. */
  79414. equals(other: Size): boolean;
  79415. /**
  79416. * The surface of the Size : width * height (float).
  79417. */
  79418. readonly surface: number;
  79419. /**
  79420. * Create a new size of zero
  79421. * @returns a new Size set to (0.0, 0.0)
  79422. */
  79423. static Zero(): Size;
  79424. /**
  79425. * Sums the width and height of two sizes
  79426. * @param otherSize size to add to this size
  79427. * @returns a new Size set as the addition result of the current Size and the given one.
  79428. */
  79429. add(otherSize: Size): Size;
  79430. /**
  79431. * Subtracts the width and height of two
  79432. * @param otherSize size to subtract to this size
  79433. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79434. */
  79435. subtract(otherSize: Size): Size;
  79436. /**
  79437. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79438. * @param start starting size to lerp between
  79439. * @param end end size to lerp between
  79440. * @param amount amount to lerp between the start and end values
  79441. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79442. */
  79443. static Lerp(start: Size, end: Size, amount: number): Size;
  79444. }
  79445. }
  79446. declare module BABYLON {
  79447. /**
  79448. * Defines a runtime animation
  79449. */
  79450. export class RuntimeAnimation {
  79451. private _events;
  79452. /**
  79453. * The current frame of the runtime animation
  79454. */
  79455. private _currentFrame;
  79456. /**
  79457. * The animation used by the runtime animation
  79458. */
  79459. private _animation;
  79460. /**
  79461. * The target of the runtime animation
  79462. */
  79463. private _target;
  79464. /**
  79465. * The initiating animatable
  79466. */
  79467. private _host;
  79468. /**
  79469. * The original value of the runtime animation
  79470. */
  79471. private _originalValue;
  79472. /**
  79473. * The original blend value of the runtime animation
  79474. */
  79475. private _originalBlendValue;
  79476. /**
  79477. * The offsets cache of the runtime animation
  79478. */
  79479. private _offsetsCache;
  79480. /**
  79481. * The high limits cache of the runtime animation
  79482. */
  79483. private _highLimitsCache;
  79484. /**
  79485. * Specifies if the runtime animation has been stopped
  79486. */
  79487. private _stopped;
  79488. /**
  79489. * The blending factor of the runtime animation
  79490. */
  79491. private _blendingFactor;
  79492. /**
  79493. * The BabylonJS scene
  79494. */
  79495. private _scene;
  79496. /**
  79497. * The current value of the runtime animation
  79498. */
  79499. private _currentValue;
  79500. /** @hidden */
  79501. _animationState: _IAnimationState;
  79502. /**
  79503. * The active target of the runtime animation
  79504. */
  79505. private _activeTargets;
  79506. private _currentActiveTarget;
  79507. private _directTarget;
  79508. /**
  79509. * The target path of the runtime animation
  79510. */
  79511. private _targetPath;
  79512. /**
  79513. * The weight of the runtime animation
  79514. */
  79515. private _weight;
  79516. /**
  79517. * The ratio offset of the runtime animation
  79518. */
  79519. private _ratioOffset;
  79520. /**
  79521. * The previous delay of the runtime animation
  79522. */
  79523. private _previousDelay;
  79524. /**
  79525. * The previous ratio of the runtime animation
  79526. */
  79527. private _previousRatio;
  79528. private _enableBlending;
  79529. private _keys;
  79530. private _minFrame;
  79531. private _maxFrame;
  79532. private _minValue;
  79533. private _maxValue;
  79534. private _targetIsArray;
  79535. /**
  79536. * Gets the current frame of the runtime animation
  79537. */
  79538. readonly currentFrame: number;
  79539. /**
  79540. * Gets the weight of the runtime animation
  79541. */
  79542. readonly weight: number;
  79543. /**
  79544. * Gets the current value of the runtime animation
  79545. */
  79546. readonly currentValue: any;
  79547. /**
  79548. * Gets the target path of the runtime animation
  79549. */
  79550. readonly targetPath: string;
  79551. /**
  79552. * Gets the actual target of the runtime animation
  79553. */
  79554. readonly target: any;
  79555. /** @hidden */
  79556. _onLoop: () => void;
  79557. /**
  79558. * Create a new RuntimeAnimation object
  79559. * @param target defines the target of the animation
  79560. * @param animation defines the source animation object
  79561. * @param scene defines the hosting scene
  79562. * @param host defines the initiating Animatable
  79563. */
  79564. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79565. private _preparePath;
  79566. /**
  79567. * Gets the animation from the runtime animation
  79568. */
  79569. readonly animation: Animation;
  79570. /**
  79571. * Resets the runtime animation to the beginning
  79572. * @param restoreOriginal defines whether to restore the target property to the original value
  79573. */
  79574. reset(restoreOriginal?: boolean): void;
  79575. /**
  79576. * Specifies if the runtime animation is stopped
  79577. * @returns Boolean specifying if the runtime animation is stopped
  79578. */
  79579. isStopped(): boolean;
  79580. /**
  79581. * Disposes of the runtime animation
  79582. */
  79583. dispose(): void;
  79584. /**
  79585. * Apply the interpolated value to the target
  79586. * @param currentValue defines the value computed by the animation
  79587. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79588. */
  79589. setValue(currentValue: any, weight: number): void;
  79590. private _getOriginalValues;
  79591. private _setValue;
  79592. /**
  79593. * Gets the loop pmode of the runtime animation
  79594. * @returns Loop Mode
  79595. */
  79596. private _getCorrectLoopMode;
  79597. /**
  79598. * Move the current animation to a given frame
  79599. * @param frame defines the frame to move to
  79600. */
  79601. goToFrame(frame: number): void;
  79602. /**
  79603. * @hidden Internal use only
  79604. */
  79605. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79606. /**
  79607. * Execute the current animation
  79608. * @param delay defines the delay to add to the current frame
  79609. * @param from defines the lower bound of the animation range
  79610. * @param to defines the upper bound of the animation range
  79611. * @param loop defines if the current animation must loop
  79612. * @param speedRatio defines the current speed ratio
  79613. * @param weight defines the weight of the animation (default is -1 so no weight)
  79614. * @param onLoop optional callback called when animation loops
  79615. * @returns a boolean indicating if the animation is running
  79616. */
  79617. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79618. }
  79619. }
  79620. declare module BABYLON {
  79621. /**
  79622. * Class used to store an actual running animation
  79623. */
  79624. export class Animatable {
  79625. /** defines the target object */
  79626. target: any;
  79627. /** defines the starting frame number (default is 0) */
  79628. fromFrame: number;
  79629. /** defines the ending frame number (default is 100) */
  79630. toFrame: number;
  79631. /** defines if the animation must loop (default is false) */
  79632. loopAnimation: boolean;
  79633. /** defines a callback to call when animation ends if it is not looping */
  79634. onAnimationEnd?: (() => void) | null | undefined;
  79635. /** defines a callback to call when animation loops */
  79636. onAnimationLoop?: (() => void) | null | undefined;
  79637. private _localDelayOffset;
  79638. private _pausedDelay;
  79639. private _runtimeAnimations;
  79640. private _paused;
  79641. private _scene;
  79642. private _speedRatio;
  79643. private _weight;
  79644. private _syncRoot;
  79645. /**
  79646. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79647. * This will only apply for non looping animation (default is true)
  79648. */
  79649. disposeOnEnd: boolean;
  79650. /**
  79651. * Gets a boolean indicating if the animation has started
  79652. */
  79653. animationStarted: boolean;
  79654. /**
  79655. * Observer raised when the animation ends
  79656. */
  79657. onAnimationEndObservable: Observable<Animatable>;
  79658. /**
  79659. * Observer raised when the animation loops
  79660. */
  79661. onAnimationLoopObservable: Observable<Animatable>;
  79662. /**
  79663. * Gets the root Animatable used to synchronize and normalize animations
  79664. */
  79665. readonly syncRoot: Nullable<Animatable>;
  79666. /**
  79667. * Gets the current frame of the first RuntimeAnimation
  79668. * Used to synchronize Animatables
  79669. */
  79670. readonly masterFrame: number;
  79671. /**
  79672. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79673. */
  79674. weight: number;
  79675. /**
  79676. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79677. */
  79678. speedRatio: number;
  79679. /**
  79680. * Creates a new Animatable
  79681. * @param scene defines the hosting scene
  79682. * @param target defines the target object
  79683. * @param fromFrame defines the starting frame number (default is 0)
  79684. * @param toFrame defines the ending frame number (default is 100)
  79685. * @param loopAnimation defines if the animation must loop (default is false)
  79686. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79687. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79688. * @param animations defines a group of animation to add to the new Animatable
  79689. * @param onAnimationLoop defines a callback to call when animation loops
  79690. */
  79691. constructor(scene: Scene,
  79692. /** defines the target object */
  79693. target: any,
  79694. /** defines the starting frame number (default is 0) */
  79695. fromFrame?: number,
  79696. /** defines the ending frame number (default is 100) */
  79697. toFrame?: number,
  79698. /** defines if the animation must loop (default is false) */
  79699. loopAnimation?: boolean, speedRatio?: number,
  79700. /** defines a callback to call when animation ends if it is not looping */
  79701. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79702. /** defines a callback to call when animation loops */
  79703. onAnimationLoop?: (() => void) | null | undefined);
  79704. /**
  79705. * Synchronize and normalize current Animatable with a source Animatable
  79706. * This is useful when using animation weights and when animations are not of the same length
  79707. * @param root defines the root Animatable to synchronize with
  79708. * @returns the current Animatable
  79709. */
  79710. syncWith(root: Animatable): Animatable;
  79711. /**
  79712. * Gets the list of runtime animations
  79713. * @returns an array of RuntimeAnimation
  79714. */
  79715. getAnimations(): RuntimeAnimation[];
  79716. /**
  79717. * Adds more animations to the current animatable
  79718. * @param target defines the target of the animations
  79719. * @param animations defines the new animations to add
  79720. */
  79721. appendAnimations(target: any, animations: Animation[]): void;
  79722. /**
  79723. * Gets the source animation for a specific property
  79724. * @param property defines the propertyu to look for
  79725. * @returns null or the source animation for the given property
  79726. */
  79727. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79728. /**
  79729. * Gets the runtime animation for a specific property
  79730. * @param property defines the propertyu to look for
  79731. * @returns null or the runtime animation for the given property
  79732. */
  79733. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79734. /**
  79735. * Resets the animatable to its original state
  79736. */
  79737. reset(): void;
  79738. /**
  79739. * Allows the animatable to blend with current running animations
  79740. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79741. * @param blendingSpeed defines the blending speed to use
  79742. */
  79743. enableBlending(blendingSpeed: number): void;
  79744. /**
  79745. * Disable animation blending
  79746. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79747. */
  79748. disableBlending(): void;
  79749. /**
  79750. * Jump directly to a given frame
  79751. * @param frame defines the frame to jump to
  79752. */
  79753. goToFrame(frame: number): void;
  79754. /**
  79755. * Pause the animation
  79756. */
  79757. pause(): void;
  79758. /**
  79759. * Restart the animation
  79760. */
  79761. restart(): void;
  79762. private _raiseOnAnimationEnd;
  79763. /**
  79764. * Stop and delete the current animation
  79765. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79766. * @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)
  79767. */
  79768. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79769. /**
  79770. * Wait asynchronously for the animation to end
  79771. * @returns a promise which will be fullfilled when the animation ends
  79772. */
  79773. waitAsync(): Promise<Animatable>;
  79774. /** @hidden */
  79775. _animate(delay: number): boolean;
  79776. }
  79777. interface Scene {
  79778. /** @hidden */
  79779. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79780. /** @hidden */
  79781. _processLateAnimationBindingsForMatrices(holder: {
  79782. totalWeight: number;
  79783. animations: RuntimeAnimation[];
  79784. originalValue: Matrix;
  79785. }): any;
  79786. /** @hidden */
  79787. _processLateAnimationBindingsForQuaternions(holder: {
  79788. totalWeight: number;
  79789. animations: RuntimeAnimation[];
  79790. originalValue: Quaternion;
  79791. }, refQuaternion: Quaternion): Quaternion;
  79792. /** @hidden */
  79793. _processLateAnimationBindings(): void;
  79794. /**
  79795. * Will start the animation sequence of a given target
  79796. * @param target defines the target
  79797. * @param from defines from which frame should animation start
  79798. * @param to defines until which frame should animation run.
  79799. * @param weight defines the weight to apply to the animation (1.0 by default)
  79800. * @param loop defines if the animation loops
  79801. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79802. * @param onAnimationEnd defines the function to be executed when the animation ends
  79803. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79804. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79805. * @param onAnimationLoop defines the callback to call when an animation loops
  79806. * @returns the animatable object created for this animation
  79807. */
  79808. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79809. /**
  79810. * Will start the animation sequence of a given target
  79811. * @param target defines the target
  79812. * @param from defines from which frame should animation start
  79813. * @param to defines until which frame should animation run.
  79814. * @param loop defines if the animation loops
  79815. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79816. * @param onAnimationEnd defines the function to be executed when the animation ends
  79817. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79818. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79819. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79820. * @param onAnimationLoop defines the callback to call when an animation loops
  79821. * @returns the animatable object created for this animation
  79822. */
  79823. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79824. /**
  79825. * Will start the animation sequence of a given target and its hierarchy
  79826. * @param target defines the target
  79827. * @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.
  79828. * @param from defines from which frame should animation start
  79829. * @param to defines until which frame should animation run.
  79830. * @param loop defines if the animation loops
  79831. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79832. * @param onAnimationEnd defines the function to be executed when the animation ends
  79833. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79834. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79835. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79836. * @param onAnimationLoop defines the callback to call when an animation loops
  79837. * @returns the list of created animatables
  79838. */
  79839. 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[];
  79840. /**
  79841. * Begin a new animation on a given node
  79842. * @param target defines the target where the animation will take place
  79843. * @param animations defines the list of animations to start
  79844. * @param from defines the initial value
  79845. * @param to defines the final value
  79846. * @param loop defines if you want animation to loop (off by default)
  79847. * @param speedRatio defines the speed ratio to apply to all animations
  79848. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79849. * @param onAnimationLoop defines the callback to call when an animation loops
  79850. * @returns the list of created animatables
  79851. */
  79852. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79853. /**
  79854. * Begin a new animation on a given node and its hierarchy
  79855. * @param target defines the root node where the animation will take place
  79856. * @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.
  79857. * @param animations defines the list of animations to start
  79858. * @param from defines the initial value
  79859. * @param to defines the final value
  79860. * @param loop defines if you want animation to loop (off by default)
  79861. * @param speedRatio defines the speed ratio to apply to all animations
  79862. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79863. * @param onAnimationLoop defines the callback to call when an animation loops
  79864. * @returns the list of animatables created for all nodes
  79865. */
  79866. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79867. /**
  79868. * Gets the animatable associated with a specific target
  79869. * @param target defines the target of the animatable
  79870. * @returns the required animatable if found
  79871. */
  79872. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79873. /**
  79874. * Gets all animatables associated with a given target
  79875. * @param target defines the target to look animatables for
  79876. * @returns an array of Animatables
  79877. */
  79878. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79879. /**
  79880. * Stops and removes all animations that have been applied to the scene
  79881. */
  79882. stopAllAnimations(): void;
  79883. /**
  79884. * Gets the current delta time used by animation engine
  79885. */
  79886. deltaTime: number;
  79887. }
  79888. interface Bone {
  79889. /**
  79890. * Copy an animation range from another bone
  79891. * @param source defines the source bone
  79892. * @param rangeName defines the range name to copy
  79893. * @param frameOffset defines the frame offset
  79894. * @param rescaleAsRequired defines if rescaling must be applied if required
  79895. * @param skelDimensionsRatio defines the scaling ratio
  79896. * @returns true if operation was successful
  79897. */
  79898. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79899. }
  79900. }
  79901. declare module BABYLON {
  79902. /**
  79903. * Class used to override all child animations of a given target
  79904. */
  79905. export class AnimationPropertiesOverride {
  79906. /**
  79907. * Gets or sets a value indicating if animation blending must be used
  79908. */
  79909. enableBlending: boolean;
  79910. /**
  79911. * Gets or sets the blending speed to use when enableBlending is true
  79912. */
  79913. blendingSpeed: number;
  79914. /**
  79915. * Gets or sets the default loop mode to use
  79916. */
  79917. loopMode: number;
  79918. }
  79919. }
  79920. declare module BABYLON {
  79921. /**
  79922. * Class used to handle skinning animations
  79923. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79924. */
  79925. export class Skeleton implements IAnimatable {
  79926. /** defines the skeleton name */
  79927. name: string;
  79928. /** defines the skeleton Id */
  79929. id: string;
  79930. /**
  79931. * Defines the list of child bones
  79932. */
  79933. bones: Bone[];
  79934. /**
  79935. * Defines an estimate of the dimension of the skeleton at rest
  79936. */
  79937. dimensionsAtRest: Vector3;
  79938. /**
  79939. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79940. */
  79941. needInitialSkinMatrix: boolean;
  79942. /**
  79943. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79944. */
  79945. overrideMesh: Nullable<AbstractMesh>;
  79946. /**
  79947. * Gets the list of animations attached to this skeleton
  79948. */
  79949. animations: Array<Animation>;
  79950. private _scene;
  79951. private _isDirty;
  79952. private _transformMatrices;
  79953. private _transformMatrixTexture;
  79954. private _meshesWithPoseMatrix;
  79955. private _animatables;
  79956. private _identity;
  79957. private _synchronizedWithMesh;
  79958. private _ranges;
  79959. private _lastAbsoluteTransformsUpdateId;
  79960. private _canUseTextureForBones;
  79961. private _uniqueId;
  79962. /** @hidden */
  79963. _numBonesWithLinkedTransformNode: number;
  79964. /** @hidden */
  79965. _hasWaitingData: Nullable<boolean>;
  79966. /**
  79967. * Specifies if the skeleton should be serialized
  79968. */
  79969. doNotSerialize: boolean;
  79970. private _useTextureToStoreBoneMatrices;
  79971. /**
  79972. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79973. * Please note that this option is not available if the hardware does not support it
  79974. */
  79975. useTextureToStoreBoneMatrices: boolean;
  79976. private _animationPropertiesOverride;
  79977. /**
  79978. * Gets or sets the animation properties override
  79979. */
  79980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  79981. /**
  79982. * List of inspectable custom properties (used by the Inspector)
  79983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  79984. */
  79985. inspectableCustomProperties: IInspectable[];
  79986. /**
  79987. * An observable triggered before computing the skeleton's matrices
  79988. */
  79989. onBeforeComputeObservable: Observable<Skeleton>;
  79990. /**
  79991. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  79992. */
  79993. readonly isUsingTextureForMatrices: boolean;
  79994. /**
  79995. * Gets the unique ID of this skeleton
  79996. */
  79997. readonly uniqueId: number;
  79998. /**
  79999. * Creates a new skeleton
  80000. * @param name defines the skeleton name
  80001. * @param id defines the skeleton Id
  80002. * @param scene defines the hosting scene
  80003. */
  80004. constructor(
  80005. /** defines the skeleton name */
  80006. name: string,
  80007. /** defines the skeleton Id */
  80008. id: string, scene: Scene);
  80009. /**
  80010. * Gets the current object class name.
  80011. * @return the class name
  80012. */
  80013. getClassName(): string;
  80014. /**
  80015. * Returns an array containing the root bones
  80016. * @returns an array containing the root bones
  80017. */
  80018. getChildren(): Array<Bone>;
  80019. /**
  80020. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80021. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80022. * @returns a Float32Array containing matrices data
  80023. */
  80024. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80025. /**
  80026. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80027. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80028. * @returns a raw texture containing the data
  80029. */
  80030. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80031. /**
  80032. * Gets the current hosting scene
  80033. * @returns a scene object
  80034. */
  80035. getScene(): Scene;
  80036. /**
  80037. * Gets a string representing the current skeleton data
  80038. * @param fullDetails defines a boolean indicating if we want a verbose version
  80039. * @returns a string representing the current skeleton data
  80040. */
  80041. toString(fullDetails?: boolean): string;
  80042. /**
  80043. * Get bone's index searching by name
  80044. * @param name defines bone's name to search for
  80045. * @return the indice of the bone. Returns -1 if not found
  80046. */
  80047. getBoneIndexByName(name: string): number;
  80048. /**
  80049. * Creater a new animation range
  80050. * @param name defines the name of the range
  80051. * @param from defines the start key
  80052. * @param to defines the end key
  80053. */
  80054. createAnimationRange(name: string, from: number, to: number): void;
  80055. /**
  80056. * Delete a specific animation range
  80057. * @param name defines the name of the range
  80058. * @param deleteFrames defines if frames must be removed as well
  80059. */
  80060. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80061. /**
  80062. * Gets a specific animation range
  80063. * @param name defines the name of the range to look for
  80064. * @returns the requested animation range or null if not found
  80065. */
  80066. getAnimationRange(name: string): Nullable<AnimationRange>;
  80067. /**
  80068. * Gets the list of all animation ranges defined on this skeleton
  80069. * @returns an array
  80070. */
  80071. getAnimationRanges(): Nullable<AnimationRange>[];
  80072. /**
  80073. * Copy animation range from a source skeleton.
  80074. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80075. * @param source defines the source skeleton
  80076. * @param name defines the name of the range to copy
  80077. * @param rescaleAsRequired defines if rescaling must be applied if required
  80078. * @returns true if operation was successful
  80079. */
  80080. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80081. /**
  80082. * Forces the skeleton to go to rest pose
  80083. */
  80084. returnToRest(): void;
  80085. private _getHighestAnimationFrame;
  80086. /**
  80087. * Begin a specific animation range
  80088. * @param name defines the name of the range to start
  80089. * @param loop defines if looping must be turned on (false by default)
  80090. * @param speedRatio defines the speed ratio to apply (1 by default)
  80091. * @param onAnimationEnd defines a callback which will be called when animation will end
  80092. * @returns a new animatable
  80093. */
  80094. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80095. /** @hidden */
  80096. _markAsDirty(): void;
  80097. /** @hidden */
  80098. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80099. /** @hidden */
  80100. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80101. private _computeTransformMatrices;
  80102. /**
  80103. * Build all resources required to render a skeleton
  80104. */
  80105. prepare(): void;
  80106. /**
  80107. * Gets the list of animatables currently running for this skeleton
  80108. * @returns an array of animatables
  80109. */
  80110. getAnimatables(): IAnimatable[];
  80111. /**
  80112. * Clone the current skeleton
  80113. * @param name defines the name of the new skeleton
  80114. * @param id defines the id of the new skeleton
  80115. * @returns the new skeleton
  80116. */
  80117. clone(name: string, id: string): Skeleton;
  80118. /**
  80119. * Enable animation blending for this skeleton
  80120. * @param blendingSpeed defines the blending speed to apply
  80121. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80122. */
  80123. enableBlending(blendingSpeed?: number): void;
  80124. /**
  80125. * Releases all resources associated with the current skeleton
  80126. */
  80127. dispose(): void;
  80128. /**
  80129. * Serialize the skeleton in a JSON object
  80130. * @returns a JSON object
  80131. */
  80132. serialize(): any;
  80133. /**
  80134. * Creates a new skeleton from serialized data
  80135. * @param parsedSkeleton defines the serialized data
  80136. * @param scene defines the hosting scene
  80137. * @returns a new skeleton
  80138. */
  80139. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80140. /**
  80141. * Compute all node absolute transforms
  80142. * @param forceUpdate defines if computation must be done even if cache is up to date
  80143. */
  80144. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80145. /**
  80146. * Gets the root pose matrix
  80147. * @returns a matrix
  80148. */
  80149. getPoseMatrix(): Nullable<Matrix>;
  80150. /**
  80151. * Sorts bones per internal index
  80152. */
  80153. sortBones(): void;
  80154. private _sortBones;
  80155. }
  80156. }
  80157. declare module BABYLON {
  80158. /**
  80159. * Class used to store bone information
  80160. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80161. */
  80162. export class Bone extends Node {
  80163. /**
  80164. * defines the bone name
  80165. */
  80166. name: string;
  80167. private static _tmpVecs;
  80168. private static _tmpQuat;
  80169. private static _tmpMats;
  80170. /**
  80171. * Gets the list of child bones
  80172. */
  80173. children: Bone[];
  80174. /** Gets the animations associated with this bone */
  80175. animations: Animation[];
  80176. /**
  80177. * Gets or sets bone length
  80178. */
  80179. length: number;
  80180. /**
  80181. * @hidden Internal only
  80182. * Set this value to map this bone to a different index in the transform matrices
  80183. * Set this value to -1 to exclude the bone from the transform matrices
  80184. */
  80185. _index: Nullable<number>;
  80186. private _skeleton;
  80187. private _localMatrix;
  80188. private _restPose;
  80189. private _baseMatrix;
  80190. private _absoluteTransform;
  80191. private _invertedAbsoluteTransform;
  80192. private _parent;
  80193. private _scalingDeterminant;
  80194. private _worldTransform;
  80195. private _localScaling;
  80196. private _localRotation;
  80197. private _localPosition;
  80198. private _needToDecompose;
  80199. private _needToCompose;
  80200. /** @hidden */
  80201. _linkedTransformNode: Nullable<TransformNode>;
  80202. /** @hidden */
  80203. _waitingTransformNodeId: Nullable<string>;
  80204. /** @hidden */
  80205. /** @hidden */
  80206. _matrix: Matrix;
  80207. /**
  80208. * Create a new bone
  80209. * @param name defines the bone name
  80210. * @param skeleton defines the parent skeleton
  80211. * @param parentBone defines the parent (can be null if the bone is the root)
  80212. * @param localMatrix defines the local matrix
  80213. * @param restPose defines the rest pose matrix
  80214. * @param baseMatrix defines the base matrix
  80215. * @param index defines index of the bone in the hiearchy
  80216. */
  80217. constructor(
  80218. /**
  80219. * defines the bone name
  80220. */
  80221. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80222. /**
  80223. * Gets the current object class name.
  80224. * @return the class name
  80225. */
  80226. getClassName(): string;
  80227. /**
  80228. * Gets the parent skeleton
  80229. * @returns a skeleton
  80230. */
  80231. getSkeleton(): Skeleton;
  80232. /**
  80233. * Gets parent bone
  80234. * @returns a bone or null if the bone is the root of the bone hierarchy
  80235. */
  80236. getParent(): Nullable<Bone>;
  80237. /**
  80238. * Returns an array containing the root bones
  80239. * @returns an array containing the root bones
  80240. */
  80241. getChildren(): Array<Bone>;
  80242. /**
  80243. * Sets the parent bone
  80244. * @param parent defines the parent (can be null if the bone is the root)
  80245. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80246. */
  80247. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80248. /**
  80249. * Gets the local matrix
  80250. * @returns a matrix
  80251. */
  80252. getLocalMatrix(): Matrix;
  80253. /**
  80254. * Gets the base matrix (initial matrix which remains unchanged)
  80255. * @returns a matrix
  80256. */
  80257. getBaseMatrix(): Matrix;
  80258. /**
  80259. * Gets the rest pose matrix
  80260. * @returns a matrix
  80261. */
  80262. getRestPose(): Matrix;
  80263. /**
  80264. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80265. */
  80266. getWorldMatrix(): Matrix;
  80267. /**
  80268. * Sets the local matrix to rest pose matrix
  80269. */
  80270. returnToRest(): void;
  80271. /**
  80272. * Gets the inverse of the absolute transform matrix.
  80273. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80274. * @returns a matrix
  80275. */
  80276. getInvertedAbsoluteTransform(): Matrix;
  80277. /**
  80278. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80279. * @returns a matrix
  80280. */
  80281. getAbsoluteTransform(): Matrix;
  80282. /**
  80283. * Links with the given transform node.
  80284. * The local matrix of this bone is copied from the transform node every frame.
  80285. * @param transformNode defines the transform node to link to
  80286. */
  80287. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80288. /**
  80289. * Gets the node used to drive the bone's transformation
  80290. * @returns a transform node or null
  80291. */
  80292. getTransformNode(): Nullable<TransformNode>;
  80293. /** Gets or sets current position (in local space) */
  80294. position: Vector3;
  80295. /** Gets or sets current rotation (in local space) */
  80296. rotation: Vector3;
  80297. /** Gets or sets current rotation quaternion (in local space) */
  80298. rotationQuaternion: Quaternion;
  80299. /** Gets or sets current scaling (in local space) */
  80300. scaling: Vector3;
  80301. /**
  80302. * Gets the animation properties override
  80303. */
  80304. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80305. private _decompose;
  80306. private _compose;
  80307. /**
  80308. * Update the base and local matrices
  80309. * @param matrix defines the new base or local matrix
  80310. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80311. * @param updateLocalMatrix defines if the local matrix should be updated
  80312. */
  80313. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80314. /** @hidden */
  80315. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80316. /**
  80317. * Flag the bone as dirty (Forcing it to update everything)
  80318. */
  80319. markAsDirty(): void;
  80320. /** @hidden */
  80321. _markAsDirtyAndCompose(): void;
  80322. private _markAsDirtyAndDecompose;
  80323. /**
  80324. * Translate the bone in local or world space
  80325. * @param vec The amount to translate the bone
  80326. * @param space The space that the translation is in
  80327. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80328. */
  80329. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80330. /**
  80331. * Set the postion of the bone in local or world space
  80332. * @param position The position to set the bone
  80333. * @param space The space that the position is in
  80334. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80335. */
  80336. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80337. /**
  80338. * Set the absolute position of the bone (world space)
  80339. * @param position The position to set the bone
  80340. * @param mesh The mesh that this bone is attached to
  80341. */
  80342. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80343. /**
  80344. * Scale the bone on the x, y and z axes (in local space)
  80345. * @param x The amount to scale the bone on the x axis
  80346. * @param y The amount to scale the bone on the y axis
  80347. * @param z The amount to scale the bone on the z axis
  80348. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80349. */
  80350. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80351. /**
  80352. * Set the bone scaling in local space
  80353. * @param scale defines the scaling vector
  80354. */
  80355. setScale(scale: Vector3): void;
  80356. /**
  80357. * Gets the current scaling in local space
  80358. * @returns the current scaling vector
  80359. */
  80360. getScale(): Vector3;
  80361. /**
  80362. * Gets the current scaling in local space and stores it in a target vector
  80363. * @param result defines the target vector
  80364. */
  80365. getScaleToRef(result: Vector3): void;
  80366. /**
  80367. * Set the yaw, pitch, and roll of the bone in local or world space
  80368. * @param yaw The rotation of the bone on the y axis
  80369. * @param pitch The rotation of the bone on the x axis
  80370. * @param roll The rotation of the bone on the z axis
  80371. * @param space The space that the axes of rotation are in
  80372. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80373. */
  80374. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80375. /**
  80376. * Add a rotation to the bone on an axis in local or world space
  80377. * @param axis The axis to rotate the bone on
  80378. * @param amount The amount to rotate the bone
  80379. * @param space The space that the axis is in
  80380. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80381. */
  80382. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80383. /**
  80384. * Set the rotation of the bone to a particular axis angle in local or world space
  80385. * @param axis The axis to rotate the bone on
  80386. * @param angle The angle that the bone should be rotated to
  80387. * @param space The space that the axis is in
  80388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80389. */
  80390. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80391. /**
  80392. * Set the euler rotation of the bone in local of world space
  80393. * @param rotation The euler rotation that the bone should be set to
  80394. * @param space The space that the rotation is in
  80395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80396. */
  80397. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80398. /**
  80399. * Set the quaternion rotation of the bone in local of world space
  80400. * @param quat The quaternion rotation that the bone should be set to
  80401. * @param space The space that the rotation is in
  80402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80403. */
  80404. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80405. /**
  80406. * Set the rotation matrix of the bone in local of world space
  80407. * @param rotMat The rotation matrix that the bone should be set to
  80408. * @param space The space that the rotation is in
  80409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80410. */
  80411. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80412. private _rotateWithMatrix;
  80413. private _getNegativeRotationToRef;
  80414. /**
  80415. * Get the position of the bone in local or world space
  80416. * @param space The space that the returned position is in
  80417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80418. * @returns The position of the bone
  80419. */
  80420. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80421. /**
  80422. * Copy the position of the bone to a vector3 in local or world space
  80423. * @param space The space that the returned position is in
  80424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80425. * @param result The vector3 to copy the position to
  80426. */
  80427. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80428. /**
  80429. * Get the absolute position of the bone (world space)
  80430. * @param mesh The mesh that this bone is attached to
  80431. * @returns The absolute position of the bone
  80432. */
  80433. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80434. /**
  80435. * Copy the absolute position of the bone (world space) to the result param
  80436. * @param mesh The mesh that this bone is attached to
  80437. * @param result The vector3 to copy the absolute position to
  80438. */
  80439. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80440. /**
  80441. * Compute the absolute transforms of this bone and its children
  80442. */
  80443. computeAbsoluteTransforms(): void;
  80444. /**
  80445. * Get the world direction from an axis that is in the local space of the bone
  80446. * @param localAxis The local direction that is used to compute the world direction
  80447. * @param mesh The mesh that this bone is attached to
  80448. * @returns The world direction
  80449. */
  80450. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80451. /**
  80452. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80453. * @param localAxis The local direction that is used to compute the world direction
  80454. * @param mesh The mesh that this bone is attached to
  80455. * @param result The vector3 that the world direction will be copied to
  80456. */
  80457. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80458. /**
  80459. * Get the euler rotation of the bone in local or world space
  80460. * @param space The space that the rotation should be in
  80461. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80462. * @returns The euler rotation
  80463. */
  80464. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80465. /**
  80466. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80467. * @param space The space that the rotation should be in
  80468. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80469. * @param result The vector3 that the rotation should be copied to
  80470. */
  80471. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80472. /**
  80473. * Get the quaternion rotation of the bone in either local or world space
  80474. * @param space The space that the rotation should be in
  80475. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80476. * @returns The quaternion rotation
  80477. */
  80478. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80479. /**
  80480. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80481. * @param space The space that the rotation should be in
  80482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80483. * @param result The quaternion that the rotation should be copied to
  80484. */
  80485. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80486. /**
  80487. * Get the rotation matrix of the bone in local or world space
  80488. * @param space The space that the rotation should be in
  80489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80490. * @returns The rotation matrix
  80491. */
  80492. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80493. /**
  80494. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80495. * @param space The space that the rotation should be in
  80496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80497. * @param result The quaternion that the rotation should be copied to
  80498. */
  80499. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80500. /**
  80501. * Get the world position of a point that is in the local space of the bone
  80502. * @param position The local position
  80503. * @param mesh The mesh that this bone is attached to
  80504. * @returns The world position
  80505. */
  80506. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80507. /**
  80508. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80509. * @param position The local position
  80510. * @param mesh The mesh that this bone is attached to
  80511. * @param result The vector3 that the world position should be copied to
  80512. */
  80513. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80514. /**
  80515. * Get the local position of a point that is in world space
  80516. * @param position The world position
  80517. * @param mesh The mesh that this bone is attached to
  80518. * @returns The local position
  80519. */
  80520. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80521. /**
  80522. * Get the local position of a point that is in world space and copy it to the result param
  80523. * @param position The world position
  80524. * @param mesh The mesh that this bone is attached to
  80525. * @param result The vector3 that the local position should be copied to
  80526. */
  80527. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80528. }
  80529. }
  80530. declare module BABYLON {
  80531. /**
  80532. * 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.
  80533. * @see https://doc.babylonjs.com/how_to/transformnode
  80534. */
  80535. export class TransformNode extends Node {
  80536. /**
  80537. * Object will not rotate to face the camera
  80538. */
  80539. static BILLBOARDMODE_NONE: number;
  80540. /**
  80541. * Object will rotate to face the camera but only on the x axis
  80542. */
  80543. static BILLBOARDMODE_X: number;
  80544. /**
  80545. * Object will rotate to face the camera but only on the y axis
  80546. */
  80547. static BILLBOARDMODE_Y: number;
  80548. /**
  80549. * Object will rotate to face the camera but only on the z axis
  80550. */
  80551. static BILLBOARDMODE_Z: number;
  80552. /**
  80553. * Object will rotate to face the camera
  80554. */
  80555. static BILLBOARDMODE_ALL: number;
  80556. /**
  80557. * Object will rotate to face the camera's position instead of orientation
  80558. */
  80559. static BILLBOARDMODE_USE_POSITION: number;
  80560. private _forward;
  80561. private _forwardInverted;
  80562. private _up;
  80563. private _right;
  80564. private _rightInverted;
  80565. private _position;
  80566. private _rotation;
  80567. private _rotationQuaternion;
  80568. protected _scaling: Vector3;
  80569. protected _isDirty: boolean;
  80570. private _transformToBoneReferal;
  80571. private _isAbsoluteSynced;
  80572. private _billboardMode;
  80573. /**
  80574. * Gets or sets the billboard mode. Default is 0.
  80575. *
  80576. * | Value | Type | Description |
  80577. * | --- | --- | --- |
  80578. * | 0 | BILLBOARDMODE_NONE | |
  80579. * | 1 | BILLBOARDMODE_X | |
  80580. * | 2 | BILLBOARDMODE_Y | |
  80581. * | 4 | BILLBOARDMODE_Z | |
  80582. * | 7 | BILLBOARDMODE_ALL | |
  80583. *
  80584. */
  80585. billboardMode: number;
  80586. private _preserveParentRotationForBillboard;
  80587. /**
  80588. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80589. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80590. */
  80591. preserveParentRotationForBillboard: boolean;
  80592. /**
  80593. * 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
  80594. */
  80595. scalingDeterminant: number;
  80596. private _infiniteDistance;
  80597. /**
  80598. * Gets or sets the distance of the object to max, often used by skybox
  80599. */
  80600. infiniteDistance: boolean;
  80601. /**
  80602. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80603. * By default the system will update normals to compensate
  80604. */
  80605. ignoreNonUniformScaling: boolean;
  80606. /**
  80607. * 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
  80608. */
  80609. reIntegrateRotationIntoRotationQuaternion: boolean;
  80610. /** @hidden */
  80611. _poseMatrix: Nullable<Matrix>;
  80612. /** @hidden */
  80613. _localMatrix: Matrix;
  80614. private _usePivotMatrix;
  80615. private _absolutePosition;
  80616. private _absoluteScaling;
  80617. private _absoluteRotationQuaternion;
  80618. private _pivotMatrix;
  80619. private _pivotMatrixInverse;
  80620. protected _postMultiplyPivotMatrix: boolean;
  80621. protected _isWorldMatrixFrozen: boolean;
  80622. /** @hidden */
  80623. _indexInSceneTransformNodesArray: number;
  80624. /**
  80625. * An event triggered after the world matrix is updated
  80626. */
  80627. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80628. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80629. /**
  80630. * Gets a string identifying the name of the class
  80631. * @returns "TransformNode" string
  80632. */
  80633. getClassName(): string;
  80634. /**
  80635. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80636. */
  80637. position: Vector3;
  80638. /**
  80639. * 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)).
  80640. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80641. */
  80642. rotation: Vector3;
  80643. /**
  80644. * 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)).
  80645. */
  80646. scaling: Vector3;
  80647. /**
  80648. * 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).
  80649. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80650. */
  80651. rotationQuaternion: Nullable<Quaternion>;
  80652. /**
  80653. * The forward direction of that transform in world space.
  80654. */
  80655. readonly forward: Vector3;
  80656. /**
  80657. * The up direction of that transform in world space.
  80658. */
  80659. readonly up: Vector3;
  80660. /**
  80661. * The right direction of that transform in world space.
  80662. */
  80663. readonly right: Vector3;
  80664. /**
  80665. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80666. * @param matrix the matrix to copy the pose from
  80667. * @returns this TransformNode.
  80668. */
  80669. updatePoseMatrix(matrix: Matrix): TransformNode;
  80670. /**
  80671. * Returns the mesh Pose matrix.
  80672. * @returns the pose matrix
  80673. */
  80674. getPoseMatrix(): Matrix;
  80675. /** @hidden */
  80676. _isSynchronized(): boolean;
  80677. /** @hidden */
  80678. _initCache(): void;
  80679. /**
  80680. * Flag the transform node as dirty (Forcing it to update everything)
  80681. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80682. * @returns this transform node
  80683. */
  80684. markAsDirty(property: string): TransformNode;
  80685. /**
  80686. * Returns the current mesh absolute position.
  80687. * Returns a Vector3.
  80688. */
  80689. readonly absolutePosition: Vector3;
  80690. /**
  80691. * Returns the current mesh absolute scaling.
  80692. * Returns a Vector3.
  80693. */
  80694. readonly absoluteScaling: Vector3;
  80695. /**
  80696. * Returns the current mesh absolute rotation.
  80697. * Returns a Quaternion.
  80698. */
  80699. readonly absoluteRotationQuaternion: Quaternion;
  80700. /**
  80701. * Sets a new matrix to apply before all other transformation
  80702. * @param matrix defines the transform matrix
  80703. * @returns the current TransformNode
  80704. */
  80705. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80706. /**
  80707. * Sets a new pivot matrix to the current node
  80708. * @param matrix defines the new pivot matrix to use
  80709. * @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
  80710. * @returns the current TransformNode
  80711. */
  80712. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80713. /**
  80714. * Returns the mesh pivot matrix.
  80715. * Default : Identity.
  80716. * @returns the matrix
  80717. */
  80718. getPivotMatrix(): Matrix;
  80719. /**
  80720. * Instantiate (when possible) or clone that node with its hierarchy
  80721. * @param newParent defines the new parent to use for the instance (or clone)
  80722. * @returns an instance (or a clone) of the current node with its hiearchy
  80723. */
  80724. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80725. /**
  80726. * Prevents the World matrix to be computed any longer
  80727. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80728. * @returns the TransformNode.
  80729. */
  80730. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80731. /**
  80732. * Allows back the World matrix computation.
  80733. * @returns the TransformNode.
  80734. */
  80735. unfreezeWorldMatrix(): this;
  80736. /**
  80737. * True if the World matrix has been frozen.
  80738. */
  80739. readonly isWorldMatrixFrozen: boolean;
  80740. /**
  80741. * Retuns the mesh absolute position in the World.
  80742. * @returns a Vector3.
  80743. */
  80744. getAbsolutePosition(): Vector3;
  80745. /**
  80746. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80747. * @param absolutePosition the absolute position to set
  80748. * @returns the TransformNode.
  80749. */
  80750. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80751. /**
  80752. * Sets the mesh position in its local space.
  80753. * @param vector3 the position to set in localspace
  80754. * @returns the TransformNode.
  80755. */
  80756. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80757. /**
  80758. * Returns the mesh position in the local space from the current World matrix values.
  80759. * @returns a new Vector3.
  80760. */
  80761. getPositionExpressedInLocalSpace(): Vector3;
  80762. /**
  80763. * Translates the mesh along the passed Vector3 in its local space.
  80764. * @param vector3 the distance to translate in localspace
  80765. * @returns the TransformNode.
  80766. */
  80767. locallyTranslate(vector3: Vector3): TransformNode;
  80768. private static _lookAtVectorCache;
  80769. /**
  80770. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80771. * @param targetPoint the position (must be in same space as current mesh) to look at
  80772. * @param yawCor optional yaw (y-axis) correction in radians
  80773. * @param pitchCor optional pitch (x-axis) correction in radians
  80774. * @param rollCor optional roll (z-axis) correction in radians
  80775. * @param space the choosen space of the target
  80776. * @returns the TransformNode.
  80777. */
  80778. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80779. /**
  80780. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80781. * This Vector3 is expressed in the World space.
  80782. * @param localAxis axis to rotate
  80783. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80784. */
  80785. getDirection(localAxis: Vector3): Vector3;
  80786. /**
  80787. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80788. * localAxis is expressed in the mesh local space.
  80789. * result is computed in the Wordl space from the mesh World matrix.
  80790. * @param localAxis axis to rotate
  80791. * @param result the resulting transformnode
  80792. * @returns this TransformNode.
  80793. */
  80794. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80795. /**
  80796. * Sets this transform node rotation to the given local axis.
  80797. * @param localAxis the axis in local space
  80798. * @param yawCor optional yaw (y-axis) correction in radians
  80799. * @param pitchCor optional pitch (x-axis) correction in radians
  80800. * @param rollCor optional roll (z-axis) correction in radians
  80801. * @returns this TransformNode
  80802. */
  80803. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80804. /**
  80805. * Sets a new pivot point to the current node
  80806. * @param point defines the new pivot point to use
  80807. * @param space defines if the point is in world or local space (local by default)
  80808. * @returns the current TransformNode
  80809. */
  80810. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80811. /**
  80812. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80813. * @returns the pivot point
  80814. */
  80815. getPivotPoint(): Vector3;
  80816. /**
  80817. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80818. * @param result the vector3 to store the result
  80819. * @returns this TransformNode.
  80820. */
  80821. getPivotPointToRef(result: Vector3): TransformNode;
  80822. /**
  80823. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80824. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80825. */
  80826. getAbsolutePivotPoint(): Vector3;
  80827. /**
  80828. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80829. * @param result vector3 to store the result
  80830. * @returns this TransformNode.
  80831. */
  80832. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80833. /**
  80834. * Defines the passed node as the parent of the current node.
  80835. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80836. * @see https://doc.babylonjs.com/how_to/parenting
  80837. * @param node the node ot set as the parent
  80838. * @returns this TransformNode.
  80839. */
  80840. setParent(node: Nullable<Node>): TransformNode;
  80841. private _nonUniformScaling;
  80842. /**
  80843. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80844. */
  80845. readonly nonUniformScaling: boolean;
  80846. /** @hidden */
  80847. _updateNonUniformScalingState(value: boolean): boolean;
  80848. /**
  80849. * Attach the current TransformNode to another TransformNode associated with a bone
  80850. * @param bone Bone affecting the TransformNode
  80851. * @param affectedTransformNode TransformNode associated with the bone
  80852. * @returns this object
  80853. */
  80854. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80855. /**
  80856. * Detach the transform node if its associated with a bone
  80857. * @returns this object
  80858. */
  80859. detachFromBone(): TransformNode;
  80860. private static _rotationAxisCache;
  80861. /**
  80862. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80863. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80864. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80865. * The passed axis is also normalized.
  80866. * @param axis the axis to rotate around
  80867. * @param amount the amount to rotate in radians
  80868. * @param space Space to rotate in (Default: local)
  80869. * @returns the TransformNode.
  80870. */
  80871. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80872. /**
  80873. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80874. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80875. * The passed axis is also normalized. .
  80876. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80877. * @param point the point to rotate around
  80878. * @param axis the axis to rotate around
  80879. * @param amount the amount to rotate in radians
  80880. * @returns the TransformNode
  80881. */
  80882. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80883. /**
  80884. * Translates the mesh along the axis vector for the passed distance in the given space.
  80885. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80886. * @param axis the axis to translate in
  80887. * @param distance the distance to translate
  80888. * @param space Space to rotate in (Default: local)
  80889. * @returns the TransformNode.
  80890. */
  80891. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80892. /**
  80893. * Adds a rotation step to the mesh current rotation.
  80894. * x, y, z are Euler angles expressed in radians.
  80895. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80896. * This means this rotation is made in the mesh local space only.
  80897. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80898. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80899. * ```javascript
  80900. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80901. * ```
  80902. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80903. * 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.
  80904. * @param x Rotation to add
  80905. * @param y Rotation to add
  80906. * @param z Rotation to add
  80907. * @returns the TransformNode.
  80908. */
  80909. addRotation(x: number, y: number, z: number): TransformNode;
  80910. /**
  80911. * @hidden
  80912. */
  80913. protected _getEffectiveParent(): Nullable<Node>;
  80914. /**
  80915. * Computes the world matrix of the node
  80916. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80917. * @returns the world matrix
  80918. */
  80919. computeWorldMatrix(force?: boolean): Matrix;
  80920. protected _afterComputeWorldMatrix(): void;
  80921. /**
  80922. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80923. * @param func callback function to add
  80924. *
  80925. * @returns the TransformNode.
  80926. */
  80927. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80928. /**
  80929. * Removes a registered callback function.
  80930. * @param func callback function to remove
  80931. * @returns the TransformNode.
  80932. */
  80933. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80934. /**
  80935. * Gets the position of the current mesh in camera space
  80936. * @param camera defines the camera to use
  80937. * @returns a position
  80938. */
  80939. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80940. /**
  80941. * Returns the distance from the mesh to the active camera
  80942. * @param camera defines the camera to use
  80943. * @returns the distance
  80944. */
  80945. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80946. /**
  80947. * Clone the current transform node
  80948. * @param name Name of the new clone
  80949. * @param newParent New parent for the clone
  80950. * @param doNotCloneChildren Do not clone children hierarchy
  80951. * @returns the new transform node
  80952. */
  80953. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80954. /**
  80955. * Serializes the objects information.
  80956. * @param currentSerializationObject defines the object to serialize in
  80957. * @returns the serialized object
  80958. */
  80959. serialize(currentSerializationObject?: any): any;
  80960. /**
  80961. * Returns a new TransformNode object parsed from the source provided.
  80962. * @param parsedTransformNode is the source.
  80963. * @param scene the scne the object belongs to
  80964. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80965. * @returns a new TransformNode object parsed from the source provided.
  80966. */
  80967. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80968. /**
  80969. * Get all child-transformNodes of this node
  80970. * @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
  80971. * @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
  80972. * @returns an array of TransformNode
  80973. */
  80974. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80975. /**
  80976. * Releases resources associated with this transform node.
  80977. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80978. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80979. */
  80980. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80981. /**
  80982. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  80983. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  80984. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  80985. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  80986. * @returns the current mesh
  80987. */
  80988. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  80989. private _syncAbsoluteScalingAndRotation;
  80990. }
  80991. }
  80992. declare module BABYLON {
  80993. /**
  80994. * Defines the types of pose enabled controllers that are supported
  80995. */
  80996. export enum PoseEnabledControllerType {
  80997. /**
  80998. * HTC Vive
  80999. */
  81000. VIVE = 0,
  81001. /**
  81002. * Oculus Rift
  81003. */
  81004. OCULUS = 1,
  81005. /**
  81006. * Windows mixed reality
  81007. */
  81008. WINDOWS = 2,
  81009. /**
  81010. * Samsung gear VR
  81011. */
  81012. GEAR_VR = 3,
  81013. /**
  81014. * Google Daydream
  81015. */
  81016. DAYDREAM = 4,
  81017. /**
  81018. * Generic
  81019. */
  81020. GENERIC = 5
  81021. }
  81022. /**
  81023. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81024. */
  81025. export interface MutableGamepadButton {
  81026. /**
  81027. * Value of the button/trigger
  81028. */
  81029. value: number;
  81030. /**
  81031. * If the button/trigger is currently touched
  81032. */
  81033. touched: boolean;
  81034. /**
  81035. * If the button/trigger is currently pressed
  81036. */
  81037. pressed: boolean;
  81038. }
  81039. /**
  81040. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81041. * @hidden
  81042. */
  81043. export interface ExtendedGamepadButton extends GamepadButton {
  81044. /**
  81045. * If the button/trigger is currently pressed
  81046. */
  81047. readonly pressed: boolean;
  81048. /**
  81049. * If the button/trigger is currently touched
  81050. */
  81051. readonly touched: boolean;
  81052. /**
  81053. * Value of the button/trigger
  81054. */
  81055. readonly value: number;
  81056. }
  81057. /** @hidden */
  81058. export interface _GamePadFactory {
  81059. /**
  81060. * Returns wether or not the current gamepad can be created for this type of controller.
  81061. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81062. * @returns true if it can be created, otherwise false
  81063. */
  81064. canCreate(gamepadInfo: any): boolean;
  81065. /**
  81066. * Creates a new instance of the Gamepad.
  81067. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81068. * @returns the new gamepad instance
  81069. */
  81070. create(gamepadInfo: any): Gamepad;
  81071. }
  81072. /**
  81073. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81074. */
  81075. export class PoseEnabledControllerHelper {
  81076. /** @hidden */
  81077. static _ControllerFactories: _GamePadFactory[];
  81078. /** @hidden */
  81079. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81080. /**
  81081. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81082. * @param vrGamepad the gamepad to initialized
  81083. * @returns a vr controller of the type the gamepad identified as
  81084. */
  81085. static InitiateController(vrGamepad: any): Gamepad;
  81086. }
  81087. /**
  81088. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81089. */
  81090. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81091. /**
  81092. * If the controller is used in a webXR session
  81093. */
  81094. isXR: boolean;
  81095. private _deviceRoomPosition;
  81096. private _deviceRoomRotationQuaternion;
  81097. /**
  81098. * The device position in babylon space
  81099. */
  81100. devicePosition: Vector3;
  81101. /**
  81102. * The device rotation in babylon space
  81103. */
  81104. deviceRotationQuaternion: Quaternion;
  81105. /**
  81106. * The scale factor of the device in babylon space
  81107. */
  81108. deviceScaleFactor: number;
  81109. /**
  81110. * (Likely devicePosition should be used instead) The device position in its room space
  81111. */
  81112. position: Vector3;
  81113. /**
  81114. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81115. */
  81116. rotationQuaternion: Quaternion;
  81117. /**
  81118. * The type of controller (Eg. Windows mixed reality)
  81119. */
  81120. controllerType: PoseEnabledControllerType;
  81121. protected _calculatedPosition: Vector3;
  81122. private _calculatedRotation;
  81123. /**
  81124. * The raw pose from the device
  81125. */
  81126. rawPose: DevicePose;
  81127. private _trackPosition;
  81128. private _maxRotationDistFromHeadset;
  81129. private _draggedRoomRotation;
  81130. /**
  81131. * @hidden
  81132. */
  81133. _disableTrackPosition(fixedPosition: Vector3): void;
  81134. /**
  81135. * Internal, the mesh attached to the controller
  81136. * @hidden
  81137. */
  81138. _mesh: Nullable<AbstractMesh>;
  81139. private _poseControlledCamera;
  81140. private _leftHandSystemQuaternion;
  81141. /**
  81142. * Internal, matrix used to convert room space to babylon space
  81143. * @hidden
  81144. */
  81145. _deviceToWorld: Matrix;
  81146. /**
  81147. * Node to be used when casting a ray from the controller
  81148. * @hidden
  81149. */
  81150. _pointingPoseNode: Nullable<TransformNode>;
  81151. /**
  81152. * Name of the child mesh that can be used to cast a ray from the controller
  81153. */
  81154. static readonly POINTING_POSE: string;
  81155. /**
  81156. * Creates a new PoseEnabledController from a gamepad
  81157. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81158. */
  81159. constructor(browserGamepad: any);
  81160. private _workingMatrix;
  81161. /**
  81162. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81163. */
  81164. update(): void;
  81165. /**
  81166. * Updates only the pose device and mesh without doing any button event checking
  81167. */
  81168. protected _updatePoseAndMesh(): void;
  81169. /**
  81170. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81171. * @param poseData raw pose fromthe device
  81172. */
  81173. updateFromDevice(poseData: DevicePose): void;
  81174. /**
  81175. * @hidden
  81176. */
  81177. _meshAttachedObservable: Observable<AbstractMesh>;
  81178. /**
  81179. * Attaches a mesh to the controller
  81180. * @param mesh the mesh to be attached
  81181. */
  81182. attachToMesh(mesh: AbstractMesh): void;
  81183. /**
  81184. * Attaches the controllers mesh to a camera
  81185. * @param camera the camera the mesh should be attached to
  81186. */
  81187. attachToPoseControlledCamera(camera: TargetCamera): void;
  81188. /**
  81189. * Disposes of the controller
  81190. */
  81191. dispose(): void;
  81192. /**
  81193. * The mesh that is attached to the controller
  81194. */
  81195. readonly mesh: Nullable<AbstractMesh>;
  81196. /**
  81197. * Gets the ray of the controller in the direction the controller is pointing
  81198. * @param length the length the resulting ray should be
  81199. * @returns a ray in the direction the controller is pointing
  81200. */
  81201. getForwardRay(length?: number): Ray;
  81202. }
  81203. }
  81204. declare module BABYLON {
  81205. /**
  81206. * Defines the WebVRController object that represents controllers tracked in 3D space
  81207. */
  81208. export abstract class WebVRController extends PoseEnabledController {
  81209. /**
  81210. * Internal, the default controller model for the controller
  81211. */
  81212. protected _defaultModel: Nullable<AbstractMesh>;
  81213. /**
  81214. * Fired when the trigger state has changed
  81215. */
  81216. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81217. /**
  81218. * Fired when the main button state has changed
  81219. */
  81220. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81221. /**
  81222. * Fired when the secondary button state has changed
  81223. */
  81224. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81225. /**
  81226. * Fired when the pad state has changed
  81227. */
  81228. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81229. /**
  81230. * Fired when controllers stick values have changed
  81231. */
  81232. onPadValuesChangedObservable: Observable<StickValues>;
  81233. /**
  81234. * Array of button availible on the controller
  81235. */
  81236. protected _buttons: Array<MutableGamepadButton>;
  81237. private _onButtonStateChange;
  81238. /**
  81239. * Fired when a controller button's state has changed
  81240. * @param callback the callback containing the button that was modified
  81241. */
  81242. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81243. /**
  81244. * X and Y axis corresponding to the controllers joystick
  81245. */
  81246. pad: StickValues;
  81247. /**
  81248. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81249. */
  81250. hand: string;
  81251. /**
  81252. * The default controller model for the controller
  81253. */
  81254. readonly defaultModel: Nullable<AbstractMesh>;
  81255. /**
  81256. * Creates a new WebVRController from a gamepad
  81257. * @param vrGamepad the gamepad that the WebVRController should be created from
  81258. */
  81259. constructor(vrGamepad: any);
  81260. /**
  81261. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81262. */
  81263. update(): void;
  81264. /**
  81265. * Function to be called when a button is modified
  81266. */
  81267. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81268. /**
  81269. * Loads a mesh and attaches it to the controller
  81270. * @param scene the scene the mesh should be added to
  81271. * @param meshLoaded callback for when the mesh has been loaded
  81272. */
  81273. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81274. private _setButtonValue;
  81275. private _changes;
  81276. private _checkChanges;
  81277. /**
  81278. * Disposes of th webVRCOntroller
  81279. */
  81280. dispose(): void;
  81281. }
  81282. }
  81283. declare module BABYLON {
  81284. /**
  81285. * The HemisphericLight simulates the ambient environment light,
  81286. * so the passed direction is the light reflection direction, not the incoming direction.
  81287. */
  81288. export class HemisphericLight extends Light {
  81289. /**
  81290. * The groundColor is the light in the opposite direction to the one specified during creation.
  81291. * 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.
  81292. */
  81293. groundColor: Color3;
  81294. /**
  81295. * The light reflection direction, not the incoming direction.
  81296. */
  81297. direction: Vector3;
  81298. /**
  81299. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81300. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81301. * The HemisphericLight can't cast shadows.
  81302. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81303. * @param name The friendly name of the light
  81304. * @param direction The direction of the light reflection
  81305. * @param scene The scene the light belongs to
  81306. */
  81307. constructor(name: string, direction: Vector3, scene: Scene);
  81308. protected _buildUniformLayout(): void;
  81309. /**
  81310. * Returns the string "HemisphericLight".
  81311. * @return The class name
  81312. */
  81313. getClassName(): string;
  81314. /**
  81315. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81316. * Returns the updated direction.
  81317. * @param target The target the direction should point to
  81318. * @return The computed direction
  81319. */
  81320. setDirectionToTarget(target: Vector3): Vector3;
  81321. /**
  81322. * Returns the shadow generator associated to the light.
  81323. * @returns Always null for hemispheric lights because it does not support shadows.
  81324. */
  81325. getShadowGenerator(): Nullable<IShadowGenerator>;
  81326. /**
  81327. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81328. * @param effect The effect to update
  81329. * @param lightIndex The index of the light in the effect to update
  81330. * @returns The hemispheric light
  81331. */
  81332. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81333. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81334. /**
  81335. * Computes the world matrix of the node
  81336. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81337. * @param useWasUpdatedFlag defines a reserved property
  81338. * @returns the world matrix
  81339. */
  81340. computeWorldMatrix(): Matrix;
  81341. /**
  81342. * Returns the integer 3.
  81343. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81344. */
  81345. getTypeID(): number;
  81346. /**
  81347. * Prepares the list of defines specific to the light type.
  81348. * @param defines the list of defines
  81349. * @param lightIndex defines the index of the light for the effect
  81350. */
  81351. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81352. }
  81353. }
  81354. declare module BABYLON {
  81355. /** @hidden */
  81356. export var vrMultiviewToSingleviewPixelShader: {
  81357. name: string;
  81358. shader: string;
  81359. };
  81360. }
  81361. declare module BABYLON {
  81362. /**
  81363. * Renders to multiple views with a single draw call
  81364. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81365. */
  81366. export class MultiviewRenderTarget extends RenderTargetTexture {
  81367. /**
  81368. * Creates a multiview render target
  81369. * @param scene scene used with the render target
  81370. * @param size the size of the render target (used for each view)
  81371. */
  81372. constructor(scene: Scene, size?: number | {
  81373. width: number;
  81374. height: number;
  81375. } | {
  81376. ratio: number;
  81377. });
  81378. /**
  81379. * @hidden
  81380. * @param faceIndex the face index, if its a cube texture
  81381. */
  81382. _bindFrameBuffer(faceIndex?: number): void;
  81383. /**
  81384. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81385. * @returns the view count
  81386. */
  81387. getViewCount(): number;
  81388. }
  81389. }
  81390. declare module BABYLON {
  81391. /**
  81392. * Represents a camera frustum
  81393. */
  81394. export class Frustum {
  81395. /**
  81396. * Gets the planes representing the frustum
  81397. * @param transform matrix to be applied to the returned planes
  81398. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81399. */
  81400. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81401. /**
  81402. * Gets the near frustum plane transformed by the transform matrix
  81403. * @param transform transformation matrix to be applied to the resulting frustum plane
  81404. * @param frustumPlane the resuling frustum plane
  81405. */
  81406. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81407. /**
  81408. * Gets the far frustum plane transformed by the transform matrix
  81409. * @param transform transformation matrix to be applied to the resulting frustum plane
  81410. * @param frustumPlane the resuling frustum plane
  81411. */
  81412. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81413. /**
  81414. * Gets the left frustum plane transformed by the transform matrix
  81415. * @param transform transformation matrix to be applied to the resulting frustum plane
  81416. * @param frustumPlane the resuling frustum plane
  81417. */
  81418. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81419. /**
  81420. * Gets the right frustum plane transformed by the transform matrix
  81421. * @param transform transformation matrix to be applied to the resulting frustum plane
  81422. * @param frustumPlane the resuling frustum plane
  81423. */
  81424. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81425. /**
  81426. * Gets the top frustum plane transformed by the transform matrix
  81427. * @param transform transformation matrix to be applied to the resulting frustum plane
  81428. * @param frustumPlane the resuling frustum plane
  81429. */
  81430. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81431. /**
  81432. * Gets the bottom frustum plane transformed by the transform matrix
  81433. * @param transform transformation matrix to be applied to the resulting frustum plane
  81434. * @param frustumPlane the resuling frustum plane
  81435. */
  81436. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81437. /**
  81438. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81439. * @param transform transformation matrix to be applied to the resulting frustum planes
  81440. * @param frustumPlanes the resuling frustum planes
  81441. */
  81442. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81443. }
  81444. }
  81445. declare module BABYLON {
  81446. interface Engine {
  81447. /**
  81448. * Creates a new multiview render target
  81449. * @param width defines the width of the texture
  81450. * @param height defines the height of the texture
  81451. * @returns the created multiview texture
  81452. */
  81453. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81454. /**
  81455. * Binds a multiview framebuffer to be drawn to
  81456. * @param multiviewTexture texture to bind
  81457. */
  81458. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81459. }
  81460. interface Camera {
  81461. /**
  81462. * @hidden
  81463. * 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)
  81464. */
  81465. _useMultiviewToSingleView: boolean;
  81466. /**
  81467. * @hidden
  81468. * 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)
  81469. */
  81470. _multiviewTexture: Nullable<RenderTargetTexture>;
  81471. /**
  81472. * @hidden
  81473. * ensures the multiview texture of the camera exists and has the specified width/height
  81474. * @param width height to set on the multiview texture
  81475. * @param height width to set on the multiview texture
  81476. */
  81477. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81478. }
  81479. interface Scene {
  81480. /** @hidden */
  81481. _transformMatrixR: Matrix;
  81482. /** @hidden */
  81483. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81484. /** @hidden */
  81485. _createMultiviewUbo(): void;
  81486. /** @hidden */
  81487. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81488. /** @hidden */
  81489. _renderMultiviewToSingleView(camera: Camera): void;
  81490. }
  81491. }
  81492. declare module BABYLON {
  81493. /**
  81494. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81495. * This will not be used for webXR as it supports displaying texture arrays directly
  81496. */
  81497. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81498. /**
  81499. * Initializes a VRMultiviewToSingleview
  81500. * @param name name of the post process
  81501. * @param camera camera to be applied to
  81502. * @param scaleFactor scaling factor to the size of the output texture
  81503. */
  81504. constructor(name: string, camera: Camera, scaleFactor: number);
  81505. }
  81506. }
  81507. declare module BABYLON {
  81508. interface Engine {
  81509. /** @hidden */
  81510. _vrDisplay: any;
  81511. /** @hidden */
  81512. _vrSupported: boolean;
  81513. /** @hidden */
  81514. _oldSize: Size;
  81515. /** @hidden */
  81516. _oldHardwareScaleFactor: number;
  81517. /** @hidden */
  81518. _vrExclusivePointerMode: boolean;
  81519. /** @hidden */
  81520. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81521. /** @hidden */
  81522. _onVRDisplayPointerRestricted: () => void;
  81523. /** @hidden */
  81524. _onVRDisplayPointerUnrestricted: () => void;
  81525. /** @hidden */
  81526. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81527. /** @hidden */
  81528. _onVrDisplayDisconnect: Nullable<() => void>;
  81529. /** @hidden */
  81530. _onVrDisplayPresentChange: Nullable<() => void>;
  81531. /**
  81532. * Observable signaled when VR display mode changes
  81533. */
  81534. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81535. /**
  81536. * Observable signaled when VR request present is complete
  81537. */
  81538. onVRRequestPresentComplete: Observable<boolean>;
  81539. /**
  81540. * Observable signaled when VR request present starts
  81541. */
  81542. onVRRequestPresentStart: Observable<Engine>;
  81543. /**
  81544. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81545. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81546. */
  81547. isInVRExclusivePointerMode: boolean;
  81548. /**
  81549. * Gets a boolean indicating if a webVR device was detected
  81550. * @returns true if a webVR device was detected
  81551. */
  81552. isVRDevicePresent(): boolean;
  81553. /**
  81554. * Gets the current webVR device
  81555. * @returns the current webVR device (or null)
  81556. */
  81557. getVRDevice(): any;
  81558. /**
  81559. * Initializes a webVR display and starts listening to display change events
  81560. * The onVRDisplayChangedObservable will be notified upon these changes
  81561. * @returns A promise containing a VRDisplay and if vr is supported
  81562. */
  81563. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81564. /** @hidden */
  81565. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81566. /**
  81567. * Call this function to switch to webVR mode
  81568. * Will do nothing if webVR is not supported or if there is no webVR device
  81569. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81570. */
  81571. enableVR(): void;
  81572. /** @hidden */
  81573. _onVRFullScreenTriggered(): void;
  81574. }
  81575. }
  81576. declare module BABYLON {
  81577. /**
  81578. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81579. * IMPORTANT!! The data is right-hand data.
  81580. * @export
  81581. * @interface DevicePose
  81582. */
  81583. export interface DevicePose {
  81584. /**
  81585. * The position of the device, values in array are [x,y,z].
  81586. */
  81587. readonly position: Nullable<Float32Array>;
  81588. /**
  81589. * The linearVelocity of the device, values in array are [x,y,z].
  81590. */
  81591. readonly linearVelocity: Nullable<Float32Array>;
  81592. /**
  81593. * The linearAcceleration of the device, values in array are [x,y,z].
  81594. */
  81595. readonly linearAcceleration: Nullable<Float32Array>;
  81596. /**
  81597. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81598. */
  81599. readonly orientation: Nullable<Float32Array>;
  81600. /**
  81601. * The angularVelocity of the device, values in array are [x,y,z].
  81602. */
  81603. readonly angularVelocity: Nullable<Float32Array>;
  81604. /**
  81605. * The angularAcceleration of the device, values in array are [x,y,z].
  81606. */
  81607. readonly angularAcceleration: Nullable<Float32Array>;
  81608. }
  81609. /**
  81610. * Interface representing a pose controlled object in Babylon.
  81611. * A pose controlled object has both regular pose values as well as pose values
  81612. * from an external device such as a VR head mounted display
  81613. */
  81614. export interface PoseControlled {
  81615. /**
  81616. * The position of the object in babylon space.
  81617. */
  81618. position: Vector3;
  81619. /**
  81620. * The rotation quaternion of the object in babylon space.
  81621. */
  81622. rotationQuaternion: Quaternion;
  81623. /**
  81624. * The position of the device in babylon space.
  81625. */
  81626. devicePosition?: Vector3;
  81627. /**
  81628. * The rotation quaternion of the device in babylon space.
  81629. */
  81630. deviceRotationQuaternion: Quaternion;
  81631. /**
  81632. * The raw pose coming from the device.
  81633. */
  81634. rawPose: Nullable<DevicePose>;
  81635. /**
  81636. * The scale of the device to be used when translating from device space to babylon space.
  81637. */
  81638. deviceScaleFactor: number;
  81639. /**
  81640. * Updates the poseControlled values based on the input device pose.
  81641. * @param poseData the pose data to update the object with
  81642. */
  81643. updateFromDevice(poseData: DevicePose): void;
  81644. }
  81645. /**
  81646. * Set of options to customize the webVRCamera
  81647. */
  81648. export interface WebVROptions {
  81649. /**
  81650. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81651. */
  81652. trackPosition?: boolean;
  81653. /**
  81654. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81655. */
  81656. positionScale?: number;
  81657. /**
  81658. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81659. */
  81660. displayName?: string;
  81661. /**
  81662. * Should the native controller meshes be initialized. (default: true)
  81663. */
  81664. controllerMeshes?: boolean;
  81665. /**
  81666. * Creating a default HemiLight only on controllers. (default: true)
  81667. */
  81668. defaultLightingOnControllers?: boolean;
  81669. /**
  81670. * If you don't want to use the default VR button of the helper. (default: false)
  81671. */
  81672. useCustomVRButton?: boolean;
  81673. /**
  81674. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81675. */
  81676. customVRButton?: HTMLButtonElement;
  81677. /**
  81678. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81679. */
  81680. rayLength?: number;
  81681. /**
  81682. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81683. */
  81684. defaultHeight?: number;
  81685. /**
  81686. * If multiview should be used if availible (default: false)
  81687. */
  81688. useMultiview?: boolean;
  81689. }
  81690. /**
  81691. * This represents a WebVR camera.
  81692. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81693. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81694. */
  81695. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81696. private webVROptions;
  81697. /**
  81698. * @hidden
  81699. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81700. */
  81701. _vrDevice: any;
  81702. /**
  81703. * The rawPose of the vrDevice.
  81704. */
  81705. rawPose: Nullable<DevicePose>;
  81706. private _onVREnabled;
  81707. private _specsVersion;
  81708. private _attached;
  81709. private _frameData;
  81710. protected _descendants: Array<Node>;
  81711. private _deviceRoomPosition;
  81712. /** @hidden */
  81713. _deviceRoomRotationQuaternion: Quaternion;
  81714. private _standingMatrix;
  81715. /**
  81716. * Represents device position in babylon space.
  81717. */
  81718. devicePosition: Vector3;
  81719. /**
  81720. * Represents device rotation in babylon space.
  81721. */
  81722. deviceRotationQuaternion: Quaternion;
  81723. /**
  81724. * The scale of the device to be used when translating from device space to babylon space.
  81725. */
  81726. deviceScaleFactor: number;
  81727. private _deviceToWorld;
  81728. private _worldToDevice;
  81729. /**
  81730. * References to the webVR controllers for the vrDevice.
  81731. */
  81732. controllers: Array<WebVRController>;
  81733. /**
  81734. * Emits an event when a controller is attached.
  81735. */
  81736. onControllersAttachedObservable: Observable<WebVRController[]>;
  81737. /**
  81738. * Emits an event when a controller's mesh has been loaded;
  81739. */
  81740. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81741. /**
  81742. * Emits an event when the HMD's pose has been updated.
  81743. */
  81744. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81745. private _poseSet;
  81746. /**
  81747. * If the rig cameras be used as parent instead of this camera.
  81748. */
  81749. rigParenting: boolean;
  81750. private _lightOnControllers;
  81751. private _defaultHeight?;
  81752. /**
  81753. * Instantiates a WebVRFreeCamera.
  81754. * @param name The name of the WebVRFreeCamera
  81755. * @param position The starting anchor position for the camera
  81756. * @param scene The scene the camera belongs to
  81757. * @param webVROptions a set of customizable options for the webVRCamera
  81758. */
  81759. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81760. /**
  81761. * Gets the device distance from the ground in meters.
  81762. * @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.
  81763. */
  81764. deviceDistanceToRoomGround(): number;
  81765. /**
  81766. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81767. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81768. */
  81769. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81770. /**
  81771. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81772. * @returns A promise with a boolean set to if the standing matrix is supported.
  81773. */
  81774. useStandingMatrixAsync(): Promise<boolean>;
  81775. /**
  81776. * Disposes the camera
  81777. */
  81778. dispose(): void;
  81779. /**
  81780. * Gets a vrController by name.
  81781. * @param name The name of the controller to retreive
  81782. * @returns the controller matching the name specified or null if not found
  81783. */
  81784. getControllerByName(name: string): Nullable<WebVRController>;
  81785. private _leftController;
  81786. /**
  81787. * The controller corresponding to the users left hand.
  81788. */
  81789. readonly leftController: Nullable<WebVRController>;
  81790. private _rightController;
  81791. /**
  81792. * The controller corresponding to the users right hand.
  81793. */
  81794. readonly rightController: Nullable<WebVRController>;
  81795. /**
  81796. * Casts a ray forward from the vrCamera's gaze.
  81797. * @param length Length of the ray (default: 100)
  81798. * @returns the ray corresponding to the gaze
  81799. */
  81800. getForwardRay(length?: number): Ray;
  81801. /**
  81802. * @hidden
  81803. * Updates the camera based on device's frame data
  81804. */
  81805. _checkInputs(): void;
  81806. /**
  81807. * Updates the poseControlled values based on the input device pose.
  81808. * @param poseData Pose coming from the device
  81809. */
  81810. updateFromDevice(poseData: DevicePose): void;
  81811. private _htmlElementAttached;
  81812. private _detachIfAttached;
  81813. /**
  81814. * WebVR's attach control will start broadcasting frames to the device.
  81815. * Note that in certain browsers (chrome for example) this function must be called
  81816. * within a user-interaction callback. Example:
  81817. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81818. *
  81819. * @param element html element to attach the vrDevice to
  81820. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81821. */
  81822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81823. /**
  81824. * Detaches the camera from the html element and disables VR
  81825. *
  81826. * @param element html element to detach from
  81827. */
  81828. detachControl(element: HTMLElement): void;
  81829. /**
  81830. * @returns the name of this class
  81831. */
  81832. getClassName(): string;
  81833. /**
  81834. * Calls resetPose on the vrDisplay
  81835. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81836. */
  81837. resetToCurrentRotation(): void;
  81838. /**
  81839. * @hidden
  81840. * Updates the rig cameras (left and right eye)
  81841. */
  81842. _updateRigCameras(): void;
  81843. private _workingVector;
  81844. private _oneVector;
  81845. private _workingMatrix;
  81846. private updateCacheCalled;
  81847. private _correctPositionIfNotTrackPosition;
  81848. /**
  81849. * @hidden
  81850. * Updates the cached values of the camera
  81851. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81852. */
  81853. _updateCache(ignoreParentClass?: boolean): void;
  81854. /**
  81855. * @hidden
  81856. * Get current device position in babylon world
  81857. */
  81858. _computeDevicePosition(): void;
  81859. /**
  81860. * Updates the current device position and rotation in the babylon world
  81861. */
  81862. update(): void;
  81863. /**
  81864. * @hidden
  81865. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81866. * @returns an identity matrix
  81867. */
  81868. _getViewMatrix(): Matrix;
  81869. private _tmpMatrix;
  81870. /**
  81871. * This function is called by the two RIG cameras.
  81872. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81873. * @hidden
  81874. */
  81875. _getWebVRViewMatrix(): Matrix;
  81876. /** @hidden */
  81877. _getWebVRProjectionMatrix(): Matrix;
  81878. private _onGamepadConnectedObserver;
  81879. private _onGamepadDisconnectedObserver;
  81880. private _updateCacheWhenTrackingDisabledObserver;
  81881. /**
  81882. * Initializes the controllers and their meshes
  81883. */
  81884. initControllers(): void;
  81885. }
  81886. }
  81887. declare module BABYLON {
  81888. /**
  81889. * Size options for a post process
  81890. */
  81891. export type PostProcessOptions = {
  81892. width: number;
  81893. height: number;
  81894. };
  81895. /**
  81896. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81897. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81898. */
  81899. export class PostProcess {
  81900. /** Name of the PostProcess. */
  81901. name: string;
  81902. /**
  81903. * Gets or sets the unique id of the post process
  81904. */
  81905. uniqueId: number;
  81906. /**
  81907. * Width of the texture to apply the post process on
  81908. */
  81909. width: number;
  81910. /**
  81911. * Height of the texture to apply the post process on
  81912. */
  81913. height: number;
  81914. /**
  81915. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81916. * @hidden
  81917. */
  81918. _outputTexture: Nullable<InternalTexture>;
  81919. /**
  81920. * Sampling mode used by the shader
  81921. * See https://doc.babylonjs.com/classes/3.1/texture
  81922. */
  81923. renderTargetSamplingMode: number;
  81924. /**
  81925. * Clear color to use when screen clearing
  81926. */
  81927. clearColor: Color4;
  81928. /**
  81929. * If the buffer needs to be cleared before applying the post process. (default: true)
  81930. * Should be set to false if shader will overwrite all previous pixels.
  81931. */
  81932. autoClear: boolean;
  81933. /**
  81934. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81935. */
  81936. alphaMode: number;
  81937. /**
  81938. * Sets the setAlphaBlendConstants of the babylon engine
  81939. */
  81940. alphaConstants: Color4;
  81941. /**
  81942. * Animations to be used for the post processing
  81943. */
  81944. animations: Animation[];
  81945. /**
  81946. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81947. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81948. */
  81949. enablePixelPerfectMode: boolean;
  81950. /**
  81951. * Force the postprocess to be applied without taking in account viewport
  81952. */
  81953. forceFullscreenViewport: boolean;
  81954. /**
  81955. * List of inspectable custom properties (used by the Inspector)
  81956. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81957. */
  81958. inspectableCustomProperties: IInspectable[];
  81959. /**
  81960. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81961. *
  81962. * | Value | Type | Description |
  81963. * | ----- | ----------------------------------- | ----------- |
  81964. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81965. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81966. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81967. *
  81968. */
  81969. scaleMode: number;
  81970. /**
  81971. * Force textures to be a power of two (default: false)
  81972. */
  81973. alwaysForcePOT: boolean;
  81974. private _samples;
  81975. /**
  81976. * Number of sample textures (default: 1)
  81977. */
  81978. samples: number;
  81979. /**
  81980. * Modify the scale of the post process to be the same as the viewport (default: false)
  81981. */
  81982. adaptScaleToCurrentViewport: boolean;
  81983. private _camera;
  81984. private _scene;
  81985. private _engine;
  81986. private _options;
  81987. private _reusable;
  81988. private _textureType;
  81989. /**
  81990. * Smart array of input and output textures for the post process.
  81991. * @hidden
  81992. */
  81993. _textures: SmartArray<InternalTexture>;
  81994. /**
  81995. * The index in _textures that corresponds to the output texture.
  81996. * @hidden
  81997. */
  81998. _currentRenderTextureInd: number;
  81999. private _effect;
  82000. private _samplers;
  82001. private _fragmentUrl;
  82002. private _vertexUrl;
  82003. private _parameters;
  82004. private _scaleRatio;
  82005. protected _indexParameters: any;
  82006. private _shareOutputWithPostProcess;
  82007. private _texelSize;
  82008. private _forcedOutputTexture;
  82009. /**
  82010. * Returns the fragment url or shader name used in the post process.
  82011. * @returns the fragment url or name in the shader store.
  82012. */
  82013. getEffectName(): string;
  82014. /**
  82015. * An event triggered when the postprocess is activated.
  82016. */
  82017. onActivateObservable: Observable<Camera>;
  82018. private _onActivateObserver;
  82019. /**
  82020. * A function that is added to the onActivateObservable
  82021. */
  82022. onActivate: Nullable<(camera: Camera) => void>;
  82023. /**
  82024. * An event triggered when the postprocess changes its size.
  82025. */
  82026. onSizeChangedObservable: Observable<PostProcess>;
  82027. private _onSizeChangedObserver;
  82028. /**
  82029. * A function that is added to the onSizeChangedObservable
  82030. */
  82031. onSizeChanged: (postProcess: PostProcess) => void;
  82032. /**
  82033. * An event triggered when the postprocess applies its effect.
  82034. */
  82035. onApplyObservable: Observable<Effect>;
  82036. private _onApplyObserver;
  82037. /**
  82038. * A function that is added to the onApplyObservable
  82039. */
  82040. onApply: (effect: Effect) => void;
  82041. /**
  82042. * An event triggered before rendering the postprocess
  82043. */
  82044. onBeforeRenderObservable: Observable<Effect>;
  82045. private _onBeforeRenderObserver;
  82046. /**
  82047. * A function that is added to the onBeforeRenderObservable
  82048. */
  82049. onBeforeRender: (effect: Effect) => void;
  82050. /**
  82051. * An event triggered after rendering the postprocess
  82052. */
  82053. onAfterRenderObservable: Observable<Effect>;
  82054. private _onAfterRenderObserver;
  82055. /**
  82056. * A function that is added to the onAfterRenderObservable
  82057. */
  82058. onAfterRender: (efect: Effect) => void;
  82059. /**
  82060. * 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
  82061. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82062. */
  82063. inputTexture: InternalTexture;
  82064. /**
  82065. * Gets the camera which post process is applied to.
  82066. * @returns The camera the post process is applied to.
  82067. */
  82068. getCamera(): Camera;
  82069. /**
  82070. * Gets the texel size of the postprocess.
  82071. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82072. */
  82073. readonly texelSize: Vector2;
  82074. /**
  82075. * Creates a new instance PostProcess
  82076. * @param name The name of the PostProcess.
  82077. * @param fragmentUrl The url of the fragment shader to be used.
  82078. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82079. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82080. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82081. * @param camera The camera to apply the render pass to.
  82082. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82083. * @param engine The engine which the post process will be applied. (default: current engine)
  82084. * @param reusable If the post process can be reused on the same frame. (default: false)
  82085. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82086. * @param textureType Type of textures used when performing the post process. (default: 0)
  82087. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82088. * @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
  82089. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82090. */
  82091. constructor(
  82092. /** Name of the PostProcess. */
  82093. 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);
  82094. /**
  82095. * Gets a string idenfifying the name of the class
  82096. * @returns "PostProcess" string
  82097. */
  82098. getClassName(): string;
  82099. /**
  82100. * Gets the engine which this post process belongs to.
  82101. * @returns The engine the post process was enabled with.
  82102. */
  82103. getEngine(): Engine;
  82104. /**
  82105. * The effect that is created when initializing the post process.
  82106. * @returns The created effect corresponding the the postprocess.
  82107. */
  82108. getEffect(): Effect;
  82109. /**
  82110. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82111. * @param postProcess The post process to share the output with.
  82112. * @returns This post process.
  82113. */
  82114. shareOutputWith(postProcess: PostProcess): PostProcess;
  82115. /**
  82116. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82117. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82118. */
  82119. useOwnOutput(): void;
  82120. /**
  82121. * Updates the effect with the current post process compile time values and recompiles the shader.
  82122. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82123. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82124. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82125. * @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
  82126. * @param onCompiled Called when the shader has been compiled.
  82127. * @param onError Called if there is an error when compiling a shader.
  82128. */
  82129. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82130. /**
  82131. * The post process is reusable if it can be used multiple times within one frame.
  82132. * @returns If the post process is reusable
  82133. */
  82134. isReusable(): boolean;
  82135. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82136. markTextureDirty(): void;
  82137. /**
  82138. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82139. * 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.
  82140. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82141. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82142. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82143. * @returns The target texture that was bound to be written to.
  82144. */
  82145. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82146. /**
  82147. * If the post process is supported.
  82148. */
  82149. readonly isSupported: boolean;
  82150. /**
  82151. * The aspect ratio of the output texture.
  82152. */
  82153. readonly aspectRatio: number;
  82154. /**
  82155. * Get a value indicating if the post-process is ready to be used
  82156. * @returns true if the post-process is ready (shader is compiled)
  82157. */
  82158. isReady(): boolean;
  82159. /**
  82160. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82161. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82162. */
  82163. apply(): Nullable<Effect>;
  82164. private _disposeTextures;
  82165. /**
  82166. * Disposes the post process.
  82167. * @param camera The camera to dispose the post process on.
  82168. */
  82169. dispose(camera?: Camera): void;
  82170. }
  82171. }
  82172. declare module BABYLON {
  82173. /** @hidden */
  82174. export var kernelBlurVaryingDeclaration: {
  82175. name: string;
  82176. shader: string;
  82177. };
  82178. }
  82179. declare module BABYLON {
  82180. /** @hidden */
  82181. export var kernelBlurFragment: {
  82182. name: string;
  82183. shader: string;
  82184. };
  82185. }
  82186. declare module BABYLON {
  82187. /** @hidden */
  82188. export var kernelBlurFragment2: {
  82189. name: string;
  82190. shader: string;
  82191. };
  82192. }
  82193. declare module BABYLON {
  82194. /** @hidden */
  82195. export var kernelBlurPixelShader: {
  82196. name: string;
  82197. shader: string;
  82198. };
  82199. }
  82200. declare module BABYLON {
  82201. /** @hidden */
  82202. export var kernelBlurVertex: {
  82203. name: string;
  82204. shader: string;
  82205. };
  82206. }
  82207. declare module BABYLON {
  82208. /** @hidden */
  82209. export var kernelBlurVertexShader: {
  82210. name: string;
  82211. shader: string;
  82212. };
  82213. }
  82214. declare module BABYLON {
  82215. /**
  82216. * The Blur Post Process which blurs an image based on a kernel and direction.
  82217. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82218. */
  82219. export class BlurPostProcess extends PostProcess {
  82220. /** The direction in which to blur the image. */
  82221. direction: Vector2;
  82222. private blockCompilation;
  82223. protected _kernel: number;
  82224. protected _idealKernel: number;
  82225. protected _packedFloat: boolean;
  82226. private _staticDefines;
  82227. /**
  82228. * Sets the length in pixels of the blur sample region
  82229. */
  82230. /**
  82231. * Gets the length in pixels of the blur sample region
  82232. */
  82233. kernel: number;
  82234. /**
  82235. * Sets wether or not the blur needs to unpack/repack floats
  82236. */
  82237. /**
  82238. * Gets wether or not the blur is unpacking/repacking floats
  82239. */
  82240. packedFloat: boolean;
  82241. /**
  82242. * Creates a new instance BlurPostProcess
  82243. * @param name The name of the effect.
  82244. * @param direction The direction in which to blur the image.
  82245. * @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.
  82246. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82247. * @param camera The camera to apply the render pass to.
  82248. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82249. * @param engine The engine which the post process will be applied. (default: current engine)
  82250. * @param reusable If the post process can be reused on the same frame. (default: false)
  82251. * @param textureType Type of textures used when performing the post process. (default: 0)
  82252. * @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)
  82253. */
  82254. constructor(name: string,
  82255. /** The direction in which to blur the image. */
  82256. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82257. /**
  82258. * Updates the effect with the current post process compile time values and recompiles the shader.
  82259. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82260. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82261. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82262. * @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
  82263. * @param onCompiled Called when the shader has been compiled.
  82264. * @param onError Called if there is an error when compiling a shader.
  82265. */
  82266. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82267. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82268. /**
  82269. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82270. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82271. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82272. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82273. * The gaps between physical kernels are compensated for in the weighting of the samples
  82274. * @param idealKernel Ideal blur kernel.
  82275. * @return Nearest best kernel.
  82276. */
  82277. protected _nearestBestKernel(idealKernel: number): number;
  82278. /**
  82279. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82280. * @param x The point on the Gaussian distribution to sample.
  82281. * @return the value of the Gaussian function at x.
  82282. */
  82283. protected _gaussianWeight(x: number): number;
  82284. /**
  82285. * Generates a string that can be used as a floating point number in GLSL.
  82286. * @param x Value to print.
  82287. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82288. * @return GLSL float string.
  82289. */
  82290. protected _glslFloat(x: number, decimalFigures?: number): string;
  82291. }
  82292. }
  82293. declare module BABYLON {
  82294. /**
  82295. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82296. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82297. * You can then easily use it as a reflectionTexture on a flat surface.
  82298. * In case the surface is not a plane, please consider relying on reflection probes.
  82299. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82300. */
  82301. export class MirrorTexture extends RenderTargetTexture {
  82302. private scene;
  82303. /**
  82304. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82305. * 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.
  82306. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82307. */
  82308. mirrorPlane: Plane;
  82309. /**
  82310. * Define the blur ratio used to blur the reflection if needed.
  82311. */
  82312. blurRatio: number;
  82313. /**
  82314. * Define the adaptive blur kernel used to blur the reflection if needed.
  82315. * This will autocompute the closest best match for the `blurKernel`
  82316. */
  82317. adaptiveBlurKernel: number;
  82318. /**
  82319. * Define the blur kernel used to blur the reflection if needed.
  82320. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82321. */
  82322. blurKernel: number;
  82323. /**
  82324. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82325. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82326. */
  82327. blurKernelX: number;
  82328. /**
  82329. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82330. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82331. */
  82332. blurKernelY: number;
  82333. private _autoComputeBlurKernel;
  82334. protected _onRatioRescale(): void;
  82335. private _updateGammaSpace;
  82336. private _imageProcessingConfigChangeObserver;
  82337. private _transformMatrix;
  82338. private _mirrorMatrix;
  82339. private _savedViewMatrix;
  82340. private _blurX;
  82341. private _blurY;
  82342. private _adaptiveBlurKernel;
  82343. private _blurKernelX;
  82344. private _blurKernelY;
  82345. private _blurRatio;
  82346. /**
  82347. * Instantiates a Mirror Texture.
  82348. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82349. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82350. * You can then easily use it as a reflectionTexture on a flat surface.
  82351. * In case the surface is not a plane, please consider relying on reflection probes.
  82352. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82353. * @param name
  82354. * @param size
  82355. * @param scene
  82356. * @param generateMipMaps
  82357. * @param type
  82358. * @param samplingMode
  82359. * @param generateDepthBuffer
  82360. */
  82361. constructor(name: string, size: number | {
  82362. width: number;
  82363. height: number;
  82364. } | {
  82365. ratio: number;
  82366. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82367. private _preparePostProcesses;
  82368. /**
  82369. * Clone the mirror texture.
  82370. * @returns the cloned texture
  82371. */
  82372. clone(): MirrorTexture;
  82373. /**
  82374. * Serialize the texture to a JSON representation you could use in Parse later on
  82375. * @returns the serialized JSON representation
  82376. */
  82377. serialize(): any;
  82378. /**
  82379. * Dispose the texture and release its associated resources.
  82380. */
  82381. dispose(): void;
  82382. }
  82383. }
  82384. declare module BABYLON {
  82385. /**
  82386. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82387. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82388. */
  82389. export class Texture extends BaseTexture {
  82390. /**
  82391. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82392. */
  82393. static SerializeBuffers: boolean;
  82394. /** @hidden */
  82395. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82396. /** @hidden */
  82397. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82398. /** @hidden */
  82399. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82400. /** nearest is mag = nearest and min = nearest and mip = linear */
  82401. static readonly NEAREST_SAMPLINGMODE: number;
  82402. /** nearest is mag = nearest and min = nearest and mip = linear */
  82403. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82404. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82405. static readonly BILINEAR_SAMPLINGMODE: number;
  82406. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82407. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82408. /** Trilinear is mag = linear and min = linear and mip = linear */
  82409. static readonly TRILINEAR_SAMPLINGMODE: number;
  82410. /** Trilinear is mag = linear and min = linear and mip = linear */
  82411. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82412. /** mag = nearest and min = nearest and mip = nearest */
  82413. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82414. /** mag = nearest and min = linear and mip = nearest */
  82415. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82416. /** mag = nearest and min = linear and mip = linear */
  82417. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82418. /** mag = nearest and min = linear and mip = none */
  82419. static readonly NEAREST_LINEAR: number;
  82420. /** mag = nearest and min = nearest and mip = none */
  82421. static readonly NEAREST_NEAREST: number;
  82422. /** mag = linear and min = nearest and mip = nearest */
  82423. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82424. /** mag = linear and min = nearest and mip = linear */
  82425. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82426. /** mag = linear and min = linear and mip = none */
  82427. static readonly LINEAR_LINEAR: number;
  82428. /** mag = linear and min = nearest and mip = none */
  82429. static readonly LINEAR_NEAREST: number;
  82430. /** Explicit coordinates mode */
  82431. static readonly EXPLICIT_MODE: number;
  82432. /** Spherical coordinates mode */
  82433. static readonly SPHERICAL_MODE: number;
  82434. /** Planar coordinates mode */
  82435. static readonly PLANAR_MODE: number;
  82436. /** Cubic coordinates mode */
  82437. static readonly CUBIC_MODE: number;
  82438. /** Projection coordinates mode */
  82439. static readonly PROJECTION_MODE: number;
  82440. /** Inverse Cubic coordinates mode */
  82441. static readonly SKYBOX_MODE: number;
  82442. /** Inverse Cubic coordinates mode */
  82443. static readonly INVCUBIC_MODE: number;
  82444. /** Equirectangular coordinates mode */
  82445. static readonly EQUIRECTANGULAR_MODE: number;
  82446. /** Equirectangular Fixed coordinates mode */
  82447. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82448. /** Equirectangular Fixed Mirrored coordinates mode */
  82449. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82450. /** Texture is not repeating outside of 0..1 UVs */
  82451. static readonly CLAMP_ADDRESSMODE: number;
  82452. /** Texture is repeating outside of 0..1 UVs */
  82453. static readonly WRAP_ADDRESSMODE: number;
  82454. /** Texture is repeating and mirrored */
  82455. static readonly MIRROR_ADDRESSMODE: number;
  82456. /**
  82457. * 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
  82458. */
  82459. static UseSerializedUrlIfAny: boolean;
  82460. /**
  82461. * Define the url of the texture.
  82462. */
  82463. url: Nullable<string>;
  82464. /**
  82465. * Define an offset on the texture to offset the u coordinates of the UVs
  82466. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82467. */
  82468. uOffset: number;
  82469. /**
  82470. * Define an offset on the texture to offset the v coordinates of the UVs
  82471. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82472. */
  82473. vOffset: number;
  82474. /**
  82475. * Define an offset on the texture to scale the u coordinates of the UVs
  82476. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82477. */
  82478. uScale: number;
  82479. /**
  82480. * Define an offset on the texture to scale the v coordinates of the UVs
  82481. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82482. */
  82483. vScale: number;
  82484. /**
  82485. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82486. * @see http://doc.babylonjs.com/how_to/more_materials
  82487. */
  82488. uAng: number;
  82489. /**
  82490. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82491. * @see http://doc.babylonjs.com/how_to/more_materials
  82492. */
  82493. vAng: number;
  82494. /**
  82495. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82496. * @see http://doc.babylonjs.com/how_to/more_materials
  82497. */
  82498. wAng: number;
  82499. /**
  82500. * Defines the center of rotation (U)
  82501. */
  82502. uRotationCenter: number;
  82503. /**
  82504. * Defines the center of rotation (V)
  82505. */
  82506. vRotationCenter: number;
  82507. /**
  82508. * Defines the center of rotation (W)
  82509. */
  82510. wRotationCenter: number;
  82511. /**
  82512. * Are mip maps generated for this texture or not.
  82513. */
  82514. readonly noMipmap: boolean;
  82515. /**
  82516. * List of inspectable custom properties (used by the Inspector)
  82517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82518. */
  82519. inspectableCustomProperties: Nullable<IInspectable[]>;
  82520. private _noMipmap;
  82521. /** @hidden */
  82522. _invertY: boolean;
  82523. private _rowGenerationMatrix;
  82524. private _cachedTextureMatrix;
  82525. private _projectionModeMatrix;
  82526. private _t0;
  82527. private _t1;
  82528. private _t2;
  82529. private _cachedUOffset;
  82530. private _cachedVOffset;
  82531. private _cachedUScale;
  82532. private _cachedVScale;
  82533. private _cachedUAng;
  82534. private _cachedVAng;
  82535. private _cachedWAng;
  82536. private _cachedProjectionMatrixId;
  82537. private _cachedCoordinatesMode;
  82538. /** @hidden */
  82539. protected _initialSamplingMode: number;
  82540. /** @hidden */
  82541. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82542. private _deleteBuffer;
  82543. protected _format: Nullable<number>;
  82544. private _delayedOnLoad;
  82545. private _delayedOnError;
  82546. /**
  82547. * Observable triggered once the texture has been loaded.
  82548. */
  82549. onLoadObservable: Observable<Texture>;
  82550. protected _isBlocking: boolean;
  82551. /**
  82552. * Is the texture preventing material to render while loading.
  82553. * If false, a default texture will be used instead of the loading one during the preparation step.
  82554. */
  82555. isBlocking: boolean;
  82556. /**
  82557. * Get the current sampling mode associated with the texture.
  82558. */
  82559. readonly samplingMode: number;
  82560. /**
  82561. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82562. */
  82563. readonly invertY: boolean;
  82564. /**
  82565. * Instantiates a new texture.
  82566. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82567. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82568. * @param url define the url of the picture to load as a texture
  82569. * @param scene define the scene or engine the texture will belong to
  82570. * @param noMipmap define if the texture will require mip maps or not
  82571. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82572. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82573. * @param onLoad define a callback triggered when the texture has been loaded
  82574. * @param onError define a callback triggered when an error occurred during the loading session
  82575. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82576. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82577. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82578. */
  82579. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  82580. /**
  82581. * Update the url (and optional buffer) of this texture if url was null during construction.
  82582. * @param url the url of the texture
  82583. * @param buffer the buffer of the texture (defaults to null)
  82584. * @param onLoad callback called when the texture is loaded (defaults to null)
  82585. */
  82586. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82587. /**
  82588. * Finish the loading sequence of a texture flagged as delayed load.
  82589. * @hidden
  82590. */
  82591. delayLoad(): void;
  82592. private _prepareRowForTextureGeneration;
  82593. /**
  82594. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82595. * @returns the transform matrix of the texture.
  82596. */
  82597. getTextureMatrix(): Matrix;
  82598. /**
  82599. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82600. * @returns The reflection texture transform
  82601. */
  82602. getReflectionTextureMatrix(): Matrix;
  82603. /**
  82604. * Clones the texture.
  82605. * @returns the cloned texture
  82606. */
  82607. clone(): Texture;
  82608. /**
  82609. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82610. * @returns The JSON representation of the texture
  82611. */
  82612. serialize(): any;
  82613. /**
  82614. * Get the current class name of the texture useful for serialization or dynamic coding.
  82615. * @returns "Texture"
  82616. */
  82617. getClassName(): string;
  82618. /**
  82619. * Dispose the texture and release its associated resources.
  82620. */
  82621. dispose(): void;
  82622. /**
  82623. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82624. * @param parsedTexture Define the JSON representation of the texture
  82625. * @param scene Define the scene the parsed texture should be instantiated in
  82626. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82627. * @returns The parsed texture if successful
  82628. */
  82629. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82630. /**
  82631. * Creates a texture from its base 64 representation.
  82632. * @param data Define the base64 payload without the data: prefix
  82633. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82634. * @param scene Define the scene the texture should belong to
  82635. * @param noMipmap Forces the texture to not create mip map information if true
  82636. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82637. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82638. * @param onLoad define a callback triggered when the texture has been loaded
  82639. * @param onError define a callback triggered when an error occurred during the loading session
  82640. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82641. * @returns the created texture
  82642. */
  82643. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82644. /**
  82645. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82646. * @param data Define the base64 payload without the data: prefix
  82647. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82648. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82649. * @param scene Define the scene the texture should belong to
  82650. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82651. * @param noMipmap Forces the texture to not create mip map information if true
  82652. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82653. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82654. * @param onLoad define a callback triggered when the texture has been loaded
  82655. * @param onError define a callback triggered when an error occurred during the loading session
  82656. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82657. * @returns the created texture
  82658. */
  82659. 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;
  82660. }
  82661. }
  82662. declare module BABYLON {
  82663. /**
  82664. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82665. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82666. */
  82667. export class PostProcessManager {
  82668. private _scene;
  82669. private _indexBuffer;
  82670. private _vertexBuffers;
  82671. /**
  82672. * Creates a new instance PostProcess
  82673. * @param scene The scene that the post process is associated with.
  82674. */
  82675. constructor(scene: Scene);
  82676. private _prepareBuffers;
  82677. private _buildIndexBuffer;
  82678. /**
  82679. * Rebuilds the vertex buffers of the manager.
  82680. * @hidden
  82681. */
  82682. _rebuild(): void;
  82683. /**
  82684. * Prepares a frame to be run through a post process.
  82685. * @param sourceTexture The input texture to the post procesess. (default: null)
  82686. * @param postProcesses An array of post processes to be run. (default: null)
  82687. * @returns True if the post processes were able to be run.
  82688. * @hidden
  82689. */
  82690. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82691. /**
  82692. * Manually render a set of post processes to a texture.
  82693. * @param postProcesses An array of post processes to be run.
  82694. * @param targetTexture The target texture to render to.
  82695. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82696. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82697. * @param lodLevel defines which lod of the texture to render to
  82698. */
  82699. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82700. /**
  82701. * Finalize the result of the output of the postprocesses.
  82702. * @param doNotPresent If true the result will not be displayed to the screen.
  82703. * @param targetTexture The target texture to render to.
  82704. * @param faceIndex The index of the face to bind the target texture to.
  82705. * @param postProcesses The array of post processes to render.
  82706. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82707. * @hidden
  82708. */
  82709. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82710. /**
  82711. * Disposes of the post process manager.
  82712. */
  82713. dispose(): void;
  82714. }
  82715. }
  82716. declare module BABYLON {
  82717. /** Interface used by value gradients (color, factor, ...) */
  82718. export interface IValueGradient {
  82719. /**
  82720. * Gets or sets the gradient value (between 0 and 1)
  82721. */
  82722. gradient: number;
  82723. }
  82724. /** Class used to store color4 gradient */
  82725. export class ColorGradient implements IValueGradient {
  82726. /**
  82727. * Gets or sets the gradient value (between 0 and 1)
  82728. */
  82729. gradient: number;
  82730. /**
  82731. * Gets or sets first associated color
  82732. */
  82733. color1: Color4;
  82734. /**
  82735. * Gets or sets second associated color
  82736. */
  82737. color2?: Color4;
  82738. /**
  82739. * Will get a color picked randomly between color1 and color2.
  82740. * If color2 is undefined then color1 will be used
  82741. * @param result defines the target Color4 to store the result in
  82742. */
  82743. getColorToRef(result: Color4): void;
  82744. }
  82745. /** Class used to store color 3 gradient */
  82746. export class Color3Gradient implements IValueGradient {
  82747. /**
  82748. * Gets or sets the gradient value (between 0 and 1)
  82749. */
  82750. gradient: number;
  82751. /**
  82752. * Gets or sets the associated color
  82753. */
  82754. color: Color3;
  82755. }
  82756. /** Class used to store factor gradient */
  82757. export class FactorGradient implements IValueGradient {
  82758. /**
  82759. * Gets or sets the gradient value (between 0 and 1)
  82760. */
  82761. gradient: number;
  82762. /**
  82763. * Gets or sets first associated factor
  82764. */
  82765. factor1: number;
  82766. /**
  82767. * Gets or sets second associated factor
  82768. */
  82769. factor2?: number;
  82770. /**
  82771. * Will get a number picked randomly between factor1 and factor2.
  82772. * If factor2 is undefined then factor1 will be used
  82773. * @returns the picked number
  82774. */
  82775. getFactor(): number;
  82776. }
  82777. /**
  82778. * Helper used to simplify some generic gradient tasks
  82779. */
  82780. export class GradientHelper {
  82781. /**
  82782. * Gets the current gradient from an array of IValueGradient
  82783. * @param ratio defines the current ratio to get
  82784. * @param gradients defines the array of IValueGradient
  82785. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82786. */
  82787. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82788. }
  82789. }
  82790. declare module BABYLON {
  82791. interface ThinEngine {
  82792. /**
  82793. * Creates a dynamic texture
  82794. * @param width defines the width of the texture
  82795. * @param height defines the height of the texture
  82796. * @param generateMipMaps defines if the engine should generate the mip levels
  82797. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82798. * @returns the dynamic texture inside an InternalTexture
  82799. */
  82800. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82801. /**
  82802. * Update the content of a dynamic texture
  82803. * @param texture defines the texture to update
  82804. * @param canvas defines the canvas containing the source
  82805. * @param invertY defines if data must be stored with Y axis inverted
  82806. * @param premulAlpha defines if alpha is stored as premultiplied
  82807. * @param format defines the format of the data
  82808. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82809. */
  82810. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82811. }
  82812. }
  82813. declare module BABYLON {
  82814. /**
  82815. * A class extending Texture allowing drawing on a texture
  82816. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82817. */
  82818. export class DynamicTexture extends Texture {
  82819. private _generateMipMaps;
  82820. private _canvas;
  82821. private _context;
  82822. private _engine;
  82823. /**
  82824. * Creates a DynamicTexture
  82825. * @param name defines the name of the texture
  82826. * @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
  82827. * @param scene defines the scene where you want the texture
  82828. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82829. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82830. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82831. */
  82832. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82833. /**
  82834. * Get the current class name of the texture useful for serialization or dynamic coding.
  82835. * @returns "DynamicTexture"
  82836. */
  82837. getClassName(): string;
  82838. /**
  82839. * Gets the current state of canRescale
  82840. */
  82841. readonly canRescale: boolean;
  82842. private _recreate;
  82843. /**
  82844. * Scales the texture
  82845. * @param ratio the scale factor to apply to both width and height
  82846. */
  82847. scale(ratio: number): void;
  82848. /**
  82849. * Resizes the texture
  82850. * @param width the new width
  82851. * @param height the new height
  82852. */
  82853. scaleTo(width: number, height: number): void;
  82854. /**
  82855. * Gets the context of the canvas used by the texture
  82856. * @returns the canvas context of the dynamic texture
  82857. */
  82858. getContext(): CanvasRenderingContext2D;
  82859. /**
  82860. * Clears the texture
  82861. */
  82862. clear(): void;
  82863. /**
  82864. * Updates the texture
  82865. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82866. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82867. */
  82868. update(invertY?: boolean, premulAlpha?: boolean): void;
  82869. /**
  82870. * Draws text onto the texture
  82871. * @param text defines the text to be drawn
  82872. * @param x defines the placement of the text from the left
  82873. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82874. * @param font defines the font to be used with font-style, font-size, font-name
  82875. * @param color defines the color used for the text
  82876. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82877. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82878. * @param update defines whether texture is immediately update (default is true)
  82879. */
  82880. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82881. /**
  82882. * Clones the texture
  82883. * @returns the clone of the texture.
  82884. */
  82885. clone(): DynamicTexture;
  82886. /**
  82887. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82888. * @returns a serialized dynamic texture object
  82889. */
  82890. serialize(): any;
  82891. /** @hidden */
  82892. _rebuild(): void;
  82893. }
  82894. }
  82895. declare module BABYLON {
  82896. interface AbstractScene {
  82897. /**
  82898. * The list of procedural textures added to the scene
  82899. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82900. */
  82901. proceduralTextures: Array<ProceduralTexture>;
  82902. }
  82903. /**
  82904. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82905. * in a given scene.
  82906. */
  82907. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82908. /**
  82909. * The component name helpfull to identify the component in the list of scene components.
  82910. */
  82911. readonly name: string;
  82912. /**
  82913. * The scene the component belongs to.
  82914. */
  82915. scene: Scene;
  82916. /**
  82917. * Creates a new instance of the component for the given scene
  82918. * @param scene Defines the scene to register the component in
  82919. */
  82920. constructor(scene: Scene);
  82921. /**
  82922. * Registers the component in a given scene
  82923. */
  82924. register(): void;
  82925. /**
  82926. * Rebuilds the elements related to this component in case of
  82927. * context lost for instance.
  82928. */
  82929. rebuild(): void;
  82930. /**
  82931. * Disposes the component and the associated ressources.
  82932. */
  82933. dispose(): void;
  82934. private _beforeClear;
  82935. }
  82936. }
  82937. declare module BABYLON {
  82938. interface ThinEngine {
  82939. /**
  82940. * Creates a new render target cube texture
  82941. * @param size defines the size of the texture
  82942. * @param options defines the options used to create the texture
  82943. * @returns a new render target cube texture stored in an InternalTexture
  82944. */
  82945. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82946. }
  82947. }
  82948. declare module BABYLON {
  82949. /** @hidden */
  82950. export var proceduralVertexShader: {
  82951. name: string;
  82952. shader: string;
  82953. };
  82954. }
  82955. declare module BABYLON {
  82956. /**
  82957. * 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.
  82958. * This is the base class of any Procedural texture and contains most of the shareable code.
  82959. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82960. */
  82961. export class ProceduralTexture extends Texture {
  82962. isCube: boolean;
  82963. /**
  82964. * Define if the texture is enabled or not (disabled texture will not render)
  82965. */
  82966. isEnabled: boolean;
  82967. /**
  82968. * Define if the texture must be cleared before rendering (default is true)
  82969. */
  82970. autoClear: boolean;
  82971. /**
  82972. * Callback called when the texture is generated
  82973. */
  82974. onGenerated: () => void;
  82975. /**
  82976. * Event raised when the texture is generated
  82977. */
  82978. onGeneratedObservable: Observable<ProceduralTexture>;
  82979. /** @hidden */
  82980. _generateMipMaps: boolean;
  82981. /** @hidden **/
  82982. _effect: Effect;
  82983. /** @hidden */
  82984. _textures: {
  82985. [key: string]: Texture;
  82986. };
  82987. private _size;
  82988. private _currentRefreshId;
  82989. private _refreshRate;
  82990. private _vertexBuffers;
  82991. private _indexBuffer;
  82992. private _uniforms;
  82993. private _samplers;
  82994. private _fragment;
  82995. private _floats;
  82996. private _ints;
  82997. private _floatsArrays;
  82998. private _colors3;
  82999. private _colors4;
  83000. private _vectors2;
  83001. private _vectors3;
  83002. private _matrices;
  83003. private _fallbackTexture;
  83004. private _fallbackTextureUsed;
  83005. private _engine;
  83006. private _cachedDefines;
  83007. private _contentUpdateId;
  83008. private _contentData;
  83009. /**
  83010. * Instantiates a new procedural texture.
  83011. * 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.
  83012. * This is the base class of any Procedural texture and contains most of the shareable code.
  83013. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83014. * @param name Define the name of the texture
  83015. * @param size Define the size of the texture to create
  83016. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83017. * @param scene Define the scene the texture belongs to
  83018. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83019. * @param generateMipMaps Define if the texture should creates mip maps or not
  83020. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83021. */
  83022. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83023. /**
  83024. * The effect that is created when initializing the post process.
  83025. * @returns The created effect corresponding the the postprocess.
  83026. */
  83027. getEffect(): Effect;
  83028. /**
  83029. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83030. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83031. */
  83032. getContent(): Nullable<ArrayBufferView>;
  83033. private _createIndexBuffer;
  83034. /** @hidden */
  83035. _rebuild(): void;
  83036. /**
  83037. * Resets the texture in order to recreate its associated resources.
  83038. * This can be called in case of context loss
  83039. */
  83040. reset(): void;
  83041. protected _getDefines(): string;
  83042. /**
  83043. * Is the texture ready to be used ? (rendered at least once)
  83044. * @returns true if ready, otherwise, false.
  83045. */
  83046. isReady(): boolean;
  83047. /**
  83048. * Resets the refresh counter of the texture and start bak from scratch.
  83049. * Could be useful to regenerate the texture if it is setup to render only once.
  83050. */
  83051. resetRefreshCounter(): void;
  83052. /**
  83053. * Set the fragment shader to use in order to render the texture.
  83054. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83055. */
  83056. setFragment(fragment: any): void;
  83057. /**
  83058. * Define the refresh rate of the texture or the rendering frequency.
  83059. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83060. */
  83061. refreshRate: number;
  83062. /** @hidden */
  83063. _shouldRender(): boolean;
  83064. /**
  83065. * Get the size the texture is rendering at.
  83066. * @returns the size (texture is always squared)
  83067. */
  83068. getRenderSize(): number;
  83069. /**
  83070. * Resize the texture to new value.
  83071. * @param size Define the new size the texture should have
  83072. * @param generateMipMaps Define whether the new texture should create mip maps
  83073. */
  83074. resize(size: number, generateMipMaps: boolean): void;
  83075. private _checkUniform;
  83076. /**
  83077. * Set a texture in the shader program used to render.
  83078. * @param name Define the name of the uniform samplers as defined in the shader
  83079. * @param texture Define the texture to bind to this sampler
  83080. * @return the texture itself allowing "fluent" like uniform updates
  83081. */
  83082. setTexture(name: string, texture: Texture): ProceduralTexture;
  83083. /**
  83084. * Set a float in the shader.
  83085. * @param name Define the name of the uniform as defined in the shader
  83086. * @param value Define the value to give to the uniform
  83087. * @return the texture itself allowing "fluent" like uniform updates
  83088. */
  83089. setFloat(name: string, value: number): ProceduralTexture;
  83090. /**
  83091. * Set a int in the shader.
  83092. * @param name Define the name of the uniform as defined in the shader
  83093. * @param value Define the value to give to the uniform
  83094. * @return the texture itself allowing "fluent" like uniform updates
  83095. */
  83096. setInt(name: string, value: number): ProceduralTexture;
  83097. /**
  83098. * Set an array of floats in the shader.
  83099. * @param name Define the name of the uniform as defined in the shader
  83100. * @param value Define the value to give to the uniform
  83101. * @return the texture itself allowing "fluent" like uniform updates
  83102. */
  83103. setFloats(name: string, value: number[]): ProceduralTexture;
  83104. /**
  83105. * Set a vec3 in the shader from a Color3.
  83106. * @param name Define the name of the uniform as defined in the shader
  83107. * @param value Define the value to give to the uniform
  83108. * @return the texture itself allowing "fluent" like uniform updates
  83109. */
  83110. setColor3(name: string, value: Color3): ProceduralTexture;
  83111. /**
  83112. * Set a vec4 in the shader from a Color4.
  83113. * @param name Define the name of the uniform as defined in the shader
  83114. * @param value Define the value to give to the uniform
  83115. * @return the texture itself allowing "fluent" like uniform updates
  83116. */
  83117. setColor4(name: string, value: Color4): ProceduralTexture;
  83118. /**
  83119. * Set a vec2 in the shader from a Vector2.
  83120. * @param name Define the name of the uniform as defined in the shader
  83121. * @param value Define the value to give to the uniform
  83122. * @return the texture itself allowing "fluent" like uniform updates
  83123. */
  83124. setVector2(name: string, value: Vector2): ProceduralTexture;
  83125. /**
  83126. * Set a vec3 in the shader from a Vector3.
  83127. * @param name Define the name of the uniform as defined in the shader
  83128. * @param value Define the value to give to the uniform
  83129. * @return the texture itself allowing "fluent" like uniform updates
  83130. */
  83131. setVector3(name: string, value: Vector3): ProceduralTexture;
  83132. /**
  83133. * Set a mat4 in the shader from a MAtrix.
  83134. * @param name Define the name of the uniform as defined in the shader
  83135. * @param value Define the value to give to the uniform
  83136. * @return the texture itself allowing "fluent" like uniform updates
  83137. */
  83138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83139. /**
  83140. * Render the texture to its associated render target.
  83141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83142. */
  83143. render(useCameraPostProcess?: boolean): void;
  83144. /**
  83145. * Clone the texture.
  83146. * @returns the cloned texture
  83147. */
  83148. clone(): ProceduralTexture;
  83149. /**
  83150. * Dispose the texture and release its asoociated resources.
  83151. */
  83152. dispose(): void;
  83153. }
  83154. }
  83155. declare module BABYLON {
  83156. /**
  83157. * This represents the base class for particle system in Babylon.
  83158. * 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.
  83159. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83160. * @example https://doc.babylonjs.com/babylon101/particles
  83161. */
  83162. export class BaseParticleSystem {
  83163. /**
  83164. * Source color is added to the destination color without alpha affecting the result
  83165. */
  83166. static BLENDMODE_ONEONE: number;
  83167. /**
  83168. * Blend current color and particle color using particle’s alpha
  83169. */
  83170. static BLENDMODE_STANDARD: number;
  83171. /**
  83172. * Add current color and particle color multiplied by particle’s alpha
  83173. */
  83174. static BLENDMODE_ADD: number;
  83175. /**
  83176. * Multiply current color with particle color
  83177. */
  83178. static BLENDMODE_MULTIPLY: number;
  83179. /**
  83180. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83181. */
  83182. static BLENDMODE_MULTIPLYADD: number;
  83183. /**
  83184. * List of animations used by the particle system.
  83185. */
  83186. animations: Animation[];
  83187. /**
  83188. * The id of the Particle system.
  83189. */
  83190. id: string;
  83191. /**
  83192. * The friendly name of the Particle system.
  83193. */
  83194. name: string;
  83195. /**
  83196. * The rendering group used by the Particle system to chose when to render.
  83197. */
  83198. renderingGroupId: number;
  83199. /**
  83200. * The emitter represents the Mesh or position we are attaching the particle system to.
  83201. */
  83202. emitter: Nullable<AbstractMesh | Vector3>;
  83203. /**
  83204. * The maximum number of particles to emit per frame
  83205. */
  83206. emitRate: number;
  83207. /**
  83208. * If you want to launch only a few particles at once, that can be done, as well.
  83209. */
  83210. manualEmitCount: number;
  83211. /**
  83212. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83213. */
  83214. updateSpeed: number;
  83215. /**
  83216. * The amount of time the particle system is running (depends of the overall update speed).
  83217. */
  83218. targetStopDuration: number;
  83219. /**
  83220. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83221. */
  83222. disposeOnStop: boolean;
  83223. /**
  83224. * Minimum power of emitting particles.
  83225. */
  83226. minEmitPower: number;
  83227. /**
  83228. * Maximum power of emitting particles.
  83229. */
  83230. maxEmitPower: number;
  83231. /**
  83232. * Minimum life time of emitting particles.
  83233. */
  83234. minLifeTime: number;
  83235. /**
  83236. * Maximum life time of emitting particles.
  83237. */
  83238. maxLifeTime: number;
  83239. /**
  83240. * Minimum Size of emitting particles.
  83241. */
  83242. minSize: number;
  83243. /**
  83244. * Maximum Size of emitting particles.
  83245. */
  83246. maxSize: number;
  83247. /**
  83248. * Minimum scale of emitting particles on X axis.
  83249. */
  83250. minScaleX: number;
  83251. /**
  83252. * Maximum scale of emitting particles on X axis.
  83253. */
  83254. maxScaleX: number;
  83255. /**
  83256. * Minimum scale of emitting particles on Y axis.
  83257. */
  83258. minScaleY: number;
  83259. /**
  83260. * Maximum scale of emitting particles on Y axis.
  83261. */
  83262. maxScaleY: number;
  83263. /**
  83264. * Gets or sets the minimal initial rotation in radians.
  83265. */
  83266. minInitialRotation: number;
  83267. /**
  83268. * Gets or sets the maximal initial rotation in radians.
  83269. */
  83270. maxInitialRotation: number;
  83271. /**
  83272. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83273. */
  83274. minAngularSpeed: number;
  83275. /**
  83276. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83277. */
  83278. maxAngularSpeed: number;
  83279. /**
  83280. * The texture used to render each particle. (this can be a spritesheet)
  83281. */
  83282. particleTexture: Nullable<Texture>;
  83283. /**
  83284. * The layer mask we are rendering the particles through.
  83285. */
  83286. layerMask: number;
  83287. /**
  83288. * This can help using your own shader to render the particle system.
  83289. * The according effect will be created
  83290. */
  83291. customShader: any;
  83292. /**
  83293. * By default particle system starts as soon as they are created. This prevents the
  83294. * automatic start to happen and let you decide when to start emitting particles.
  83295. */
  83296. preventAutoStart: boolean;
  83297. private _noiseTexture;
  83298. /**
  83299. * Gets or sets a texture used to add random noise to particle positions
  83300. */
  83301. noiseTexture: Nullable<ProceduralTexture>;
  83302. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83303. noiseStrength: Vector3;
  83304. /**
  83305. * Callback triggered when the particle animation is ending.
  83306. */
  83307. onAnimationEnd: Nullable<() => void>;
  83308. /**
  83309. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83310. */
  83311. blendMode: number;
  83312. /**
  83313. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83314. * to override the particles.
  83315. */
  83316. forceDepthWrite: boolean;
  83317. /** 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 */
  83318. preWarmCycles: number;
  83319. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83320. preWarmStepOffset: number;
  83321. /**
  83322. * 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)
  83323. */
  83324. spriteCellChangeSpeed: number;
  83325. /**
  83326. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83327. */
  83328. startSpriteCellID: number;
  83329. /**
  83330. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83331. */
  83332. endSpriteCellID: number;
  83333. /**
  83334. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83335. */
  83336. spriteCellWidth: number;
  83337. /**
  83338. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83339. */
  83340. spriteCellHeight: number;
  83341. /**
  83342. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83343. */
  83344. spriteRandomStartCell: boolean;
  83345. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83346. translationPivot: Vector2;
  83347. /** @hidden */
  83348. protected _isAnimationSheetEnabled: boolean;
  83349. /**
  83350. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83351. */
  83352. beginAnimationOnStart: boolean;
  83353. /**
  83354. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83355. */
  83356. beginAnimationFrom: number;
  83357. /**
  83358. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83359. */
  83360. beginAnimationTo: number;
  83361. /**
  83362. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83363. */
  83364. beginAnimationLoop: boolean;
  83365. /**
  83366. * Gets or sets a world offset applied to all particles
  83367. */
  83368. worldOffset: Vector3;
  83369. /**
  83370. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83371. */
  83372. isAnimationSheetEnabled: boolean;
  83373. /**
  83374. * Get hosting scene
  83375. * @returns the scene
  83376. */
  83377. getScene(): Scene;
  83378. /**
  83379. * You can use gravity if you want to give an orientation to your particles.
  83380. */
  83381. gravity: Vector3;
  83382. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83383. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83384. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83385. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83386. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83387. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83388. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83389. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83390. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83391. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83392. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83393. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83394. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83395. /**
  83396. * Defines the delay in milliseconds before starting the system (0 by default)
  83397. */
  83398. startDelay: number;
  83399. /**
  83400. * Gets the current list of drag gradients.
  83401. * You must use addDragGradient and removeDragGradient to udpate this list
  83402. * @returns the list of drag gradients
  83403. */
  83404. getDragGradients(): Nullable<Array<FactorGradient>>;
  83405. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83406. limitVelocityDamping: number;
  83407. /**
  83408. * Gets the current list of limit velocity gradients.
  83409. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83410. * @returns the list of limit velocity gradients
  83411. */
  83412. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83413. /**
  83414. * Gets the current list of color gradients.
  83415. * You must use addColorGradient and removeColorGradient to udpate this list
  83416. * @returns the list of color gradients
  83417. */
  83418. getColorGradients(): Nullable<Array<ColorGradient>>;
  83419. /**
  83420. * Gets the current list of size gradients.
  83421. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83422. * @returns the list of size gradients
  83423. */
  83424. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83425. /**
  83426. * Gets the current list of color remap gradients.
  83427. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83428. * @returns the list of color remap gradients
  83429. */
  83430. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83431. /**
  83432. * Gets the current list of alpha remap gradients.
  83433. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83434. * @returns the list of alpha remap gradients
  83435. */
  83436. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83437. /**
  83438. * Gets the current list of life time gradients.
  83439. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83440. * @returns the list of life time gradients
  83441. */
  83442. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83443. /**
  83444. * Gets the current list of angular speed gradients.
  83445. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83446. * @returns the list of angular speed gradients
  83447. */
  83448. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83449. /**
  83450. * Gets the current list of velocity gradients.
  83451. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83452. * @returns the list of velocity gradients
  83453. */
  83454. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83455. /**
  83456. * Gets the current list of start size gradients.
  83457. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83458. * @returns the list of start size gradients
  83459. */
  83460. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83461. /**
  83462. * Gets the current list of emit rate gradients.
  83463. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83464. * @returns the list of emit rate gradients
  83465. */
  83466. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83467. /**
  83468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83469. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83470. */
  83471. direction1: Vector3;
  83472. /**
  83473. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83474. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83475. */
  83476. direction2: Vector3;
  83477. /**
  83478. * 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.
  83479. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83480. */
  83481. minEmitBox: Vector3;
  83482. /**
  83483. * 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.
  83484. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83485. */
  83486. maxEmitBox: Vector3;
  83487. /**
  83488. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83489. */
  83490. color1: Color4;
  83491. /**
  83492. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83493. */
  83494. color2: Color4;
  83495. /**
  83496. * Color the particle will have at the end of its lifetime
  83497. */
  83498. colorDead: Color4;
  83499. /**
  83500. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83501. */
  83502. textureMask: Color4;
  83503. /**
  83504. * The particle emitter type defines the emitter used by the particle system.
  83505. * It can be for example box, sphere, or cone...
  83506. */
  83507. particleEmitterType: IParticleEmitterType;
  83508. /** @hidden */
  83509. _isSubEmitter: boolean;
  83510. /**
  83511. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83512. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83513. */
  83514. billboardMode: number;
  83515. protected _isBillboardBased: boolean;
  83516. /**
  83517. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83518. */
  83519. isBillboardBased: boolean;
  83520. /**
  83521. * The scene the particle system belongs to.
  83522. */
  83523. protected _scene: Scene;
  83524. /**
  83525. * Local cache of defines for image processing.
  83526. */
  83527. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83528. /**
  83529. * Default configuration related to image processing available in the standard Material.
  83530. */
  83531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83532. /**
  83533. * Gets the image processing configuration used either in this material.
  83534. */
  83535. /**
  83536. * Sets the Default image processing configuration used either in the this material.
  83537. *
  83538. * If sets to null, the scene one is in use.
  83539. */
  83540. imageProcessingConfiguration: ImageProcessingConfiguration;
  83541. /**
  83542. * Attaches a new image processing configuration to the Standard Material.
  83543. * @param configuration
  83544. */
  83545. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83546. /** @hidden */
  83547. protected _reset(): void;
  83548. /** @hidden */
  83549. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83550. /**
  83551. * Instantiates a particle system.
  83552. * 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.
  83553. * @param name The name of the particle system
  83554. */
  83555. constructor(name: string);
  83556. /**
  83557. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83558. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83559. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83560. * @returns the emitter
  83561. */
  83562. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83563. /**
  83564. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83565. * @param radius The radius of the hemisphere to emit from
  83566. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83567. * @returns the emitter
  83568. */
  83569. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83570. /**
  83571. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83572. * @param radius The radius of the sphere to emit from
  83573. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83574. * @returns the emitter
  83575. */
  83576. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83577. /**
  83578. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83579. * @param radius The radius of the sphere to emit from
  83580. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83581. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83582. * @returns the emitter
  83583. */
  83584. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83585. /**
  83586. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83587. * @param radius The radius of the emission cylinder
  83588. * @param height The height of the emission cylinder
  83589. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83590. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83591. * @returns the emitter
  83592. */
  83593. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83594. /**
  83595. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83596. * @param radius The radius of the cylinder to emit from
  83597. * @param height The height of the emission cylinder
  83598. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83599. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83600. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83601. * @returns the emitter
  83602. */
  83603. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83604. /**
  83605. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83606. * @param radius The radius of the cone to emit from
  83607. * @param angle The base angle of the cone
  83608. * @returns the emitter
  83609. */
  83610. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83611. /**
  83612. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83613. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83614. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83615. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83616. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83617. * @returns the emitter
  83618. */
  83619. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83620. }
  83621. }
  83622. declare module BABYLON {
  83623. /**
  83624. * Type of sub emitter
  83625. */
  83626. export enum SubEmitterType {
  83627. /**
  83628. * Attached to the particle over it's lifetime
  83629. */
  83630. ATTACHED = 0,
  83631. /**
  83632. * Created when the particle dies
  83633. */
  83634. END = 1
  83635. }
  83636. /**
  83637. * Sub emitter class used to emit particles from an existing particle
  83638. */
  83639. export class SubEmitter {
  83640. /**
  83641. * the particle system to be used by the sub emitter
  83642. */
  83643. particleSystem: ParticleSystem;
  83644. /**
  83645. * Type of the submitter (Default: END)
  83646. */
  83647. type: SubEmitterType;
  83648. /**
  83649. * 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)
  83650. * Note: This only is supported when using an emitter of type Mesh
  83651. */
  83652. inheritDirection: boolean;
  83653. /**
  83654. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83655. */
  83656. inheritedVelocityAmount: number;
  83657. /**
  83658. * Creates a sub emitter
  83659. * @param particleSystem the particle system to be used by the sub emitter
  83660. */
  83661. constructor(
  83662. /**
  83663. * the particle system to be used by the sub emitter
  83664. */
  83665. particleSystem: ParticleSystem);
  83666. /**
  83667. * Clones the sub emitter
  83668. * @returns the cloned sub emitter
  83669. */
  83670. clone(): SubEmitter;
  83671. /**
  83672. * Serialize current object to a JSON object
  83673. * @returns the serialized object
  83674. */
  83675. serialize(): any;
  83676. /** @hidden */
  83677. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83678. /**
  83679. * Creates a new SubEmitter from a serialized JSON version
  83680. * @param serializationObject defines the JSON object to read from
  83681. * @param scene defines the hosting scene
  83682. * @param rootUrl defines the rootUrl for data loading
  83683. * @returns a new SubEmitter
  83684. */
  83685. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83686. /** Release associated resources */
  83687. dispose(): void;
  83688. }
  83689. }
  83690. declare module BABYLON {
  83691. /** @hidden */
  83692. export var clipPlaneFragmentDeclaration: {
  83693. name: string;
  83694. shader: string;
  83695. };
  83696. }
  83697. declare module BABYLON {
  83698. /** @hidden */
  83699. export var imageProcessingDeclaration: {
  83700. name: string;
  83701. shader: string;
  83702. };
  83703. }
  83704. declare module BABYLON {
  83705. /** @hidden */
  83706. export var imageProcessingFunctions: {
  83707. name: string;
  83708. shader: string;
  83709. };
  83710. }
  83711. declare module BABYLON {
  83712. /** @hidden */
  83713. export var clipPlaneFragment: {
  83714. name: string;
  83715. shader: string;
  83716. };
  83717. }
  83718. declare module BABYLON {
  83719. /** @hidden */
  83720. export var particlesPixelShader: {
  83721. name: string;
  83722. shader: string;
  83723. };
  83724. }
  83725. declare module BABYLON {
  83726. /** @hidden */
  83727. export var clipPlaneVertexDeclaration: {
  83728. name: string;
  83729. shader: string;
  83730. };
  83731. }
  83732. declare module BABYLON {
  83733. /** @hidden */
  83734. export var clipPlaneVertex: {
  83735. name: string;
  83736. shader: string;
  83737. };
  83738. }
  83739. declare module BABYLON {
  83740. /** @hidden */
  83741. export var particlesVertexShader: {
  83742. name: string;
  83743. shader: string;
  83744. };
  83745. }
  83746. declare module BABYLON {
  83747. /**
  83748. * This represents a particle system in Babylon.
  83749. * 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.
  83750. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83751. * @example https://doc.babylonjs.com/babylon101/particles
  83752. */
  83753. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83754. /**
  83755. * Billboard mode will only apply to Y axis
  83756. */
  83757. static readonly BILLBOARDMODE_Y: number;
  83758. /**
  83759. * Billboard mode will apply to all axes
  83760. */
  83761. static readonly BILLBOARDMODE_ALL: number;
  83762. /**
  83763. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83764. */
  83765. static readonly BILLBOARDMODE_STRETCHED: number;
  83766. /**
  83767. * This function can be defined to provide custom update for active particles.
  83768. * This function will be called instead of regular update (age, position, color, etc.).
  83769. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83770. */
  83771. updateFunction: (particles: Particle[]) => void;
  83772. private _emitterWorldMatrix;
  83773. /**
  83774. * This function can be defined to specify initial direction for every new particle.
  83775. * It by default use the emitterType defined function
  83776. */
  83777. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83778. /**
  83779. * This function can be defined to specify initial position for every new particle.
  83780. * It by default use the emitterType defined function
  83781. */
  83782. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83783. /**
  83784. * @hidden
  83785. */
  83786. _inheritedVelocityOffset: Vector3;
  83787. /**
  83788. * An event triggered when the system is disposed
  83789. */
  83790. onDisposeObservable: Observable<ParticleSystem>;
  83791. private _onDisposeObserver;
  83792. /**
  83793. * Sets a callback that will be triggered when the system is disposed
  83794. */
  83795. onDispose: () => void;
  83796. private _particles;
  83797. private _epsilon;
  83798. private _capacity;
  83799. private _stockParticles;
  83800. private _newPartsExcess;
  83801. private _vertexData;
  83802. private _vertexBuffer;
  83803. private _vertexBuffers;
  83804. private _spriteBuffer;
  83805. private _indexBuffer;
  83806. private _effect;
  83807. private _customEffect;
  83808. private _cachedDefines;
  83809. private _scaledColorStep;
  83810. private _colorDiff;
  83811. private _scaledDirection;
  83812. private _scaledGravity;
  83813. private _currentRenderId;
  83814. private _alive;
  83815. private _useInstancing;
  83816. private _started;
  83817. private _stopped;
  83818. private _actualFrame;
  83819. private _scaledUpdateSpeed;
  83820. private _vertexBufferSize;
  83821. /** @hidden */
  83822. _currentEmitRateGradient: Nullable<FactorGradient>;
  83823. /** @hidden */
  83824. _currentEmitRate1: number;
  83825. /** @hidden */
  83826. _currentEmitRate2: number;
  83827. /** @hidden */
  83828. _currentStartSizeGradient: Nullable<FactorGradient>;
  83829. /** @hidden */
  83830. _currentStartSize1: number;
  83831. /** @hidden */
  83832. _currentStartSize2: number;
  83833. private readonly _rawTextureWidth;
  83834. private _rampGradientsTexture;
  83835. private _useRampGradients;
  83836. /** Gets or sets a boolean indicating that ramp gradients must be used
  83837. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83838. */
  83839. useRampGradients: boolean;
  83840. /**
  83841. * 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.
  83842. * 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: [])
  83843. */
  83844. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83845. private _subEmitters;
  83846. /**
  83847. * @hidden
  83848. * If the particle systems emitter should be disposed when the particle system is disposed
  83849. */
  83850. _disposeEmitterOnDispose: boolean;
  83851. /**
  83852. * The current active Sub-systems, this property is used by the root particle system only.
  83853. */
  83854. activeSubSystems: Array<ParticleSystem>;
  83855. private _rootParticleSystem;
  83856. /**
  83857. * Gets the current list of active particles
  83858. */
  83859. readonly particles: Particle[];
  83860. /**
  83861. * Returns the string "ParticleSystem"
  83862. * @returns a string containing the class name
  83863. */
  83864. getClassName(): string;
  83865. /**
  83866. * Instantiates a particle system.
  83867. * 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.
  83868. * @param name The name of the particle system
  83869. * @param capacity The max number of particles alive at the same time
  83870. * @param scene The scene the particle system belongs to
  83871. * @param customEffect a custom effect used to change the way particles are rendered by default
  83872. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83873. * @param epsilon Offset used to render the particles
  83874. */
  83875. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83876. private _addFactorGradient;
  83877. private _removeFactorGradient;
  83878. /**
  83879. * Adds a new life time gradient
  83880. * @param gradient defines the gradient to use (between 0 and 1)
  83881. * @param factor defines the life time factor to affect to the specified gradient
  83882. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83883. * @returns the current particle system
  83884. */
  83885. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83886. /**
  83887. * Remove a specific life time gradient
  83888. * @param gradient defines the gradient to remove
  83889. * @returns the current particle system
  83890. */
  83891. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83892. /**
  83893. * Adds a new size gradient
  83894. * @param gradient defines the gradient to use (between 0 and 1)
  83895. * @param factor defines the size factor to affect to the specified gradient
  83896. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83897. * @returns the current particle system
  83898. */
  83899. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83900. /**
  83901. * Remove a specific size gradient
  83902. * @param gradient defines the gradient to remove
  83903. * @returns the current particle system
  83904. */
  83905. removeSizeGradient(gradient: number): IParticleSystem;
  83906. /**
  83907. * Adds a new color remap gradient
  83908. * @param gradient defines the gradient to use (between 0 and 1)
  83909. * @param min defines the color remap minimal range
  83910. * @param max defines the color remap maximal range
  83911. * @returns the current particle system
  83912. */
  83913. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83914. /**
  83915. * Remove a specific color remap gradient
  83916. * @param gradient defines the gradient to remove
  83917. * @returns the current particle system
  83918. */
  83919. removeColorRemapGradient(gradient: number): IParticleSystem;
  83920. /**
  83921. * Adds a new alpha remap gradient
  83922. * @param gradient defines the gradient to use (between 0 and 1)
  83923. * @param min defines the alpha remap minimal range
  83924. * @param max defines the alpha remap maximal range
  83925. * @returns the current particle system
  83926. */
  83927. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83928. /**
  83929. * Remove a specific alpha remap gradient
  83930. * @param gradient defines the gradient to remove
  83931. * @returns the current particle system
  83932. */
  83933. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83934. /**
  83935. * Adds a new angular speed gradient
  83936. * @param gradient defines the gradient to use (between 0 and 1)
  83937. * @param factor defines the angular speed to affect to the specified gradient
  83938. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83939. * @returns the current particle system
  83940. */
  83941. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83942. /**
  83943. * Remove a specific angular speed gradient
  83944. * @param gradient defines the gradient to remove
  83945. * @returns the current particle system
  83946. */
  83947. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83948. /**
  83949. * Adds a new velocity gradient
  83950. * @param gradient defines the gradient to use (between 0 and 1)
  83951. * @param factor defines the velocity to affect to the specified gradient
  83952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83953. * @returns the current particle system
  83954. */
  83955. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83956. /**
  83957. * Remove a specific velocity gradient
  83958. * @param gradient defines the gradient to remove
  83959. * @returns the current particle system
  83960. */
  83961. removeVelocityGradient(gradient: number): IParticleSystem;
  83962. /**
  83963. * Adds a new limit velocity gradient
  83964. * @param gradient defines the gradient to use (between 0 and 1)
  83965. * @param factor defines the limit velocity value to affect to the specified gradient
  83966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83967. * @returns the current particle system
  83968. */
  83969. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83970. /**
  83971. * Remove a specific limit velocity gradient
  83972. * @param gradient defines the gradient to remove
  83973. * @returns the current particle system
  83974. */
  83975. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  83976. /**
  83977. * Adds a new drag gradient
  83978. * @param gradient defines the gradient to use (between 0 and 1)
  83979. * @param factor defines the drag value to affect to the specified gradient
  83980. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83981. * @returns the current particle system
  83982. */
  83983. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83984. /**
  83985. * Remove a specific drag gradient
  83986. * @param gradient defines the gradient to remove
  83987. * @returns the current particle system
  83988. */
  83989. removeDragGradient(gradient: number): IParticleSystem;
  83990. /**
  83991. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  83992. * @param gradient defines the gradient to use (between 0 and 1)
  83993. * @param factor defines the emit rate value to affect to the specified gradient
  83994. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83995. * @returns the current particle system
  83996. */
  83997. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83998. /**
  83999. * Remove a specific emit rate gradient
  84000. * @param gradient defines the gradient to remove
  84001. * @returns the current particle system
  84002. */
  84003. removeEmitRateGradient(gradient: number): IParticleSystem;
  84004. /**
  84005. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84006. * @param gradient defines the gradient to use (between 0 and 1)
  84007. * @param factor defines the start size value to affect to the specified gradient
  84008. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84009. * @returns the current particle system
  84010. */
  84011. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84012. /**
  84013. * Remove a specific start size gradient
  84014. * @param gradient defines the gradient to remove
  84015. * @returns the current particle system
  84016. */
  84017. removeStartSizeGradient(gradient: number): IParticleSystem;
  84018. private _createRampGradientTexture;
  84019. /**
  84020. * Gets the current list of ramp gradients.
  84021. * You must use addRampGradient and removeRampGradient to udpate this list
  84022. * @returns the list of ramp gradients
  84023. */
  84024. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84025. /**
  84026. * Adds a new ramp gradient used to remap particle colors
  84027. * @param gradient defines the gradient to use (between 0 and 1)
  84028. * @param color defines the color to affect to the specified gradient
  84029. * @returns the current particle system
  84030. */
  84031. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84032. /**
  84033. * Remove a specific ramp gradient
  84034. * @param gradient defines the gradient to remove
  84035. * @returns the current particle system
  84036. */
  84037. removeRampGradient(gradient: number): ParticleSystem;
  84038. /**
  84039. * Adds a new color gradient
  84040. * @param gradient defines the gradient to use (between 0 and 1)
  84041. * @param color1 defines the color to affect to the specified gradient
  84042. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84043. * @returns this particle system
  84044. */
  84045. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84046. /**
  84047. * Remove a specific color gradient
  84048. * @param gradient defines the gradient to remove
  84049. * @returns this particle system
  84050. */
  84051. removeColorGradient(gradient: number): IParticleSystem;
  84052. private _fetchR;
  84053. protected _reset(): void;
  84054. private _resetEffect;
  84055. private _createVertexBuffers;
  84056. private _createIndexBuffer;
  84057. /**
  84058. * Gets the maximum number of particles active at the same time.
  84059. * @returns The max number of active particles.
  84060. */
  84061. getCapacity(): number;
  84062. /**
  84063. * Gets whether there are still active particles in the system.
  84064. * @returns True if it is alive, otherwise false.
  84065. */
  84066. isAlive(): boolean;
  84067. /**
  84068. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84069. * @returns True if it has been started, otherwise false.
  84070. */
  84071. isStarted(): boolean;
  84072. private _prepareSubEmitterInternalArray;
  84073. /**
  84074. * Starts the particle system and begins to emit
  84075. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84076. */
  84077. start(delay?: number): void;
  84078. /**
  84079. * Stops the particle system.
  84080. * @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.
  84081. */
  84082. stop(stopSubEmitters?: boolean): void;
  84083. /**
  84084. * Remove all active particles
  84085. */
  84086. reset(): void;
  84087. /**
  84088. * @hidden (for internal use only)
  84089. */
  84090. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84091. /**
  84092. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84093. * Its lifetime will start back at 0.
  84094. */
  84095. recycleParticle: (particle: Particle) => void;
  84096. private _stopSubEmitters;
  84097. private _createParticle;
  84098. private _removeFromRoot;
  84099. private _emitFromParticle;
  84100. private _update;
  84101. /** @hidden */
  84102. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84103. /** @hidden */
  84104. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84105. /** @hidden */
  84106. private _getEffect;
  84107. /**
  84108. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84109. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84110. */
  84111. animate(preWarmOnly?: boolean): void;
  84112. private _appendParticleVertices;
  84113. /**
  84114. * Rebuilds the particle system.
  84115. */
  84116. rebuild(): void;
  84117. /**
  84118. * Is this system ready to be used/rendered
  84119. * @return true if the system is ready
  84120. */
  84121. isReady(): boolean;
  84122. private _render;
  84123. /**
  84124. * Renders the particle system in its current state.
  84125. * @returns the current number of particles
  84126. */
  84127. render(): number;
  84128. /**
  84129. * Disposes the particle system and free the associated resources
  84130. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84131. */
  84132. dispose(disposeTexture?: boolean): void;
  84133. /**
  84134. * Clones the particle system.
  84135. * @param name The name of the cloned object
  84136. * @param newEmitter The new emitter to use
  84137. * @returns the cloned particle system
  84138. */
  84139. clone(name: string, newEmitter: any): ParticleSystem;
  84140. /**
  84141. * Serializes the particle system to a JSON object.
  84142. * @returns the JSON object
  84143. */
  84144. serialize(): any;
  84145. /** @hidden */
  84146. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84147. /** @hidden */
  84148. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84149. /**
  84150. * Parses a JSON object to create a particle system.
  84151. * @param parsedParticleSystem The JSON object to parse
  84152. * @param scene The scene to create the particle system in
  84153. * @param rootUrl The root url to use to load external dependencies like texture
  84154. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84155. * @returns the Parsed particle system
  84156. */
  84157. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84158. }
  84159. }
  84160. declare module BABYLON {
  84161. /**
  84162. * A particle represents one of the element emitted by a particle system.
  84163. * This is mainly define by its coordinates, direction, velocity and age.
  84164. */
  84165. export class Particle {
  84166. /**
  84167. * The particle system the particle belongs to.
  84168. */
  84169. particleSystem: ParticleSystem;
  84170. private static _Count;
  84171. /**
  84172. * Unique ID of the particle
  84173. */
  84174. id: number;
  84175. /**
  84176. * The world position of the particle in the scene.
  84177. */
  84178. position: Vector3;
  84179. /**
  84180. * The world direction of the particle in the scene.
  84181. */
  84182. direction: Vector3;
  84183. /**
  84184. * The color of the particle.
  84185. */
  84186. color: Color4;
  84187. /**
  84188. * The color change of the particle per step.
  84189. */
  84190. colorStep: Color4;
  84191. /**
  84192. * Defines how long will the life of the particle be.
  84193. */
  84194. lifeTime: number;
  84195. /**
  84196. * The current age of the particle.
  84197. */
  84198. age: number;
  84199. /**
  84200. * The current size of the particle.
  84201. */
  84202. size: number;
  84203. /**
  84204. * The current scale of the particle.
  84205. */
  84206. scale: Vector2;
  84207. /**
  84208. * The current angle of the particle.
  84209. */
  84210. angle: number;
  84211. /**
  84212. * Defines how fast is the angle changing.
  84213. */
  84214. angularSpeed: number;
  84215. /**
  84216. * Defines the cell index used by the particle to be rendered from a sprite.
  84217. */
  84218. cellIndex: number;
  84219. /**
  84220. * The information required to support color remapping
  84221. */
  84222. remapData: Vector4;
  84223. /** @hidden */
  84224. _randomCellOffset?: number;
  84225. /** @hidden */
  84226. _initialDirection: Nullable<Vector3>;
  84227. /** @hidden */
  84228. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84229. /** @hidden */
  84230. _initialStartSpriteCellID: number;
  84231. /** @hidden */
  84232. _initialEndSpriteCellID: number;
  84233. /** @hidden */
  84234. _currentColorGradient: Nullable<ColorGradient>;
  84235. /** @hidden */
  84236. _currentColor1: Color4;
  84237. /** @hidden */
  84238. _currentColor2: Color4;
  84239. /** @hidden */
  84240. _currentSizeGradient: Nullable<FactorGradient>;
  84241. /** @hidden */
  84242. _currentSize1: number;
  84243. /** @hidden */
  84244. _currentSize2: number;
  84245. /** @hidden */
  84246. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84247. /** @hidden */
  84248. _currentAngularSpeed1: number;
  84249. /** @hidden */
  84250. _currentAngularSpeed2: number;
  84251. /** @hidden */
  84252. _currentVelocityGradient: Nullable<FactorGradient>;
  84253. /** @hidden */
  84254. _currentVelocity1: number;
  84255. /** @hidden */
  84256. _currentVelocity2: number;
  84257. /** @hidden */
  84258. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84259. /** @hidden */
  84260. _currentLimitVelocity1: number;
  84261. /** @hidden */
  84262. _currentLimitVelocity2: number;
  84263. /** @hidden */
  84264. _currentDragGradient: Nullable<FactorGradient>;
  84265. /** @hidden */
  84266. _currentDrag1: number;
  84267. /** @hidden */
  84268. _currentDrag2: number;
  84269. /** @hidden */
  84270. _randomNoiseCoordinates1: Vector3;
  84271. /** @hidden */
  84272. _randomNoiseCoordinates2: Vector3;
  84273. /**
  84274. * Creates a new instance Particle
  84275. * @param particleSystem the particle system the particle belongs to
  84276. */
  84277. constructor(
  84278. /**
  84279. * The particle system the particle belongs to.
  84280. */
  84281. particleSystem: ParticleSystem);
  84282. private updateCellInfoFromSystem;
  84283. /**
  84284. * Defines how the sprite cell index is updated for the particle
  84285. */
  84286. updateCellIndex(): void;
  84287. /** @hidden */
  84288. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84289. /** @hidden */
  84290. _inheritParticleInfoToSubEmitters(): void;
  84291. /** @hidden */
  84292. _reset(): void;
  84293. /**
  84294. * Copy the properties of particle to another one.
  84295. * @param other the particle to copy the information to.
  84296. */
  84297. copyTo(other: Particle): void;
  84298. }
  84299. }
  84300. declare module BABYLON {
  84301. /**
  84302. * Particle emitter represents a volume emitting particles.
  84303. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84304. */
  84305. export interface IParticleEmitterType {
  84306. /**
  84307. * Called by the particle System when the direction is computed for the created particle.
  84308. * @param worldMatrix is the world matrix of the particle system
  84309. * @param directionToUpdate is the direction vector to update with the result
  84310. * @param particle is the particle we are computed the direction for
  84311. */
  84312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84313. /**
  84314. * Called by the particle System when the position is computed for the created particle.
  84315. * @param worldMatrix is the world matrix of the particle system
  84316. * @param positionToUpdate is the position vector to update with the result
  84317. * @param particle is the particle we are computed the position for
  84318. */
  84319. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84320. /**
  84321. * Clones the current emitter and returns a copy of it
  84322. * @returns the new emitter
  84323. */
  84324. clone(): IParticleEmitterType;
  84325. /**
  84326. * Called by the GPUParticleSystem to setup the update shader
  84327. * @param effect defines the update shader
  84328. */
  84329. applyToShader(effect: Effect): void;
  84330. /**
  84331. * Returns a string to use to update the GPU particles update shader
  84332. * @returns the effect defines string
  84333. */
  84334. getEffectDefines(): string;
  84335. /**
  84336. * Returns a string representing the class name
  84337. * @returns a string containing the class name
  84338. */
  84339. getClassName(): string;
  84340. /**
  84341. * Serializes the particle system to a JSON object.
  84342. * @returns the JSON object
  84343. */
  84344. serialize(): any;
  84345. /**
  84346. * Parse properties from a JSON object
  84347. * @param serializationObject defines the JSON object
  84348. */
  84349. parse(serializationObject: any): void;
  84350. }
  84351. }
  84352. declare module BABYLON {
  84353. /**
  84354. * Particle emitter emitting particles from the inside of a box.
  84355. * It emits the particles randomly between 2 given directions.
  84356. */
  84357. export class BoxParticleEmitter implements IParticleEmitterType {
  84358. /**
  84359. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84360. */
  84361. direction1: Vector3;
  84362. /**
  84363. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84364. */
  84365. direction2: Vector3;
  84366. /**
  84367. * 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.
  84368. */
  84369. minEmitBox: Vector3;
  84370. /**
  84371. * 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.
  84372. */
  84373. maxEmitBox: Vector3;
  84374. /**
  84375. * Creates a new instance BoxParticleEmitter
  84376. */
  84377. constructor();
  84378. /**
  84379. * Called by the particle System when the direction is computed for the created particle.
  84380. * @param worldMatrix is the world matrix of the particle system
  84381. * @param directionToUpdate is the direction vector to update with the result
  84382. * @param particle is the particle we are computed the direction for
  84383. */
  84384. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84385. /**
  84386. * Called by the particle System when the position is computed for the created particle.
  84387. * @param worldMatrix is the world matrix of the particle system
  84388. * @param positionToUpdate is the position vector to update with the result
  84389. * @param particle is the particle we are computed the position for
  84390. */
  84391. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84392. /**
  84393. * Clones the current emitter and returns a copy of it
  84394. * @returns the new emitter
  84395. */
  84396. clone(): BoxParticleEmitter;
  84397. /**
  84398. * Called by the GPUParticleSystem to setup the update shader
  84399. * @param effect defines the update shader
  84400. */
  84401. applyToShader(effect: Effect): void;
  84402. /**
  84403. * Returns a string to use to update the GPU particles update shader
  84404. * @returns a string containng the defines string
  84405. */
  84406. getEffectDefines(): string;
  84407. /**
  84408. * Returns the string "BoxParticleEmitter"
  84409. * @returns a string containing the class name
  84410. */
  84411. getClassName(): string;
  84412. /**
  84413. * Serializes the particle system to a JSON object.
  84414. * @returns the JSON object
  84415. */
  84416. serialize(): any;
  84417. /**
  84418. * Parse properties from a JSON object
  84419. * @param serializationObject defines the JSON object
  84420. */
  84421. parse(serializationObject: any): void;
  84422. }
  84423. }
  84424. declare module BABYLON {
  84425. /**
  84426. * Particle emitter emitting particles from the inside of a cone.
  84427. * It emits the particles alongside the cone volume from the base to the particle.
  84428. * The emission direction might be randomized.
  84429. */
  84430. export class ConeParticleEmitter implements IParticleEmitterType {
  84431. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84432. directionRandomizer: number;
  84433. private _radius;
  84434. private _angle;
  84435. private _height;
  84436. /**
  84437. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84438. */
  84439. radiusRange: number;
  84440. /**
  84441. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84442. */
  84443. heightRange: number;
  84444. /**
  84445. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84446. */
  84447. emitFromSpawnPointOnly: boolean;
  84448. /**
  84449. * Gets or sets the radius of the emission cone
  84450. */
  84451. radius: number;
  84452. /**
  84453. * Gets or sets the angle of the emission cone
  84454. */
  84455. angle: number;
  84456. private _buildHeight;
  84457. /**
  84458. * Creates a new instance ConeParticleEmitter
  84459. * @param radius the radius of the emission cone (1 by default)
  84460. * @param angle the cone base angle (PI by default)
  84461. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84462. */
  84463. constructor(radius?: number, angle?: number,
  84464. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84465. directionRandomizer?: number);
  84466. /**
  84467. * Called by the particle System when the direction is computed for the created particle.
  84468. * @param worldMatrix is the world matrix of the particle system
  84469. * @param directionToUpdate is the direction vector to update with the result
  84470. * @param particle is the particle we are computed the direction for
  84471. */
  84472. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84473. /**
  84474. * Called by the particle System when the position is computed for the created particle.
  84475. * @param worldMatrix is the world matrix of the particle system
  84476. * @param positionToUpdate is the position vector to update with the result
  84477. * @param particle is the particle we are computed the position for
  84478. */
  84479. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84480. /**
  84481. * Clones the current emitter and returns a copy of it
  84482. * @returns the new emitter
  84483. */
  84484. clone(): ConeParticleEmitter;
  84485. /**
  84486. * Called by the GPUParticleSystem to setup the update shader
  84487. * @param effect defines the update shader
  84488. */
  84489. applyToShader(effect: Effect): void;
  84490. /**
  84491. * Returns a string to use to update the GPU particles update shader
  84492. * @returns a string containng the defines string
  84493. */
  84494. getEffectDefines(): string;
  84495. /**
  84496. * Returns the string "ConeParticleEmitter"
  84497. * @returns a string containing the class name
  84498. */
  84499. getClassName(): string;
  84500. /**
  84501. * Serializes the particle system to a JSON object.
  84502. * @returns the JSON object
  84503. */
  84504. serialize(): any;
  84505. /**
  84506. * Parse properties from a JSON object
  84507. * @param serializationObject defines the JSON object
  84508. */
  84509. parse(serializationObject: any): void;
  84510. }
  84511. }
  84512. declare module BABYLON {
  84513. /**
  84514. * Particle emitter emitting particles from the inside of a cylinder.
  84515. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84516. */
  84517. export class CylinderParticleEmitter implements IParticleEmitterType {
  84518. /**
  84519. * The radius of the emission cylinder.
  84520. */
  84521. radius: number;
  84522. /**
  84523. * The height of the emission cylinder.
  84524. */
  84525. height: number;
  84526. /**
  84527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84528. */
  84529. radiusRange: number;
  84530. /**
  84531. * How much to randomize the particle direction [0-1].
  84532. */
  84533. directionRandomizer: number;
  84534. /**
  84535. * Creates a new instance CylinderParticleEmitter
  84536. * @param radius the radius of the emission cylinder (1 by default)
  84537. * @param height the height of the emission cylinder (1 by default)
  84538. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84539. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84540. */
  84541. constructor(
  84542. /**
  84543. * The radius of the emission cylinder.
  84544. */
  84545. radius?: number,
  84546. /**
  84547. * The height of the emission cylinder.
  84548. */
  84549. height?: number,
  84550. /**
  84551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84552. */
  84553. radiusRange?: number,
  84554. /**
  84555. * How much to randomize the particle direction [0-1].
  84556. */
  84557. directionRandomizer?: number);
  84558. /**
  84559. * Called by the particle System when the direction is computed for the created particle.
  84560. * @param worldMatrix is the world matrix of the particle system
  84561. * @param directionToUpdate is the direction vector to update with the result
  84562. * @param particle is the particle we are computed the direction for
  84563. */
  84564. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84565. /**
  84566. * Called by the particle System when the position is computed for the created particle.
  84567. * @param worldMatrix is the world matrix of the particle system
  84568. * @param positionToUpdate is the position vector to update with the result
  84569. * @param particle is the particle we are computed the position for
  84570. */
  84571. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84572. /**
  84573. * Clones the current emitter and returns a copy of it
  84574. * @returns the new emitter
  84575. */
  84576. clone(): CylinderParticleEmitter;
  84577. /**
  84578. * Called by the GPUParticleSystem to setup the update shader
  84579. * @param effect defines the update shader
  84580. */
  84581. applyToShader(effect: Effect): void;
  84582. /**
  84583. * Returns a string to use to update the GPU particles update shader
  84584. * @returns a string containng the defines string
  84585. */
  84586. getEffectDefines(): string;
  84587. /**
  84588. * Returns the string "CylinderParticleEmitter"
  84589. * @returns a string containing the class name
  84590. */
  84591. getClassName(): string;
  84592. /**
  84593. * Serializes the particle system to a JSON object.
  84594. * @returns the JSON object
  84595. */
  84596. serialize(): any;
  84597. /**
  84598. * Parse properties from a JSON object
  84599. * @param serializationObject defines the JSON object
  84600. */
  84601. parse(serializationObject: any): void;
  84602. }
  84603. /**
  84604. * Particle emitter emitting particles from the inside of a cylinder.
  84605. * It emits the particles randomly between two vectors.
  84606. */
  84607. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84608. /**
  84609. * The min limit of the emission direction.
  84610. */
  84611. direction1: Vector3;
  84612. /**
  84613. * The max limit of the emission direction.
  84614. */
  84615. direction2: Vector3;
  84616. /**
  84617. * Creates a new instance CylinderDirectedParticleEmitter
  84618. * @param radius the radius of the emission cylinder (1 by default)
  84619. * @param height the height of the emission cylinder (1 by default)
  84620. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84621. * @param direction1 the min limit of the emission direction (up vector by default)
  84622. * @param direction2 the max limit of the emission direction (up vector by default)
  84623. */
  84624. constructor(radius?: number, height?: number, radiusRange?: number,
  84625. /**
  84626. * The min limit of the emission direction.
  84627. */
  84628. direction1?: Vector3,
  84629. /**
  84630. * The max limit of the emission direction.
  84631. */
  84632. direction2?: Vector3);
  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. * Clones the current emitter and returns a copy of it
  84642. * @returns the new emitter
  84643. */
  84644. clone(): CylinderDirectedParticleEmitter;
  84645. /**
  84646. * Called by the GPUParticleSystem to setup the update shader
  84647. * @param effect defines the update shader
  84648. */
  84649. applyToShader(effect: Effect): void;
  84650. /**
  84651. * Returns a string to use to update the GPU particles update shader
  84652. * @returns a string containng the defines string
  84653. */
  84654. getEffectDefines(): string;
  84655. /**
  84656. * Returns the string "CylinderDirectedParticleEmitter"
  84657. * @returns a string containing the class name
  84658. */
  84659. getClassName(): string;
  84660. /**
  84661. * Serializes the particle system to a JSON object.
  84662. * @returns the JSON object
  84663. */
  84664. serialize(): any;
  84665. /**
  84666. * Parse properties from a JSON object
  84667. * @param serializationObject defines the JSON object
  84668. */
  84669. parse(serializationObject: any): void;
  84670. }
  84671. }
  84672. declare module BABYLON {
  84673. /**
  84674. * Particle emitter emitting particles from the inside of a hemisphere.
  84675. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84676. */
  84677. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84678. /**
  84679. * The radius of the emission hemisphere.
  84680. */
  84681. radius: number;
  84682. /**
  84683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84684. */
  84685. radiusRange: number;
  84686. /**
  84687. * How much to randomize the particle direction [0-1].
  84688. */
  84689. directionRandomizer: number;
  84690. /**
  84691. * Creates a new instance HemisphericParticleEmitter
  84692. * @param radius the radius of the emission hemisphere (1 by default)
  84693. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84694. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84695. */
  84696. constructor(
  84697. /**
  84698. * The radius of the emission hemisphere.
  84699. */
  84700. radius?: number,
  84701. /**
  84702. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84703. */
  84704. radiusRange?: number,
  84705. /**
  84706. * How much to randomize the particle direction [0-1].
  84707. */
  84708. directionRandomizer?: number);
  84709. /**
  84710. * Called by the particle System when the direction is computed for the created particle.
  84711. * @param worldMatrix is the world matrix of the particle system
  84712. * @param directionToUpdate is the direction vector to update with the result
  84713. * @param particle is the particle we are computed the direction for
  84714. */
  84715. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84716. /**
  84717. * Called by the particle System when the position is computed for the created particle.
  84718. * @param worldMatrix is the world matrix of the particle system
  84719. * @param positionToUpdate is the position vector to update with the result
  84720. * @param particle is the particle we are computed the position for
  84721. */
  84722. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84723. /**
  84724. * Clones the current emitter and returns a copy of it
  84725. * @returns the new emitter
  84726. */
  84727. clone(): HemisphericParticleEmitter;
  84728. /**
  84729. * Called by the GPUParticleSystem to setup the update shader
  84730. * @param effect defines the update shader
  84731. */
  84732. applyToShader(effect: Effect): void;
  84733. /**
  84734. * Returns a string to use to update the GPU particles update shader
  84735. * @returns a string containng the defines string
  84736. */
  84737. getEffectDefines(): string;
  84738. /**
  84739. * Returns the string "HemisphericParticleEmitter"
  84740. * @returns a string containing the class name
  84741. */
  84742. getClassName(): string;
  84743. /**
  84744. * Serializes the particle system to a JSON object.
  84745. * @returns the JSON object
  84746. */
  84747. serialize(): any;
  84748. /**
  84749. * Parse properties from a JSON object
  84750. * @param serializationObject defines the JSON object
  84751. */
  84752. parse(serializationObject: any): void;
  84753. }
  84754. }
  84755. declare module BABYLON {
  84756. /**
  84757. * Particle emitter emitting particles from a point.
  84758. * It emits the particles randomly between 2 given directions.
  84759. */
  84760. export class PointParticleEmitter implements IParticleEmitterType {
  84761. /**
  84762. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84763. */
  84764. direction1: Vector3;
  84765. /**
  84766. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84767. */
  84768. direction2: Vector3;
  84769. /**
  84770. * Creates a new instance PointParticleEmitter
  84771. */
  84772. constructor();
  84773. /**
  84774. * Called by the particle System when the direction is computed for the created particle.
  84775. * @param worldMatrix is the world matrix of the particle system
  84776. * @param directionToUpdate is the direction vector to update with the result
  84777. * @param particle is the particle we are computed the direction for
  84778. */
  84779. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84780. /**
  84781. * Called by the particle System when the position is computed for the created particle.
  84782. * @param worldMatrix is the world matrix of the particle system
  84783. * @param positionToUpdate is the position vector to update with the result
  84784. * @param particle is the particle we are computed the position for
  84785. */
  84786. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84787. /**
  84788. * Clones the current emitter and returns a copy of it
  84789. * @returns the new emitter
  84790. */
  84791. clone(): PointParticleEmitter;
  84792. /**
  84793. * Called by the GPUParticleSystem to setup the update shader
  84794. * @param effect defines the update shader
  84795. */
  84796. applyToShader(effect: Effect): void;
  84797. /**
  84798. * Returns a string to use to update the GPU particles update shader
  84799. * @returns a string containng the defines string
  84800. */
  84801. getEffectDefines(): string;
  84802. /**
  84803. * Returns the string "PointParticleEmitter"
  84804. * @returns a string containing the class name
  84805. */
  84806. getClassName(): string;
  84807. /**
  84808. * Serializes the particle system to a JSON object.
  84809. * @returns the JSON object
  84810. */
  84811. serialize(): any;
  84812. /**
  84813. * Parse properties from a JSON object
  84814. * @param serializationObject defines the JSON object
  84815. */
  84816. parse(serializationObject: any): void;
  84817. }
  84818. }
  84819. declare module BABYLON {
  84820. /**
  84821. * Particle emitter emitting particles from the inside of a sphere.
  84822. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84823. */
  84824. export class SphereParticleEmitter implements IParticleEmitterType {
  84825. /**
  84826. * The radius of the emission sphere.
  84827. */
  84828. radius: number;
  84829. /**
  84830. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84831. */
  84832. radiusRange: number;
  84833. /**
  84834. * How much to randomize the particle direction [0-1].
  84835. */
  84836. directionRandomizer: number;
  84837. /**
  84838. * Creates a new instance SphereParticleEmitter
  84839. * @param radius the radius of the emission sphere (1 by default)
  84840. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84841. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84842. */
  84843. constructor(
  84844. /**
  84845. * The radius of the emission sphere.
  84846. */
  84847. radius?: number,
  84848. /**
  84849. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84850. */
  84851. radiusRange?: number,
  84852. /**
  84853. * How much to randomize the particle direction [0-1].
  84854. */
  84855. directionRandomizer?: number);
  84856. /**
  84857. * Called by the particle System when the direction is computed for the created particle.
  84858. * @param worldMatrix is the world matrix of the particle system
  84859. * @param directionToUpdate is the direction vector to update with the result
  84860. * @param particle is the particle we are computed the direction for
  84861. */
  84862. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84863. /**
  84864. * Called by the particle System when the position is computed for the created particle.
  84865. * @param worldMatrix is the world matrix of the particle system
  84866. * @param positionToUpdate is the position vector to update with the result
  84867. * @param particle is the particle we are computed the position for
  84868. */
  84869. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84870. /**
  84871. * Clones the current emitter and returns a copy of it
  84872. * @returns the new emitter
  84873. */
  84874. clone(): SphereParticleEmitter;
  84875. /**
  84876. * Called by the GPUParticleSystem to setup the update shader
  84877. * @param effect defines the update shader
  84878. */
  84879. applyToShader(effect: Effect): void;
  84880. /**
  84881. * Returns a string to use to update the GPU particles update shader
  84882. * @returns a string containng the defines string
  84883. */
  84884. getEffectDefines(): string;
  84885. /**
  84886. * Returns the string "SphereParticleEmitter"
  84887. * @returns a string containing the class name
  84888. */
  84889. getClassName(): string;
  84890. /**
  84891. * Serializes the particle system to a JSON object.
  84892. * @returns the JSON object
  84893. */
  84894. serialize(): any;
  84895. /**
  84896. * Parse properties from a JSON object
  84897. * @param serializationObject defines the JSON object
  84898. */
  84899. parse(serializationObject: any): void;
  84900. }
  84901. /**
  84902. * Particle emitter emitting particles from the inside of a sphere.
  84903. * It emits the particles randomly between two vectors.
  84904. */
  84905. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84906. /**
  84907. * The min limit of the emission direction.
  84908. */
  84909. direction1: Vector3;
  84910. /**
  84911. * The max limit of the emission direction.
  84912. */
  84913. direction2: Vector3;
  84914. /**
  84915. * Creates a new instance SphereDirectedParticleEmitter
  84916. * @param radius the radius of the emission sphere (1 by default)
  84917. * @param direction1 the min limit of the emission direction (up vector by default)
  84918. * @param direction2 the max limit of the emission direction (up vector by default)
  84919. */
  84920. constructor(radius?: number,
  84921. /**
  84922. * The min limit of the emission direction.
  84923. */
  84924. direction1?: Vector3,
  84925. /**
  84926. * The max limit of the emission direction.
  84927. */
  84928. direction2?: Vector3);
  84929. /**
  84930. * Called by the particle System when the direction is computed for the created particle.
  84931. * @param worldMatrix is the world matrix of the particle system
  84932. * @param directionToUpdate is the direction vector to update with the result
  84933. * @param particle is the particle we are computed the direction for
  84934. */
  84935. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84936. /**
  84937. * Clones the current emitter and returns a copy of it
  84938. * @returns the new emitter
  84939. */
  84940. clone(): SphereDirectedParticleEmitter;
  84941. /**
  84942. * Called by the GPUParticleSystem to setup the update shader
  84943. * @param effect defines the update shader
  84944. */
  84945. applyToShader(effect: Effect): void;
  84946. /**
  84947. * Returns a string to use to update the GPU particles update shader
  84948. * @returns a string containng the defines string
  84949. */
  84950. getEffectDefines(): string;
  84951. /**
  84952. * Returns the string "SphereDirectedParticleEmitter"
  84953. * @returns a string containing the class name
  84954. */
  84955. getClassName(): string;
  84956. /**
  84957. * Serializes the particle system to a JSON object.
  84958. * @returns the JSON object
  84959. */
  84960. serialize(): any;
  84961. /**
  84962. * Parse properties from a JSON object
  84963. * @param serializationObject defines the JSON object
  84964. */
  84965. parse(serializationObject: any): void;
  84966. }
  84967. }
  84968. declare module BABYLON {
  84969. /**
  84970. * Interface representing a particle system in Babylon.js.
  84971. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84972. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84973. */
  84974. export interface IParticleSystem {
  84975. /**
  84976. * List of animations used by the particle system.
  84977. */
  84978. animations: Animation[];
  84979. /**
  84980. * The id of the Particle system.
  84981. */
  84982. id: string;
  84983. /**
  84984. * The name of the Particle system.
  84985. */
  84986. name: string;
  84987. /**
  84988. * The emitter represents the Mesh or position we are attaching the particle system to.
  84989. */
  84990. emitter: Nullable<AbstractMesh | Vector3>;
  84991. /**
  84992. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84993. */
  84994. isBillboardBased: boolean;
  84995. /**
  84996. * The rendering group used by the Particle system to chose when to render.
  84997. */
  84998. renderingGroupId: number;
  84999. /**
  85000. * The layer mask we are rendering the particles through.
  85001. */
  85002. layerMask: number;
  85003. /**
  85004. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85005. */
  85006. updateSpeed: number;
  85007. /**
  85008. * The amount of time the particle system is running (depends of the overall update speed).
  85009. */
  85010. targetStopDuration: number;
  85011. /**
  85012. * The texture used to render each particle. (this can be a spritesheet)
  85013. */
  85014. particleTexture: Nullable<Texture>;
  85015. /**
  85016. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85017. */
  85018. blendMode: number;
  85019. /**
  85020. * Minimum life time of emitting particles.
  85021. */
  85022. minLifeTime: number;
  85023. /**
  85024. * Maximum life time of emitting particles.
  85025. */
  85026. maxLifeTime: number;
  85027. /**
  85028. * Minimum Size of emitting particles.
  85029. */
  85030. minSize: number;
  85031. /**
  85032. * Maximum Size of emitting particles.
  85033. */
  85034. maxSize: number;
  85035. /**
  85036. * Minimum scale of emitting particles on X axis.
  85037. */
  85038. minScaleX: number;
  85039. /**
  85040. * Maximum scale of emitting particles on X axis.
  85041. */
  85042. maxScaleX: number;
  85043. /**
  85044. * Minimum scale of emitting particles on Y axis.
  85045. */
  85046. minScaleY: number;
  85047. /**
  85048. * Maximum scale of emitting particles on Y axis.
  85049. */
  85050. maxScaleY: number;
  85051. /**
  85052. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85053. */
  85054. color1: Color4;
  85055. /**
  85056. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85057. */
  85058. color2: Color4;
  85059. /**
  85060. * Color the particle will have at the end of its lifetime.
  85061. */
  85062. colorDead: Color4;
  85063. /**
  85064. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85065. */
  85066. emitRate: number;
  85067. /**
  85068. * You can use gravity if you want to give an orientation to your particles.
  85069. */
  85070. gravity: Vector3;
  85071. /**
  85072. * Minimum power of emitting particles.
  85073. */
  85074. minEmitPower: number;
  85075. /**
  85076. * Maximum power of emitting particles.
  85077. */
  85078. maxEmitPower: number;
  85079. /**
  85080. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85081. */
  85082. minAngularSpeed: number;
  85083. /**
  85084. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85085. */
  85086. maxAngularSpeed: number;
  85087. /**
  85088. * Gets or sets the minimal initial rotation in radians.
  85089. */
  85090. minInitialRotation: number;
  85091. /**
  85092. * Gets or sets the maximal initial rotation in radians.
  85093. */
  85094. maxInitialRotation: number;
  85095. /**
  85096. * The particle emitter type defines the emitter used by the particle system.
  85097. * It can be for example box, sphere, or cone...
  85098. */
  85099. particleEmitterType: Nullable<IParticleEmitterType>;
  85100. /**
  85101. * Defines the delay in milliseconds before starting the system (0 by default)
  85102. */
  85103. startDelay: number;
  85104. /**
  85105. * 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
  85106. */
  85107. preWarmCycles: number;
  85108. /**
  85109. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85110. */
  85111. preWarmStepOffset: number;
  85112. /**
  85113. * 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)
  85114. */
  85115. spriteCellChangeSpeed: number;
  85116. /**
  85117. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85118. */
  85119. startSpriteCellID: number;
  85120. /**
  85121. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85122. */
  85123. endSpriteCellID: number;
  85124. /**
  85125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85126. */
  85127. spriteCellWidth: number;
  85128. /**
  85129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85130. */
  85131. spriteCellHeight: number;
  85132. /**
  85133. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85134. */
  85135. spriteRandomStartCell: boolean;
  85136. /**
  85137. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85138. */
  85139. isAnimationSheetEnabled: boolean;
  85140. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85141. translationPivot: Vector2;
  85142. /**
  85143. * Gets or sets a texture used to add random noise to particle positions
  85144. */
  85145. noiseTexture: Nullable<BaseTexture>;
  85146. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85147. noiseStrength: Vector3;
  85148. /**
  85149. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85150. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85151. */
  85152. billboardMode: number;
  85153. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85154. limitVelocityDamping: number;
  85155. /**
  85156. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85157. */
  85158. beginAnimationOnStart: boolean;
  85159. /**
  85160. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85161. */
  85162. beginAnimationFrom: number;
  85163. /**
  85164. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85165. */
  85166. beginAnimationTo: number;
  85167. /**
  85168. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85169. */
  85170. beginAnimationLoop: boolean;
  85171. /**
  85172. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85173. */
  85174. disposeOnStop: boolean;
  85175. /**
  85176. * Gets the maximum number of particles active at the same time.
  85177. * @returns The max number of active particles.
  85178. */
  85179. getCapacity(): number;
  85180. /**
  85181. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85182. * @returns True if it has been started, otherwise false.
  85183. */
  85184. isStarted(): boolean;
  85185. /**
  85186. * Animates the particle system for this frame.
  85187. */
  85188. animate(): void;
  85189. /**
  85190. * Renders the particle system in its current state.
  85191. * @returns the current number of particles
  85192. */
  85193. render(): number;
  85194. /**
  85195. * Dispose the particle system and frees its associated resources.
  85196. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85197. */
  85198. dispose(disposeTexture?: boolean): void;
  85199. /**
  85200. * Clones the particle system.
  85201. * @param name The name of the cloned object
  85202. * @param newEmitter The new emitter to use
  85203. * @returns the cloned particle system
  85204. */
  85205. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85206. /**
  85207. * Serializes the particle system to a JSON object.
  85208. * @returns the JSON object
  85209. */
  85210. serialize(): any;
  85211. /**
  85212. * Rebuild the particle system
  85213. */
  85214. rebuild(): void;
  85215. /**
  85216. * Starts the particle system and begins to emit
  85217. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85218. */
  85219. start(delay?: number): void;
  85220. /**
  85221. * Stops the particle system.
  85222. */
  85223. stop(): void;
  85224. /**
  85225. * Remove all active particles
  85226. */
  85227. reset(): void;
  85228. /**
  85229. * Is this system ready to be used/rendered
  85230. * @return true if the system is ready
  85231. */
  85232. isReady(): boolean;
  85233. /**
  85234. * Adds a new color gradient
  85235. * @param gradient defines the gradient to use (between 0 and 1)
  85236. * @param color1 defines the color to affect to the specified gradient
  85237. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85238. * @returns the current particle system
  85239. */
  85240. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85241. /**
  85242. * Remove a specific color gradient
  85243. * @param gradient defines the gradient to remove
  85244. * @returns the current particle system
  85245. */
  85246. removeColorGradient(gradient: number): IParticleSystem;
  85247. /**
  85248. * Adds a new size gradient
  85249. * @param gradient defines the gradient to use (between 0 and 1)
  85250. * @param factor defines the size factor to affect to the specified gradient
  85251. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85252. * @returns the current particle system
  85253. */
  85254. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85255. /**
  85256. * Remove a specific size gradient
  85257. * @param gradient defines the gradient to remove
  85258. * @returns the current particle system
  85259. */
  85260. removeSizeGradient(gradient: number): IParticleSystem;
  85261. /**
  85262. * Gets the current list of color gradients.
  85263. * You must use addColorGradient and removeColorGradient to udpate this list
  85264. * @returns the list of color gradients
  85265. */
  85266. getColorGradients(): Nullable<Array<ColorGradient>>;
  85267. /**
  85268. * Gets the current list of size gradients.
  85269. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85270. * @returns the list of size gradients
  85271. */
  85272. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85273. /**
  85274. * Gets the current list of angular speed gradients.
  85275. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85276. * @returns the list of angular speed gradients
  85277. */
  85278. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85279. /**
  85280. * Adds a new angular speed gradient
  85281. * @param gradient defines the gradient to use (between 0 and 1)
  85282. * @param factor defines the angular speed to affect to the specified gradient
  85283. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85284. * @returns the current particle system
  85285. */
  85286. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85287. /**
  85288. * Remove a specific angular speed gradient
  85289. * @param gradient defines the gradient to remove
  85290. * @returns the current particle system
  85291. */
  85292. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85293. /**
  85294. * Gets the current list of velocity gradients.
  85295. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85296. * @returns the list of velocity gradients
  85297. */
  85298. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85299. /**
  85300. * Adds a new velocity gradient
  85301. * @param gradient defines the gradient to use (between 0 and 1)
  85302. * @param factor defines the velocity to affect to the specified gradient
  85303. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85304. * @returns the current particle system
  85305. */
  85306. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85307. /**
  85308. * Remove a specific velocity gradient
  85309. * @param gradient defines the gradient to remove
  85310. * @returns the current particle system
  85311. */
  85312. removeVelocityGradient(gradient: number): IParticleSystem;
  85313. /**
  85314. * Gets the current list of limit velocity gradients.
  85315. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85316. * @returns the list of limit velocity gradients
  85317. */
  85318. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85319. /**
  85320. * Adds a new limit velocity gradient
  85321. * @param gradient defines the gradient to use (between 0 and 1)
  85322. * @param factor defines the limit velocity to affect to the specified gradient
  85323. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85324. * @returns the current particle system
  85325. */
  85326. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85327. /**
  85328. * Remove a specific limit velocity gradient
  85329. * @param gradient defines the gradient to remove
  85330. * @returns the current particle system
  85331. */
  85332. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85333. /**
  85334. * Adds a new drag gradient
  85335. * @param gradient defines the gradient to use (between 0 and 1)
  85336. * @param factor defines the drag to affect to the specified gradient
  85337. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85338. * @returns the current particle system
  85339. */
  85340. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85341. /**
  85342. * Remove a specific drag gradient
  85343. * @param gradient defines the gradient to remove
  85344. * @returns the current particle system
  85345. */
  85346. removeDragGradient(gradient: number): IParticleSystem;
  85347. /**
  85348. * Gets the current list of drag gradients.
  85349. * You must use addDragGradient and removeDragGradient to udpate this list
  85350. * @returns the list of drag gradients
  85351. */
  85352. getDragGradients(): Nullable<Array<FactorGradient>>;
  85353. /**
  85354. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85355. * @param gradient defines the gradient to use (between 0 and 1)
  85356. * @param factor defines the emit rate to affect to the specified gradient
  85357. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85358. * @returns the current particle system
  85359. */
  85360. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85361. /**
  85362. * Remove a specific emit rate gradient
  85363. * @param gradient defines the gradient to remove
  85364. * @returns the current particle system
  85365. */
  85366. removeEmitRateGradient(gradient: number): IParticleSystem;
  85367. /**
  85368. * Gets the current list of emit rate gradients.
  85369. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85370. * @returns the list of emit rate gradients
  85371. */
  85372. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85373. /**
  85374. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85375. * @param gradient defines the gradient to use (between 0 and 1)
  85376. * @param factor defines the start size to affect to the specified gradient
  85377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85378. * @returns the current particle system
  85379. */
  85380. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85381. /**
  85382. * Remove a specific start size gradient
  85383. * @param gradient defines the gradient to remove
  85384. * @returns the current particle system
  85385. */
  85386. removeStartSizeGradient(gradient: number): IParticleSystem;
  85387. /**
  85388. * Gets the current list of start size gradients.
  85389. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85390. * @returns the list of start size gradients
  85391. */
  85392. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85393. /**
  85394. * Adds a new life time gradient
  85395. * @param gradient defines the gradient to use (between 0 and 1)
  85396. * @param factor defines the life time factor to affect to the specified gradient
  85397. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85398. * @returns the current particle system
  85399. */
  85400. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85401. /**
  85402. * Remove a specific life time gradient
  85403. * @param gradient defines the gradient to remove
  85404. * @returns the current particle system
  85405. */
  85406. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85407. /**
  85408. * Gets the current list of life time gradients.
  85409. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85410. * @returns the list of life time gradients
  85411. */
  85412. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85413. /**
  85414. * Gets the current list of color gradients.
  85415. * You must use addColorGradient and removeColorGradient to udpate this list
  85416. * @returns the list of color gradients
  85417. */
  85418. getColorGradients(): Nullable<Array<ColorGradient>>;
  85419. /**
  85420. * Adds a new ramp gradient used to remap particle colors
  85421. * @param gradient defines the gradient to use (between 0 and 1)
  85422. * @param color defines the color to affect to the specified gradient
  85423. * @returns the current particle system
  85424. */
  85425. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85426. /**
  85427. * Gets the current list of ramp gradients.
  85428. * You must use addRampGradient and removeRampGradient to udpate this list
  85429. * @returns the list of ramp gradients
  85430. */
  85431. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85432. /** Gets or sets a boolean indicating that ramp gradients must be used
  85433. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85434. */
  85435. useRampGradients: boolean;
  85436. /**
  85437. * Adds a new color remap gradient
  85438. * @param gradient defines the gradient to use (between 0 and 1)
  85439. * @param min defines the color remap minimal range
  85440. * @param max defines the color remap maximal range
  85441. * @returns the current particle system
  85442. */
  85443. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85444. /**
  85445. * Gets the current list of color remap gradients.
  85446. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85447. * @returns the list of color remap gradients
  85448. */
  85449. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85450. /**
  85451. * Adds a new alpha remap gradient
  85452. * @param gradient defines the gradient to use (between 0 and 1)
  85453. * @param min defines the alpha remap minimal range
  85454. * @param max defines the alpha remap maximal range
  85455. * @returns the current particle system
  85456. */
  85457. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85458. /**
  85459. * Gets the current list of alpha remap gradients.
  85460. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85461. * @returns the list of alpha remap gradients
  85462. */
  85463. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85464. /**
  85465. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85468. * @returns the emitter
  85469. */
  85470. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85471. /**
  85472. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85473. * @param radius The radius of the hemisphere to emit from
  85474. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85475. * @returns the emitter
  85476. */
  85477. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85478. /**
  85479. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85480. * @param radius The radius of the sphere to emit from
  85481. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85482. * @returns the emitter
  85483. */
  85484. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85485. /**
  85486. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85487. * @param radius The radius of the sphere to emit from
  85488. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85489. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85490. * @returns the emitter
  85491. */
  85492. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85493. /**
  85494. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85495. * @param radius The radius of the emission cylinder
  85496. * @param height The height of the emission cylinder
  85497. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85498. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85499. * @returns the emitter
  85500. */
  85501. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85502. /**
  85503. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85504. * @param radius The radius of the cylinder to emit from
  85505. * @param height The height of the emission cylinder
  85506. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85507. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85508. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85509. * @returns the emitter
  85510. */
  85511. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85512. /**
  85513. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85514. * @param radius The radius of the cone to emit from
  85515. * @param angle The base angle of the cone
  85516. * @returns the emitter
  85517. */
  85518. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85519. /**
  85520. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85521. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85522. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85523. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85524. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85525. * @returns the emitter
  85526. */
  85527. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85528. /**
  85529. * Get hosting scene
  85530. * @returns the scene
  85531. */
  85532. getScene(): Scene;
  85533. }
  85534. }
  85535. declare module BABYLON {
  85536. /**
  85537. * Creates an instance based on a source mesh.
  85538. */
  85539. export class InstancedMesh extends AbstractMesh {
  85540. private _sourceMesh;
  85541. private _currentLOD;
  85542. /** @hidden */
  85543. _indexInSourceMeshInstanceArray: number;
  85544. constructor(name: string, source: Mesh);
  85545. /**
  85546. * Returns the string "InstancedMesh".
  85547. */
  85548. getClassName(): string;
  85549. /** Gets the list of lights affecting that mesh */
  85550. readonly lightSources: Light[];
  85551. _resyncLightSources(): void;
  85552. _resyncLighSource(light: Light): void;
  85553. _removeLightSource(light: Light, dispose: boolean): void;
  85554. /**
  85555. * If the source mesh receives shadows
  85556. */
  85557. readonly receiveShadows: boolean;
  85558. /**
  85559. * The material of the source mesh
  85560. */
  85561. readonly material: Nullable<Material>;
  85562. /**
  85563. * Visibility of the source mesh
  85564. */
  85565. readonly visibility: number;
  85566. /**
  85567. * Skeleton of the source mesh
  85568. */
  85569. readonly skeleton: Nullable<Skeleton>;
  85570. /**
  85571. * Rendering ground id of the source mesh
  85572. */
  85573. renderingGroupId: number;
  85574. /**
  85575. * Returns the total number of vertices (integer).
  85576. */
  85577. getTotalVertices(): number;
  85578. /**
  85579. * Returns a positive integer : the total number of indices in this mesh geometry.
  85580. * @returns the numner of indices or zero if the mesh has no geometry.
  85581. */
  85582. getTotalIndices(): number;
  85583. /**
  85584. * The source mesh of the instance
  85585. */
  85586. readonly sourceMesh: Mesh;
  85587. /**
  85588. * Is this node ready to be used/rendered
  85589. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85590. * @return {boolean} is it ready
  85591. */
  85592. isReady(completeCheck?: boolean): boolean;
  85593. /**
  85594. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85595. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85596. * @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.
  85597. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85598. */
  85599. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85600. /**
  85601. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85602. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85603. * The `data` are either a numeric array either a Float32Array.
  85604. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85605. * 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).
  85606. * Note that a new underlying VertexBuffer object is created each call.
  85607. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85608. *
  85609. * Possible `kind` values :
  85610. * - VertexBuffer.PositionKind
  85611. * - VertexBuffer.UVKind
  85612. * - VertexBuffer.UV2Kind
  85613. * - VertexBuffer.UV3Kind
  85614. * - VertexBuffer.UV4Kind
  85615. * - VertexBuffer.UV5Kind
  85616. * - VertexBuffer.UV6Kind
  85617. * - VertexBuffer.ColorKind
  85618. * - VertexBuffer.MatricesIndicesKind
  85619. * - VertexBuffer.MatricesIndicesExtraKind
  85620. * - VertexBuffer.MatricesWeightsKind
  85621. * - VertexBuffer.MatricesWeightsExtraKind
  85622. *
  85623. * Returns the Mesh.
  85624. */
  85625. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85626. /**
  85627. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85628. * If the mesh has no geometry, it is simply returned as it is.
  85629. * The `data` are either a numeric array either a Float32Array.
  85630. * No new underlying VertexBuffer object is created.
  85631. * 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.
  85632. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85633. *
  85634. * Possible `kind` values :
  85635. * - VertexBuffer.PositionKind
  85636. * - VertexBuffer.UVKind
  85637. * - VertexBuffer.UV2Kind
  85638. * - VertexBuffer.UV3Kind
  85639. * - VertexBuffer.UV4Kind
  85640. * - VertexBuffer.UV5Kind
  85641. * - VertexBuffer.UV6Kind
  85642. * - VertexBuffer.ColorKind
  85643. * - VertexBuffer.MatricesIndicesKind
  85644. * - VertexBuffer.MatricesIndicesExtraKind
  85645. * - VertexBuffer.MatricesWeightsKind
  85646. * - VertexBuffer.MatricesWeightsExtraKind
  85647. *
  85648. * Returns the Mesh.
  85649. */
  85650. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85651. /**
  85652. * Sets the mesh indices.
  85653. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85654. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85655. * This method creates a new index buffer each call.
  85656. * Returns the Mesh.
  85657. */
  85658. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85659. /**
  85660. * Boolean : True if the mesh owns the requested kind of data.
  85661. */
  85662. isVerticesDataPresent(kind: string): boolean;
  85663. /**
  85664. * Returns an array of indices (IndicesArray).
  85665. */
  85666. getIndices(): Nullable<IndicesArray>;
  85667. readonly _positions: Nullable<Vector3[]>;
  85668. /**
  85669. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85670. * This means the mesh underlying bounding box and sphere are recomputed.
  85671. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85672. * @returns the current mesh
  85673. */
  85674. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85675. /** @hidden */
  85676. _preActivate(): InstancedMesh;
  85677. /** @hidden */
  85678. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85679. /** @hidden */
  85680. _postActivate(): void;
  85681. getWorldMatrix(): Matrix;
  85682. readonly isAnInstance: boolean;
  85683. /**
  85684. * Returns the current associated LOD AbstractMesh.
  85685. */
  85686. getLOD(camera: Camera): AbstractMesh;
  85687. /** @hidden */
  85688. _syncSubMeshes(): InstancedMesh;
  85689. /** @hidden */
  85690. _generatePointsArray(): boolean;
  85691. /**
  85692. * Creates a new InstancedMesh from the current mesh.
  85693. * - name (string) : the cloned mesh name
  85694. * - newParent (optional Node) : the optional Node to parent the clone to.
  85695. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85696. *
  85697. * Returns the clone.
  85698. */
  85699. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85700. /**
  85701. * Disposes the InstancedMesh.
  85702. * Returns nothing.
  85703. */
  85704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85705. }
  85706. }
  85707. declare module BABYLON {
  85708. /**
  85709. * Defines the options associated with the creation of a shader material.
  85710. */
  85711. export interface IShaderMaterialOptions {
  85712. /**
  85713. * Does the material work in alpha blend mode
  85714. */
  85715. needAlphaBlending: boolean;
  85716. /**
  85717. * Does the material work in alpha test mode
  85718. */
  85719. needAlphaTesting: boolean;
  85720. /**
  85721. * The list of attribute names used in the shader
  85722. */
  85723. attributes: string[];
  85724. /**
  85725. * The list of unifrom names used in the shader
  85726. */
  85727. uniforms: string[];
  85728. /**
  85729. * The list of UBO names used in the shader
  85730. */
  85731. uniformBuffers: string[];
  85732. /**
  85733. * The list of sampler names used in the shader
  85734. */
  85735. samplers: string[];
  85736. /**
  85737. * The list of defines used in the shader
  85738. */
  85739. defines: string[];
  85740. }
  85741. /**
  85742. * 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.
  85743. *
  85744. * This returned material effects how the mesh will look based on the code in the shaders.
  85745. *
  85746. * @see http://doc.babylonjs.com/how_to/shader_material
  85747. */
  85748. export class ShaderMaterial extends Material {
  85749. private _shaderPath;
  85750. private _options;
  85751. private _textures;
  85752. private _textureArrays;
  85753. private _floats;
  85754. private _ints;
  85755. private _floatsArrays;
  85756. private _colors3;
  85757. private _colors3Arrays;
  85758. private _colors4;
  85759. private _colors4Arrays;
  85760. private _vectors2;
  85761. private _vectors3;
  85762. private _vectors4;
  85763. private _matrices;
  85764. private _matrices3x3;
  85765. private _matrices2x2;
  85766. private _vectors2Arrays;
  85767. private _vectors3Arrays;
  85768. private _vectors4Arrays;
  85769. private _cachedWorldViewMatrix;
  85770. private _cachedWorldViewProjectionMatrix;
  85771. private _renderId;
  85772. /**
  85773. * Instantiate a new shader material.
  85774. * 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.
  85775. * This returned material effects how the mesh will look based on the code in the shaders.
  85776. * @see http://doc.babylonjs.com/how_to/shader_material
  85777. * @param name Define the name of the material in the scene
  85778. * @param scene Define the scene the material belongs to
  85779. * @param shaderPath Defines the route to the shader code in one of three ways:
  85780. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85781. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85782. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85783. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85784. * @param options Define the options used to create the shader
  85785. */
  85786. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85787. /**
  85788. * Gets the options used to compile the shader.
  85789. * They can be modified to trigger a new compilation
  85790. */
  85791. readonly options: IShaderMaterialOptions;
  85792. /**
  85793. * Gets the current class name of the material e.g. "ShaderMaterial"
  85794. * Mainly use in serialization.
  85795. * @returns the class name
  85796. */
  85797. getClassName(): string;
  85798. /**
  85799. * Specifies if the material will require alpha blending
  85800. * @returns a boolean specifying if alpha blending is needed
  85801. */
  85802. needAlphaBlending(): boolean;
  85803. /**
  85804. * Specifies if this material should be rendered in alpha test mode
  85805. * @returns a boolean specifying if an alpha test is needed.
  85806. */
  85807. needAlphaTesting(): boolean;
  85808. private _checkUniform;
  85809. /**
  85810. * Set a texture in the shader.
  85811. * @param name Define the name of the uniform samplers as defined in the shader
  85812. * @param texture Define the texture to bind to this sampler
  85813. * @return the material itself allowing "fluent" like uniform updates
  85814. */
  85815. setTexture(name: string, texture: Texture): ShaderMaterial;
  85816. /**
  85817. * Set a texture array in the shader.
  85818. * @param name Define the name of the uniform sampler array as defined in the shader
  85819. * @param textures Define the list of textures to bind to this sampler
  85820. * @return the material itself allowing "fluent" like uniform updates
  85821. */
  85822. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85823. /**
  85824. * Set a float in the shader.
  85825. * @param name Define the name of the uniform as defined in the shader
  85826. * @param value Define the value to give to the uniform
  85827. * @return the material itself allowing "fluent" like uniform updates
  85828. */
  85829. setFloat(name: string, value: number): ShaderMaterial;
  85830. /**
  85831. * Set a int in the shader.
  85832. * @param name Define the name of the uniform as defined in the shader
  85833. * @param value Define the value to give to the uniform
  85834. * @return the material itself allowing "fluent" like uniform updates
  85835. */
  85836. setInt(name: string, value: number): ShaderMaterial;
  85837. /**
  85838. * Set an array of floats in the shader.
  85839. * @param name Define the name of the uniform as defined in the shader
  85840. * @param value Define the value to give to the uniform
  85841. * @return the material itself allowing "fluent" like uniform updates
  85842. */
  85843. setFloats(name: string, value: number[]): ShaderMaterial;
  85844. /**
  85845. * Set a vec3 in the shader from a Color3.
  85846. * @param name Define the name of the uniform as defined in the shader
  85847. * @param value Define the value to give to the uniform
  85848. * @return the material itself allowing "fluent" like uniform updates
  85849. */
  85850. setColor3(name: string, value: Color3): ShaderMaterial;
  85851. /**
  85852. * Set a vec3 array in the shader from a Color3 array.
  85853. * @param name Define the name of the uniform as defined in the shader
  85854. * @param value Define the value to give to the uniform
  85855. * @return the material itself allowing "fluent" like uniform updates
  85856. */
  85857. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85858. /**
  85859. * Set a vec4 in the shader from a Color4.
  85860. * @param name Define the name of the uniform as defined in the shader
  85861. * @param value Define the value to give to the uniform
  85862. * @return the material itself allowing "fluent" like uniform updates
  85863. */
  85864. setColor4(name: string, value: Color4): ShaderMaterial;
  85865. /**
  85866. * Set a vec4 array in the shader from a Color4 array.
  85867. * @param name Define the name of the uniform as defined in the shader
  85868. * @param value Define the value to give to the uniform
  85869. * @return the material itself allowing "fluent" like uniform updates
  85870. */
  85871. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85872. /**
  85873. * Set a vec2 in the shader from a Vector2.
  85874. * @param name Define the name of the uniform as defined in the shader
  85875. * @param value Define the value to give to the uniform
  85876. * @return the material itself allowing "fluent" like uniform updates
  85877. */
  85878. setVector2(name: string, value: Vector2): ShaderMaterial;
  85879. /**
  85880. * Set a vec3 in the shader from a Vector3.
  85881. * @param name Define the name of the uniform as defined in the shader
  85882. * @param value Define the value to give to the uniform
  85883. * @return the material itself allowing "fluent" like uniform updates
  85884. */
  85885. setVector3(name: string, value: Vector3): ShaderMaterial;
  85886. /**
  85887. * Set a vec4 in the shader from a Vector4.
  85888. * @param name Define the name of the uniform as defined in the shader
  85889. * @param value Define the value to give to the uniform
  85890. * @return the material itself allowing "fluent" like uniform updates
  85891. */
  85892. setVector4(name: string, value: Vector4): ShaderMaterial;
  85893. /**
  85894. * Set a mat4 in the shader from a Matrix.
  85895. * @param name Define the name of the uniform as defined in the shader
  85896. * @param value Define the value to give to the uniform
  85897. * @return the material itself allowing "fluent" like uniform updates
  85898. */
  85899. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85900. /**
  85901. * Set a mat3 in the shader from a Float32Array.
  85902. * @param name Define the name of the uniform as defined in the shader
  85903. * @param value Define the value to give to the uniform
  85904. * @return the material itself allowing "fluent" like uniform updates
  85905. */
  85906. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85907. /**
  85908. * Set a mat2 in the shader from a Float32Array.
  85909. * @param name Define the name of the uniform as defined in the shader
  85910. * @param value Define the value to give to the uniform
  85911. * @return the material itself allowing "fluent" like uniform updates
  85912. */
  85913. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85914. /**
  85915. * Set a vec2 array in the shader from a number array.
  85916. * @param name Define the name of the uniform as defined in the shader
  85917. * @param value Define the value to give to the uniform
  85918. * @return the material itself allowing "fluent" like uniform updates
  85919. */
  85920. setArray2(name: string, value: number[]): ShaderMaterial;
  85921. /**
  85922. * Set a vec3 array in the shader from a number array.
  85923. * @param name Define the name of the uniform as defined in the shader
  85924. * @param value Define the value to give to the uniform
  85925. * @return the material itself allowing "fluent" like uniform updates
  85926. */
  85927. setArray3(name: string, value: number[]): ShaderMaterial;
  85928. /**
  85929. * Set a vec4 array in the shader from a number array.
  85930. * @param name Define the name of the uniform as defined in the shader
  85931. * @param value Define the value to give to the uniform
  85932. * @return the material itself allowing "fluent" like uniform updates
  85933. */
  85934. setArray4(name: string, value: number[]): ShaderMaterial;
  85935. private _checkCache;
  85936. /**
  85937. * Specifies that the submesh is ready to be used
  85938. * @param mesh defines the mesh to check
  85939. * @param subMesh defines which submesh to check
  85940. * @param useInstances specifies that instances should be used
  85941. * @returns a boolean indicating that the submesh is ready or not
  85942. */
  85943. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85944. /**
  85945. * Checks if the material is ready to render the requested mesh
  85946. * @param mesh Define the mesh to render
  85947. * @param useInstances Define whether or not the material is used with instances
  85948. * @returns true if ready, otherwise false
  85949. */
  85950. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85951. /**
  85952. * Binds the world matrix to the material
  85953. * @param world defines the world transformation matrix
  85954. */
  85955. bindOnlyWorldMatrix(world: Matrix): void;
  85956. /**
  85957. * Binds the material to the mesh
  85958. * @param world defines the world transformation matrix
  85959. * @param mesh defines the mesh to bind the material to
  85960. */
  85961. bind(world: Matrix, mesh?: Mesh): void;
  85962. /**
  85963. * Gets the active textures from the material
  85964. * @returns an array of textures
  85965. */
  85966. getActiveTextures(): BaseTexture[];
  85967. /**
  85968. * Specifies if the material uses a texture
  85969. * @param texture defines the texture to check against the material
  85970. * @returns a boolean specifying if the material uses the texture
  85971. */
  85972. hasTexture(texture: BaseTexture): boolean;
  85973. /**
  85974. * Makes a duplicate of the material, and gives it a new name
  85975. * @param name defines the new name for the duplicated material
  85976. * @returns the cloned material
  85977. */
  85978. clone(name: string): ShaderMaterial;
  85979. /**
  85980. * Disposes the material
  85981. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  85982. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  85983. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  85984. */
  85985. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  85986. /**
  85987. * Serializes this material in a JSON representation
  85988. * @returns the serialized material object
  85989. */
  85990. serialize(): any;
  85991. /**
  85992. * Creates a shader material from parsed shader material data
  85993. * @param source defines the JSON represnetation of the material
  85994. * @param scene defines the hosting scene
  85995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  85996. * @returns a new material
  85997. */
  85998. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  85999. }
  86000. }
  86001. declare module BABYLON {
  86002. /** @hidden */
  86003. export var colorPixelShader: {
  86004. name: string;
  86005. shader: string;
  86006. };
  86007. }
  86008. declare module BABYLON {
  86009. /** @hidden */
  86010. export var colorVertexShader: {
  86011. name: string;
  86012. shader: string;
  86013. };
  86014. }
  86015. declare module BABYLON {
  86016. /**
  86017. * Line mesh
  86018. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86019. */
  86020. export class LinesMesh extends Mesh {
  86021. /**
  86022. * If vertex color should be applied to the mesh
  86023. */
  86024. readonly useVertexColor?: boolean | undefined;
  86025. /**
  86026. * If vertex alpha should be applied to the mesh
  86027. */
  86028. readonly useVertexAlpha?: boolean | undefined;
  86029. /**
  86030. * Color of the line (Default: White)
  86031. */
  86032. color: Color3;
  86033. /**
  86034. * Alpha of the line (Default: 1)
  86035. */
  86036. alpha: number;
  86037. /**
  86038. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86039. * This margin is expressed in world space coordinates, so its value may vary.
  86040. * Default value is 0.1
  86041. */
  86042. intersectionThreshold: number;
  86043. private _colorShader;
  86044. private color4;
  86045. /**
  86046. * Creates a new LinesMesh
  86047. * @param name defines the name
  86048. * @param scene defines the hosting scene
  86049. * @param parent defines the parent mesh if any
  86050. * @param source defines the optional source LinesMesh used to clone data from
  86051. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86052. * When false, achieved by calling a clone(), also passing False.
  86053. * This will make creation of children, recursive.
  86054. * @param useVertexColor defines if this LinesMesh supports vertex color
  86055. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86056. */
  86057. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86058. /**
  86059. * If vertex color should be applied to the mesh
  86060. */
  86061. useVertexColor?: boolean | undefined,
  86062. /**
  86063. * If vertex alpha should be applied to the mesh
  86064. */
  86065. useVertexAlpha?: boolean | undefined);
  86066. private _addClipPlaneDefine;
  86067. private _removeClipPlaneDefine;
  86068. isReady(): boolean;
  86069. /**
  86070. * Returns the string "LineMesh"
  86071. */
  86072. getClassName(): string;
  86073. /**
  86074. * @hidden
  86075. */
  86076. /**
  86077. * @hidden
  86078. */
  86079. material: Material;
  86080. /**
  86081. * @hidden
  86082. */
  86083. readonly checkCollisions: boolean;
  86084. /** @hidden */
  86085. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86086. /** @hidden */
  86087. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86088. /**
  86089. * Disposes of the line mesh
  86090. * @param doNotRecurse If children should be disposed
  86091. */
  86092. dispose(doNotRecurse?: boolean): void;
  86093. /**
  86094. * Returns a new LineMesh object cloned from the current one.
  86095. */
  86096. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86097. /**
  86098. * Creates a new InstancedLinesMesh object from the mesh model.
  86099. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86100. * @param name defines the name of the new instance
  86101. * @returns a new InstancedLinesMesh
  86102. */
  86103. createInstance(name: string): InstancedLinesMesh;
  86104. }
  86105. /**
  86106. * Creates an instance based on a source LinesMesh
  86107. */
  86108. export class InstancedLinesMesh extends InstancedMesh {
  86109. /**
  86110. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86111. * This margin is expressed in world space coordinates, so its value may vary.
  86112. * Initilized with the intersectionThreshold value of the source LinesMesh
  86113. */
  86114. intersectionThreshold: number;
  86115. constructor(name: string, source: LinesMesh);
  86116. /**
  86117. * Returns the string "InstancedLinesMesh".
  86118. */
  86119. getClassName(): string;
  86120. }
  86121. }
  86122. declare module BABYLON {
  86123. /** @hidden */
  86124. export var linePixelShader: {
  86125. name: string;
  86126. shader: string;
  86127. };
  86128. }
  86129. declare module BABYLON {
  86130. /** @hidden */
  86131. export var lineVertexShader: {
  86132. name: string;
  86133. shader: string;
  86134. };
  86135. }
  86136. declare module BABYLON {
  86137. interface AbstractMesh {
  86138. /**
  86139. * Gets the edgesRenderer associated with the mesh
  86140. */
  86141. edgesRenderer: Nullable<EdgesRenderer>;
  86142. }
  86143. interface LinesMesh {
  86144. /**
  86145. * Enables the edge rendering mode on the mesh.
  86146. * This mode makes the mesh edges visible
  86147. * @param epsilon defines the maximal distance between two angles to detect a face
  86148. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86149. * @returns the currentAbstractMesh
  86150. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86151. */
  86152. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86153. }
  86154. interface InstancedLinesMesh {
  86155. /**
  86156. * Enables the edge rendering mode on the mesh.
  86157. * This mode makes the mesh edges visible
  86158. * @param epsilon defines the maximal distance between two angles to detect a face
  86159. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86160. * @returns the current InstancedLinesMesh
  86161. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86162. */
  86163. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86164. }
  86165. /**
  86166. * Defines the minimum contract an Edges renderer should follow.
  86167. */
  86168. export interface IEdgesRenderer extends IDisposable {
  86169. /**
  86170. * Gets or sets a boolean indicating if the edgesRenderer is active
  86171. */
  86172. isEnabled: boolean;
  86173. /**
  86174. * Renders the edges of the attached mesh,
  86175. */
  86176. render(): void;
  86177. /**
  86178. * Checks wether or not the edges renderer is ready to render.
  86179. * @return true if ready, otherwise false.
  86180. */
  86181. isReady(): boolean;
  86182. }
  86183. /**
  86184. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86185. */
  86186. export class EdgesRenderer implements IEdgesRenderer {
  86187. /**
  86188. * Define the size of the edges with an orthographic camera
  86189. */
  86190. edgesWidthScalerForOrthographic: number;
  86191. /**
  86192. * Define the size of the edges with a perspective camera
  86193. */
  86194. edgesWidthScalerForPerspective: number;
  86195. protected _source: AbstractMesh;
  86196. protected _linesPositions: number[];
  86197. protected _linesNormals: number[];
  86198. protected _linesIndices: number[];
  86199. protected _epsilon: number;
  86200. protected _indicesCount: number;
  86201. protected _lineShader: ShaderMaterial;
  86202. protected _ib: DataBuffer;
  86203. protected _buffers: {
  86204. [key: string]: Nullable<VertexBuffer>;
  86205. };
  86206. protected _checkVerticesInsteadOfIndices: boolean;
  86207. private _meshRebuildObserver;
  86208. private _meshDisposeObserver;
  86209. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86210. isEnabled: boolean;
  86211. /**
  86212. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86213. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86214. * @param source Mesh used to create edges
  86215. * @param epsilon sum of angles in adjacency to check for edge
  86216. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86217. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86218. */
  86219. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86220. protected _prepareRessources(): void;
  86221. /** @hidden */
  86222. _rebuild(): void;
  86223. /**
  86224. * Releases the required resources for the edges renderer
  86225. */
  86226. dispose(): void;
  86227. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86228. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86229. /**
  86230. * Checks if the pair of p0 and p1 is en edge
  86231. * @param faceIndex
  86232. * @param edge
  86233. * @param faceNormals
  86234. * @param p0
  86235. * @param p1
  86236. * @private
  86237. */
  86238. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86239. /**
  86240. * push line into the position, normal and index buffer
  86241. * @protected
  86242. */
  86243. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86244. /**
  86245. * Generates lines edges from adjacencjes
  86246. * @private
  86247. */
  86248. _generateEdgesLines(): void;
  86249. /**
  86250. * Checks wether or not the edges renderer is ready to render.
  86251. * @return true if ready, otherwise false.
  86252. */
  86253. isReady(): boolean;
  86254. /**
  86255. * Renders the edges of the attached mesh,
  86256. */
  86257. render(): void;
  86258. }
  86259. /**
  86260. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86261. */
  86262. export class LineEdgesRenderer extends EdgesRenderer {
  86263. /**
  86264. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86265. * @param source LineMesh used to generate edges
  86266. * @param epsilon not important (specified angle for edge detection)
  86267. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86268. */
  86269. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86270. /**
  86271. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86272. */
  86273. _generateEdgesLines(): void;
  86274. }
  86275. }
  86276. declare module BABYLON {
  86277. /**
  86278. * This represents the object necessary to create a rendering group.
  86279. * This is exclusively used and created by the rendering manager.
  86280. * To modify the behavior, you use the available helpers in your scene or meshes.
  86281. * @hidden
  86282. */
  86283. export class RenderingGroup {
  86284. index: number;
  86285. private static _zeroVector;
  86286. private _scene;
  86287. private _opaqueSubMeshes;
  86288. private _transparentSubMeshes;
  86289. private _alphaTestSubMeshes;
  86290. private _depthOnlySubMeshes;
  86291. private _particleSystems;
  86292. private _spriteManagers;
  86293. private _opaqueSortCompareFn;
  86294. private _alphaTestSortCompareFn;
  86295. private _transparentSortCompareFn;
  86296. private _renderOpaque;
  86297. private _renderAlphaTest;
  86298. private _renderTransparent;
  86299. /** @hidden */
  86300. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86301. onBeforeTransparentRendering: () => void;
  86302. /**
  86303. * Set the opaque sort comparison function.
  86304. * If null the sub meshes will be render in the order they were created
  86305. */
  86306. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86307. /**
  86308. * Set the alpha test sort comparison function.
  86309. * If null the sub meshes will be render in the order they were created
  86310. */
  86311. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86312. /**
  86313. * Set the transparent sort comparison function.
  86314. * If null the sub meshes will be render in the order they were created
  86315. */
  86316. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86317. /**
  86318. * Creates a new rendering group.
  86319. * @param index The rendering group index
  86320. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86321. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86322. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86323. */
  86324. 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>);
  86325. /**
  86326. * Render all the sub meshes contained in the group.
  86327. * @param customRenderFunction Used to override the default render behaviour of the group.
  86328. * @returns true if rendered some submeshes.
  86329. */
  86330. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86331. /**
  86332. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86333. * @param subMeshes The submeshes to render
  86334. */
  86335. private renderOpaqueSorted;
  86336. /**
  86337. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86338. * @param subMeshes The submeshes to render
  86339. */
  86340. private renderAlphaTestSorted;
  86341. /**
  86342. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86343. * @param subMeshes The submeshes to render
  86344. */
  86345. private renderTransparentSorted;
  86346. /**
  86347. * Renders the submeshes in a specified order.
  86348. * @param subMeshes The submeshes to sort before render
  86349. * @param sortCompareFn The comparison function use to sort
  86350. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86351. * @param transparent Specifies to activate blending if true
  86352. */
  86353. private static renderSorted;
  86354. /**
  86355. * Renders the submeshes in the order they were dispatched (no sort applied).
  86356. * @param subMeshes The submeshes to render
  86357. */
  86358. private static renderUnsorted;
  86359. /**
  86360. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86361. * are rendered back to front if in the same alpha index.
  86362. *
  86363. * @param a The first submesh
  86364. * @param b The second submesh
  86365. * @returns The result of the comparison
  86366. */
  86367. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86368. /**
  86369. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86370. * are rendered back to front.
  86371. *
  86372. * @param a The first submesh
  86373. * @param b The second submesh
  86374. * @returns The result of the comparison
  86375. */
  86376. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86377. /**
  86378. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86379. * are rendered front to back (prevent overdraw).
  86380. *
  86381. * @param a The first submesh
  86382. * @param b The second submesh
  86383. * @returns The result of the comparison
  86384. */
  86385. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86386. /**
  86387. * Resets the different lists of submeshes to prepare a new frame.
  86388. */
  86389. prepare(): void;
  86390. dispose(): void;
  86391. /**
  86392. * Inserts the submesh in its correct queue depending on its material.
  86393. * @param subMesh The submesh to dispatch
  86394. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86395. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86396. */
  86397. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86398. dispatchSprites(spriteManager: ISpriteManager): void;
  86399. dispatchParticles(particleSystem: IParticleSystem): void;
  86400. private _renderParticles;
  86401. private _renderSprites;
  86402. }
  86403. }
  86404. declare module BABYLON {
  86405. /**
  86406. * Interface describing the different options available in the rendering manager
  86407. * regarding Auto Clear between groups.
  86408. */
  86409. export interface IRenderingManagerAutoClearSetup {
  86410. /**
  86411. * Defines whether or not autoclear is enable.
  86412. */
  86413. autoClear: boolean;
  86414. /**
  86415. * Defines whether or not to autoclear the depth buffer.
  86416. */
  86417. depth: boolean;
  86418. /**
  86419. * Defines whether or not to autoclear the stencil buffer.
  86420. */
  86421. stencil: boolean;
  86422. }
  86423. /**
  86424. * This class is used by the onRenderingGroupObservable
  86425. */
  86426. export class RenderingGroupInfo {
  86427. /**
  86428. * The Scene that being rendered
  86429. */
  86430. scene: Scene;
  86431. /**
  86432. * The camera currently used for the rendering pass
  86433. */
  86434. camera: Nullable<Camera>;
  86435. /**
  86436. * The ID of the renderingGroup being processed
  86437. */
  86438. renderingGroupId: number;
  86439. }
  86440. /**
  86441. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86442. * It is enable to manage the different groups as well as the different necessary sort functions.
  86443. * This should not be used directly aside of the few static configurations
  86444. */
  86445. export class RenderingManager {
  86446. /**
  86447. * The max id used for rendering groups (not included)
  86448. */
  86449. static MAX_RENDERINGGROUPS: number;
  86450. /**
  86451. * The min id used for rendering groups (included)
  86452. */
  86453. static MIN_RENDERINGGROUPS: number;
  86454. /**
  86455. * Used to globally prevent autoclearing scenes.
  86456. */
  86457. static AUTOCLEAR: boolean;
  86458. /**
  86459. * @hidden
  86460. */
  86461. _useSceneAutoClearSetup: boolean;
  86462. private _scene;
  86463. private _renderingGroups;
  86464. private _depthStencilBufferAlreadyCleaned;
  86465. private _autoClearDepthStencil;
  86466. private _customOpaqueSortCompareFn;
  86467. private _customAlphaTestSortCompareFn;
  86468. private _customTransparentSortCompareFn;
  86469. private _renderingGroupInfo;
  86470. /**
  86471. * Instantiates a new rendering group for a particular scene
  86472. * @param scene Defines the scene the groups belongs to
  86473. */
  86474. constructor(scene: Scene);
  86475. private _clearDepthStencilBuffer;
  86476. /**
  86477. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86478. * @hidden
  86479. */
  86480. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86481. /**
  86482. * Resets the different information of the group to prepare a new frame
  86483. * @hidden
  86484. */
  86485. reset(): void;
  86486. /**
  86487. * Dispose and release the group and its associated resources.
  86488. * @hidden
  86489. */
  86490. dispose(): void;
  86491. /**
  86492. * Clear the info related to rendering groups preventing retention points during dispose.
  86493. */
  86494. freeRenderingGroups(): void;
  86495. private _prepareRenderingGroup;
  86496. /**
  86497. * Add a sprite manager to the rendering manager in order to render it this frame.
  86498. * @param spriteManager Define the sprite manager to render
  86499. */
  86500. dispatchSprites(spriteManager: ISpriteManager): void;
  86501. /**
  86502. * Add a particle system to the rendering manager in order to render it this frame.
  86503. * @param particleSystem Define the particle system to render
  86504. */
  86505. dispatchParticles(particleSystem: IParticleSystem): void;
  86506. /**
  86507. * Add a submesh to the manager in order to render it this frame
  86508. * @param subMesh The submesh to dispatch
  86509. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86510. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86511. */
  86512. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86513. /**
  86514. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86515. * This allowed control for front to back rendering or reversly depending of the special needs.
  86516. *
  86517. * @param renderingGroupId The rendering group id corresponding to its index
  86518. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86519. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86520. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86521. */
  86522. 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;
  86523. /**
  86524. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86525. *
  86526. * @param renderingGroupId The rendering group id corresponding to its index
  86527. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86528. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86529. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86530. */
  86531. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86532. /**
  86533. * Gets the current auto clear configuration for one rendering group of the rendering
  86534. * manager.
  86535. * @param index the rendering group index to get the information for
  86536. * @returns The auto clear setup for the requested rendering group
  86537. */
  86538. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86539. }
  86540. }
  86541. declare module BABYLON {
  86542. /**
  86543. * This Helps creating a texture that will be created from a camera in your scene.
  86544. * It is basically a dynamic texture that could be used to create special effects for instance.
  86545. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86546. */
  86547. export class RenderTargetTexture extends Texture {
  86548. isCube: boolean;
  86549. /**
  86550. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86551. */
  86552. static readonly REFRESHRATE_RENDER_ONCE: number;
  86553. /**
  86554. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86555. */
  86556. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86557. /**
  86558. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86559. * the central point of your effect and can save a lot of performances.
  86560. */
  86561. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86562. /**
  86563. * Use this predicate to dynamically define the list of mesh you want to render.
  86564. * If set, the renderList property will be overwritten.
  86565. */
  86566. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86567. private _renderList;
  86568. /**
  86569. * Use this list to define the list of mesh you want to render.
  86570. */
  86571. renderList: Nullable<Array<AbstractMesh>>;
  86572. private _hookArray;
  86573. /**
  86574. * Define if particles should be rendered in your texture.
  86575. */
  86576. renderParticles: boolean;
  86577. /**
  86578. * Define if sprites should be rendered in your texture.
  86579. */
  86580. renderSprites: boolean;
  86581. /**
  86582. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86583. */
  86584. coordinatesMode: number;
  86585. /**
  86586. * Define the camera used to render the texture.
  86587. */
  86588. activeCamera: Nullable<Camera>;
  86589. /**
  86590. * Override the render function of the texture with your own one.
  86591. */
  86592. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86593. /**
  86594. * Define if camera post processes should be use while rendering the texture.
  86595. */
  86596. useCameraPostProcesses: boolean;
  86597. /**
  86598. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86599. */
  86600. ignoreCameraViewport: boolean;
  86601. private _postProcessManager;
  86602. private _postProcesses;
  86603. private _resizeObserver;
  86604. /**
  86605. * An event triggered when the texture is unbind.
  86606. */
  86607. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86608. /**
  86609. * An event triggered when the texture is unbind.
  86610. */
  86611. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86612. private _onAfterUnbindObserver;
  86613. /**
  86614. * Set a after unbind callback in the texture.
  86615. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86616. */
  86617. onAfterUnbind: () => void;
  86618. /**
  86619. * An event triggered before rendering the texture
  86620. */
  86621. onBeforeRenderObservable: Observable<number>;
  86622. private _onBeforeRenderObserver;
  86623. /**
  86624. * Set a before render callback in the texture.
  86625. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86626. */
  86627. onBeforeRender: (faceIndex: number) => void;
  86628. /**
  86629. * An event triggered after rendering the texture
  86630. */
  86631. onAfterRenderObservable: Observable<number>;
  86632. private _onAfterRenderObserver;
  86633. /**
  86634. * Set a after render callback in the texture.
  86635. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86636. */
  86637. onAfterRender: (faceIndex: number) => void;
  86638. /**
  86639. * An event triggered after the texture clear
  86640. */
  86641. onClearObservable: Observable<Engine>;
  86642. private _onClearObserver;
  86643. /**
  86644. * Set a clear callback in the texture.
  86645. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86646. */
  86647. onClear: (Engine: Engine) => void;
  86648. /**
  86649. * An event triggered when the texture is resized.
  86650. */
  86651. onResizeObservable: Observable<RenderTargetTexture>;
  86652. /**
  86653. * Define the clear color of the Render Target if it should be different from the scene.
  86654. */
  86655. clearColor: Color4;
  86656. protected _size: number | {
  86657. width: number;
  86658. height: number;
  86659. };
  86660. protected _initialSizeParameter: number | {
  86661. width: number;
  86662. height: number;
  86663. } | {
  86664. ratio: number;
  86665. };
  86666. protected _sizeRatio: Nullable<number>;
  86667. /** @hidden */
  86668. _generateMipMaps: boolean;
  86669. protected _renderingManager: RenderingManager;
  86670. /** @hidden */
  86671. _waitingRenderList: string[];
  86672. protected _doNotChangeAspectRatio: boolean;
  86673. protected _currentRefreshId: number;
  86674. protected _refreshRate: number;
  86675. protected _textureMatrix: Matrix;
  86676. protected _samples: number;
  86677. protected _renderTargetOptions: RenderTargetCreationOptions;
  86678. /**
  86679. * Gets render target creation options that were used.
  86680. */
  86681. readonly renderTargetOptions: RenderTargetCreationOptions;
  86682. protected _engine: Engine;
  86683. protected _onRatioRescale(): void;
  86684. /**
  86685. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86686. * It must define where the camera used to render the texture is set
  86687. */
  86688. boundingBoxPosition: Vector3;
  86689. private _boundingBoxSize;
  86690. /**
  86691. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86692. * When defined, the cubemap will switch to local mode
  86693. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86694. * @example https://www.babylonjs-playground.com/#RNASML
  86695. */
  86696. boundingBoxSize: Vector3;
  86697. /**
  86698. * In case the RTT has been created with a depth texture, get the associated
  86699. * depth texture.
  86700. * Otherwise, return null.
  86701. */
  86702. depthStencilTexture: Nullable<InternalTexture>;
  86703. /**
  86704. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86705. * or used a shadow, depth texture...
  86706. * @param name The friendly name of the texture
  86707. * @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)
  86708. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86709. * @param generateMipMaps True if mip maps need to be generated after render.
  86710. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86711. * @param type The type of the buffer in the RTT (int, half float, float...)
  86712. * @param isCube True if a cube texture needs to be created
  86713. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86714. * @param generateDepthBuffer True to generate a depth buffer
  86715. * @param generateStencilBuffer True to generate a stencil buffer
  86716. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86717. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86718. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86719. */
  86720. constructor(name: string, size: number | {
  86721. width: number;
  86722. height: number;
  86723. } | {
  86724. ratio: number;
  86725. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86726. /**
  86727. * Creates a depth stencil texture.
  86728. * This is only available in WebGL 2 or with the depth texture extension available.
  86729. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86730. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86731. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86732. */
  86733. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86734. private _processSizeParameter;
  86735. /**
  86736. * Define the number of samples to use in case of MSAA.
  86737. * It defaults to one meaning no MSAA has been enabled.
  86738. */
  86739. samples: number;
  86740. /**
  86741. * Resets the refresh counter of the texture and start bak from scratch.
  86742. * Could be useful to regenerate the texture if it is setup to render only once.
  86743. */
  86744. resetRefreshCounter(): void;
  86745. /**
  86746. * Define the refresh rate of the texture or the rendering frequency.
  86747. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86748. */
  86749. refreshRate: number;
  86750. /**
  86751. * Adds a post process to the render target rendering passes.
  86752. * @param postProcess define the post process to add
  86753. */
  86754. addPostProcess(postProcess: PostProcess): void;
  86755. /**
  86756. * Clear all the post processes attached to the render target
  86757. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86758. */
  86759. clearPostProcesses(dispose?: boolean): void;
  86760. /**
  86761. * Remove one of the post process from the list of attached post processes to the texture
  86762. * @param postProcess define the post process to remove from the list
  86763. */
  86764. removePostProcess(postProcess: PostProcess): void;
  86765. /** @hidden */
  86766. _shouldRender(): boolean;
  86767. /**
  86768. * Gets the actual render size of the texture.
  86769. * @returns the width of the render size
  86770. */
  86771. getRenderSize(): number;
  86772. /**
  86773. * Gets the actual render width of the texture.
  86774. * @returns the width of the render size
  86775. */
  86776. getRenderWidth(): number;
  86777. /**
  86778. * Gets the actual render height of the texture.
  86779. * @returns the height of the render size
  86780. */
  86781. getRenderHeight(): number;
  86782. /**
  86783. * Get if the texture can be rescaled or not.
  86784. */
  86785. readonly canRescale: boolean;
  86786. /**
  86787. * Resize the texture using a ratio.
  86788. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86789. */
  86790. scale(ratio: number): void;
  86791. /**
  86792. * Get the texture reflection matrix used to rotate/transform the reflection.
  86793. * @returns the reflection matrix
  86794. */
  86795. getReflectionTextureMatrix(): Matrix;
  86796. /**
  86797. * Resize the texture to a new desired size.
  86798. * Be carrefull as it will recreate all the data in the new texture.
  86799. * @param size Define the new size. It can be:
  86800. * - a number for squared texture,
  86801. * - an object containing { width: number, height: number }
  86802. * - or an object containing a ratio { ratio: number }
  86803. */
  86804. resize(size: number | {
  86805. width: number;
  86806. height: number;
  86807. } | {
  86808. ratio: number;
  86809. }): void;
  86810. /**
  86811. * Renders all the objects from the render list into the texture.
  86812. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86813. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86814. */
  86815. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86816. private _bestReflectionRenderTargetDimension;
  86817. /**
  86818. * @hidden
  86819. * @param faceIndex face index to bind to if this is a cubetexture
  86820. */
  86821. _bindFrameBuffer(faceIndex?: number): void;
  86822. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86823. private renderToTarget;
  86824. /**
  86825. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86826. * This allowed control for front to back rendering or reversly depending of the special needs.
  86827. *
  86828. * @param renderingGroupId The rendering group id corresponding to its index
  86829. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86830. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86831. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86832. */
  86833. 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;
  86834. /**
  86835. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86836. *
  86837. * @param renderingGroupId The rendering group id corresponding to its index
  86838. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86839. */
  86840. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86841. /**
  86842. * Clones the texture.
  86843. * @returns the cloned texture
  86844. */
  86845. clone(): RenderTargetTexture;
  86846. /**
  86847. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86848. * @returns The JSON representation of the texture
  86849. */
  86850. serialize(): any;
  86851. /**
  86852. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86853. */
  86854. disposeFramebufferObjects(): void;
  86855. /**
  86856. * Dispose the texture and release its associated resources.
  86857. */
  86858. dispose(): void;
  86859. /** @hidden */
  86860. _rebuild(): void;
  86861. /**
  86862. * Clear the info related to rendering groups preventing retention point in material dispose.
  86863. */
  86864. freeRenderingGroups(): void;
  86865. /**
  86866. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86867. * @returns the view count
  86868. */
  86869. getViewCount(): number;
  86870. }
  86871. }
  86872. declare module BABYLON {
  86873. /**
  86874. * Base class for the main features of a material in Babylon.js
  86875. */
  86876. export class Material implements IAnimatable {
  86877. /**
  86878. * Returns the triangle fill mode
  86879. */
  86880. static readonly TriangleFillMode: number;
  86881. /**
  86882. * Returns the wireframe mode
  86883. */
  86884. static readonly WireFrameFillMode: number;
  86885. /**
  86886. * Returns the point fill mode
  86887. */
  86888. static readonly PointFillMode: number;
  86889. /**
  86890. * Returns the point list draw mode
  86891. */
  86892. static readonly PointListDrawMode: number;
  86893. /**
  86894. * Returns the line list draw mode
  86895. */
  86896. static readonly LineListDrawMode: number;
  86897. /**
  86898. * Returns the line loop draw mode
  86899. */
  86900. static readonly LineLoopDrawMode: number;
  86901. /**
  86902. * Returns the line strip draw mode
  86903. */
  86904. static readonly LineStripDrawMode: number;
  86905. /**
  86906. * Returns the triangle strip draw mode
  86907. */
  86908. static readonly TriangleStripDrawMode: number;
  86909. /**
  86910. * Returns the triangle fan draw mode
  86911. */
  86912. static readonly TriangleFanDrawMode: number;
  86913. /**
  86914. * Stores the clock-wise side orientation
  86915. */
  86916. static readonly ClockWiseSideOrientation: number;
  86917. /**
  86918. * Stores the counter clock-wise side orientation
  86919. */
  86920. static readonly CounterClockWiseSideOrientation: number;
  86921. /**
  86922. * The dirty texture flag value
  86923. */
  86924. static readonly TextureDirtyFlag: number;
  86925. /**
  86926. * The dirty light flag value
  86927. */
  86928. static readonly LightDirtyFlag: number;
  86929. /**
  86930. * The dirty fresnel flag value
  86931. */
  86932. static readonly FresnelDirtyFlag: number;
  86933. /**
  86934. * The dirty attribute flag value
  86935. */
  86936. static readonly AttributesDirtyFlag: number;
  86937. /**
  86938. * The dirty misc flag value
  86939. */
  86940. static readonly MiscDirtyFlag: number;
  86941. /**
  86942. * The all dirty flag value
  86943. */
  86944. static readonly AllDirtyFlag: number;
  86945. /**
  86946. * The ID of the material
  86947. */
  86948. id: string;
  86949. /**
  86950. * Gets or sets the unique id of the material
  86951. */
  86952. uniqueId: number;
  86953. /**
  86954. * The name of the material
  86955. */
  86956. name: string;
  86957. /**
  86958. * Gets or sets user defined metadata
  86959. */
  86960. metadata: any;
  86961. /**
  86962. * For internal use only. Please do not use.
  86963. */
  86964. reservedDataStore: any;
  86965. /**
  86966. * Specifies if the ready state should be checked on each call
  86967. */
  86968. checkReadyOnEveryCall: boolean;
  86969. /**
  86970. * Specifies if the ready state should be checked once
  86971. */
  86972. checkReadyOnlyOnce: boolean;
  86973. /**
  86974. * The state of the material
  86975. */
  86976. state: string;
  86977. /**
  86978. * The alpha value of the material
  86979. */
  86980. protected _alpha: number;
  86981. /**
  86982. * List of inspectable custom properties (used by the Inspector)
  86983. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  86984. */
  86985. inspectableCustomProperties: IInspectable[];
  86986. /**
  86987. * Sets the alpha value of the material
  86988. */
  86989. /**
  86990. * Gets the alpha value of the material
  86991. */
  86992. alpha: number;
  86993. /**
  86994. * Specifies if back face culling is enabled
  86995. */
  86996. protected _backFaceCulling: boolean;
  86997. /**
  86998. * Sets the back-face culling state
  86999. */
  87000. /**
  87001. * Gets the back-face culling state
  87002. */
  87003. backFaceCulling: boolean;
  87004. /**
  87005. * Stores the value for side orientation
  87006. */
  87007. sideOrientation: number;
  87008. /**
  87009. * Callback triggered when the material is compiled
  87010. */
  87011. onCompiled: Nullable<(effect: Effect) => void>;
  87012. /**
  87013. * Callback triggered when an error occurs
  87014. */
  87015. onError: Nullable<(effect: Effect, errors: string) => void>;
  87016. /**
  87017. * Callback triggered to get the render target textures
  87018. */
  87019. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87020. /**
  87021. * Gets a boolean indicating that current material needs to register RTT
  87022. */
  87023. readonly hasRenderTargetTextures: boolean;
  87024. /**
  87025. * Specifies if the material should be serialized
  87026. */
  87027. doNotSerialize: boolean;
  87028. /**
  87029. * @hidden
  87030. */
  87031. _storeEffectOnSubMeshes: boolean;
  87032. /**
  87033. * Stores the animations for the material
  87034. */
  87035. animations: Nullable<Array<Animation>>;
  87036. /**
  87037. * An event triggered when the material is disposed
  87038. */
  87039. onDisposeObservable: Observable<Material>;
  87040. /**
  87041. * An observer which watches for dispose events
  87042. */
  87043. private _onDisposeObserver;
  87044. private _onUnBindObservable;
  87045. /**
  87046. * Called during a dispose event
  87047. */
  87048. onDispose: () => void;
  87049. private _onBindObservable;
  87050. /**
  87051. * An event triggered when the material is bound
  87052. */
  87053. readonly onBindObservable: Observable<AbstractMesh>;
  87054. /**
  87055. * An observer which watches for bind events
  87056. */
  87057. private _onBindObserver;
  87058. /**
  87059. * Called during a bind event
  87060. */
  87061. onBind: (Mesh: AbstractMesh) => void;
  87062. /**
  87063. * An event triggered when the material is unbound
  87064. */
  87065. readonly onUnBindObservable: Observable<Material>;
  87066. /**
  87067. * Stores the value of the alpha mode
  87068. */
  87069. private _alphaMode;
  87070. /**
  87071. * Sets the value of the alpha mode.
  87072. *
  87073. * | Value | Type | Description |
  87074. * | --- | --- | --- |
  87075. * | 0 | ALPHA_DISABLE | |
  87076. * | 1 | ALPHA_ADD | |
  87077. * | 2 | ALPHA_COMBINE | |
  87078. * | 3 | ALPHA_SUBTRACT | |
  87079. * | 4 | ALPHA_MULTIPLY | |
  87080. * | 5 | ALPHA_MAXIMIZED | |
  87081. * | 6 | ALPHA_ONEONE | |
  87082. * | 7 | ALPHA_PREMULTIPLIED | |
  87083. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87084. * | 9 | ALPHA_INTERPOLATE | |
  87085. * | 10 | ALPHA_SCREENMODE | |
  87086. *
  87087. */
  87088. /**
  87089. * Gets the value of the alpha mode
  87090. */
  87091. alphaMode: number;
  87092. /**
  87093. * Stores the state of the need depth pre-pass value
  87094. */
  87095. private _needDepthPrePass;
  87096. /**
  87097. * Sets the need depth pre-pass value
  87098. */
  87099. /**
  87100. * Gets the depth pre-pass value
  87101. */
  87102. needDepthPrePass: boolean;
  87103. /**
  87104. * Specifies if depth writing should be disabled
  87105. */
  87106. disableDepthWrite: boolean;
  87107. /**
  87108. * Specifies if depth writing should be forced
  87109. */
  87110. forceDepthWrite: boolean;
  87111. /**
  87112. * Specifies if there should be a separate pass for culling
  87113. */
  87114. separateCullingPass: boolean;
  87115. /**
  87116. * Stores the state specifing if fog should be enabled
  87117. */
  87118. private _fogEnabled;
  87119. /**
  87120. * Sets the state for enabling fog
  87121. */
  87122. /**
  87123. * Gets the value of the fog enabled state
  87124. */
  87125. fogEnabled: boolean;
  87126. /**
  87127. * Stores the size of points
  87128. */
  87129. pointSize: number;
  87130. /**
  87131. * Stores the z offset value
  87132. */
  87133. zOffset: number;
  87134. /**
  87135. * Gets a value specifying if wireframe mode is enabled
  87136. */
  87137. /**
  87138. * Sets the state of wireframe mode
  87139. */
  87140. wireframe: boolean;
  87141. /**
  87142. * Gets the value specifying if point clouds are enabled
  87143. */
  87144. /**
  87145. * Sets the state of point cloud mode
  87146. */
  87147. pointsCloud: boolean;
  87148. /**
  87149. * Gets the material fill mode
  87150. */
  87151. /**
  87152. * Sets the material fill mode
  87153. */
  87154. fillMode: number;
  87155. /**
  87156. * @hidden
  87157. * Stores the effects for the material
  87158. */
  87159. _effect: Nullable<Effect>;
  87160. /**
  87161. * @hidden
  87162. * Specifies if the material was previously ready
  87163. */
  87164. _wasPreviouslyReady: boolean;
  87165. /**
  87166. * Specifies if uniform buffers should be used
  87167. */
  87168. private _useUBO;
  87169. /**
  87170. * Stores a reference to the scene
  87171. */
  87172. private _scene;
  87173. /**
  87174. * Stores the fill mode state
  87175. */
  87176. private _fillMode;
  87177. /**
  87178. * Specifies if the depth write state should be cached
  87179. */
  87180. private _cachedDepthWriteState;
  87181. /**
  87182. * Stores the uniform buffer
  87183. */
  87184. protected _uniformBuffer: UniformBuffer;
  87185. /** @hidden */
  87186. _indexInSceneMaterialArray: number;
  87187. /** @hidden */
  87188. meshMap: Nullable<{
  87189. [id: string]: AbstractMesh | undefined;
  87190. }>;
  87191. /**
  87192. * Creates a material instance
  87193. * @param name defines the name of the material
  87194. * @param scene defines the scene to reference
  87195. * @param doNotAdd specifies if the material should be added to the scene
  87196. */
  87197. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87198. /**
  87199. * Returns a string representation of the current material
  87200. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87201. * @returns a string with material information
  87202. */
  87203. toString(fullDetails?: boolean): string;
  87204. /**
  87205. * Gets the class name of the material
  87206. * @returns a string with the class name of the material
  87207. */
  87208. getClassName(): string;
  87209. /**
  87210. * Specifies if updates for the material been locked
  87211. */
  87212. readonly isFrozen: boolean;
  87213. /**
  87214. * Locks updates for the material
  87215. */
  87216. freeze(): void;
  87217. /**
  87218. * Unlocks updates for the material
  87219. */
  87220. unfreeze(): void;
  87221. /**
  87222. * Specifies if the material is ready to be used
  87223. * @param mesh defines the mesh to check
  87224. * @param useInstances specifies if instances should be used
  87225. * @returns a boolean indicating if the material is ready to be used
  87226. */
  87227. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87228. /**
  87229. * Specifies that the submesh is ready to be used
  87230. * @param mesh defines the mesh to check
  87231. * @param subMesh defines which submesh to check
  87232. * @param useInstances specifies that instances should be used
  87233. * @returns a boolean indicating that the submesh is ready or not
  87234. */
  87235. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87236. /**
  87237. * Returns the material effect
  87238. * @returns the effect associated with the material
  87239. */
  87240. getEffect(): Nullable<Effect>;
  87241. /**
  87242. * Returns the current scene
  87243. * @returns a Scene
  87244. */
  87245. getScene(): Scene;
  87246. /**
  87247. * Specifies if the material will require alpha blending
  87248. * @returns a boolean specifying if alpha blending is needed
  87249. */
  87250. needAlphaBlending(): boolean;
  87251. /**
  87252. * Specifies if the mesh will require alpha blending
  87253. * @param mesh defines the mesh to check
  87254. * @returns a boolean specifying if alpha blending is needed for the mesh
  87255. */
  87256. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87257. /**
  87258. * Specifies if this material should be rendered in alpha test mode
  87259. * @returns a boolean specifying if an alpha test is needed.
  87260. */
  87261. needAlphaTesting(): boolean;
  87262. /**
  87263. * Gets the texture used for the alpha test
  87264. * @returns the texture to use for alpha testing
  87265. */
  87266. getAlphaTestTexture(): Nullable<BaseTexture>;
  87267. /**
  87268. * Marks the material to indicate that it needs to be re-calculated
  87269. */
  87270. markDirty(): void;
  87271. /** @hidden */
  87272. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87273. /**
  87274. * Binds the material to the mesh
  87275. * @param world defines the world transformation matrix
  87276. * @param mesh defines the mesh to bind the material to
  87277. */
  87278. bind(world: Matrix, mesh?: Mesh): void;
  87279. /**
  87280. * Binds the submesh to the material
  87281. * @param world defines the world transformation matrix
  87282. * @param mesh defines the mesh containing the submesh
  87283. * @param subMesh defines the submesh to bind the material to
  87284. */
  87285. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87286. /**
  87287. * Binds the world matrix to the material
  87288. * @param world defines the world transformation matrix
  87289. */
  87290. bindOnlyWorldMatrix(world: Matrix): void;
  87291. /**
  87292. * Binds the scene's uniform buffer to the effect.
  87293. * @param effect defines the effect to bind to the scene uniform buffer
  87294. * @param sceneUbo defines the uniform buffer storing scene data
  87295. */
  87296. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87297. /**
  87298. * Binds the view matrix to the effect
  87299. * @param effect defines the effect to bind the view matrix to
  87300. */
  87301. bindView(effect: Effect): void;
  87302. /**
  87303. * Binds the view projection matrix to the effect
  87304. * @param effect defines the effect to bind the view projection matrix to
  87305. */
  87306. bindViewProjection(effect: Effect): void;
  87307. /**
  87308. * Specifies if material alpha testing should be turned on for the mesh
  87309. * @param mesh defines the mesh to check
  87310. */
  87311. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87312. /**
  87313. * Processes to execute after binding the material to a mesh
  87314. * @param mesh defines the rendered mesh
  87315. */
  87316. protected _afterBind(mesh?: Mesh): void;
  87317. /**
  87318. * Unbinds the material from the mesh
  87319. */
  87320. unbind(): void;
  87321. /**
  87322. * Gets the active textures from the material
  87323. * @returns an array of textures
  87324. */
  87325. getActiveTextures(): BaseTexture[];
  87326. /**
  87327. * Specifies if the material uses a texture
  87328. * @param texture defines the texture to check against the material
  87329. * @returns a boolean specifying if the material uses the texture
  87330. */
  87331. hasTexture(texture: BaseTexture): boolean;
  87332. /**
  87333. * Makes a duplicate of the material, and gives it a new name
  87334. * @param name defines the new name for the duplicated material
  87335. * @returns the cloned material
  87336. */
  87337. clone(name: string): Nullable<Material>;
  87338. /**
  87339. * Gets the meshes bound to the material
  87340. * @returns an array of meshes bound to the material
  87341. */
  87342. getBindedMeshes(): AbstractMesh[];
  87343. /**
  87344. * Force shader compilation
  87345. * @param mesh defines the mesh associated with this material
  87346. * @param onCompiled defines a function to execute once the material is compiled
  87347. * @param options defines the options to configure the compilation
  87348. * @param onError defines a function to execute if the material fails compiling
  87349. */
  87350. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87351. clipPlane: boolean;
  87352. }>, onError?: (reason: string) => void): void;
  87353. /**
  87354. * Force shader compilation
  87355. * @param mesh defines the mesh that will use this material
  87356. * @param options defines additional options for compiling the shaders
  87357. * @returns a promise that resolves when the compilation completes
  87358. */
  87359. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87360. clipPlane: boolean;
  87361. }>): Promise<void>;
  87362. private static readonly _AllDirtyCallBack;
  87363. private static readonly _ImageProcessingDirtyCallBack;
  87364. private static readonly _TextureDirtyCallBack;
  87365. private static readonly _FresnelDirtyCallBack;
  87366. private static readonly _MiscDirtyCallBack;
  87367. private static readonly _LightsDirtyCallBack;
  87368. private static readonly _AttributeDirtyCallBack;
  87369. private static _FresnelAndMiscDirtyCallBack;
  87370. private static _TextureAndMiscDirtyCallBack;
  87371. private static readonly _DirtyCallbackArray;
  87372. private static readonly _RunDirtyCallBacks;
  87373. /**
  87374. * Marks a define in the material to indicate that it needs to be re-computed
  87375. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87376. */
  87377. markAsDirty(flag: number): void;
  87378. /**
  87379. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87380. * @param func defines a function which checks material defines against the submeshes
  87381. */
  87382. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87383. /**
  87384. * Indicates that we need to re-calculated for all submeshes
  87385. */
  87386. protected _markAllSubMeshesAsAllDirty(): void;
  87387. /**
  87388. * Indicates that image processing needs to be re-calculated for all submeshes
  87389. */
  87390. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87391. /**
  87392. * Indicates that textures need to be re-calculated for all submeshes
  87393. */
  87394. protected _markAllSubMeshesAsTexturesDirty(): void;
  87395. /**
  87396. * Indicates that fresnel needs to be re-calculated for all submeshes
  87397. */
  87398. protected _markAllSubMeshesAsFresnelDirty(): void;
  87399. /**
  87400. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87401. */
  87402. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87403. /**
  87404. * Indicates that lights need to be re-calculated for all submeshes
  87405. */
  87406. protected _markAllSubMeshesAsLightsDirty(): void;
  87407. /**
  87408. * Indicates that attributes need to be re-calculated for all submeshes
  87409. */
  87410. protected _markAllSubMeshesAsAttributesDirty(): void;
  87411. /**
  87412. * Indicates that misc needs to be re-calculated for all submeshes
  87413. */
  87414. protected _markAllSubMeshesAsMiscDirty(): void;
  87415. /**
  87416. * Indicates that textures and misc need to be re-calculated for all submeshes
  87417. */
  87418. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87419. /**
  87420. * Disposes the material
  87421. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87422. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87423. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87424. */
  87425. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87426. /** @hidden */
  87427. private releaseVertexArrayObject;
  87428. /**
  87429. * Serializes this material
  87430. * @returns the serialized material object
  87431. */
  87432. serialize(): any;
  87433. /**
  87434. * Creates a material from parsed material data
  87435. * @param parsedMaterial defines parsed material data
  87436. * @param scene defines the hosting scene
  87437. * @param rootUrl defines the root URL to use to load textures
  87438. * @returns a new material
  87439. */
  87440. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87441. }
  87442. }
  87443. declare module BABYLON {
  87444. /**
  87445. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87446. * separate meshes. This can be use to improve performances.
  87447. * @see http://doc.babylonjs.com/how_to/multi_materials
  87448. */
  87449. export class MultiMaterial extends Material {
  87450. private _subMaterials;
  87451. /**
  87452. * Gets or Sets the list of Materials used within the multi material.
  87453. * They need to be ordered according to the submeshes order in the associated mesh
  87454. */
  87455. subMaterials: Nullable<Material>[];
  87456. /**
  87457. * Function used to align with Node.getChildren()
  87458. * @returns the list of Materials used within the multi material
  87459. */
  87460. getChildren(): Nullable<Material>[];
  87461. /**
  87462. * Instantiates a new Multi Material
  87463. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87464. * separate meshes. This can be use to improve performances.
  87465. * @see http://doc.babylonjs.com/how_to/multi_materials
  87466. * @param name Define the name in the scene
  87467. * @param scene Define the scene the material belongs to
  87468. */
  87469. constructor(name: string, scene: Scene);
  87470. private _hookArray;
  87471. /**
  87472. * Get one of the submaterial by its index in the submaterials array
  87473. * @param index The index to look the sub material at
  87474. * @returns The Material if the index has been defined
  87475. */
  87476. getSubMaterial(index: number): Nullable<Material>;
  87477. /**
  87478. * Get the list of active textures for the whole sub materials list.
  87479. * @returns All the textures that will be used during the rendering
  87480. */
  87481. getActiveTextures(): BaseTexture[];
  87482. /**
  87483. * Gets the current class name of the material e.g. "MultiMaterial"
  87484. * Mainly use in serialization.
  87485. * @returns the class name
  87486. */
  87487. getClassName(): string;
  87488. /**
  87489. * Checks if the material is ready to render the requested sub mesh
  87490. * @param mesh Define the mesh the submesh belongs to
  87491. * @param subMesh Define the sub mesh to look readyness for
  87492. * @param useInstances Define whether or not the material is used with instances
  87493. * @returns true if ready, otherwise false
  87494. */
  87495. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87496. /**
  87497. * Clones the current material and its related sub materials
  87498. * @param name Define the name of the newly cloned material
  87499. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87500. * @returns the cloned material
  87501. */
  87502. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87503. /**
  87504. * Serializes the materials into a JSON representation.
  87505. * @returns the JSON representation
  87506. */
  87507. serialize(): any;
  87508. /**
  87509. * Dispose the material and release its associated resources
  87510. * @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)
  87511. * @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)
  87512. * @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)
  87513. */
  87514. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87515. /**
  87516. * Creates a MultiMaterial from parsed MultiMaterial data.
  87517. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87518. * @param scene defines the hosting scene
  87519. * @returns a new MultiMaterial
  87520. */
  87521. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87522. }
  87523. }
  87524. declare module BABYLON {
  87525. /**
  87526. * Base class for submeshes
  87527. */
  87528. export class BaseSubMesh {
  87529. /** @hidden */
  87530. _materialDefines: Nullable<MaterialDefines>;
  87531. /** @hidden */
  87532. _materialEffect: Nullable<Effect>;
  87533. /**
  87534. * Gets associated effect
  87535. */
  87536. readonly effect: Nullable<Effect>;
  87537. /**
  87538. * Sets associated effect (effect used to render this submesh)
  87539. * @param effect defines the effect to associate with
  87540. * @param defines defines the set of defines used to compile this effect
  87541. */
  87542. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87543. }
  87544. /**
  87545. * Defines a subdivision inside a mesh
  87546. */
  87547. export class SubMesh extends BaseSubMesh implements ICullable {
  87548. /** the material index to use */
  87549. materialIndex: number;
  87550. /** vertex index start */
  87551. verticesStart: number;
  87552. /** vertices count */
  87553. verticesCount: number;
  87554. /** index start */
  87555. indexStart: number;
  87556. /** indices count */
  87557. indexCount: number;
  87558. /** @hidden */
  87559. _linesIndexCount: number;
  87560. private _mesh;
  87561. private _renderingMesh;
  87562. private _boundingInfo;
  87563. private _linesIndexBuffer;
  87564. /** @hidden */
  87565. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87566. /** @hidden */
  87567. _trianglePlanes: Plane[];
  87568. /** @hidden */
  87569. _lastColliderTransformMatrix: Nullable<Matrix>;
  87570. /** @hidden */
  87571. _renderId: number;
  87572. /** @hidden */
  87573. _alphaIndex: number;
  87574. /** @hidden */
  87575. _distanceToCamera: number;
  87576. /** @hidden */
  87577. _id: number;
  87578. private _currentMaterial;
  87579. /**
  87580. * Add a new submesh to a mesh
  87581. * @param materialIndex defines the material index to use
  87582. * @param verticesStart defines vertex index start
  87583. * @param verticesCount defines vertices count
  87584. * @param indexStart defines index start
  87585. * @param indexCount defines indices count
  87586. * @param mesh defines the parent mesh
  87587. * @param renderingMesh defines an optional rendering mesh
  87588. * @param createBoundingBox defines if bounding box should be created for this submesh
  87589. * @returns the new submesh
  87590. */
  87591. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87592. /**
  87593. * Creates a new submesh
  87594. * @param materialIndex defines the material index to use
  87595. * @param verticesStart defines vertex index start
  87596. * @param verticesCount defines vertices count
  87597. * @param indexStart defines index start
  87598. * @param indexCount defines indices count
  87599. * @param mesh defines the parent mesh
  87600. * @param renderingMesh defines an optional rendering mesh
  87601. * @param createBoundingBox defines if bounding box should be created for this submesh
  87602. */
  87603. constructor(
  87604. /** the material index to use */
  87605. materialIndex: number,
  87606. /** vertex index start */
  87607. verticesStart: number,
  87608. /** vertices count */
  87609. verticesCount: number,
  87610. /** index start */
  87611. indexStart: number,
  87612. /** indices count */
  87613. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87614. /**
  87615. * Returns true if this submesh covers the entire parent mesh
  87616. * @ignorenaming
  87617. */
  87618. readonly IsGlobal: boolean;
  87619. /**
  87620. * Returns the submesh BoudingInfo object
  87621. * @returns current bounding info (or mesh's one if the submesh is global)
  87622. */
  87623. getBoundingInfo(): BoundingInfo;
  87624. /**
  87625. * Sets the submesh BoundingInfo
  87626. * @param boundingInfo defines the new bounding info to use
  87627. * @returns the SubMesh
  87628. */
  87629. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87630. /**
  87631. * Returns the mesh of the current submesh
  87632. * @return the parent mesh
  87633. */
  87634. getMesh(): AbstractMesh;
  87635. /**
  87636. * Returns the rendering mesh of the submesh
  87637. * @returns the rendering mesh (could be different from parent mesh)
  87638. */
  87639. getRenderingMesh(): Mesh;
  87640. /**
  87641. * Returns the submesh material
  87642. * @returns null or the current material
  87643. */
  87644. getMaterial(): Nullable<Material>;
  87645. /**
  87646. * Sets a new updated BoundingInfo object to the submesh
  87647. * @param data defines an optional position array to use to determine the bounding info
  87648. * @returns the SubMesh
  87649. */
  87650. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87651. /** @hidden */
  87652. _checkCollision(collider: Collider): boolean;
  87653. /**
  87654. * Updates the submesh BoundingInfo
  87655. * @param world defines the world matrix to use to update the bounding info
  87656. * @returns the submesh
  87657. */
  87658. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87659. /**
  87660. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87661. * @param frustumPlanes defines the frustum planes
  87662. * @returns true if the submesh is intersecting with the frustum
  87663. */
  87664. isInFrustum(frustumPlanes: Plane[]): boolean;
  87665. /**
  87666. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87667. * @param frustumPlanes defines the frustum planes
  87668. * @returns true if the submesh is inside the frustum
  87669. */
  87670. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87671. /**
  87672. * Renders the submesh
  87673. * @param enableAlphaMode defines if alpha needs to be used
  87674. * @returns the submesh
  87675. */
  87676. render(enableAlphaMode: boolean): SubMesh;
  87677. /**
  87678. * @hidden
  87679. */
  87680. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87681. /**
  87682. * Checks if the submesh intersects with a ray
  87683. * @param ray defines the ray to test
  87684. * @returns true is the passed ray intersects the submesh bounding box
  87685. */
  87686. canIntersects(ray: Ray): boolean;
  87687. /**
  87688. * Intersects current submesh with a ray
  87689. * @param ray defines the ray to test
  87690. * @param positions defines mesh's positions array
  87691. * @param indices defines mesh's indices array
  87692. * @param fastCheck defines if only bounding info should be used
  87693. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87694. * @returns intersection info or null if no intersection
  87695. */
  87696. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87697. /** @hidden */
  87698. private _intersectLines;
  87699. /** @hidden */
  87700. private _intersectUnIndexedLines;
  87701. /** @hidden */
  87702. private _intersectTriangles;
  87703. /** @hidden */
  87704. private _intersectUnIndexedTriangles;
  87705. /** @hidden */
  87706. _rebuild(): void;
  87707. /**
  87708. * Creates a new submesh from the passed mesh
  87709. * @param newMesh defines the new hosting mesh
  87710. * @param newRenderingMesh defines an optional rendering mesh
  87711. * @returns the new submesh
  87712. */
  87713. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87714. /**
  87715. * Release associated resources
  87716. */
  87717. dispose(): void;
  87718. /**
  87719. * Gets the class name
  87720. * @returns the string "SubMesh".
  87721. */
  87722. getClassName(): string;
  87723. /**
  87724. * Creates a new submesh from indices data
  87725. * @param materialIndex the index of the main mesh material
  87726. * @param startIndex the index where to start the copy in the mesh indices array
  87727. * @param indexCount the number of indices to copy then from the startIndex
  87728. * @param mesh the main mesh to create the submesh from
  87729. * @param renderingMesh the optional rendering mesh
  87730. * @returns a new submesh
  87731. */
  87732. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87733. }
  87734. }
  87735. declare module BABYLON {
  87736. /**
  87737. * Class used to represent data loading progression
  87738. */
  87739. export class SceneLoaderFlags {
  87740. private static _ForceFullSceneLoadingForIncremental;
  87741. private static _ShowLoadingScreen;
  87742. private static _CleanBoneMatrixWeights;
  87743. private static _loggingLevel;
  87744. /**
  87745. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87746. */
  87747. static ForceFullSceneLoadingForIncremental: boolean;
  87748. /**
  87749. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87750. */
  87751. static ShowLoadingScreen: boolean;
  87752. /**
  87753. * Defines the current logging level (while loading the scene)
  87754. * @ignorenaming
  87755. */
  87756. static loggingLevel: number;
  87757. /**
  87758. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87759. */
  87760. static CleanBoneMatrixWeights: boolean;
  87761. }
  87762. }
  87763. declare module BABYLON {
  87764. /**
  87765. * Class used to store geometry data (vertex buffers + index buffer)
  87766. */
  87767. export class Geometry implements IGetSetVerticesData {
  87768. /**
  87769. * Gets or sets the ID of the geometry
  87770. */
  87771. id: string;
  87772. /**
  87773. * Gets or sets the unique ID of the geometry
  87774. */
  87775. uniqueId: number;
  87776. /**
  87777. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87778. */
  87779. delayLoadState: number;
  87780. /**
  87781. * Gets the file containing the data to load when running in delay load state
  87782. */
  87783. delayLoadingFile: Nullable<string>;
  87784. /**
  87785. * Callback called when the geometry is updated
  87786. */
  87787. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87788. private _scene;
  87789. private _engine;
  87790. private _meshes;
  87791. private _totalVertices;
  87792. /** @hidden */
  87793. _indices: IndicesArray;
  87794. /** @hidden */
  87795. _vertexBuffers: {
  87796. [key: string]: VertexBuffer;
  87797. };
  87798. private _isDisposed;
  87799. private _extend;
  87800. private _boundingBias;
  87801. /** @hidden */
  87802. _delayInfo: Array<string>;
  87803. private _indexBuffer;
  87804. private _indexBufferIsUpdatable;
  87805. /** @hidden */
  87806. _boundingInfo: Nullable<BoundingInfo>;
  87807. /** @hidden */
  87808. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87809. /** @hidden */
  87810. _softwareSkinningFrameId: number;
  87811. private _vertexArrayObjects;
  87812. private _updatable;
  87813. /** @hidden */
  87814. _positions: Nullable<Vector3[]>;
  87815. /**
  87816. * 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
  87817. */
  87818. /**
  87819. * 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
  87820. */
  87821. boundingBias: Vector2;
  87822. /**
  87823. * Static function used to attach a new empty geometry to a mesh
  87824. * @param mesh defines the mesh to attach the geometry to
  87825. * @returns the new Geometry
  87826. */
  87827. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87828. /**
  87829. * Creates a new geometry
  87830. * @param id defines the unique ID
  87831. * @param scene defines the hosting scene
  87832. * @param vertexData defines the VertexData used to get geometry data
  87833. * @param updatable defines if geometry must be updatable (false by default)
  87834. * @param mesh defines the mesh that will be associated with the geometry
  87835. */
  87836. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87837. /**
  87838. * Gets the current extend of the geometry
  87839. */
  87840. readonly extend: {
  87841. minimum: Vector3;
  87842. maximum: Vector3;
  87843. };
  87844. /**
  87845. * Gets the hosting scene
  87846. * @returns the hosting Scene
  87847. */
  87848. getScene(): Scene;
  87849. /**
  87850. * Gets the hosting engine
  87851. * @returns the hosting Engine
  87852. */
  87853. getEngine(): Engine;
  87854. /**
  87855. * Defines if the geometry is ready to use
  87856. * @returns true if the geometry is ready to be used
  87857. */
  87858. isReady(): boolean;
  87859. /**
  87860. * Gets a value indicating that the geometry should not be serialized
  87861. */
  87862. readonly doNotSerialize: boolean;
  87863. /** @hidden */
  87864. _rebuild(): void;
  87865. /**
  87866. * Affects all geometry data in one call
  87867. * @param vertexData defines the geometry data
  87868. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87869. */
  87870. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87871. /**
  87872. * Set specific vertex data
  87873. * @param kind defines the data kind (Position, normal, etc...)
  87874. * @param data defines the vertex data to use
  87875. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87876. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87877. */
  87878. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87879. /**
  87880. * Removes a specific vertex data
  87881. * @param kind defines the data kind (Position, normal, etc...)
  87882. */
  87883. removeVerticesData(kind: string): void;
  87884. /**
  87885. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87886. * @param buffer defines the vertex buffer to use
  87887. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87888. */
  87889. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87890. /**
  87891. * Update a specific vertex buffer
  87892. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87893. * It will do nothing if the buffer is not updatable
  87894. * @param kind defines the data kind (Position, normal, etc...)
  87895. * @param data defines the data to use
  87896. * @param offset defines the offset in the target buffer where to store the data
  87897. * @param useBytes set to true if the offset is in bytes
  87898. */
  87899. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87900. /**
  87901. * Update a specific vertex buffer
  87902. * This function will create a new buffer if the current one is not updatable
  87903. * @param kind defines the data kind (Position, normal, etc...)
  87904. * @param data defines the data to use
  87905. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87906. */
  87907. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87908. private _updateBoundingInfo;
  87909. /** @hidden */
  87910. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87911. /**
  87912. * Gets total number of vertices
  87913. * @returns the total number of vertices
  87914. */
  87915. getTotalVertices(): number;
  87916. /**
  87917. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87918. * @param kind defines the data kind (Position, normal, etc...)
  87919. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87920. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87921. * @returns a float array containing vertex data
  87922. */
  87923. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87924. /**
  87925. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87926. * @param kind defines the data kind (Position, normal, etc...)
  87927. * @returns true if the vertex buffer with the specified kind is updatable
  87928. */
  87929. isVertexBufferUpdatable(kind: string): boolean;
  87930. /**
  87931. * Gets a specific vertex buffer
  87932. * @param kind defines the data kind (Position, normal, etc...)
  87933. * @returns a VertexBuffer
  87934. */
  87935. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87936. /**
  87937. * Returns all vertex buffers
  87938. * @return an object holding all vertex buffers indexed by kind
  87939. */
  87940. getVertexBuffers(): Nullable<{
  87941. [key: string]: VertexBuffer;
  87942. }>;
  87943. /**
  87944. * Gets a boolean indicating if specific vertex buffer is present
  87945. * @param kind defines the data kind (Position, normal, etc...)
  87946. * @returns true if data is present
  87947. */
  87948. isVerticesDataPresent(kind: string): boolean;
  87949. /**
  87950. * Gets a list of all attached data kinds (Position, normal, etc...)
  87951. * @returns a list of string containing all kinds
  87952. */
  87953. getVerticesDataKinds(): string[];
  87954. /**
  87955. * Update index buffer
  87956. * @param indices defines the indices to store in the index buffer
  87957. * @param offset defines the offset in the target buffer where to store the data
  87958. * @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)
  87959. */
  87960. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87961. /**
  87962. * Creates a new index buffer
  87963. * @param indices defines the indices to store in the index buffer
  87964. * @param totalVertices defines the total number of vertices (could be null)
  87965. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87966. */
  87967. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87968. /**
  87969. * Return the total number of indices
  87970. * @returns the total number of indices
  87971. */
  87972. getTotalIndices(): number;
  87973. /**
  87974. * Gets the index buffer array
  87975. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87976. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87977. * @returns the index buffer array
  87978. */
  87979. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  87980. /**
  87981. * Gets the index buffer
  87982. * @return the index buffer
  87983. */
  87984. getIndexBuffer(): Nullable<DataBuffer>;
  87985. /** @hidden */
  87986. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  87987. /**
  87988. * Release the associated resources for a specific mesh
  87989. * @param mesh defines the source mesh
  87990. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  87991. */
  87992. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  87993. /**
  87994. * Apply current geometry to a given mesh
  87995. * @param mesh defines the mesh to apply geometry to
  87996. */
  87997. applyToMesh(mesh: Mesh): void;
  87998. private _updateExtend;
  87999. private _applyToMesh;
  88000. private notifyUpdate;
  88001. /**
  88002. * Load the geometry if it was flagged as delay loaded
  88003. * @param scene defines the hosting scene
  88004. * @param onLoaded defines a callback called when the geometry is loaded
  88005. */
  88006. load(scene: Scene, onLoaded?: () => void): void;
  88007. private _queueLoad;
  88008. /**
  88009. * Invert the geometry to move from a right handed system to a left handed one.
  88010. */
  88011. toLeftHanded(): void;
  88012. /** @hidden */
  88013. _resetPointsArrayCache(): void;
  88014. /** @hidden */
  88015. _generatePointsArray(): boolean;
  88016. /**
  88017. * Gets a value indicating if the geometry is disposed
  88018. * @returns true if the geometry was disposed
  88019. */
  88020. isDisposed(): boolean;
  88021. private _disposeVertexArrayObjects;
  88022. /**
  88023. * Free all associated resources
  88024. */
  88025. dispose(): void;
  88026. /**
  88027. * Clone the current geometry into a new geometry
  88028. * @param id defines the unique ID of the new geometry
  88029. * @returns a new geometry object
  88030. */
  88031. copy(id: string): Geometry;
  88032. /**
  88033. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88034. * @return a JSON representation of the current geometry data (without the vertices data)
  88035. */
  88036. serialize(): any;
  88037. private toNumberArray;
  88038. /**
  88039. * Serialize all vertices data into a JSON oject
  88040. * @returns a JSON representation of the current geometry data
  88041. */
  88042. serializeVerticeData(): any;
  88043. /**
  88044. * Extracts a clone of a mesh geometry
  88045. * @param mesh defines the source mesh
  88046. * @param id defines the unique ID of the new geometry object
  88047. * @returns the new geometry object
  88048. */
  88049. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88050. /**
  88051. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88052. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88053. * Be aware Math.random() could cause collisions, but:
  88054. * "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"
  88055. * @returns a string containing a new GUID
  88056. */
  88057. static RandomId(): string;
  88058. /** @hidden */
  88059. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88060. private static _CleanMatricesWeights;
  88061. /**
  88062. * Create a new geometry from persisted data (Using .babylon file format)
  88063. * @param parsedVertexData defines the persisted data
  88064. * @param scene defines the hosting scene
  88065. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88066. * @returns the new geometry object
  88067. */
  88068. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88069. }
  88070. }
  88071. declare module BABYLON {
  88072. /**
  88073. * Define an interface for all classes that will get and set the data on vertices
  88074. */
  88075. export interface IGetSetVerticesData {
  88076. /**
  88077. * Gets a boolean indicating if specific vertex data is present
  88078. * @param kind defines the vertex data kind to use
  88079. * @returns true is data kind is present
  88080. */
  88081. isVerticesDataPresent(kind: string): boolean;
  88082. /**
  88083. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88084. * @param kind defines the data kind (Position, normal, etc...)
  88085. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88086. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88087. * @returns a float array containing vertex data
  88088. */
  88089. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88090. /**
  88091. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88092. * @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.
  88093. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88094. * @returns the indices array or an empty array if the mesh has no geometry
  88095. */
  88096. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88097. /**
  88098. * Set specific vertex data
  88099. * @param kind defines the data kind (Position, normal, etc...)
  88100. * @param data defines the vertex data to use
  88101. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88102. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88103. */
  88104. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88105. /**
  88106. * Update a specific associated vertex buffer
  88107. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88108. * - VertexBuffer.PositionKind
  88109. * - VertexBuffer.UVKind
  88110. * - VertexBuffer.UV2Kind
  88111. * - VertexBuffer.UV3Kind
  88112. * - VertexBuffer.UV4Kind
  88113. * - VertexBuffer.UV5Kind
  88114. * - VertexBuffer.UV6Kind
  88115. * - VertexBuffer.ColorKind
  88116. * - VertexBuffer.MatricesIndicesKind
  88117. * - VertexBuffer.MatricesIndicesExtraKind
  88118. * - VertexBuffer.MatricesWeightsKind
  88119. * - VertexBuffer.MatricesWeightsExtraKind
  88120. * @param data defines the data source
  88121. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88122. * @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)
  88123. */
  88124. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88125. /**
  88126. * Creates a new index buffer
  88127. * @param indices defines the indices to store in the index buffer
  88128. * @param totalVertices defines the total number of vertices (could be null)
  88129. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88130. */
  88131. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88132. }
  88133. /**
  88134. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88135. */
  88136. export class VertexData {
  88137. /**
  88138. * Mesh side orientation : usually the external or front surface
  88139. */
  88140. static readonly FRONTSIDE: number;
  88141. /**
  88142. * Mesh side orientation : usually the internal or back surface
  88143. */
  88144. static readonly BACKSIDE: number;
  88145. /**
  88146. * Mesh side orientation : both internal and external or front and back surfaces
  88147. */
  88148. static readonly DOUBLESIDE: number;
  88149. /**
  88150. * Mesh side orientation : by default, `FRONTSIDE`
  88151. */
  88152. static readonly DEFAULTSIDE: number;
  88153. /**
  88154. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88155. */
  88156. positions: Nullable<FloatArray>;
  88157. /**
  88158. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88159. */
  88160. normals: Nullable<FloatArray>;
  88161. /**
  88162. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88163. */
  88164. tangents: Nullable<FloatArray>;
  88165. /**
  88166. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88167. */
  88168. uvs: Nullable<FloatArray>;
  88169. /**
  88170. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88171. */
  88172. uvs2: Nullable<FloatArray>;
  88173. /**
  88174. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88175. */
  88176. uvs3: Nullable<FloatArray>;
  88177. /**
  88178. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88179. */
  88180. uvs4: Nullable<FloatArray>;
  88181. /**
  88182. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88183. */
  88184. uvs5: Nullable<FloatArray>;
  88185. /**
  88186. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88187. */
  88188. uvs6: Nullable<FloatArray>;
  88189. /**
  88190. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88191. */
  88192. colors: Nullable<FloatArray>;
  88193. /**
  88194. * 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).
  88195. */
  88196. matricesIndices: Nullable<FloatArray>;
  88197. /**
  88198. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88199. */
  88200. matricesWeights: Nullable<FloatArray>;
  88201. /**
  88202. * An array extending the number of possible indices
  88203. */
  88204. matricesIndicesExtra: Nullable<FloatArray>;
  88205. /**
  88206. * An array extending the number of possible weights when the number of indices is extended
  88207. */
  88208. matricesWeightsExtra: Nullable<FloatArray>;
  88209. /**
  88210. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88211. */
  88212. indices: Nullable<IndicesArray>;
  88213. /**
  88214. * Uses the passed data array to set the set the values for the specified kind of data
  88215. * @param data a linear array of floating numbers
  88216. * @param kind the type of data that is being set, eg positions, colors etc
  88217. */
  88218. set(data: FloatArray, kind: string): void;
  88219. /**
  88220. * Associates the vertexData to the passed Mesh.
  88221. * Sets it as updatable or not (default `false`)
  88222. * @param mesh the mesh the vertexData is applied to
  88223. * @param updatable when used and having the value true allows new data to update the vertexData
  88224. * @returns the VertexData
  88225. */
  88226. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88227. /**
  88228. * Associates the vertexData to the passed Geometry.
  88229. * Sets it as updatable or not (default `false`)
  88230. * @param geometry the geometry the vertexData is applied to
  88231. * @param updatable when used and having the value true allows new data to update the vertexData
  88232. * @returns VertexData
  88233. */
  88234. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88235. /**
  88236. * Updates the associated mesh
  88237. * @param mesh the mesh to be updated
  88238. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88239. * @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
  88240. * @returns VertexData
  88241. */
  88242. updateMesh(mesh: Mesh): VertexData;
  88243. /**
  88244. * Updates the associated geometry
  88245. * @param geometry the geometry to be updated
  88246. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88247. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  88248. * @returns VertexData.
  88249. */
  88250. updateGeometry(geometry: Geometry): VertexData;
  88251. private _applyTo;
  88252. private _update;
  88253. /**
  88254. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88255. * @param matrix the transforming matrix
  88256. * @returns the VertexData
  88257. */
  88258. transform(matrix: Matrix): VertexData;
  88259. /**
  88260. * Merges the passed VertexData into the current one
  88261. * @param other the VertexData to be merged into the current one
  88262. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88263. * @returns the modified VertexData
  88264. */
  88265. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88266. private _mergeElement;
  88267. private _validate;
  88268. /**
  88269. * Serializes the VertexData
  88270. * @returns a serialized object
  88271. */
  88272. serialize(): any;
  88273. /**
  88274. * Extracts the vertexData from a mesh
  88275. * @param mesh the mesh from which to extract the VertexData
  88276. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88277. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88278. * @returns the object VertexData associated to the passed mesh
  88279. */
  88280. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88281. /**
  88282. * Extracts the vertexData from the geometry
  88283. * @param geometry the geometry from which to extract the VertexData
  88284. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88285. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88286. * @returns the object VertexData associated to the passed mesh
  88287. */
  88288. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88289. private static _ExtractFrom;
  88290. /**
  88291. * Creates the VertexData for a Ribbon
  88292. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88293. * * pathArray array of paths, each of which an array of successive Vector3
  88294. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88295. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88296. * * 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
  88297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88298. * * 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)
  88299. * * 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)
  88300. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88301. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88302. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88303. * @returns the VertexData of the ribbon
  88304. */
  88305. static CreateRibbon(options: {
  88306. pathArray: Vector3[][];
  88307. closeArray?: boolean;
  88308. closePath?: boolean;
  88309. offset?: number;
  88310. sideOrientation?: number;
  88311. frontUVs?: Vector4;
  88312. backUVs?: Vector4;
  88313. invertUV?: boolean;
  88314. uvs?: Vector2[];
  88315. colors?: Color4[];
  88316. }): VertexData;
  88317. /**
  88318. * Creates the VertexData for a box
  88319. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88320. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88321. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88322. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88323. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88324. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88325. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88326. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88327. * * 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)
  88328. * * 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)
  88329. * @returns the VertexData of the box
  88330. */
  88331. static CreateBox(options: {
  88332. size?: number;
  88333. width?: number;
  88334. height?: number;
  88335. depth?: number;
  88336. faceUV?: Vector4[];
  88337. faceColors?: Color4[];
  88338. sideOrientation?: number;
  88339. frontUVs?: Vector4;
  88340. backUVs?: Vector4;
  88341. }): VertexData;
  88342. /**
  88343. * Creates the VertexData for a tiled box
  88344. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88345. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88346. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88347. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88349. * @returns the VertexData of the box
  88350. */
  88351. static CreateTiledBox(options: {
  88352. pattern?: number;
  88353. width?: number;
  88354. height?: number;
  88355. depth?: number;
  88356. tileSize?: number;
  88357. tileWidth?: number;
  88358. tileHeight?: number;
  88359. alignHorizontal?: number;
  88360. alignVertical?: number;
  88361. faceUV?: Vector4[];
  88362. faceColors?: Color4[];
  88363. sideOrientation?: number;
  88364. }): VertexData;
  88365. /**
  88366. * Creates the VertexData for a tiled plane
  88367. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88368. * * pattern a limited pattern arrangement depending on the number
  88369. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88370. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88371. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88373. * * 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)
  88374. * * 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)
  88375. * @returns the VertexData of the tiled plane
  88376. */
  88377. static CreateTiledPlane(options: {
  88378. pattern?: number;
  88379. tileSize?: number;
  88380. tileWidth?: number;
  88381. tileHeight?: number;
  88382. size?: number;
  88383. width?: number;
  88384. height?: number;
  88385. alignHorizontal?: number;
  88386. alignVertical?: number;
  88387. sideOrientation?: number;
  88388. frontUVs?: Vector4;
  88389. backUVs?: Vector4;
  88390. }): VertexData;
  88391. /**
  88392. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88393. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88394. * * segments sets the number of horizontal strips optional, default 32
  88395. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88396. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88397. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88398. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88399. * * 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
  88400. * * 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
  88401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88402. * * 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)
  88403. * * 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)
  88404. * @returns the VertexData of the ellipsoid
  88405. */
  88406. static CreateSphere(options: {
  88407. segments?: number;
  88408. diameter?: number;
  88409. diameterX?: number;
  88410. diameterY?: number;
  88411. diameterZ?: number;
  88412. arc?: number;
  88413. slice?: number;
  88414. sideOrientation?: number;
  88415. frontUVs?: Vector4;
  88416. backUVs?: Vector4;
  88417. }): VertexData;
  88418. /**
  88419. * Creates the VertexData for a cylinder, cone or prism
  88420. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88421. * * height sets the height (y direction) of the cylinder, optional, default 2
  88422. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88423. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88424. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88425. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88426. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88427. * * 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
  88428. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88429. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88430. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88431. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88432. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88433. * * 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)
  88434. * * 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)
  88435. * @returns the VertexData of the cylinder, cone or prism
  88436. */
  88437. static CreateCylinder(options: {
  88438. height?: number;
  88439. diameterTop?: number;
  88440. diameterBottom?: number;
  88441. diameter?: number;
  88442. tessellation?: number;
  88443. subdivisions?: number;
  88444. arc?: number;
  88445. faceColors?: Color4[];
  88446. faceUV?: Vector4[];
  88447. hasRings?: boolean;
  88448. enclose?: boolean;
  88449. sideOrientation?: number;
  88450. frontUVs?: Vector4;
  88451. backUVs?: Vector4;
  88452. }): VertexData;
  88453. /**
  88454. * Creates the VertexData for a torus
  88455. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88456. * * diameter the diameter of the torus, optional default 1
  88457. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88458. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88459. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88460. * * 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)
  88461. * * 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)
  88462. * @returns the VertexData of the torus
  88463. */
  88464. static CreateTorus(options: {
  88465. diameter?: number;
  88466. thickness?: number;
  88467. tessellation?: number;
  88468. sideOrientation?: number;
  88469. frontUVs?: Vector4;
  88470. backUVs?: Vector4;
  88471. }): VertexData;
  88472. /**
  88473. * Creates the VertexData of the LineSystem
  88474. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88475. * - lines an array of lines, each line being an array of successive Vector3
  88476. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88477. * @returns the VertexData of the LineSystem
  88478. */
  88479. static CreateLineSystem(options: {
  88480. lines: Vector3[][];
  88481. colors?: Nullable<Color4[][]>;
  88482. }): VertexData;
  88483. /**
  88484. * Create the VertexData for a DashedLines
  88485. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88486. * - points an array successive Vector3
  88487. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88488. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88489. * - dashNb the intended total number of dashes, optional, default 200
  88490. * @returns the VertexData for the DashedLines
  88491. */
  88492. static CreateDashedLines(options: {
  88493. points: Vector3[];
  88494. dashSize?: number;
  88495. gapSize?: number;
  88496. dashNb?: number;
  88497. }): VertexData;
  88498. /**
  88499. * Creates the VertexData for a Ground
  88500. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88501. * - width the width (x direction) of the ground, optional, default 1
  88502. * - height the height (z direction) of the ground, optional, default 1
  88503. * - subdivisions the number of subdivisions per side, optional, default 1
  88504. * @returns the VertexData of the Ground
  88505. */
  88506. static CreateGround(options: {
  88507. width?: number;
  88508. height?: number;
  88509. subdivisions?: number;
  88510. subdivisionsX?: number;
  88511. subdivisionsY?: number;
  88512. }): VertexData;
  88513. /**
  88514. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88515. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88516. * * xmin the ground minimum X coordinate, optional, default -1
  88517. * * zmin the ground minimum Z coordinate, optional, default -1
  88518. * * xmax the ground maximum X coordinate, optional, default 1
  88519. * * zmax the ground maximum Z coordinate, optional, default 1
  88520. * * 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}
  88521. * * 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}
  88522. * @returns the VertexData of the TiledGround
  88523. */
  88524. static CreateTiledGround(options: {
  88525. xmin: number;
  88526. zmin: number;
  88527. xmax: number;
  88528. zmax: number;
  88529. subdivisions?: {
  88530. w: number;
  88531. h: number;
  88532. };
  88533. precision?: {
  88534. w: number;
  88535. h: number;
  88536. };
  88537. }): VertexData;
  88538. /**
  88539. * Creates the VertexData of the Ground designed from a heightmap
  88540. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88541. * * width the width (x direction) of the ground
  88542. * * height the height (z direction) of the ground
  88543. * * subdivisions the number of subdivisions per side
  88544. * * minHeight the minimum altitude on the ground, optional, default 0
  88545. * * maxHeight the maximum altitude on the ground, optional default 1
  88546. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88547. * * buffer the array holding the image color data
  88548. * * bufferWidth the width of image
  88549. * * bufferHeight the height of image
  88550. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88551. * @returns the VertexData of the Ground designed from a heightmap
  88552. */
  88553. static CreateGroundFromHeightMap(options: {
  88554. width: number;
  88555. height: number;
  88556. subdivisions: number;
  88557. minHeight: number;
  88558. maxHeight: number;
  88559. colorFilter: Color3;
  88560. buffer: Uint8Array;
  88561. bufferWidth: number;
  88562. bufferHeight: number;
  88563. alphaFilter: number;
  88564. }): VertexData;
  88565. /**
  88566. * Creates the VertexData for a Plane
  88567. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88568. * * size sets the width and height of the plane to the value of size, optional default 1
  88569. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88570. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88571. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88572. * * 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)
  88573. * * 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)
  88574. * @returns the VertexData of the box
  88575. */
  88576. static CreatePlane(options: {
  88577. size?: number;
  88578. width?: number;
  88579. height?: number;
  88580. sideOrientation?: number;
  88581. frontUVs?: Vector4;
  88582. backUVs?: Vector4;
  88583. }): VertexData;
  88584. /**
  88585. * Creates the VertexData of the Disc or regular Polygon
  88586. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88587. * * radius the radius of the disc, optional default 0.5
  88588. * * tessellation the number of polygon sides, optional, default 64
  88589. * * 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
  88590. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88591. * * 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)
  88592. * * 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)
  88593. * @returns the VertexData of the box
  88594. */
  88595. static CreateDisc(options: {
  88596. radius?: number;
  88597. tessellation?: number;
  88598. arc?: number;
  88599. sideOrientation?: number;
  88600. frontUVs?: Vector4;
  88601. backUVs?: Vector4;
  88602. }): VertexData;
  88603. /**
  88604. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88605. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88606. * @param polygon a mesh built from polygonTriangulation.build()
  88607. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88608. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88609. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88610. * @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)
  88611. * @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)
  88612. * @returns the VertexData of the Polygon
  88613. */
  88614. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88615. /**
  88616. * Creates the VertexData of the IcoSphere
  88617. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88618. * * radius the radius of the IcoSphere, optional default 1
  88619. * * radiusX allows stretching in the x direction, optional, default radius
  88620. * * radiusY allows stretching in the y direction, optional, default radius
  88621. * * radiusZ allows stretching in the z direction, optional, default radius
  88622. * * flat when true creates a flat shaded mesh, optional, default true
  88623. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88624. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88625. * * 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)
  88626. * * 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)
  88627. * @returns the VertexData of the IcoSphere
  88628. */
  88629. static CreateIcoSphere(options: {
  88630. radius?: number;
  88631. radiusX?: number;
  88632. radiusY?: number;
  88633. radiusZ?: number;
  88634. flat?: boolean;
  88635. subdivisions?: number;
  88636. sideOrientation?: number;
  88637. frontUVs?: Vector4;
  88638. backUVs?: Vector4;
  88639. }): VertexData;
  88640. /**
  88641. * Creates the VertexData for a Polyhedron
  88642. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88643. * * type provided types are:
  88644. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88645. * * 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)
  88646. * * size the size of the IcoSphere, optional default 1
  88647. * * sizeX allows stretching in the x direction, optional, default size
  88648. * * sizeY allows stretching in the y direction, optional, default size
  88649. * * sizeZ allows stretching in the z direction, optional, default size
  88650. * * 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
  88651. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88652. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88653. * * flat when true creates a flat shaded mesh, optional, default true
  88654. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88655. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88656. * * 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)
  88657. * * 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)
  88658. * @returns the VertexData of the Polyhedron
  88659. */
  88660. static CreatePolyhedron(options: {
  88661. type?: number;
  88662. size?: number;
  88663. sizeX?: number;
  88664. sizeY?: number;
  88665. sizeZ?: number;
  88666. custom?: any;
  88667. faceUV?: Vector4[];
  88668. faceColors?: Color4[];
  88669. flat?: boolean;
  88670. sideOrientation?: number;
  88671. frontUVs?: Vector4;
  88672. backUVs?: Vector4;
  88673. }): VertexData;
  88674. /**
  88675. * Creates the VertexData for a TorusKnot
  88676. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88677. * * radius the radius of the torus knot, optional, default 2
  88678. * * tube the thickness of the tube, optional, default 0.5
  88679. * * radialSegments the number of sides on each tube segments, optional, default 32
  88680. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88681. * * p the number of windings around the z axis, optional, default 2
  88682. * * q the number of windings around the x axis, optional, default 3
  88683. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88684. * * 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. * * 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 Torus Knot
  88687. */
  88688. static CreateTorusKnot(options: {
  88689. radius?: number;
  88690. tube?: number;
  88691. radialSegments?: number;
  88692. tubularSegments?: number;
  88693. p?: number;
  88694. q?: number;
  88695. sideOrientation?: number;
  88696. frontUVs?: Vector4;
  88697. backUVs?: Vector4;
  88698. }): VertexData;
  88699. /**
  88700. * Compute normals for given positions and indices
  88701. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88702. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88703. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88704. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88705. * * facetNormals : optional array of facet normals (vector3)
  88706. * * facetPositions : optional array of facet positions (vector3)
  88707. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88708. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88709. * * bInfo : optional bounding info, required for facetPartitioning computation
  88710. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88711. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88712. * * useRightHandedSystem: optional boolean to for right handed system computation
  88713. * * depthSort : optional boolean to enable the facet depth sort computation
  88714. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88715. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88716. */
  88717. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88718. facetNormals?: any;
  88719. facetPositions?: any;
  88720. facetPartitioning?: any;
  88721. ratio?: number;
  88722. bInfo?: any;
  88723. bbSize?: Vector3;
  88724. subDiv?: any;
  88725. useRightHandedSystem?: boolean;
  88726. depthSort?: boolean;
  88727. distanceTo?: Vector3;
  88728. depthSortedFacets?: any;
  88729. }): void;
  88730. /** @hidden */
  88731. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88732. /**
  88733. * Applies VertexData created from the imported parameters to the geometry
  88734. * @param parsedVertexData the parsed data from an imported file
  88735. * @param geometry the geometry to apply the VertexData to
  88736. */
  88737. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88738. }
  88739. }
  88740. declare module BABYLON {
  88741. /**
  88742. * Defines a target to use with MorphTargetManager
  88743. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88744. */
  88745. export class MorphTarget implements IAnimatable {
  88746. /** defines the name of the target */
  88747. name: string;
  88748. /**
  88749. * Gets or sets the list of animations
  88750. */
  88751. animations: Animation[];
  88752. private _scene;
  88753. private _positions;
  88754. private _normals;
  88755. private _tangents;
  88756. private _uvs;
  88757. private _influence;
  88758. /**
  88759. * Observable raised when the influence changes
  88760. */
  88761. onInfluenceChanged: Observable<boolean>;
  88762. /** @hidden */
  88763. _onDataLayoutChanged: Observable<void>;
  88764. /**
  88765. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88766. */
  88767. influence: number;
  88768. /**
  88769. * Gets or sets the id of the morph Target
  88770. */
  88771. id: string;
  88772. private _animationPropertiesOverride;
  88773. /**
  88774. * Gets or sets the animation properties override
  88775. */
  88776. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88777. /**
  88778. * Creates a new MorphTarget
  88779. * @param name defines the name of the target
  88780. * @param influence defines the influence to use
  88781. * @param scene defines the scene the morphtarget belongs to
  88782. */
  88783. constructor(
  88784. /** defines the name of the target */
  88785. name: string, influence?: number, scene?: Nullable<Scene>);
  88786. /**
  88787. * Gets a boolean defining if the target contains position data
  88788. */
  88789. readonly hasPositions: boolean;
  88790. /**
  88791. * Gets a boolean defining if the target contains normal data
  88792. */
  88793. readonly hasNormals: boolean;
  88794. /**
  88795. * Gets a boolean defining if the target contains tangent data
  88796. */
  88797. readonly hasTangents: boolean;
  88798. /**
  88799. * Gets a boolean defining if the target contains texture coordinates data
  88800. */
  88801. readonly hasUVs: boolean;
  88802. /**
  88803. * Affects position data to this target
  88804. * @param data defines the position data to use
  88805. */
  88806. setPositions(data: Nullable<FloatArray>): void;
  88807. /**
  88808. * Gets the position data stored in this target
  88809. * @returns a FloatArray containing the position data (or null if not present)
  88810. */
  88811. getPositions(): Nullable<FloatArray>;
  88812. /**
  88813. * Affects normal data to this target
  88814. * @param data defines the normal data to use
  88815. */
  88816. setNormals(data: Nullable<FloatArray>): void;
  88817. /**
  88818. * Gets the normal data stored in this target
  88819. * @returns a FloatArray containing the normal data (or null if not present)
  88820. */
  88821. getNormals(): Nullable<FloatArray>;
  88822. /**
  88823. * Affects tangent data to this target
  88824. * @param data defines the tangent data to use
  88825. */
  88826. setTangents(data: Nullable<FloatArray>): void;
  88827. /**
  88828. * Gets the tangent data stored in this target
  88829. * @returns a FloatArray containing the tangent data (or null if not present)
  88830. */
  88831. getTangents(): Nullable<FloatArray>;
  88832. /**
  88833. * Affects texture coordinates data to this target
  88834. * @param data defines the texture coordinates data to use
  88835. */
  88836. setUVs(data: Nullable<FloatArray>): void;
  88837. /**
  88838. * Gets the texture coordinates data stored in this target
  88839. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88840. */
  88841. getUVs(): Nullable<FloatArray>;
  88842. /**
  88843. * Serializes the current target into a Serialization object
  88844. * @returns the serialized object
  88845. */
  88846. serialize(): any;
  88847. /**
  88848. * Returns the string "MorphTarget"
  88849. * @returns "MorphTarget"
  88850. */
  88851. getClassName(): string;
  88852. /**
  88853. * Creates a new target from serialized data
  88854. * @param serializationObject defines the serialized data to use
  88855. * @returns a new MorphTarget
  88856. */
  88857. static Parse(serializationObject: any): MorphTarget;
  88858. /**
  88859. * Creates a MorphTarget from mesh data
  88860. * @param mesh defines the source mesh
  88861. * @param name defines the name to use for the new target
  88862. * @param influence defines the influence to attach to the target
  88863. * @returns a new MorphTarget
  88864. */
  88865. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88866. }
  88867. }
  88868. declare module BABYLON {
  88869. /**
  88870. * This class is used to deform meshes using morphing between different targets
  88871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88872. */
  88873. export class MorphTargetManager {
  88874. private _targets;
  88875. private _targetInfluenceChangedObservers;
  88876. private _targetDataLayoutChangedObservers;
  88877. private _activeTargets;
  88878. private _scene;
  88879. private _influences;
  88880. private _supportsNormals;
  88881. private _supportsTangents;
  88882. private _supportsUVs;
  88883. private _vertexCount;
  88884. private _uniqueId;
  88885. private _tempInfluences;
  88886. /**
  88887. * Gets or sets a boolean indicating if normals must be morphed
  88888. */
  88889. enableNormalMorphing: boolean;
  88890. /**
  88891. * Gets or sets a boolean indicating if tangents must be morphed
  88892. */
  88893. enableTangentMorphing: boolean;
  88894. /**
  88895. * Gets or sets a boolean indicating if UV must be morphed
  88896. */
  88897. enableUVMorphing: boolean;
  88898. /**
  88899. * Creates a new MorphTargetManager
  88900. * @param scene defines the current scene
  88901. */
  88902. constructor(scene?: Nullable<Scene>);
  88903. /**
  88904. * Gets the unique ID of this manager
  88905. */
  88906. readonly uniqueId: number;
  88907. /**
  88908. * Gets the number of vertices handled by this manager
  88909. */
  88910. readonly vertexCount: number;
  88911. /**
  88912. * Gets a boolean indicating if this manager supports morphing of normals
  88913. */
  88914. readonly supportsNormals: boolean;
  88915. /**
  88916. * Gets a boolean indicating if this manager supports morphing of tangents
  88917. */
  88918. readonly supportsTangents: boolean;
  88919. /**
  88920. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88921. */
  88922. readonly supportsUVs: boolean;
  88923. /**
  88924. * Gets the number of targets stored in this manager
  88925. */
  88926. readonly numTargets: number;
  88927. /**
  88928. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88929. */
  88930. readonly numInfluencers: number;
  88931. /**
  88932. * Gets the list of influences (one per target)
  88933. */
  88934. readonly influences: Float32Array;
  88935. /**
  88936. * Gets the active target at specified index. An active target is a target with an influence > 0
  88937. * @param index defines the index to check
  88938. * @returns the requested target
  88939. */
  88940. getActiveTarget(index: number): MorphTarget;
  88941. /**
  88942. * Gets the target at specified index
  88943. * @param index defines the index to check
  88944. * @returns the requested target
  88945. */
  88946. getTarget(index: number): MorphTarget;
  88947. /**
  88948. * Add a new target to this manager
  88949. * @param target defines the target to add
  88950. */
  88951. addTarget(target: MorphTarget): void;
  88952. /**
  88953. * Removes a target from the manager
  88954. * @param target defines the target to remove
  88955. */
  88956. removeTarget(target: MorphTarget): void;
  88957. /**
  88958. * Serializes the current manager into a Serialization object
  88959. * @returns the serialized object
  88960. */
  88961. serialize(): any;
  88962. private _syncActiveTargets;
  88963. /**
  88964. * Syncrhonize the targets with all the meshes using this morph target manager
  88965. */
  88966. synchronize(): void;
  88967. /**
  88968. * Creates a new MorphTargetManager from serialized data
  88969. * @param serializationObject defines the serialized data
  88970. * @param scene defines the hosting scene
  88971. * @returns the new MorphTargetManager
  88972. */
  88973. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88974. }
  88975. }
  88976. declare module BABYLON {
  88977. /**
  88978. * Class used to represent a specific level of detail of a mesh
  88979. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  88980. */
  88981. export class MeshLODLevel {
  88982. /** Defines the distance where this level should start being displayed */
  88983. distance: number;
  88984. /** Defines the mesh to use to render this level */
  88985. mesh: Nullable<Mesh>;
  88986. /**
  88987. * Creates a new LOD level
  88988. * @param distance defines the distance where this level should star being displayed
  88989. * @param mesh defines the mesh to use to render this level
  88990. */
  88991. constructor(
  88992. /** Defines the distance where this level should start being displayed */
  88993. distance: number,
  88994. /** Defines the mesh to use to render this level */
  88995. mesh: Nullable<Mesh>);
  88996. }
  88997. }
  88998. declare module BABYLON {
  88999. /**
  89000. * Mesh representing the gorund
  89001. */
  89002. export class GroundMesh extends Mesh {
  89003. /** If octree should be generated */
  89004. generateOctree: boolean;
  89005. private _heightQuads;
  89006. /** @hidden */
  89007. _subdivisionsX: number;
  89008. /** @hidden */
  89009. _subdivisionsY: number;
  89010. /** @hidden */
  89011. _width: number;
  89012. /** @hidden */
  89013. _height: number;
  89014. /** @hidden */
  89015. _minX: number;
  89016. /** @hidden */
  89017. _maxX: number;
  89018. /** @hidden */
  89019. _minZ: number;
  89020. /** @hidden */
  89021. _maxZ: number;
  89022. constructor(name: string, scene: Scene);
  89023. /**
  89024. * "GroundMesh"
  89025. * @returns "GroundMesh"
  89026. */
  89027. getClassName(): string;
  89028. /**
  89029. * The minimum of x and y subdivisions
  89030. */
  89031. readonly subdivisions: number;
  89032. /**
  89033. * X subdivisions
  89034. */
  89035. readonly subdivisionsX: number;
  89036. /**
  89037. * Y subdivisions
  89038. */
  89039. readonly subdivisionsY: number;
  89040. /**
  89041. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89042. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89043. * @param chunksCount the number of subdivisions for x and y
  89044. * @param octreeBlocksSize (Default: 32)
  89045. */
  89046. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89047. /**
  89048. * Returns a height (y) value in the Worl system :
  89049. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89050. * @param x x coordinate
  89051. * @param z z coordinate
  89052. * @returns the ground y position if (x, z) are outside the ground surface.
  89053. */
  89054. getHeightAtCoordinates(x: number, z: number): number;
  89055. /**
  89056. * Returns a normalized vector (Vector3) orthogonal to the ground
  89057. * at the ground coordinates (x, z) expressed in the World system.
  89058. * @param x x coordinate
  89059. * @param z z coordinate
  89060. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89061. */
  89062. getNormalAtCoordinates(x: number, z: number): Vector3;
  89063. /**
  89064. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89065. * at the ground coordinates (x, z) expressed in the World system.
  89066. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89067. * @param x x coordinate
  89068. * @param z z coordinate
  89069. * @param ref vector to store the result
  89070. * @returns the GroundMesh.
  89071. */
  89072. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89073. /**
  89074. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89075. * if the ground has been updated.
  89076. * This can be used in the render loop.
  89077. * @returns the GroundMesh.
  89078. */
  89079. updateCoordinateHeights(): GroundMesh;
  89080. private _getFacetAt;
  89081. private _initHeightQuads;
  89082. private _computeHeightQuads;
  89083. /**
  89084. * Serializes this ground mesh
  89085. * @param serializationObject object to write serialization to
  89086. */
  89087. serialize(serializationObject: any): void;
  89088. /**
  89089. * Parses a serialized ground mesh
  89090. * @param parsedMesh the serialized mesh
  89091. * @param scene the scene to create the ground mesh in
  89092. * @returns the created ground mesh
  89093. */
  89094. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89095. }
  89096. }
  89097. declare module BABYLON {
  89098. /**
  89099. * Interface for Physics-Joint data
  89100. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89101. */
  89102. export interface PhysicsJointData {
  89103. /**
  89104. * The main pivot of the joint
  89105. */
  89106. mainPivot?: Vector3;
  89107. /**
  89108. * The connected pivot of the joint
  89109. */
  89110. connectedPivot?: Vector3;
  89111. /**
  89112. * The main axis of the joint
  89113. */
  89114. mainAxis?: Vector3;
  89115. /**
  89116. * The connected axis of the joint
  89117. */
  89118. connectedAxis?: Vector3;
  89119. /**
  89120. * The collision of the joint
  89121. */
  89122. collision?: boolean;
  89123. /**
  89124. * Native Oimo/Cannon/Energy data
  89125. */
  89126. nativeParams?: any;
  89127. }
  89128. /**
  89129. * This is a holder class for the physics joint created by the physics plugin
  89130. * It holds a set of functions to control the underlying joint
  89131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89132. */
  89133. export class PhysicsJoint {
  89134. /**
  89135. * The type of the physics joint
  89136. */
  89137. type: number;
  89138. /**
  89139. * The data for the physics joint
  89140. */
  89141. jointData: PhysicsJointData;
  89142. private _physicsJoint;
  89143. protected _physicsPlugin: IPhysicsEnginePlugin;
  89144. /**
  89145. * Initializes the physics joint
  89146. * @param type The type of the physics joint
  89147. * @param jointData The data for the physics joint
  89148. */
  89149. constructor(
  89150. /**
  89151. * The type of the physics joint
  89152. */
  89153. type: number,
  89154. /**
  89155. * The data for the physics joint
  89156. */
  89157. jointData: PhysicsJointData);
  89158. /**
  89159. * Gets the physics joint
  89160. */
  89161. /**
  89162. * Sets the physics joint
  89163. */
  89164. physicsJoint: any;
  89165. /**
  89166. * Sets the physics plugin
  89167. */
  89168. physicsPlugin: IPhysicsEnginePlugin;
  89169. /**
  89170. * Execute a function that is physics-plugin specific.
  89171. * @param {Function} func the function that will be executed.
  89172. * It accepts two parameters: the physics world and the physics joint
  89173. */
  89174. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89175. /**
  89176. * Distance-Joint type
  89177. */
  89178. static DistanceJoint: number;
  89179. /**
  89180. * Hinge-Joint type
  89181. */
  89182. static HingeJoint: number;
  89183. /**
  89184. * Ball-and-Socket joint type
  89185. */
  89186. static BallAndSocketJoint: number;
  89187. /**
  89188. * Wheel-Joint type
  89189. */
  89190. static WheelJoint: number;
  89191. /**
  89192. * Slider-Joint type
  89193. */
  89194. static SliderJoint: number;
  89195. /**
  89196. * Prismatic-Joint type
  89197. */
  89198. static PrismaticJoint: number;
  89199. /**
  89200. * Universal-Joint type
  89201. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89202. */
  89203. static UniversalJoint: number;
  89204. /**
  89205. * Hinge-Joint 2 type
  89206. */
  89207. static Hinge2Joint: number;
  89208. /**
  89209. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89210. */
  89211. static PointToPointJoint: number;
  89212. /**
  89213. * Spring-Joint type
  89214. */
  89215. static SpringJoint: number;
  89216. /**
  89217. * Lock-Joint type
  89218. */
  89219. static LockJoint: number;
  89220. }
  89221. /**
  89222. * A class representing a physics distance joint
  89223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89224. */
  89225. export class DistanceJoint extends PhysicsJoint {
  89226. /**
  89227. *
  89228. * @param jointData The data for the Distance-Joint
  89229. */
  89230. constructor(jointData: DistanceJointData);
  89231. /**
  89232. * Update the predefined distance.
  89233. * @param maxDistance The maximum preferred distance
  89234. * @param minDistance The minimum preferred distance
  89235. */
  89236. updateDistance(maxDistance: number, minDistance?: number): void;
  89237. }
  89238. /**
  89239. * Represents a Motor-Enabled Joint
  89240. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89241. */
  89242. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89243. /**
  89244. * Initializes the Motor-Enabled Joint
  89245. * @param type The type of the joint
  89246. * @param jointData The physica joint data for the joint
  89247. */
  89248. constructor(type: number, jointData: PhysicsJointData);
  89249. /**
  89250. * Set the motor values.
  89251. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89252. * @param force the force to apply
  89253. * @param maxForce max force for this motor.
  89254. */
  89255. setMotor(force?: number, maxForce?: number): void;
  89256. /**
  89257. * Set the motor's limits.
  89258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89259. * @param upperLimit The upper limit of the motor
  89260. * @param lowerLimit The lower limit of the motor
  89261. */
  89262. setLimit(upperLimit: number, lowerLimit?: number): void;
  89263. }
  89264. /**
  89265. * This class represents a single physics Hinge-Joint
  89266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89267. */
  89268. export class HingeJoint extends MotorEnabledJoint {
  89269. /**
  89270. * Initializes the Hinge-Joint
  89271. * @param jointData The joint data for the Hinge-Joint
  89272. */
  89273. constructor(jointData: PhysicsJointData);
  89274. /**
  89275. * Set the motor values.
  89276. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89277. * @param {number} force the force to apply
  89278. * @param {number} maxForce max force for this motor.
  89279. */
  89280. setMotor(force?: number, maxForce?: number): void;
  89281. /**
  89282. * Set the motor's limits.
  89283. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89284. * @param upperLimit The upper limit of the motor
  89285. * @param lowerLimit The lower limit of the motor
  89286. */
  89287. setLimit(upperLimit: number, lowerLimit?: number): void;
  89288. }
  89289. /**
  89290. * This class represents a dual hinge physics joint (same as wheel joint)
  89291. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89292. */
  89293. export class Hinge2Joint extends MotorEnabledJoint {
  89294. /**
  89295. * Initializes the Hinge2-Joint
  89296. * @param jointData The joint data for the Hinge2-Joint
  89297. */
  89298. constructor(jointData: PhysicsJointData);
  89299. /**
  89300. * Set the motor values.
  89301. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89302. * @param {number} targetSpeed the speed the motor is to reach
  89303. * @param {number} maxForce max force for this motor.
  89304. * @param {motorIndex} the motor's index, 0 or 1.
  89305. */
  89306. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89307. /**
  89308. * Set the motor limits.
  89309. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89310. * @param {number} upperLimit the upper limit
  89311. * @param {number} lowerLimit lower limit
  89312. * @param {motorIndex} the motor's index, 0 or 1.
  89313. */
  89314. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89315. }
  89316. /**
  89317. * Interface for a motor enabled joint
  89318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89319. */
  89320. export interface IMotorEnabledJoint {
  89321. /**
  89322. * Physics joint
  89323. */
  89324. physicsJoint: any;
  89325. /**
  89326. * Sets the motor of the motor-enabled joint
  89327. * @param force The force of the motor
  89328. * @param maxForce The maximum force of the motor
  89329. * @param motorIndex The index of the motor
  89330. */
  89331. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89332. /**
  89333. * Sets the limit of the motor
  89334. * @param upperLimit The upper limit of the motor
  89335. * @param lowerLimit The lower limit of the motor
  89336. * @param motorIndex The index of the motor
  89337. */
  89338. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89339. }
  89340. /**
  89341. * Joint data for a Distance-Joint
  89342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89343. */
  89344. export interface DistanceJointData extends PhysicsJointData {
  89345. /**
  89346. * Max distance the 2 joint objects can be apart
  89347. */
  89348. maxDistance: number;
  89349. }
  89350. /**
  89351. * Joint data from a spring joint
  89352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89353. */
  89354. export interface SpringJointData extends PhysicsJointData {
  89355. /**
  89356. * Length of the spring
  89357. */
  89358. length: number;
  89359. /**
  89360. * Stiffness of the spring
  89361. */
  89362. stiffness: number;
  89363. /**
  89364. * Damping of the spring
  89365. */
  89366. damping: number;
  89367. /** this callback will be called when applying the force to the impostors. */
  89368. forceApplicationCallback: () => void;
  89369. }
  89370. }
  89371. declare module BABYLON {
  89372. /**
  89373. * Holds the data for the raycast result
  89374. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89375. */
  89376. export class PhysicsRaycastResult {
  89377. private _hasHit;
  89378. private _hitDistance;
  89379. private _hitNormalWorld;
  89380. private _hitPointWorld;
  89381. private _rayFromWorld;
  89382. private _rayToWorld;
  89383. /**
  89384. * Gets if there was a hit
  89385. */
  89386. readonly hasHit: boolean;
  89387. /**
  89388. * Gets the distance from the hit
  89389. */
  89390. readonly hitDistance: number;
  89391. /**
  89392. * Gets the hit normal/direction in the world
  89393. */
  89394. readonly hitNormalWorld: Vector3;
  89395. /**
  89396. * Gets the hit point in the world
  89397. */
  89398. readonly hitPointWorld: Vector3;
  89399. /**
  89400. * Gets the ray "start point" of the ray in the world
  89401. */
  89402. readonly rayFromWorld: Vector3;
  89403. /**
  89404. * Gets the ray "end point" of the ray in the world
  89405. */
  89406. readonly rayToWorld: Vector3;
  89407. /**
  89408. * Sets the hit data (normal & point in world space)
  89409. * @param hitNormalWorld defines the normal in world space
  89410. * @param hitPointWorld defines the point in world space
  89411. */
  89412. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89413. /**
  89414. * Sets the distance from the start point to the hit point
  89415. * @param distance
  89416. */
  89417. setHitDistance(distance: number): void;
  89418. /**
  89419. * Calculates the distance manually
  89420. */
  89421. calculateHitDistance(): void;
  89422. /**
  89423. * Resets all the values to default
  89424. * @param from The from point on world space
  89425. * @param to The to point on world space
  89426. */
  89427. reset(from?: Vector3, to?: Vector3): void;
  89428. }
  89429. /**
  89430. * Interface for the size containing width and height
  89431. */
  89432. interface IXYZ {
  89433. /**
  89434. * X
  89435. */
  89436. x: number;
  89437. /**
  89438. * Y
  89439. */
  89440. y: number;
  89441. /**
  89442. * Z
  89443. */
  89444. z: number;
  89445. }
  89446. }
  89447. declare module BABYLON {
  89448. /**
  89449. * Interface used to describe a physics joint
  89450. */
  89451. export interface PhysicsImpostorJoint {
  89452. /** Defines the main impostor to which the joint is linked */
  89453. mainImpostor: PhysicsImpostor;
  89454. /** Defines the impostor that is connected to the main impostor using this joint */
  89455. connectedImpostor: PhysicsImpostor;
  89456. /** Defines the joint itself */
  89457. joint: PhysicsJoint;
  89458. }
  89459. /** @hidden */
  89460. export interface IPhysicsEnginePlugin {
  89461. world: any;
  89462. name: string;
  89463. setGravity(gravity: Vector3): void;
  89464. setTimeStep(timeStep: number): void;
  89465. getTimeStep(): number;
  89466. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89467. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89468. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89469. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89470. removePhysicsBody(impostor: PhysicsImpostor): void;
  89471. generateJoint(joint: PhysicsImpostorJoint): void;
  89472. removeJoint(joint: PhysicsImpostorJoint): void;
  89473. isSupported(): boolean;
  89474. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89475. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89476. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89477. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89478. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89479. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89480. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89481. getBodyMass(impostor: PhysicsImpostor): number;
  89482. getBodyFriction(impostor: PhysicsImpostor): number;
  89483. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89484. getBodyRestitution(impostor: PhysicsImpostor): number;
  89485. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89486. getBodyPressure?(impostor: PhysicsImpostor): number;
  89487. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89488. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89489. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89490. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89491. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89492. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89493. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89494. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89495. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89496. sleepBody(impostor: PhysicsImpostor): void;
  89497. wakeUpBody(impostor: PhysicsImpostor): void;
  89498. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89499. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89500. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89501. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89502. getRadius(impostor: PhysicsImpostor): number;
  89503. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89504. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89505. dispose(): void;
  89506. }
  89507. /**
  89508. * Interface used to define a physics engine
  89509. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89510. */
  89511. export interface IPhysicsEngine {
  89512. /**
  89513. * Gets the gravity vector used by the simulation
  89514. */
  89515. gravity: Vector3;
  89516. /**
  89517. * Sets the gravity vector used by the simulation
  89518. * @param gravity defines the gravity vector to use
  89519. */
  89520. setGravity(gravity: Vector3): void;
  89521. /**
  89522. * Set the time step of the physics engine.
  89523. * Default is 1/60.
  89524. * To slow it down, enter 1/600 for example.
  89525. * To speed it up, 1/30
  89526. * @param newTimeStep the new timestep to apply to this world.
  89527. */
  89528. setTimeStep(newTimeStep: number): void;
  89529. /**
  89530. * Get the time step of the physics engine.
  89531. * @returns the current time step
  89532. */
  89533. getTimeStep(): number;
  89534. /**
  89535. * Release all resources
  89536. */
  89537. dispose(): void;
  89538. /**
  89539. * Gets the name of the current physics plugin
  89540. * @returns the name of the plugin
  89541. */
  89542. getPhysicsPluginName(): string;
  89543. /**
  89544. * Adding a new impostor for the impostor tracking.
  89545. * This will be done by the impostor itself.
  89546. * @param impostor the impostor to add
  89547. */
  89548. addImpostor(impostor: PhysicsImpostor): void;
  89549. /**
  89550. * Remove an impostor from the engine.
  89551. * This impostor and its mesh will not longer be updated by the physics engine.
  89552. * @param impostor the impostor to remove
  89553. */
  89554. removeImpostor(impostor: PhysicsImpostor): void;
  89555. /**
  89556. * Add a joint to the physics engine
  89557. * @param mainImpostor defines the main impostor to which the joint is added.
  89558. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89559. * @param joint defines the joint that will connect both impostors.
  89560. */
  89561. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89562. /**
  89563. * Removes a joint from the simulation
  89564. * @param mainImpostor defines the impostor used with the joint
  89565. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89566. * @param joint defines the joint to remove
  89567. */
  89568. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89569. /**
  89570. * Gets the current plugin used to run the simulation
  89571. * @returns current plugin
  89572. */
  89573. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89574. /**
  89575. * Gets the list of physic impostors
  89576. * @returns an array of PhysicsImpostor
  89577. */
  89578. getImpostors(): Array<PhysicsImpostor>;
  89579. /**
  89580. * Gets the impostor for a physics enabled object
  89581. * @param object defines the object impersonated by the impostor
  89582. * @returns the PhysicsImpostor or null if not found
  89583. */
  89584. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89585. /**
  89586. * Gets the impostor for a physics body object
  89587. * @param body defines physics body used by the impostor
  89588. * @returns the PhysicsImpostor or null if not found
  89589. */
  89590. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89591. /**
  89592. * Does a raycast in the physics world
  89593. * @param from when should the ray start?
  89594. * @param to when should the ray end?
  89595. * @returns PhysicsRaycastResult
  89596. */
  89597. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89598. /**
  89599. * Called by the scene. No need to call it.
  89600. * @param delta defines the timespam between frames
  89601. */
  89602. _step(delta: number): void;
  89603. }
  89604. }
  89605. declare module BABYLON {
  89606. /**
  89607. * The interface for the physics imposter parameters
  89608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89609. */
  89610. export interface PhysicsImpostorParameters {
  89611. /**
  89612. * The mass of the physics imposter
  89613. */
  89614. mass: number;
  89615. /**
  89616. * The friction of the physics imposter
  89617. */
  89618. friction?: number;
  89619. /**
  89620. * The coefficient of restitution of the physics imposter
  89621. */
  89622. restitution?: number;
  89623. /**
  89624. * The native options of the physics imposter
  89625. */
  89626. nativeOptions?: any;
  89627. /**
  89628. * Specifies if the parent should be ignored
  89629. */
  89630. ignoreParent?: boolean;
  89631. /**
  89632. * Specifies if bi-directional transformations should be disabled
  89633. */
  89634. disableBidirectionalTransformation?: boolean;
  89635. /**
  89636. * The pressure inside the physics imposter, soft object only
  89637. */
  89638. pressure?: number;
  89639. /**
  89640. * The stiffness the physics imposter, soft object only
  89641. */
  89642. stiffness?: number;
  89643. /**
  89644. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89645. */
  89646. velocityIterations?: number;
  89647. /**
  89648. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89649. */
  89650. positionIterations?: number;
  89651. /**
  89652. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89653. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89654. * Add to fix multiple points
  89655. */
  89656. fixedPoints?: number;
  89657. /**
  89658. * The collision margin around a soft object
  89659. */
  89660. margin?: number;
  89661. /**
  89662. * The collision margin around a soft object
  89663. */
  89664. damping?: number;
  89665. /**
  89666. * The path for a rope based on an extrusion
  89667. */
  89668. path?: any;
  89669. /**
  89670. * The shape of an extrusion used for a rope based on an extrusion
  89671. */
  89672. shape?: any;
  89673. }
  89674. /**
  89675. * Interface for a physics-enabled object
  89676. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89677. */
  89678. export interface IPhysicsEnabledObject {
  89679. /**
  89680. * The position of the physics-enabled object
  89681. */
  89682. position: Vector3;
  89683. /**
  89684. * The rotation of the physics-enabled object
  89685. */
  89686. rotationQuaternion: Nullable<Quaternion>;
  89687. /**
  89688. * The scale of the physics-enabled object
  89689. */
  89690. scaling: Vector3;
  89691. /**
  89692. * The rotation of the physics-enabled object
  89693. */
  89694. rotation?: Vector3;
  89695. /**
  89696. * The parent of the physics-enabled object
  89697. */
  89698. parent?: any;
  89699. /**
  89700. * The bounding info of the physics-enabled object
  89701. * @returns The bounding info of the physics-enabled object
  89702. */
  89703. getBoundingInfo(): BoundingInfo;
  89704. /**
  89705. * Computes the world matrix
  89706. * @param force Specifies if the world matrix should be computed by force
  89707. * @returns A world matrix
  89708. */
  89709. computeWorldMatrix(force: boolean): Matrix;
  89710. /**
  89711. * Gets the world matrix
  89712. * @returns A world matrix
  89713. */
  89714. getWorldMatrix?(): Matrix;
  89715. /**
  89716. * Gets the child meshes
  89717. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89718. * @returns An array of abstract meshes
  89719. */
  89720. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89721. /**
  89722. * Gets the vertex data
  89723. * @param kind The type of vertex data
  89724. * @returns A nullable array of numbers, or a float32 array
  89725. */
  89726. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89727. /**
  89728. * Gets the indices from the mesh
  89729. * @returns A nullable array of index arrays
  89730. */
  89731. getIndices?(): Nullable<IndicesArray>;
  89732. /**
  89733. * Gets the scene from the mesh
  89734. * @returns the indices array or null
  89735. */
  89736. getScene?(): Scene;
  89737. /**
  89738. * Gets the absolute position from the mesh
  89739. * @returns the absolute position
  89740. */
  89741. getAbsolutePosition(): Vector3;
  89742. /**
  89743. * Gets the absolute pivot point from the mesh
  89744. * @returns the absolute pivot point
  89745. */
  89746. getAbsolutePivotPoint(): Vector3;
  89747. /**
  89748. * Rotates the mesh
  89749. * @param axis The axis of rotation
  89750. * @param amount The amount of rotation
  89751. * @param space The space of the rotation
  89752. * @returns The rotation transform node
  89753. */
  89754. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89755. /**
  89756. * Translates the mesh
  89757. * @param axis The axis of translation
  89758. * @param distance The distance of translation
  89759. * @param space The space of the translation
  89760. * @returns The transform node
  89761. */
  89762. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89763. /**
  89764. * Sets the absolute position of the mesh
  89765. * @param absolutePosition The absolute position of the mesh
  89766. * @returns The transform node
  89767. */
  89768. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89769. /**
  89770. * Gets the class name of the mesh
  89771. * @returns The class name
  89772. */
  89773. getClassName(): string;
  89774. }
  89775. /**
  89776. * Represents a physics imposter
  89777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89778. */
  89779. export class PhysicsImpostor {
  89780. /**
  89781. * The physics-enabled object used as the physics imposter
  89782. */
  89783. object: IPhysicsEnabledObject;
  89784. /**
  89785. * The type of the physics imposter
  89786. */
  89787. type: number;
  89788. private _options;
  89789. private _scene?;
  89790. /**
  89791. * The default object size of the imposter
  89792. */
  89793. static DEFAULT_OBJECT_SIZE: Vector3;
  89794. /**
  89795. * The identity quaternion of the imposter
  89796. */
  89797. static IDENTITY_QUATERNION: Quaternion;
  89798. /** @hidden */
  89799. _pluginData: any;
  89800. private _physicsEngine;
  89801. private _physicsBody;
  89802. private _bodyUpdateRequired;
  89803. private _onBeforePhysicsStepCallbacks;
  89804. private _onAfterPhysicsStepCallbacks;
  89805. /** @hidden */
  89806. _onPhysicsCollideCallbacks: Array<{
  89807. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89808. otherImpostors: Array<PhysicsImpostor>;
  89809. }>;
  89810. private _deltaPosition;
  89811. private _deltaRotation;
  89812. private _deltaRotationConjugated;
  89813. /** @hidden */
  89814. _isFromLine: boolean;
  89815. private _parent;
  89816. private _isDisposed;
  89817. private static _tmpVecs;
  89818. private static _tmpQuat;
  89819. /**
  89820. * Specifies if the physics imposter is disposed
  89821. */
  89822. readonly isDisposed: boolean;
  89823. /**
  89824. * Gets the mass of the physics imposter
  89825. */
  89826. mass: number;
  89827. /**
  89828. * Gets the coefficient of friction
  89829. */
  89830. /**
  89831. * Sets the coefficient of friction
  89832. */
  89833. friction: number;
  89834. /**
  89835. * Gets the coefficient of restitution
  89836. */
  89837. /**
  89838. * Sets the coefficient of restitution
  89839. */
  89840. restitution: number;
  89841. /**
  89842. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89843. */
  89844. /**
  89845. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89846. */
  89847. pressure: number;
  89848. /**
  89849. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89850. */
  89851. /**
  89852. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89853. */
  89854. stiffness: number;
  89855. /**
  89856. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89857. */
  89858. /**
  89859. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89860. */
  89861. velocityIterations: number;
  89862. /**
  89863. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89864. */
  89865. /**
  89866. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89867. */
  89868. positionIterations: number;
  89869. /**
  89870. * The unique id of the physics imposter
  89871. * set by the physics engine when adding this impostor to the array
  89872. */
  89873. uniqueId: number;
  89874. /**
  89875. * @hidden
  89876. */
  89877. soft: boolean;
  89878. /**
  89879. * @hidden
  89880. */
  89881. segments: number;
  89882. private _joints;
  89883. /**
  89884. * Initializes the physics imposter
  89885. * @param object The physics-enabled object used as the physics imposter
  89886. * @param type The type of the physics imposter
  89887. * @param _options The options for the physics imposter
  89888. * @param _scene The Babylon scene
  89889. */
  89890. constructor(
  89891. /**
  89892. * The physics-enabled object used as the physics imposter
  89893. */
  89894. object: IPhysicsEnabledObject,
  89895. /**
  89896. * The type of the physics imposter
  89897. */
  89898. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89899. /**
  89900. * This function will completly initialize this impostor.
  89901. * It will create a new body - but only if this mesh has no parent.
  89902. * If it has, this impostor will not be used other than to define the impostor
  89903. * of the child mesh.
  89904. * @hidden
  89905. */
  89906. _init(): void;
  89907. private _getPhysicsParent;
  89908. /**
  89909. * Should a new body be generated.
  89910. * @returns boolean specifying if body initialization is required
  89911. */
  89912. isBodyInitRequired(): boolean;
  89913. /**
  89914. * Sets the updated scaling
  89915. * @param updated Specifies if the scaling is updated
  89916. */
  89917. setScalingUpdated(): void;
  89918. /**
  89919. * Force a regeneration of this or the parent's impostor's body.
  89920. * Use under cautious - This will remove all joints already implemented.
  89921. */
  89922. forceUpdate(): void;
  89923. /**
  89924. * Gets the body that holds this impostor. Either its own, or its parent.
  89925. */
  89926. /**
  89927. * Set the physics body. Used mainly by the physics engine/plugin
  89928. */
  89929. physicsBody: any;
  89930. /**
  89931. * Get the parent of the physics imposter
  89932. * @returns Physics imposter or null
  89933. */
  89934. /**
  89935. * Sets the parent of the physics imposter
  89936. */
  89937. parent: Nullable<PhysicsImpostor>;
  89938. /**
  89939. * Resets the update flags
  89940. */
  89941. resetUpdateFlags(): void;
  89942. /**
  89943. * Gets the object extend size
  89944. * @returns the object extend size
  89945. */
  89946. getObjectExtendSize(): Vector3;
  89947. /**
  89948. * Gets the object center
  89949. * @returns The object center
  89950. */
  89951. getObjectCenter(): Vector3;
  89952. /**
  89953. * Get a specific parametes from the options parameter
  89954. * @param paramName The object parameter name
  89955. * @returns The object parameter
  89956. */
  89957. getParam(paramName: string): any;
  89958. /**
  89959. * Sets a specific parameter in the options given to the physics plugin
  89960. * @param paramName The parameter name
  89961. * @param value The value of the parameter
  89962. */
  89963. setParam(paramName: string, value: number): void;
  89964. /**
  89965. * Specifically change the body's mass option. Won't recreate the physics body object
  89966. * @param mass The mass of the physics imposter
  89967. */
  89968. setMass(mass: number): void;
  89969. /**
  89970. * Gets the linear velocity
  89971. * @returns linear velocity or null
  89972. */
  89973. getLinearVelocity(): Nullable<Vector3>;
  89974. /**
  89975. * Sets the linear velocity
  89976. * @param velocity linear velocity or null
  89977. */
  89978. setLinearVelocity(velocity: Nullable<Vector3>): void;
  89979. /**
  89980. * Gets the angular velocity
  89981. * @returns angular velocity or null
  89982. */
  89983. getAngularVelocity(): Nullable<Vector3>;
  89984. /**
  89985. * Sets the angular velocity
  89986. * @param velocity The velocity or null
  89987. */
  89988. setAngularVelocity(velocity: Nullable<Vector3>): void;
  89989. /**
  89990. * Execute a function with the physics plugin native code
  89991. * Provide a function the will have two variables - the world object and the physics body object
  89992. * @param func The function to execute with the physics plugin native code
  89993. */
  89994. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  89995. /**
  89996. * Register a function that will be executed before the physics world is stepping forward
  89997. * @param func The function to execute before the physics world is stepped forward
  89998. */
  89999. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90000. /**
  90001. * Unregister a function that will be executed before the physics world is stepping forward
  90002. * @param func The function to execute before the physics world is stepped forward
  90003. */
  90004. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90005. /**
  90006. * Register a function that will be executed after the physics step
  90007. * @param func The function to execute after physics step
  90008. */
  90009. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90010. /**
  90011. * Unregisters a function that will be executed after the physics step
  90012. * @param func The function to execute after physics step
  90013. */
  90014. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90015. /**
  90016. * register a function that will be executed when this impostor collides against a different body
  90017. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90018. * @param func Callback that is executed on collision
  90019. */
  90020. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90021. /**
  90022. * Unregisters the physics imposter on contact
  90023. * @param collideAgainst The physics object to collide against
  90024. * @param func Callback to execute on collision
  90025. */
  90026. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90027. private _tmpQuat;
  90028. private _tmpQuat2;
  90029. /**
  90030. * Get the parent rotation
  90031. * @returns The parent rotation
  90032. */
  90033. getParentsRotation(): Quaternion;
  90034. /**
  90035. * this function is executed by the physics engine.
  90036. */
  90037. beforeStep: () => void;
  90038. /**
  90039. * this function is executed by the physics engine
  90040. */
  90041. afterStep: () => void;
  90042. /**
  90043. * Legacy collision detection event support
  90044. */
  90045. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90046. /**
  90047. * event and body object due to cannon's event-based architecture.
  90048. */
  90049. onCollide: (e: {
  90050. body: any;
  90051. }) => void;
  90052. /**
  90053. * Apply a force
  90054. * @param force The force to apply
  90055. * @param contactPoint The contact point for the force
  90056. * @returns The physics imposter
  90057. */
  90058. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90059. /**
  90060. * Apply an impulse
  90061. * @param force The impulse force
  90062. * @param contactPoint The contact point for the impulse force
  90063. * @returns The physics imposter
  90064. */
  90065. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90066. /**
  90067. * A help function to create a joint
  90068. * @param otherImpostor A physics imposter used to create a joint
  90069. * @param jointType The type of joint
  90070. * @param jointData The data for the joint
  90071. * @returns The physics imposter
  90072. */
  90073. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90074. /**
  90075. * Add a joint to this impostor with a different impostor
  90076. * @param otherImpostor A physics imposter used to add a joint
  90077. * @param joint The joint to add
  90078. * @returns The physics imposter
  90079. */
  90080. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90081. /**
  90082. * Add an anchor to a cloth impostor
  90083. * @param otherImpostor rigid impostor to anchor to
  90084. * @param width ratio across width from 0 to 1
  90085. * @param height ratio up height from 0 to 1
  90086. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90087. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90088. * @returns impostor the soft imposter
  90089. */
  90090. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90091. /**
  90092. * Add a hook to a rope impostor
  90093. * @param otherImpostor rigid impostor to anchor to
  90094. * @param length ratio across rope from 0 to 1
  90095. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90096. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90097. * @returns impostor the rope imposter
  90098. */
  90099. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90100. /**
  90101. * Will keep this body still, in a sleep mode.
  90102. * @returns the physics imposter
  90103. */
  90104. sleep(): PhysicsImpostor;
  90105. /**
  90106. * Wake the body up.
  90107. * @returns The physics imposter
  90108. */
  90109. wakeUp(): PhysicsImpostor;
  90110. /**
  90111. * Clones the physics imposter
  90112. * @param newObject The physics imposter clones to this physics-enabled object
  90113. * @returns A nullable physics imposter
  90114. */
  90115. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90116. /**
  90117. * Disposes the physics imposter
  90118. */
  90119. dispose(): void;
  90120. /**
  90121. * Sets the delta position
  90122. * @param position The delta position amount
  90123. */
  90124. setDeltaPosition(position: Vector3): void;
  90125. /**
  90126. * Sets the delta rotation
  90127. * @param rotation The delta rotation amount
  90128. */
  90129. setDeltaRotation(rotation: Quaternion): void;
  90130. /**
  90131. * Gets the box size of the physics imposter and stores the result in the input parameter
  90132. * @param result Stores the box size
  90133. * @returns The physics imposter
  90134. */
  90135. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90136. /**
  90137. * Gets the radius of the physics imposter
  90138. * @returns Radius of the physics imposter
  90139. */
  90140. getRadius(): number;
  90141. /**
  90142. * Sync a bone with this impostor
  90143. * @param bone The bone to sync to the impostor.
  90144. * @param boneMesh The mesh that the bone is influencing.
  90145. * @param jointPivot The pivot of the joint / bone in local space.
  90146. * @param distToJoint Optional distance from the impostor to the joint.
  90147. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90148. */
  90149. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90150. /**
  90151. * Sync impostor to a bone
  90152. * @param bone The bone that the impostor will be synced to.
  90153. * @param boneMesh The mesh that the bone is influencing.
  90154. * @param jointPivot The pivot of the joint / bone in local space.
  90155. * @param distToJoint Optional distance from the impostor to the joint.
  90156. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90157. * @param boneAxis Optional vector3 axis the bone is aligned with
  90158. */
  90159. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90160. /**
  90161. * No-Imposter type
  90162. */
  90163. static NoImpostor: number;
  90164. /**
  90165. * Sphere-Imposter type
  90166. */
  90167. static SphereImpostor: number;
  90168. /**
  90169. * Box-Imposter type
  90170. */
  90171. static BoxImpostor: number;
  90172. /**
  90173. * Plane-Imposter type
  90174. */
  90175. static PlaneImpostor: number;
  90176. /**
  90177. * Mesh-imposter type
  90178. */
  90179. static MeshImpostor: number;
  90180. /**
  90181. * Capsule-Impostor type (Ammo.js plugin only)
  90182. */
  90183. static CapsuleImpostor: number;
  90184. /**
  90185. * Cylinder-Imposter type
  90186. */
  90187. static CylinderImpostor: number;
  90188. /**
  90189. * Particle-Imposter type
  90190. */
  90191. static ParticleImpostor: number;
  90192. /**
  90193. * Heightmap-Imposter type
  90194. */
  90195. static HeightmapImpostor: number;
  90196. /**
  90197. * ConvexHull-Impostor type (Ammo.js plugin only)
  90198. */
  90199. static ConvexHullImpostor: number;
  90200. /**
  90201. * Rope-Imposter type
  90202. */
  90203. static RopeImpostor: number;
  90204. /**
  90205. * Cloth-Imposter type
  90206. */
  90207. static ClothImpostor: number;
  90208. /**
  90209. * Softbody-Imposter type
  90210. */
  90211. static SoftbodyImpostor: number;
  90212. }
  90213. }
  90214. declare module BABYLON {
  90215. /**
  90216. * @hidden
  90217. **/
  90218. export class _CreationDataStorage {
  90219. closePath?: boolean;
  90220. closeArray?: boolean;
  90221. idx: number[];
  90222. dashSize: number;
  90223. gapSize: number;
  90224. path3D: Path3D;
  90225. pathArray: Vector3[][];
  90226. arc: number;
  90227. radius: number;
  90228. cap: number;
  90229. tessellation: number;
  90230. }
  90231. /**
  90232. * @hidden
  90233. **/
  90234. class _InstanceDataStorage {
  90235. visibleInstances: any;
  90236. batchCache: _InstancesBatch;
  90237. instancesBufferSize: number;
  90238. instancesBuffer: Nullable<Buffer>;
  90239. instancesData: Float32Array;
  90240. overridenInstanceCount: number;
  90241. isFrozen: boolean;
  90242. previousBatch: Nullable<_InstancesBatch>;
  90243. hardwareInstancedRendering: boolean;
  90244. sideOrientation: number;
  90245. }
  90246. /**
  90247. * @hidden
  90248. **/
  90249. export class _InstancesBatch {
  90250. mustReturn: boolean;
  90251. visibleInstances: Nullable<InstancedMesh[]>[];
  90252. renderSelf: boolean[];
  90253. hardwareInstancedRendering: boolean[];
  90254. }
  90255. /**
  90256. * Class used to represent renderable models
  90257. */
  90258. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90259. /**
  90260. * Mesh side orientation : usually the external or front surface
  90261. */
  90262. static readonly FRONTSIDE: number;
  90263. /**
  90264. * Mesh side orientation : usually the internal or back surface
  90265. */
  90266. static readonly BACKSIDE: number;
  90267. /**
  90268. * Mesh side orientation : both internal and external or front and back surfaces
  90269. */
  90270. static readonly DOUBLESIDE: number;
  90271. /**
  90272. * Mesh side orientation : by default, `FRONTSIDE`
  90273. */
  90274. static readonly DEFAULTSIDE: number;
  90275. /**
  90276. * Mesh cap setting : no cap
  90277. */
  90278. static readonly NO_CAP: number;
  90279. /**
  90280. * Mesh cap setting : one cap at the beginning of the mesh
  90281. */
  90282. static readonly CAP_START: number;
  90283. /**
  90284. * Mesh cap setting : one cap at the end of the mesh
  90285. */
  90286. static readonly CAP_END: number;
  90287. /**
  90288. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90289. */
  90290. static readonly CAP_ALL: number;
  90291. /**
  90292. * Mesh pattern setting : no flip or rotate
  90293. */
  90294. static readonly NO_FLIP: number;
  90295. /**
  90296. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90297. */
  90298. static readonly FLIP_TILE: number;
  90299. /**
  90300. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90301. */
  90302. static readonly ROTATE_TILE: number;
  90303. /**
  90304. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90305. */
  90306. static readonly FLIP_ROW: number;
  90307. /**
  90308. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90309. */
  90310. static readonly ROTATE_ROW: number;
  90311. /**
  90312. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90313. */
  90314. static readonly FLIP_N_ROTATE_TILE: number;
  90315. /**
  90316. * Mesh pattern setting : rotate pattern and rotate
  90317. */
  90318. static readonly FLIP_N_ROTATE_ROW: number;
  90319. /**
  90320. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90321. */
  90322. static readonly CENTER: number;
  90323. /**
  90324. * Mesh tile positioning : part tiles on left
  90325. */
  90326. static readonly LEFT: number;
  90327. /**
  90328. * Mesh tile positioning : part tiles on right
  90329. */
  90330. static readonly RIGHT: number;
  90331. /**
  90332. * Mesh tile positioning : part tiles on top
  90333. */
  90334. static readonly TOP: number;
  90335. /**
  90336. * Mesh tile positioning : part tiles on bottom
  90337. */
  90338. static readonly BOTTOM: number;
  90339. /**
  90340. * Gets the default side orientation.
  90341. * @param orientation the orientation to value to attempt to get
  90342. * @returns the default orientation
  90343. * @hidden
  90344. */
  90345. static _GetDefaultSideOrientation(orientation?: number): number;
  90346. private _internalMeshDataInfo;
  90347. /**
  90348. * An event triggered before rendering the mesh
  90349. */
  90350. readonly onBeforeRenderObservable: Observable<Mesh>;
  90351. /**
  90352. * An event triggered before binding the mesh
  90353. */
  90354. readonly onBeforeBindObservable: Observable<Mesh>;
  90355. /**
  90356. * An event triggered after rendering the mesh
  90357. */
  90358. readonly onAfterRenderObservable: Observable<Mesh>;
  90359. /**
  90360. * An event triggered before drawing the mesh
  90361. */
  90362. readonly onBeforeDrawObservable: Observable<Mesh>;
  90363. private _onBeforeDrawObserver;
  90364. /**
  90365. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90366. */
  90367. onBeforeDraw: () => void;
  90368. readonly hasInstances: boolean;
  90369. /**
  90370. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90371. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90372. */
  90373. delayLoadState: number;
  90374. /**
  90375. * Gets the list of instances created from this mesh
  90376. * it is not supposed to be modified manually.
  90377. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90378. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90379. */
  90380. instances: InstancedMesh[];
  90381. /**
  90382. * Gets the file containing delay loading data for this mesh
  90383. */
  90384. delayLoadingFile: string;
  90385. /** @hidden */
  90386. _binaryInfo: any;
  90387. /**
  90388. * User defined function used to change how LOD level selection is done
  90389. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90390. */
  90391. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90392. /**
  90393. * Gets or sets the morph target manager
  90394. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90395. */
  90396. morphTargetManager: Nullable<MorphTargetManager>;
  90397. /** @hidden */
  90398. _creationDataStorage: Nullable<_CreationDataStorage>;
  90399. /** @hidden */
  90400. _geometry: Nullable<Geometry>;
  90401. /** @hidden */
  90402. _delayInfo: Array<string>;
  90403. /** @hidden */
  90404. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90405. /** @hidden */
  90406. _instanceDataStorage: _InstanceDataStorage;
  90407. private _effectiveMaterial;
  90408. /** @hidden */
  90409. _shouldGenerateFlatShading: boolean;
  90410. /** @hidden */
  90411. _originalBuilderSideOrientation: number;
  90412. /**
  90413. * Use this property to change the original side orientation defined at construction time
  90414. */
  90415. overrideMaterialSideOrientation: Nullable<number>;
  90416. /**
  90417. * Gets the source mesh (the one used to clone this one from)
  90418. */
  90419. readonly source: Nullable<Mesh>;
  90420. /**
  90421. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90422. */
  90423. isUnIndexed: boolean;
  90424. /**
  90425. * @constructor
  90426. * @param name The value used by scene.getMeshByName() to do a lookup.
  90427. * @param scene The scene to add this mesh to.
  90428. * @param parent The parent of this mesh, if it has one
  90429. * @param source An optional Mesh from which geometry is shared, cloned.
  90430. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90431. * When false, achieved by calling a clone(), also passing False.
  90432. * This will make creation of children, recursive.
  90433. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90434. */
  90435. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90436. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90437. /**
  90438. * Gets the class name
  90439. * @returns the string "Mesh".
  90440. */
  90441. getClassName(): string;
  90442. /** @hidden */
  90443. readonly _isMesh: boolean;
  90444. /**
  90445. * Returns a description of this mesh
  90446. * @param fullDetails define if full details about this mesh must be used
  90447. * @returns a descriptive string representing this mesh
  90448. */
  90449. toString(fullDetails?: boolean): string;
  90450. /** @hidden */
  90451. _unBindEffect(): void;
  90452. /**
  90453. * Gets a boolean indicating if this mesh has LOD
  90454. */
  90455. readonly hasLODLevels: boolean;
  90456. /**
  90457. * Gets the list of MeshLODLevel associated with the current mesh
  90458. * @returns an array of MeshLODLevel
  90459. */
  90460. getLODLevels(): MeshLODLevel[];
  90461. private _sortLODLevels;
  90462. /**
  90463. * Add a mesh as LOD level triggered at the given distance.
  90464. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90465. * @param distance The distance from the center of the object to show this level
  90466. * @param mesh The mesh to be added as LOD level (can be null)
  90467. * @return This mesh (for chaining)
  90468. */
  90469. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90470. /**
  90471. * Returns the LOD level mesh at the passed distance or null if not found.
  90472. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90473. * @param distance The distance from the center of the object to show this level
  90474. * @returns a Mesh or `null`
  90475. */
  90476. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90477. /**
  90478. * Remove a mesh from the LOD array
  90479. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90480. * @param mesh defines the mesh to be removed
  90481. * @return This mesh (for chaining)
  90482. */
  90483. removeLODLevel(mesh: Mesh): Mesh;
  90484. /**
  90485. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90486. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90487. * @param camera defines the camera to use to compute distance
  90488. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90489. * @return This mesh (for chaining)
  90490. */
  90491. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90492. /**
  90493. * Gets the mesh internal Geometry object
  90494. */
  90495. readonly geometry: Nullable<Geometry>;
  90496. /**
  90497. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90498. * @returns the total number of vertices
  90499. */
  90500. getTotalVertices(): number;
  90501. /**
  90502. * Returns the content of an associated vertex buffer
  90503. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90504. * - VertexBuffer.PositionKind
  90505. * - VertexBuffer.UVKind
  90506. * - VertexBuffer.UV2Kind
  90507. * - VertexBuffer.UV3Kind
  90508. * - VertexBuffer.UV4Kind
  90509. * - VertexBuffer.UV5Kind
  90510. * - VertexBuffer.UV6Kind
  90511. * - VertexBuffer.ColorKind
  90512. * - VertexBuffer.MatricesIndicesKind
  90513. * - VertexBuffer.MatricesIndicesExtraKind
  90514. * - VertexBuffer.MatricesWeightsKind
  90515. * - VertexBuffer.MatricesWeightsExtraKind
  90516. * @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
  90517. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90518. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90519. */
  90520. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90521. /**
  90522. * Returns the mesh VertexBuffer object from the requested `kind`
  90523. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90524. * - VertexBuffer.PositionKind
  90525. * - VertexBuffer.NormalKind
  90526. * - VertexBuffer.UVKind
  90527. * - VertexBuffer.UV2Kind
  90528. * - VertexBuffer.UV3Kind
  90529. * - VertexBuffer.UV4Kind
  90530. * - VertexBuffer.UV5Kind
  90531. * - VertexBuffer.UV6Kind
  90532. * - VertexBuffer.ColorKind
  90533. * - VertexBuffer.MatricesIndicesKind
  90534. * - VertexBuffer.MatricesIndicesExtraKind
  90535. * - VertexBuffer.MatricesWeightsKind
  90536. * - VertexBuffer.MatricesWeightsExtraKind
  90537. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90538. */
  90539. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90540. /**
  90541. * Tests if a specific vertex buffer is associated with this mesh
  90542. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90543. * - VertexBuffer.PositionKind
  90544. * - VertexBuffer.NormalKind
  90545. * - VertexBuffer.UVKind
  90546. * - VertexBuffer.UV2Kind
  90547. * - VertexBuffer.UV3Kind
  90548. * - VertexBuffer.UV4Kind
  90549. * - VertexBuffer.UV5Kind
  90550. * - VertexBuffer.UV6Kind
  90551. * - VertexBuffer.ColorKind
  90552. * - VertexBuffer.MatricesIndicesKind
  90553. * - VertexBuffer.MatricesIndicesExtraKind
  90554. * - VertexBuffer.MatricesWeightsKind
  90555. * - VertexBuffer.MatricesWeightsExtraKind
  90556. * @returns a boolean
  90557. */
  90558. isVerticesDataPresent(kind: string): boolean;
  90559. /**
  90560. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90561. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90562. * - VertexBuffer.PositionKind
  90563. * - VertexBuffer.UVKind
  90564. * - VertexBuffer.UV2Kind
  90565. * - VertexBuffer.UV3Kind
  90566. * - VertexBuffer.UV4Kind
  90567. * - VertexBuffer.UV5Kind
  90568. * - VertexBuffer.UV6Kind
  90569. * - VertexBuffer.ColorKind
  90570. * - VertexBuffer.MatricesIndicesKind
  90571. * - VertexBuffer.MatricesIndicesExtraKind
  90572. * - VertexBuffer.MatricesWeightsKind
  90573. * - VertexBuffer.MatricesWeightsExtraKind
  90574. * @returns a boolean
  90575. */
  90576. isVertexBufferUpdatable(kind: string): boolean;
  90577. /**
  90578. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90579. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90580. * - VertexBuffer.PositionKind
  90581. * - VertexBuffer.NormalKind
  90582. * - VertexBuffer.UVKind
  90583. * - VertexBuffer.UV2Kind
  90584. * - VertexBuffer.UV3Kind
  90585. * - VertexBuffer.UV4Kind
  90586. * - VertexBuffer.UV5Kind
  90587. * - VertexBuffer.UV6Kind
  90588. * - VertexBuffer.ColorKind
  90589. * - VertexBuffer.MatricesIndicesKind
  90590. * - VertexBuffer.MatricesIndicesExtraKind
  90591. * - VertexBuffer.MatricesWeightsKind
  90592. * - VertexBuffer.MatricesWeightsExtraKind
  90593. * @returns an array of strings
  90594. */
  90595. getVerticesDataKinds(): string[];
  90596. /**
  90597. * Returns a positive integer : the total number of indices in this mesh geometry.
  90598. * @returns the numner of indices or zero if the mesh has no geometry.
  90599. */
  90600. getTotalIndices(): number;
  90601. /**
  90602. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90603. * @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.
  90604. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90605. * @returns the indices array or an empty array if the mesh has no geometry
  90606. */
  90607. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90608. readonly isBlocked: boolean;
  90609. /**
  90610. * Determine if the current mesh is ready to be rendered
  90611. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90612. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90613. * @returns true if all associated assets are ready (material, textures, shaders)
  90614. */
  90615. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90616. /**
  90617. * 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.
  90618. */
  90619. readonly areNormalsFrozen: boolean;
  90620. /**
  90621. * 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.
  90622. * @returns the current mesh
  90623. */
  90624. freezeNormals(): Mesh;
  90625. /**
  90626. * 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
  90627. * @returns the current mesh
  90628. */
  90629. unfreezeNormals(): Mesh;
  90630. /**
  90631. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90632. */
  90633. overridenInstanceCount: number;
  90634. /** @hidden */
  90635. _preActivate(): Mesh;
  90636. /** @hidden */
  90637. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90638. /** @hidden */
  90639. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90640. /**
  90641. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90642. * This means the mesh underlying bounding box and sphere are recomputed.
  90643. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90644. * @returns the current mesh
  90645. */
  90646. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90647. /** @hidden */
  90648. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90649. /**
  90650. * This function will subdivide the mesh into multiple submeshes
  90651. * @param count defines the expected number of submeshes
  90652. */
  90653. subdivide(count: number): void;
  90654. /**
  90655. * Copy a FloatArray into a specific associated vertex buffer
  90656. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90657. * - VertexBuffer.PositionKind
  90658. * - VertexBuffer.UVKind
  90659. * - VertexBuffer.UV2Kind
  90660. * - VertexBuffer.UV3Kind
  90661. * - VertexBuffer.UV4Kind
  90662. * - VertexBuffer.UV5Kind
  90663. * - VertexBuffer.UV6Kind
  90664. * - VertexBuffer.ColorKind
  90665. * - VertexBuffer.MatricesIndicesKind
  90666. * - VertexBuffer.MatricesIndicesExtraKind
  90667. * - VertexBuffer.MatricesWeightsKind
  90668. * - VertexBuffer.MatricesWeightsExtraKind
  90669. * @param data defines the data source
  90670. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90671. * @param stride defines the data stride size (can be null)
  90672. * @returns the current mesh
  90673. */
  90674. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90675. /**
  90676. * Flags an associated vertex buffer as updatable
  90677. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90678. * - VertexBuffer.PositionKind
  90679. * - VertexBuffer.UVKind
  90680. * - VertexBuffer.UV2Kind
  90681. * - VertexBuffer.UV3Kind
  90682. * - VertexBuffer.UV4Kind
  90683. * - VertexBuffer.UV5Kind
  90684. * - VertexBuffer.UV6Kind
  90685. * - VertexBuffer.ColorKind
  90686. * - VertexBuffer.MatricesIndicesKind
  90687. * - VertexBuffer.MatricesIndicesExtraKind
  90688. * - VertexBuffer.MatricesWeightsKind
  90689. * - VertexBuffer.MatricesWeightsExtraKind
  90690. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90691. */
  90692. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90693. /**
  90694. * Sets the mesh global Vertex Buffer
  90695. * @param buffer defines the buffer to use
  90696. * @returns the current mesh
  90697. */
  90698. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90699. /**
  90700. * Update a specific associated vertex buffer
  90701. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90702. * - VertexBuffer.PositionKind
  90703. * - VertexBuffer.UVKind
  90704. * - VertexBuffer.UV2Kind
  90705. * - VertexBuffer.UV3Kind
  90706. * - VertexBuffer.UV4Kind
  90707. * - VertexBuffer.UV5Kind
  90708. * - VertexBuffer.UV6Kind
  90709. * - VertexBuffer.ColorKind
  90710. * - VertexBuffer.MatricesIndicesKind
  90711. * - VertexBuffer.MatricesIndicesExtraKind
  90712. * - VertexBuffer.MatricesWeightsKind
  90713. * - VertexBuffer.MatricesWeightsExtraKind
  90714. * @param data defines the data source
  90715. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90716. * @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)
  90717. * @returns the current mesh
  90718. */
  90719. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90720. /**
  90721. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90722. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90723. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90724. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90725. * @returns the current mesh
  90726. */
  90727. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90728. /**
  90729. * Creates a un-shared specific occurence of the geometry for the mesh.
  90730. * @returns the current mesh
  90731. */
  90732. makeGeometryUnique(): Mesh;
  90733. /**
  90734. * Set the index buffer of this mesh
  90735. * @param indices defines the source data
  90736. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90737. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90738. * @returns the current mesh
  90739. */
  90740. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90741. /**
  90742. * Update the current index buffer
  90743. * @param indices defines the source data
  90744. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90745. * @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)
  90746. * @returns the current mesh
  90747. */
  90748. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90749. /**
  90750. * Invert the geometry to move from a right handed system to a left handed one.
  90751. * @returns the current mesh
  90752. */
  90753. toLeftHanded(): Mesh;
  90754. /** @hidden */
  90755. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90756. /** @hidden */
  90757. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90758. /**
  90759. * Registers for this mesh a javascript function called just before the rendering process
  90760. * @param func defines the function to call before rendering this mesh
  90761. * @returns the current mesh
  90762. */
  90763. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90764. /**
  90765. * Disposes a previously registered javascript function called before the rendering
  90766. * @param func defines the function to remove
  90767. * @returns the current mesh
  90768. */
  90769. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90770. /**
  90771. * Registers for this mesh a javascript function called just after the rendering is complete
  90772. * @param func defines the function to call after rendering this mesh
  90773. * @returns the current mesh
  90774. */
  90775. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90776. /**
  90777. * Disposes a previously registered javascript function called after the rendering.
  90778. * @param func defines the function to remove
  90779. * @returns the current mesh
  90780. */
  90781. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90782. /** @hidden */
  90783. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90784. /** @hidden */
  90785. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90786. /** @hidden */
  90787. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90788. /** @hidden */
  90789. _rebuild(): void;
  90790. /** @hidden */
  90791. _freeze(): void;
  90792. /** @hidden */
  90793. _unFreeze(): void;
  90794. /**
  90795. * 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
  90796. * @param subMesh defines the subMesh to render
  90797. * @param enableAlphaMode defines if alpha mode can be changed
  90798. * @returns the current mesh
  90799. */
  90800. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90801. private _onBeforeDraw;
  90802. /**
  90803. * Renormalize the mesh and patch it up if there are no weights
  90804. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90805. * However in the case of zero weights then we set just a single influence to 1.
  90806. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90807. */
  90808. cleanMatrixWeights(): void;
  90809. private normalizeSkinFourWeights;
  90810. private normalizeSkinWeightsAndExtra;
  90811. /**
  90812. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90813. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90814. * the user know there was an issue with importing the mesh
  90815. * @returns a validation object with skinned, valid and report string
  90816. */
  90817. validateSkinning(): {
  90818. skinned: boolean;
  90819. valid: boolean;
  90820. report: string;
  90821. };
  90822. /** @hidden */
  90823. _checkDelayState(): Mesh;
  90824. private _queueLoad;
  90825. /**
  90826. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90827. * A mesh is in the frustum if its bounding box intersects the frustum
  90828. * @param frustumPlanes defines the frustum to test
  90829. * @returns true if the mesh is in the frustum planes
  90830. */
  90831. isInFrustum(frustumPlanes: Plane[]): boolean;
  90832. /**
  90833. * Sets the mesh material by the material or multiMaterial `id` property
  90834. * @param id is a string identifying the material or the multiMaterial
  90835. * @returns the current mesh
  90836. */
  90837. setMaterialByID(id: string): Mesh;
  90838. /**
  90839. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90840. * @returns an array of IAnimatable
  90841. */
  90842. getAnimatables(): IAnimatable[];
  90843. /**
  90844. * Modifies the mesh geometry according to the passed transformation matrix.
  90845. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90846. * The mesh normals are modified using the same transformation.
  90847. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90848. * @param transform defines the transform matrix to use
  90849. * @see http://doc.babylonjs.com/resources/baking_transformations
  90850. * @returns the current mesh
  90851. */
  90852. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90853. /**
  90854. * Modifies the mesh geometry according to its own current World Matrix.
  90855. * The mesh World Matrix is then reset.
  90856. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90857. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90858. * @see http://doc.babylonjs.com/resources/baking_transformations
  90859. * @returns the current mesh
  90860. */
  90861. bakeCurrentTransformIntoVertices(): Mesh;
  90862. /** @hidden */
  90863. readonly _positions: Nullable<Vector3[]>;
  90864. /** @hidden */
  90865. _resetPointsArrayCache(): Mesh;
  90866. /** @hidden */
  90867. _generatePointsArray(): boolean;
  90868. /**
  90869. * Returns a new Mesh object generated from the current mesh properties.
  90870. * This method must not get confused with createInstance()
  90871. * @param name is a string, the name given to the new mesh
  90872. * @param newParent can be any Node object (default `null`)
  90873. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90874. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90875. * @returns a new mesh
  90876. */
  90877. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90878. /**
  90879. * Releases resources associated with this mesh.
  90880. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90881. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90882. */
  90883. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90884. /**
  90885. * Modifies the mesh geometry according to a displacement map.
  90886. * 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.
  90887. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90888. * @param url is a string, the URL from the image file is to be downloaded.
  90889. * @param minHeight is the lower limit of the displacement.
  90890. * @param maxHeight is the upper limit of the displacement.
  90891. * @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.
  90892. * @param uvOffset is an optional vector2 used to offset UV.
  90893. * @param uvScale is an optional vector2 used to scale UV.
  90894. * @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.
  90895. * @returns the Mesh.
  90896. */
  90897. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90898. /**
  90899. * Modifies the mesh geometry according to a displacementMap buffer.
  90900. * 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.
  90901. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90902. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90903. * @param heightMapWidth is the width of the buffer image.
  90904. * @param heightMapHeight is the height of the buffer image.
  90905. * @param minHeight is the lower limit of the displacement.
  90906. * @param maxHeight is the upper limit of the displacement.
  90907. * @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.
  90908. * @param uvOffset is an optional vector2 used to offset UV.
  90909. * @param uvScale is an optional vector2 used to scale UV.
  90910. * @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.
  90911. * @returns the Mesh.
  90912. */
  90913. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90914. /**
  90915. * Modify the mesh to get a flat shading rendering.
  90916. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90917. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90918. * @returns current mesh
  90919. */
  90920. convertToFlatShadedMesh(): Mesh;
  90921. /**
  90922. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90923. * In other words, more vertices, no more indices and a single bigger VBO.
  90924. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90925. * @returns current mesh
  90926. */
  90927. convertToUnIndexedMesh(): Mesh;
  90928. /**
  90929. * Inverses facet orientations.
  90930. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90931. * @param flipNormals will also inverts the normals
  90932. * @returns current mesh
  90933. */
  90934. flipFaces(flipNormals?: boolean): Mesh;
  90935. /**
  90936. * Increase the number of facets and hence vertices in a mesh
  90937. * Vertex normals are interpolated from existing vertex normals
  90938. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90939. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90940. */
  90941. increaseVertices(numberPerEdge: number): void;
  90942. /**
  90943. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90944. * This will undo any application of covertToFlatShadedMesh
  90945. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90946. */
  90947. forceSharedVertices(): void;
  90948. /** @hidden */
  90949. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90950. /** @hidden */
  90951. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90952. /**
  90953. * Creates a new InstancedMesh object from the mesh model.
  90954. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90955. * @param name defines the name of the new instance
  90956. * @returns a new InstancedMesh
  90957. */
  90958. createInstance(name: string): InstancedMesh;
  90959. /**
  90960. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90961. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90962. * @returns the current mesh
  90963. */
  90964. synchronizeInstances(): Mesh;
  90965. /**
  90966. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90967. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90968. * This should be used together with the simplification to avoid disappearing triangles.
  90969. * @param successCallback an optional success callback to be called after the optimization finished.
  90970. * @returns the current mesh
  90971. */
  90972. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90973. /**
  90974. * Serialize current mesh
  90975. * @param serializationObject defines the object which will receive the serialization data
  90976. */
  90977. serialize(serializationObject: any): void;
  90978. /** @hidden */
  90979. _syncGeometryWithMorphTargetManager(): void;
  90980. /** @hidden */
  90981. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  90982. /**
  90983. * Returns a new Mesh object parsed from the source provided.
  90984. * @param parsedMesh is the source
  90985. * @param scene defines the hosting scene
  90986. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  90987. * @returns a new Mesh
  90988. */
  90989. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  90990. /**
  90991. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  90992. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  90993. * @param name defines the name of the mesh to create
  90994. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  90995. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  90996. * @param closePath creates a seam between the first and the last points of each path of the path array
  90997. * @param offset is taken in account only if the `pathArray` is containing a single path
  90998. * @param scene defines the hosting scene
  90999. * @param updatable defines if the mesh must be flagged as updatable
  91000. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91001. * @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)
  91002. * @returns a new Mesh
  91003. */
  91004. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91005. /**
  91006. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91007. * @param name defines the name of the mesh to create
  91008. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91009. * @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
  91010. * @param scene defines the hosting scene
  91011. * @param updatable defines if the mesh must be flagged as updatable
  91012. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91013. * @returns a new Mesh
  91014. */
  91015. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91016. /**
  91017. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91018. * @param name defines the name of the mesh to create
  91019. * @param size sets the size (float) of each box side (default 1)
  91020. * @param scene defines the hosting scene
  91021. * @param updatable defines if the mesh must be flagged as updatable
  91022. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91023. * @returns a new Mesh
  91024. */
  91025. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91026. /**
  91027. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91028. * @param name defines the name of the mesh to create
  91029. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91030. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91031. * @param scene defines the hosting scene
  91032. * @param updatable defines if the mesh must be flagged as updatable
  91033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91034. * @returns a new Mesh
  91035. */
  91036. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91037. /**
  91038. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91039. * @param name defines the name of the mesh to create
  91040. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91041. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91042. * @param scene defines the hosting scene
  91043. * @returns a new Mesh
  91044. */
  91045. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91046. /**
  91047. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91048. * @param name defines the name of the mesh to create
  91049. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91050. * @param diameterTop set the top cap diameter (floats, default 1)
  91051. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91052. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91053. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91054. * @param scene defines the hosting scene
  91055. * @param updatable defines if the mesh must be flagged as updatable
  91056. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91057. * @returns a new Mesh
  91058. */
  91059. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91060. /**
  91061. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91062. * @param name defines the name of the mesh to create
  91063. * @param diameter sets the diameter size (float) of the torus (default 1)
  91064. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91065. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91066. * @param scene defines the hosting scene
  91067. * @param updatable defines if the mesh must be flagged as updatable
  91068. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91069. * @returns a new Mesh
  91070. */
  91071. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91072. /**
  91073. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91074. * @param name defines the name of the mesh to create
  91075. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91076. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91077. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91078. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91079. * @param p the number of windings on X axis (positive integers, default 2)
  91080. * @param q the number of windings on Y axis (positive integers, default 3)
  91081. * @param scene defines the hosting scene
  91082. * @param updatable defines if the mesh must be flagged as updatable
  91083. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91084. * @returns a new Mesh
  91085. */
  91086. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91087. /**
  91088. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91089. * @param name defines the name of the mesh to create
  91090. * @param points is an array successive Vector3
  91091. * @param scene defines the hosting scene
  91092. * @param updatable defines if the mesh must be flagged as updatable
  91093. * @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).
  91094. * @returns a new Mesh
  91095. */
  91096. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91097. /**
  91098. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91099. * @param name defines the name of the mesh to create
  91100. * @param points is an array successive Vector3
  91101. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91102. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91103. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91104. * @param scene defines the hosting scene
  91105. * @param updatable defines if the mesh must be flagged as updatable
  91106. * @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)
  91107. * @returns a new Mesh
  91108. */
  91109. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91110. /**
  91111. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91112. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91113. * 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.
  91114. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91115. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91116. * Remember you can only change the shape positions, not their number when updating a polygon.
  91117. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91118. * @param name defines the name of the mesh to create
  91119. * @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
  91120. * @param scene defines the hosting scene
  91121. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91122. * @param updatable defines if the mesh must be flagged as updatable
  91123. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91124. * @param earcutInjection can be used to inject your own earcut reference
  91125. * @returns a new Mesh
  91126. */
  91127. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91128. /**
  91129. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91130. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91131. * @param name defines the name of the mesh to create
  91132. * @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
  91133. * @param depth defines the height of extrusion
  91134. * @param scene defines the hosting scene
  91135. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91136. * @param updatable defines if the mesh must be flagged as updatable
  91137. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91138. * @param earcutInjection can be used to inject your own earcut reference
  91139. * @returns a new Mesh
  91140. */
  91141. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91142. /**
  91143. * Creates an extruded shape mesh.
  91144. * 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
  91145. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91146. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91147. * @param name defines the name of the mesh to create
  91148. * @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
  91149. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91150. * @param scale is the value to scale the shape
  91151. * @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
  91152. * @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
  91153. * @param scene defines the hosting scene
  91154. * @param updatable defines if the mesh must be flagged as updatable
  91155. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91156. * @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)
  91157. * @returns a new Mesh
  91158. */
  91159. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91160. /**
  91161. * Creates an custom extruded shape mesh.
  91162. * The custom extrusion is a parametric shape.
  91163. * It has no predefined shape. Its final shape will depend on the input parameters.
  91164. * Please consider using the same method from the MeshBuilder class instead
  91165. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91166. * @param name defines the name of the mesh to create
  91167. * @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
  91168. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91169. * @param scaleFunction is a custom Javascript function called on each path point
  91170. * @param rotationFunction is a custom Javascript function called on each path point
  91171. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91172. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91173. * @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
  91174. * @param scene defines the hosting scene
  91175. * @param updatable defines if the mesh must be flagged as updatable
  91176. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91177. * @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)
  91178. * @returns a new Mesh
  91179. */
  91180. 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;
  91181. /**
  91182. * Creates lathe mesh.
  91183. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91184. * Please consider using the same method from the MeshBuilder class instead
  91185. * @param name defines the name of the mesh to create
  91186. * @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
  91187. * @param radius is the radius value of the lathe
  91188. * @param tessellation is the side number of the lathe.
  91189. * @param scene defines the hosting scene
  91190. * @param updatable defines if the mesh must be flagged as updatable
  91191. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91192. * @returns a new Mesh
  91193. */
  91194. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91195. /**
  91196. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91197. * @param name defines the name of the mesh to create
  91198. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91199. * @param scene defines the hosting scene
  91200. * @param updatable defines if the mesh must be flagged as updatable
  91201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91202. * @returns a new Mesh
  91203. */
  91204. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91205. /**
  91206. * Creates a ground mesh.
  91207. * Please consider using the same method from the MeshBuilder class instead
  91208. * @param name defines the name of the mesh to create
  91209. * @param width set the width of the ground
  91210. * @param height set the height of the ground
  91211. * @param subdivisions sets the number of subdivisions per side
  91212. * @param scene defines the hosting scene
  91213. * @param updatable defines if the mesh must be flagged as updatable
  91214. * @returns a new Mesh
  91215. */
  91216. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91217. /**
  91218. * Creates a tiled ground mesh.
  91219. * Please consider using the same method from the MeshBuilder class instead
  91220. * @param name defines the name of the mesh to create
  91221. * @param xmin set the ground minimum X coordinate
  91222. * @param zmin set the ground minimum Y coordinate
  91223. * @param xmax set the ground maximum X coordinate
  91224. * @param zmax set the ground maximum Z coordinate
  91225. * @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
  91226. * @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
  91227. * @param scene defines the hosting scene
  91228. * @param updatable defines if the mesh must be flagged as updatable
  91229. * @returns a new Mesh
  91230. */
  91231. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91232. w: number;
  91233. h: number;
  91234. }, precision: {
  91235. w: number;
  91236. h: number;
  91237. }, scene: Scene, updatable?: boolean): Mesh;
  91238. /**
  91239. * Creates a ground mesh from a height map.
  91240. * Please consider using the same method from the MeshBuilder class instead
  91241. * @see http://doc.babylonjs.com/babylon101/height_map
  91242. * @param name defines the name of the mesh to create
  91243. * @param url sets the URL of the height map image resource
  91244. * @param width set the ground width size
  91245. * @param height set the ground height size
  91246. * @param subdivisions sets the number of subdivision per side
  91247. * @param minHeight is the minimum altitude on the ground
  91248. * @param maxHeight is the maximum altitude on the ground
  91249. * @param scene defines the hosting scene
  91250. * @param updatable defines if the mesh must be flagged as updatable
  91251. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91252. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91253. * @returns a new Mesh
  91254. */
  91255. 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;
  91256. /**
  91257. * Creates a tube mesh.
  91258. * The tube is a parametric shape.
  91259. * It has no predefined shape. Its final shape will depend on the input parameters.
  91260. * Please consider using the same method from the MeshBuilder class instead
  91261. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91262. * @param name defines the name of the mesh to create
  91263. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91264. * @param radius sets the tube radius size
  91265. * @param tessellation is the number of sides on the tubular surface
  91266. * @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
  91267. * @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
  91268. * @param scene defines the hosting scene
  91269. * @param updatable defines if the mesh must be flagged as updatable
  91270. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91271. * @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)
  91272. * @returns a new Mesh
  91273. */
  91274. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91275. (i: number, distance: number): number;
  91276. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91277. /**
  91278. * Creates a polyhedron mesh.
  91279. * Please consider using the same method from the MeshBuilder class instead.
  91280. * * 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
  91281. * * The parameter `size` (positive float, default 1) sets the polygon size
  91282. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91283. * * 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`
  91284. * * 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
  91285. * * 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)`)
  91286. * * 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
  91287. * * 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
  91288. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91289. * * If you create a double-sided mesh, you can choose what parts of 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
  91290. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91291. * @param name defines the name of the mesh to create
  91292. * @param options defines the options used to create the mesh
  91293. * @param scene defines the hosting scene
  91294. * @returns a new Mesh
  91295. */
  91296. static CreatePolyhedron(name: string, options: {
  91297. type?: number;
  91298. size?: number;
  91299. sizeX?: number;
  91300. sizeY?: number;
  91301. sizeZ?: number;
  91302. custom?: any;
  91303. faceUV?: Vector4[];
  91304. faceColors?: Color4[];
  91305. updatable?: boolean;
  91306. sideOrientation?: number;
  91307. }, scene: Scene): Mesh;
  91308. /**
  91309. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91310. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91311. * * 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`)
  91312. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91313. * * 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
  91314. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91315. * * If you create a double-sided mesh, you can choose what parts of 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
  91316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91317. * @param name defines the name of the mesh
  91318. * @param options defines the options used to create the mesh
  91319. * @param scene defines the hosting scene
  91320. * @returns a new Mesh
  91321. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91322. */
  91323. static CreateIcoSphere(name: string, options: {
  91324. radius?: number;
  91325. flat?: boolean;
  91326. subdivisions?: number;
  91327. sideOrientation?: number;
  91328. updatable?: boolean;
  91329. }, scene: Scene): Mesh;
  91330. /**
  91331. * Creates a decal mesh.
  91332. * Please consider using the same method from the MeshBuilder class instead.
  91333. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91334. * @param name defines the name of the mesh
  91335. * @param sourceMesh defines the mesh receiving the decal
  91336. * @param position sets the position of the decal in world coordinates
  91337. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91338. * @param size sets the decal scaling
  91339. * @param angle sets the angle to rotate the decal
  91340. * @returns a new Mesh
  91341. */
  91342. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91343. /**
  91344. * Prepare internal position array for software CPU skinning
  91345. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91346. */
  91347. setPositionsForCPUSkinning(): Float32Array;
  91348. /**
  91349. * Prepare internal normal array for software CPU skinning
  91350. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91351. */
  91352. setNormalsForCPUSkinning(): Float32Array;
  91353. /**
  91354. * Updates the vertex buffer by applying transformation from the bones
  91355. * @param skeleton defines the skeleton to apply to current mesh
  91356. * @returns the current mesh
  91357. */
  91358. applySkeleton(skeleton: Skeleton): Mesh;
  91359. /**
  91360. * 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
  91361. * @param meshes defines the list of meshes to scan
  91362. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91363. */
  91364. static MinMax(meshes: AbstractMesh[]): {
  91365. min: Vector3;
  91366. max: Vector3;
  91367. };
  91368. /**
  91369. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91370. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91371. * @returns a vector3
  91372. */
  91373. static Center(meshesOrMinMaxVector: {
  91374. min: Vector3;
  91375. max: Vector3;
  91376. } | AbstractMesh[]): Vector3;
  91377. /**
  91378. * Merge the array of meshes into a single mesh for performance reasons.
  91379. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91380. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91381. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91382. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91383. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91384. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91385. * @returns a new mesh
  91386. */
  91387. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91388. /** @hidden */
  91389. addInstance(instance: InstancedMesh): void;
  91390. /** @hidden */
  91391. removeInstance(instance: InstancedMesh): void;
  91392. }
  91393. }
  91394. declare module BABYLON {
  91395. /**
  91396. * This is the base class of all the camera used in the application.
  91397. * @see http://doc.babylonjs.com/features/cameras
  91398. */
  91399. export class Camera extends Node {
  91400. /** @hidden */
  91401. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91402. /**
  91403. * This is the default projection mode used by the cameras.
  91404. * It helps recreating a feeling of perspective and better appreciate depth.
  91405. * This is the best way to simulate real life cameras.
  91406. */
  91407. static readonly PERSPECTIVE_CAMERA: number;
  91408. /**
  91409. * This helps creating camera with an orthographic mode.
  91410. * 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.
  91411. */
  91412. static readonly ORTHOGRAPHIC_CAMERA: number;
  91413. /**
  91414. * This is the default FOV mode for perspective cameras.
  91415. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91416. */
  91417. static readonly FOVMODE_VERTICAL_FIXED: number;
  91418. /**
  91419. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91420. */
  91421. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91422. /**
  91423. * This specifies ther is no need for a camera rig.
  91424. * Basically only one eye is rendered corresponding to the camera.
  91425. */
  91426. static readonly RIG_MODE_NONE: number;
  91427. /**
  91428. * Simulates a camera Rig with one blue eye and one red eye.
  91429. * This can be use with 3d blue and red glasses.
  91430. */
  91431. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91432. /**
  91433. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91434. */
  91435. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91436. /**
  91437. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91438. */
  91439. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91440. /**
  91441. * Defines that both eyes of the camera will be rendered over under each other.
  91442. */
  91443. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91444. /**
  91445. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91446. */
  91447. static readonly RIG_MODE_VR: number;
  91448. /**
  91449. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91450. */
  91451. static readonly RIG_MODE_WEBVR: number;
  91452. /**
  91453. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91454. */
  91455. static readonly RIG_MODE_CUSTOM: number;
  91456. /**
  91457. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91458. */
  91459. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91460. /**
  91461. * Define the input manager associated with the camera.
  91462. */
  91463. inputs: CameraInputsManager<Camera>;
  91464. /** @hidden */
  91465. _position: Vector3;
  91466. /**
  91467. * Define the current local position of the camera in the scene
  91468. */
  91469. position: Vector3;
  91470. /**
  91471. * The vector the camera should consider as up.
  91472. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91473. */
  91474. upVector: Vector3;
  91475. /**
  91476. * Define the current limit on the left side for an orthographic camera
  91477. * In scene unit
  91478. */
  91479. orthoLeft: Nullable<number>;
  91480. /**
  91481. * Define the current limit on the right side for an orthographic camera
  91482. * In scene unit
  91483. */
  91484. orthoRight: Nullable<number>;
  91485. /**
  91486. * Define the current limit on the bottom side for an orthographic camera
  91487. * In scene unit
  91488. */
  91489. orthoBottom: Nullable<number>;
  91490. /**
  91491. * Define the current limit on the top side for an orthographic camera
  91492. * In scene unit
  91493. */
  91494. orthoTop: Nullable<number>;
  91495. /**
  91496. * Field Of View is set in Radians. (default is 0.8)
  91497. */
  91498. fov: number;
  91499. /**
  91500. * Define the minimum distance the camera can see from.
  91501. * This is important to note that the depth buffer are not infinite and the closer it starts
  91502. * the more your scene might encounter depth fighting issue.
  91503. */
  91504. minZ: number;
  91505. /**
  91506. * Define the maximum distance the camera can see to.
  91507. * This is important to note that the depth buffer are not infinite and the further it end
  91508. * the more your scene might encounter depth fighting issue.
  91509. */
  91510. maxZ: number;
  91511. /**
  91512. * Define the default inertia of the camera.
  91513. * This helps giving a smooth feeling to the camera movement.
  91514. */
  91515. inertia: number;
  91516. /**
  91517. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91518. */
  91519. mode: number;
  91520. /**
  91521. * Define wether the camera is intermediate.
  91522. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91523. */
  91524. isIntermediate: boolean;
  91525. /**
  91526. * Define the viewport of the camera.
  91527. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91528. */
  91529. viewport: Viewport;
  91530. /**
  91531. * Restricts the camera to viewing objects with the same layerMask.
  91532. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91533. */
  91534. layerMask: number;
  91535. /**
  91536. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91537. */
  91538. fovMode: number;
  91539. /**
  91540. * Rig mode of the camera.
  91541. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91542. * This is normally controlled byt the camera themselves as internal use.
  91543. */
  91544. cameraRigMode: number;
  91545. /**
  91546. * Defines the distance between both "eyes" in case of a RIG
  91547. */
  91548. interaxialDistance: number;
  91549. /**
  91550. * Defines if stereoscopic rendering is done side by side or over under.
  91551. */
  91552. isStereoscopicSideBySide: boolean;
  91553. /**
  91554. * 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
  91555. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91556. * else in the scene. (Eg. security camera)
  91557. *
  91558. * 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)
  91559. */
  91560. customRenderTargets: RenderTargetTexture[];
  91561. /**
  91562. * When set, the camera will render to this render target instead of the default canvas
  91563. *
  91564. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91565. */
  91566. outputRenderTarget: Nullable<RenderTargetTexture>;
  91567. /**
  91568. * Observable triggered when the camera view matrix has changed.
  91569. */
  91570. onViewMatrixChangedObservable: Observable<Camera>;
  91571. /**
  91572. * Observable triggered when the camera Projection matrix has changed.
  91573. */
  91574. onProjectionMatrixChangedObservable: Observable<Camera>;
  91575. /**
  91576. * Observable triggered when the inputs have been processed.
  91577. */
  91578. onAfterCheckInputsObservable: Observable<Camera>;
  91579. /**
  91580. * Observable triggered when reset has been called and applied to the camera.
  91581. */
  91582. onRestoreStateObservable: Observable<Camera>;
  91583. /** @hidden */
  91584. _cameraRigParams: any;
  91585. /** @hidden */
  91586. _rigCameras: Camera[];
  91587. /** @hidden */
  91588. _rigPostProcess: Nullable<PostProcess>;
  91589. protected _webvrViewMatrix: Matrix;
  91590. /** @hidden */
  91591. _skipRendering: boolean;
  91592. /** @hidden */
  91593. _projectionMatrix: Matrix;
  91594. /** @hidden */
  91595. _postProcesses: Nullable<PostProcess>[];
  91596. /** @hidden */
  91597. _activeMeshes: SmartArray<AbstractMesh>;
  91598. protected _globalPosition: Vector3;
  91599. /** @hidden */
  91600. _computedViewMatrix: Matrix;
  91601. private _doNotComputeProjectionMatrix;
  91602. private _transformMatrix;
  91603. private _frustumPlanes;
  91604. private _refreshFrustumPlanes;
  91605. private _storedFov;
  91606. private _stateStored;
  91607. /**
  91608. * Instantiates a new camera object.
  91609. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91610. * @see http://doc.babylonjs.com/features/cameras
  91611. * @param name Defines the name of the camera in the scene
  91612. * @param position Defines the position of the camera
  91613. * @param scene Defines the scene the camera belongs too
  91614. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91615. */
  91616. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91617. /**
  91618. * Store current camera state (fov, position, etc..)
  91619. * @returns the camera
  91620. */
  91621. storeState(): Camera;
  91622. /**
  91623. * Restores the camera state values if it has been stored. You must call storeState() first
  91624. */
  91625. protected _restoreStateValues(): boolean;
  91626. /**
  91627. * Restored camera state. You must call storeState() first.
  91628. * @returns true if restored and false otherwise
  91629. */
  91630. restoreState(): boolean;
  91631. /**
  91632. * Gets the class name of the camera.
  91633. * @returns the class name
  91634. */
  91635. getClassName(): string;
  91636. /** @hidden */
  91637. readonly _isCamera: boolean;
  91638. /**
  91639. * Gets a string representation of the camera useful for debug purpose.
  91640. * @param fullDetails Defines that a more verboe level of logging is required
  91641. * @returns the string representation
  91642. */
  91643. toString(fullDetails?: boolean): string;
  91644. /**
  91645. * Gets the current world space position of the camera.
  91646. */
  91647. readonly globalPosition: Vector3;
  91648. /**
  91649. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91650. * @returns the active meshe list
  91651. */
  91652. getActiveMeshes(): SmartArray<AbstractMesh>;
  91653. /**
  91654. * Check wether a mesh is part of the current active mesh list of the camera
  91655. * @param mesh Defines the mesh to check
  91656. * @returns true if active, false otherwise
  91657. */
  91658. isActiveMesh(mesh: Mesh): boolean;
  91659. /**
  91660. * Is this camera ready to be used/rendered
  91661. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91662. * @return true if the camera is ready
  91663. */
  91664. isReady(completeCheck?: boolean): boolean;
  91665. /** @hidden */
  91666. _initCache(): void;
  91667. /** @hidden */
  91668. _updateCache(ignoreParentClass?: boolean): void;
  91669. /** @hidden */
  91670. _isSynchronized(): boolean;
  91671. /** @hidden */
  91672. _isSynchronizedViewMatrix(): boolean;
  91673. /** @hidden */
  91674. _isSynchronizedProjectionMatrix(): boolean;
  91675. /**
  91676. * Attach the input controls to a specific dom element to get the input from.
  91677. * @param element Defines the element the controls should be listened from
  91678. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91679. */
  91680. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91681. /**
  91682. * Detach the current controls from the specified dom element.
  91683. * @param element Defines the element to stop listening the inputs from
  91684. */
  91685. detachControl(element: HTMLElement): void;
  91686. /**
  91687. * Update the camera state according to the different inputs gathered during the frame.
  91688. */
  91689. update(): void;
  91690. /** @hidden */
  91691. _checkInputs(): void;
  91692. /** @hidden */
  91693. readonly rigCameras: Camera[];
  91694. /**
  91695. * Gets the post process used by the rig cameras
  91696. */
  91697. readonly rigPostProcess: Nullable<PostProcess>;
  91698. /**
  91699. * Internal, gets the first post proces.
  91700. * @returns the first post process to be run on this camera.
  91701. */
  91702. _getFirstPostProcess(): Nullable<PostProcess>;
  91703. private _cascadePostProcessesToRigCams;
  91704. /**
  91705. * Attach a post process to the camera.
  91706. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91707. * @param postProcess The post process to attach to the camera
  91708. * @param insertAt The position of the post process in case several of them are in use in the scene
  91709. * @returns the position the post process has been inserted at
  91710. */
  91711. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91712. /**
  91713. * Detach a post process to the camera.
  91714. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91715. * @param postProcess The post process to detach from the camera
  91716. */
  91717. detachPostProcess(postProcess: PostProcess): void;
  91718. /**
  91719. * Gets the current world matrix of the camera
  91720. */
  91721. getWorldMatrix(): Matrix;
  91722. /** @hidden */
  91723. _getViewMatrix(): Matrix;
  91724. /**
  91725. * Gets the current view matrix of the camera.
  91726. * @param force forces the camera to recompute the matrix without looking at the cached state
  91727. * @returns the view matrix
  91728. */
  91729. getViewMatrix(force?: boolean): Matrix;
  91730. /**
  91731. * Freeze the projection matrix.
  91732. * It will prevent the cache check of the camera projection compute and can speed up perf
  91733. * if no parameter of the camera are meant to change
  91734. * @param projection Defines manually a projection if necessary
  91735. */
  91736. freezeProjectionMatrix(projection?: Matrix): void;
  91737. /**
  91738. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91739. */
  91740. unfreezeProjectionMatrix(): void;
  91741. /**
  91742. * Gets the current projection matrix of the camera.
  91743. * @param force forces the camera to recompute the matrix without looking at the cached state
  91744. * @returns the projection matrix
  91745. */
  91746. getProjectionMatrix(force?: boolean): Matrix;
  91747. /**
  91748. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91749. * @returns a Matrix
  91750. */
  91751. getTransformationMatrix(): Matrix;
  91752. private _updateFrustumPlanes;
  91753. /**
  91754. * Checks if a cullable object (mesh...) is in the camera frustum
  91755. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91756. * @param target The object to check
  91757. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91758. * @returns true if the object is in frustum otherwise false
  91759. */
  91760. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91761. /**
  91762. * Checks if a cullable object (mesh...) is in the camera frustum
  91763. * Unlike isInFrustum this cheks the full bounding box
  91764. * @param target The object to check
  91765. * @returns true if the object is in frustum otherwise false
  91766. */
  91767. isCompletelyInFrustum(target: ICullable): boolean;
  91768. /**
  91769. * Gets a ray in the forward direction from the camera.
  91770. * @param length Defines the length of the ray to create
  91771. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91772. * @param origin Defines the start point of the ray which defaults to the camera position
  91773. * @returns the forward ray
  91774. */
  91775. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91776. /**
  91777. * Releases resources associated with this node.
  91778. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91779. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91780. */
  91781. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91782. /** @hidden */
  91783. _isLeftCamera: boolean;
  91784. /**
  91785. * Gets the left camera of a rig setup in case of Rigged Camera
  91786. */
  91787. readonly isLeftCamera: boolean;
  91788. /** @hidden */
  91789. _isRightCamera: boolean;
  91790. /**
  91791. * Gets the right camera of a rig setup in case of Rigged Camera
  91792. */
  91793. readonly isRightCamera: boolean;
  91794. /**
  91795. * Gets the left camera of a rig setup in case of Rigged Camera
  91796. */
  91797. readonly leftCamera: Nullable<FreeCamera>;
  91798. /**
  91799. * Gets the right camera of a rig setup in case of Rigged Camera
  91800. */
  91801. readonly rightCamera: Nullable<FreeCamera>;
  91802. /**
  91803. * Gets the left camera target of a rig setup in case of Rigged Camera
  91804. * @returns the target position
  91805. */
  91806. getLeftTarget(): Nullable<Vector3>;
  91807. /**
  91808. * Gets the right camera target of a rig setup in case of Rigged Camera
  91809. * @returns the target position
  91810. */
  91811. getRightTarget(): Nullable<Vector3>;
  91812. /**
  91813. * @hidden
  91814. */
  91815. setCameraRigMode(mode: number, rigParams: any): void;
  91816. /** @hidden */
  91817. static _setStereoscopicRigMode(camera: Camera): void;
  91818. /** @hidden */
  91819. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91820. /** @hidden */
  91821. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91822. /** @hidden */
  91823. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91824. /** @hidden */
  91825. _getVRProjectionMatrix(): Matrix;
  91826. protected _updateCameraRotationMatrix(): void;
  91827. protected _updateWebVRCameraRotationMatrix(): void;
  91828. /**
  91829. * This function MUST be overwritten by the different WebVR cameras available.
  91830. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91831. * @hidden
  91832. */
  91833. _getWebVRProjectionMatrix(): Matrix;
  91834. /**
  91835. * This function MUST be overwritten by the different WebVR cameras available.
  91836. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91837. * @hidden
  91838. */
  91839. _getWebVRViewMatrix(): Matrix;
  91840. /** @hidden */
  91841. setCameraRigParameter(name: string, value: any): void;
  91842. /**
  91843. * needs to be overridden by children so sub has required properties to be copied
  91844. * @hidden
  91845. */
  91846. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91847. /**
  91848. * May need to be overridden by children
  91849. * @hidden
  91850. */
  91851. _updateRigCameras(): void;
  91852. /** @hidden */
  91853. _setupInputs(): void;
  91854. /**
  91855. * Serialiaze the camera setup to a json represention
  91856. * @returns the JSON representation
  91857. */
  91858. serialize(): any;
  91859. /**
  91860. * Clones the current camera.
  91861. * @param name The cloned camera name
  91862. * @returns the cloned camera
  91863. */
  91864. clone(name: string): Camera;
  91865. /**
  91866. * Gets the direction of the camera relative to a given local axis.
  91867. * @param localAxis Defines the reference axis to provide a relative direction.
  91868. * @return the direction
  91869. */
  91870. getDirection(localAxis: Vector3): Vector3;
  91871. /**
  91872. * Returns the current camera absolute rotation
  91873. */
  91874. readonly absoluteRotation: Quaternion;
  91875. /**
  91876. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91877. * @param localAxis Defines the reference axis to provide a relative direction.
  91878. * @param result Defines the vector to store the result in
  91879. */
  91880. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91881. /**
  91882. * Gets a camera constructor for a given camera type
  91883. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91884. * @param name The name of the camera the result will be able to instantiate
  91885. * @param scene The scene the result will construct the camera in
  91886. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91887. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91888. * @returns a factory method to construc the camera
  91889. */
  91890. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91891. /**
  91892. * Compute the world matrix of the camera.
  91893. * @returns the camera workd matrix
  91894. */
  91895. computeWorldMatrix(): Matrix;
  91896. /**
  91897. * Parse a JSON and creates the camera from the parsed information
  91898. * @param parsedCamera The JSON to parse
  91899. * @param scene The scene to instantiate the camera in
  91900. * @returns the newly constructed camera
  91901. */
  91902. static Parse(parsedCamera: any, scene: Scene): Camera;
  91903. }
  91904. }
  91905. declare module BABYLON {
  91906. /**
  91907. * Class containing static functions to help procedurally build meshes
  91908. */
  91909. export class DiscBuilder {
  91910. /**
  91911. * Creates a plane polygonal mesh. By default, this is a disc
  91912. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91913. * * 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
  91914. * * 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
  91915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  91917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91918. * @param name defines the name of the mesh
  91919. * @param options defines the options used to create the mesh
  91920. * @param scene defines the hosting scene
  91921. * @returns the plane polygonal mesh
  91922. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91923. */
  91924. static CreateDisc(name: string, options: {
  91925. radius?: number;
  91926. tessellation?: number;
  91927. arc?: number;
  91928. updatable?: boolean;
  91929. sideOrientation?: number;
  91930. frontUVs?: Vector4;
  91931. backUVs?: Vector4;
  91932. }, scene?: Nullable<Scene>): Mesh;
  91933. }
  91934. }
  91935. declare module BABYLON {
  91936. /**
  91937. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91938. *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.
  91939. * The SPS is also a particle system. It provides some methods to manage the particles.
  91940. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91941. *
  91942. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91943. */
  91944. export class SolidParticleSystem implements IDisposable {
  91945. /**
  91946. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91947. * Example : var p = SPS.particles[i];
  91948. */
  91949. particles: SolidParticle[];
  91950. /**
  91951. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91952. */
  91953. nbParticles: number;
  91954. /**
  91955. * If the particles must ever face the camera (default false). Useful for planar particles.
  91956. */
  91957. billboard: boolean;
  91958. /**
  91959. * Recompute normals when adding a shape
  91960. */
  91961. recomputeNormals: boolean;
  91962. /**
  91963. * This a counter ofr your own usage. It's not set by any SPS functions.
  91964. */
  91965. counter: number;
  91966. /**
  91967. * The SPS name. This name is also given to the underlying mesh.
  91968. */
  91969. name: string;
  91970. /**
  91971. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91972. */
  91973. mesh: Mesh;
  91974. /**
  91975. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  91976. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  91977. */
  91978. vars: any;
  91979. /**
  91980. * This array is populated when the SPS is set as 'pickable'.
  91981. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  91982. * Each element of this array is an object `{idx: int, faceId: int}`.
  91983. * `idx` is the picked particle index in the `SPS.particles` array
  91984. * `faceId` is the picked face index counted within this particle.
  91985. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  91986. */
  91987. pickedParticles: {
  91988. idx: number;
  91989. faceId: number;
  91990. }[];
  91991. /**
  91992. * This array is populated when `enableDepthSort` is set to true.
  91993. * Each element of this array is an instance of the class DepthSortedParticle.
  91994. */
  91995. depthSortedParticles: DepthSortedParticle[];
  91996. /**
  91997. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  91998. * @hidden
  91999. */
  92000. _bSphereOnly: boolean;
  92001. /**
  92002. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92003. * @hidden
  92004. */
  92005. _bSphereRadiusFactor: number;
  92006. private _scene;
  92007. private _positions;
  92008. private _indices;
  92009. private _normals;
  92010. private _colors;
  92011. private _uvs;
  92012. private _indices32;
  92013. private _positions32;
  92014. private _normals32;
  92015. private _fixedNormal32;
  92016. private _colors32;
  92017. private _uvs32;
  92018. private _index;
  92019. private _updatable;
  92020. private _pickable;
  92021. private _isVisibilityBoxLocked;
  92022. private _alwaysVisible;
  92023. private _depthSort;
  92024. private _shapeCounter;
  92025. private _copy;
  92026. private _color;
  92027. private _computeParticleColor;
  92028. private _computeParticleTexture;
  92029. private _computeParticleRotation;
  92030. private _computeParticleVertex;
  92031. private _computeBoundingBox;
  92032. private _depthSortParticles;
  92033. private _camera;
  92034. private _mustUnrotateFixedNormals;
  92035. private _particlesIntersect;
  92036. private _needs32Bits;
  92037. /**
  92038. * Creates a SPS (Solid Particle System) object.
  92039. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92040. * @param scene (Scene) is the scene in which the SPS is added.
  92041. * @param options defines the options of the sps e.g.
  92042. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92043. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92044. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92045. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92046. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92047. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92048. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92049. */
  92050. constructor(name: string, scene: Scene, options?: {
  92051. updatable?: boolean;
  92052. isPickable?: boolean;
  92053. enableDepthSort?: boolean;
  92054. particleIntersection?: boolean;
  92055. boundingSphereOnly?: boolean;
  92056. bSphereRadiusFactor?: number;
  92057. });
  92058. /**
  92059. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92060. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92061. * @returns the created mesh
  92062. */
  92063. buildMesh(): Mesh;
  92064. /**
  92065. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92066. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92067. * Thus the particles generated from `digest()` have their property `position` set yet.
  92068. * @param mesh ( Mesh ) is the mesh to be digested
  92069. * @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
  92070. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92071. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92072. * @returns the current SPS
  92073. */
  92074. digest(mesh: Mesh, options?: {
  92075. facetNb?: number;
  92076. number?: number;
  92077. delta?: number;
  92078. }): SolidParticleSystem;
  92079. private _unrotateFixedNormals;
  92080. private _resetCopy;
  92081. private _meshBuilder;
  92082. private _posToShape;
  92083. private _uvsToShapeUV;
  92084. private _addParticle;
  92085. /**
  92086. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92087. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92088. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92089. * @param nb (positive integer) the number of particles to be created from this model
  92090. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92091. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92092. * @returns the number of shapes in the system
  92093. */
  92094. addShape(mesh: Mesh, nb: number, options?: {
  92095. positionFunction?: any;
  92096. vertexFunction?: any;
  92097. }): number;
  92098. private _rebuildParticle;
  92099. /**
  92100. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92101. * @returns the SPS.
  92102. */
  92103. rebuildMesh(): SolidParticleSystem;
  92104. /**
  92105. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92106. * This method calls `updateParticle()` for each particle of the SPS.
  92107. * For an animated SPS, it is usually called within the render loop.
  92108. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92109. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92110. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92111. * @returns the SPS.
  92112. */
  92113. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92114. /**
  92115. * Disposes the SPS.
  92116. */
  92117. dispose(): void;
  92118. /**
  92119. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92120. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92121. * @returns the SPS.
  92122. */
  92123. refreshVisibleSize(): SolidParticleSystem;
  92124. /**
  92125. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92126. * @param size the size (float) of the visibility box
  92127. * note : this doesn't lock the SPS mesh bounding box.
  92128. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92129. */
  92130. setVisibilityBox(size: number): void;
  92131. /**
  92132. * Gets whether the SPS as always visible or not
  92133. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92134. */
  92135. /**
  92136. * Sets the SPS as always visible or not
  92137. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92138. */
  92139. isAlwaysVisible: boolean;
  92140. /**
  92141. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92142. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92143. */
  92144. /**
  92145. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92146. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92147. */
  92148. isVisibilityBoxLocked: boolean;
  92149. /**
  92150. * Tells to `setParticles()` to compute the particle rotations or not.
  92151. * Default value : true. The SPS is faster when it's set to false.
  92152. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92153. */
  92154. /**
  92155. * Gets if `setParticles()` computes the particle rotations or not.
  92156. * Default value : true. The SPS is faster when it's set to false.
  92157. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92158. */
  92159. computeParticleRotation: boolean;
  92160. /**
  92161. * Tells to `setParticles()` to compute the particle colors or not.
  92162. * Default value : true. The SPS is faster when it's set to false.
  92163. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92164. */
  92165. /**
  92166. * Gets if `setParticles()` computes the particle colors or not.
  92167. * Default value : true. The SPS is faster when it's set to false.
  92168. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92169. */
  92170. computeParticleColor: boolean;
  92171. /**
  92172. * Gets if `setParticles()` computes the particle textures or not.
  92173. * Default value : true. The SPS is faster when it's set to false.
  92174. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92175. */
  92176. computeParticleTexture: boolean;
  92177. /**
  92178. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92179. * Default value : false. The SPS is faster when it's set to false.
  92180. * Note : the particle custom vertex positions aren't stored values.
  92181. */
  92182. /**
  92183. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92184. * Default value : false. The SPS is faster when it's set to false.
  92185. * Note : the particle custom vertex positions aren't stored values.
  92186. */
  92187. computeParticleVertex: boolean;
  92188. /**
  92189. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92190. */
  92191. /**
  92192. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92193. */
  92194. computeBoundingBox: boolean;
  92195. /**
  92196. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92197. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92198. * Default : `true`
  92199. */
  92200. /**
  92201. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92202. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92203. * Default : `true`
  92204. */
  92205. depthSortParticles: boolean;
  92206. /**
  92207. * This function does nothing. It may be overwritten to set all the particle first values.
  92208. * The SPS doesn't call this function, you may have to call it by your own.
  92209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92210. */
  92211. initParticles(): void;
  92212. /**
  92213. * This function does nothing. It may be overwritten to recycle a particle.
  92214. * The SPS doesn't call this function, you may have to call it by your own.
  92215. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92216. * @param particle The particle to recycle
  92217. * @returns the recycled particle
  92218. */
  92219. recycleParticle(particle: SolidParticle): SolidParticle;
  92220. /**
  92221. * Updates a particle : this function should be overwritten by the user.
  92222. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92223. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92224. * @example : just set a particle position or velocity and recycle conditions
  92225. * @param particle The particle to update
  92226. * @returns the updated particle
  92227. */
  92228. updateParticle(particle: SolidParticle): SolidParticle;
  92229. /**
  92230. * Updates a vertex of a particle : it can be overwritten by the user.
  92231. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92232. * @param particle the current particle
  92233. * @param vertex the current index of the current particle
  92234. * @param pt the index of the current vertex in the particle shape
  92235. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92236. * @example : just set a vertex particle position
  92237. * @returns the updated vertex
  92238. */
  92239. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92240. /**
  92241. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92242. * This does nothing and may be overwritten by the user.
  92243. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92244. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92245. * @param update the boolean update value actually passed to setParticles()
  92246. */
  92247. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92248. /**
  92249. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92250. * This will be passed three parameters.
  92251. * This does nothing and may be overwritten by the user.
  92252. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92253. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92254. * @param update the boolean update value actually passed to setParticles()
  92255. */
  92256. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92257. }
  92258. }
  92259. declare module BABYLON {
  92260. /**
  92261. * Represents one particle of a solid particle system.
  92262. */
  92263. export class SolidParticle {
  92264. /**
  92265. * particle global index
  92266. */
  92267. idx: number;
  92268. /**
  92269. * The color of the particle
  92270. */
  92271. color: Nullable<Color4>;
  92272. /**
  92273. * The world space position of the particle.
  92274. */
  92275. position: Vector3;
  92276. /**
  92277. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92278. */
  92279. rotation: Vector3;
  92280. /**
  92281. * The world space rotation quaternion of the particle.
  92282. */
  92283. rotationQuaternion: Nullable<Quaternion>;
  92284. /**
  92285. * The scaling of the particle.
  92286. */
  92287. scaling: Vector3;
  92288. /**
  92289. * The uvs of the particle.
  92290. */
  92291. uvs: Vector4;
  92292. /**
  92293. * The current speed of the particle.
  92294. */
  92295. velocity: Vector3;
  92296. /**
  92297. * The pivot point in the particle local space.
  92298. */
  92299. pivot: Vector3;
  92300. /**
  92301. * Must the particle be translated from its pivot point in its local space ?
  92302. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92303. * Default : false
  92304. */
  92305. translateFromPivot: boolean;
  92306. /**
  92307. * Is the particle active or not ?
  92308. */
  92309. alive: boolean;
  92310. /**
  92311. * Is the particle visible or not ?
  92312. */
  92313. isVisible: boolean;
  92314. /**
  92315. * Index of this particle in the global "positions" array (Internal use)
  92316. * @hidden
  92317. */
  92318. _pos: number;
  92319. /**
  92320. * @hidden Index of this particle in the global "indices" array (Internal use)
  92321. */
  92322. _ind: number;
  92323. /**
  92324. * @hidden ModelShape of this particle (Internal use)
  92325. */
  92326. _model: ModelShape;
  92327. /**
  92328. * ModelShape id of this particle
  92329. */
  92330. shapeId: number;
  92331. /**
  92332. * Index of the particle in its shape id
  92333. */
  92334. idxInShape: number;
  92335. /**
  92336. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92337. */
  92338. _modelBoundingInfo: BoundingInfo;
  92339. /**
  92340. * @hidden Particle BoundingInfo object (Internal use)
  92341. */
  92342. _boundingInfo: BoundingInfo;
  92343. /**
  92344. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92345. */
  92346. _sps: SolidParticleSystem;
  92347. /**
  92348. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92349. */
  92350. _stillInvisible: boolean;
  92351. /**
  92352. * @hidden Last computed particle rotation matrix
  92353. */
  92354. _rotationMatrix: number[];
  92355. /**
  92356. * Parent particle Id, if any.
  92357. * Default null.
  92358. */
  92359. parentId: Nullable<number>;
  92360. /**
  92361. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92362. * The possible values are :
  92363. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92364. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92365. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92366. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92367. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92368. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92369. * */
  92370. cullingStrategy: number;
  92371. /**
  92372. * @hidden Internal global position in the SPS.
  92373. */
  92374. _globalPosition: Vector3;
  92375. /**
  92376. * Creates a Solid Particle object.
  92377. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92378. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92379. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92380. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92381. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92382. * @param shapeId (integer) is the model shape identifier in the SPS.
  92383. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92384. * @param sps defines the sps it is associated to
  92385. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92386. */
  92387. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92388. /**
  92389. * Legacy support, changed scale to scaling
  92390. */
  92391. /**
  92392. * Legacy support, changed scale to scaling
  92393. */
  92394. scale: Vector3;
  92395. /**
  92396. * Legacy support, changed quaternion to rotationQuaternion
  92397. */
  92398. /**
  92399. * Legacy support, changed quaternion to rotationQuaternion
  92400. */
  92401. quaternion: Nullable<Quaternion>;
  92402. /**
  92403. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92404. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92405. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92406. * @returns true if it intersects
  92407. */
  92408. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92409. /**
  92410. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92411. * A particle is in the frustum if its bounding box intersects the frustum
  92412. * @param frustumPlanes defines the frustum to test
  92413. * @returns true if the particle is in the frustum planes
  92414. */
  92415. isInFrustum(frustumPlanes: Plane[]): boolean;
  92416. /**
  92417. * get the rotation matrix of the particle
  92418. * @hidden
  92419. */
  92420. getRotationMatrix(m: Matrix): void;
  92421. }
  92422. /**
  92423. * Represents the shape of the model used by one particle of a solid particle system.
  92424. * SPS internal tool, don't use it manually.
  92425. */
  92426. export class ModelShape {
  92427. /**
  92428. * The shape id
  92429. * @hidden
  92430. */
  92431. shapeID: number;
  92432. /**
  92433. * flat array of model positions (internal use)
  92434. * @hidden
  92435. */
  92436. _shape: Vector3[];
  92437. /**
  92438. * flat array of model UVs (internal use)
  92439. * @hidden
  92440. */
  92441. _shapeUV: number[];
  92442. /**
  92443. * length of the shape in the model indices array (internal use)
  92444. * @hidden
  92445. */
  92446. _indicesLength: number;
  92447. /**
  92448. * Custom position function (internal use)
  92449. * @hidden
  92450. */
  92451. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92452. /**
  92453. * Custom vertex function (internal use)
  92454. * @hidden
  92455. */
  92456. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92457. /**
  92458. * 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.
  92459. * SPS internal tool, don't use it manually.
  92460. * @hidden
  92461. */
  92462. 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>);
  92463. }
  92464. /**
  92465. * Represents a Depth Sorted Particle in the solid particle system.
  92466. */
  92467. export class DepthSortedParticle {
  92468. /**
  92469. * Index of the particle in the "indices" array
  92470. */
  92471. ind: number;
  92472. /**
  92473. * Length of the particle shape in the "indices" array
  92474. */
  92475. indicesLength: number;
  92476. /**
  92477. * Squared distance from the particle to the camera
  92478. */
  92479. sqDistance: number;
  92480. }
  92481. }
  92482. declare module BABYLON {
  92483. /**
  92484. * @hidden
  92485. */
  92486. export class _MeshCollisionData {
  92487. _checkCollisions: boolean;
  92488. _collisionMask: number;
  92489. _collisionGroup: number;
  92490. _collider: Nullable<Collider>;
  92491. _oldPositionForCollisions: Vector3;
  92492. _diffPositionForCollisions: Vector3;
  92493. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92494. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92495. }
  92496. }
  92497. declare module BABYLON {
  92498. /** @hidden */
  92499. class _FacetDataStorage {
  92500. facetPositions: Vector3[];
  92501. facetNormals: Vector3[];
  92502. facetPartitioning: number[][];
  92503. facetNb: number;
  92504. partitioningSubdivisions: number;
  92505. partitioningBBoxRatio: number;
  92506. facetDataEnabled: boolean;
  92507. facetParameters: any;
  92508. bbSize: Vector3;
  92509. subDiv: {
  92510. max: number;
  92511. X: number;
  92512. Y: number;
  92513. Z: number;
  92514. };
  92515. facetDepthSort: boolean;
  92516. facetDepthSortEnabled: boolean;
  92517. depthSortedIndices: IndicesArray;
  92518. depthSortedFacets: {
  92519. ind: number;
  92520. sqDistance: number;
  92521. }[];
  92522. facetDepthSortFunction: (f1: {
  92523. ind: number;
  92524. sqDistance: number;
  92525. }, f2: {
  92526. ind: number;
  92527. sqDistance: number;
  92528. }) => number;
  92529. facetDepthSortFrom: Vector3;
  92530. facetDepthSortOrigin: Vector3;
  92531. invertedMatrix: Matrix;
  92532. }
  92533. /**
  92534. * @hidden
  92535. **/
  92536. class _InternalAbstractMeshDataInfo {
  92537. _hasVertexAlpha: boolean;
  92538. _useVertexColors: boolean;
  92539. _numBoneInfluencers: number;
  92540. _applyFog: boolean;
  92541. _receiveShadows: boolean;
  92542. _facetData: _FacetDataStorage;
  92543. _visibility: number;
  92544. _skeleton: Nullable<Skeleton>;
  92545. _layerMask: number;
  92546. _computeBonesUsingShaders: boolean;
  92547. _isActive: boolean;
  92548. _onlyForInstances: boolean;
  92549. _isActiveIntermediate: boolean;
  92550. _onlyForInstancesIntermediate: boolean;
  92551. }
  92552. /**
  92553. * Class used to store all common mesh properties
  92554. */
  92555. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92556. /** No occlusion */
  92557. static OCCLUSION_TYPE_NONE: number;
  92558. /** Occlusion set to optimisitic */
  92559. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92560. /** Occlusion set to strict */
  92561. static OCCLUSION_TYPE_STRICT: number;
  92562. /** Use an accurante occlusion algorithm */
  92563. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92564. /** Use a conservative occlusion algorithm */
  92565. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92566. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92567. * Test order :
  92568. * Is the bounding sphere outside the frustum ?
  92569. * If not, are the bounding box vertices outside the frustum ?
  92570. * It not, then the cullable object is in the frustum.
  92571. */
  92572. static readonly CULLINGSTRATEGY_STANDARD: number;
  92573. /** Culling strategy : Bounding Sphere Only.
  92574. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92575. * It's also less accurate than the standard because some not visible objects can still be selected.
  92576. * Test : is the bounding sphere outside the frustum ?
  92577. * If not, then the cullable object is in the frustum.
  92578. */
  92579. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92580. /** Culling strategy : Optimistic Inclusion.
  92581. * This in an inclusion test first, then the standard exclusion test.
  92582. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92583. * 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.
  92584. * Anyway, it's as accurate as the standard strategy.
  92585. * Test :
  92586. * Is the cullable object bounding sphere center in the frustum ?
  92587. * If not, apply the default culling strategy.
  92588. */
  92589. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92590. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92591. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92592. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92593. * 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.
  92594. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92595. * Test :
  92596. * Is the cullable object bounding sphere center in the frustum ?
  92597. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92598. */
  92599. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92600. /**
  92601. * No billboard
  92602. */
  92603. static readonly BILLBOARDMODE_NONE: number;
  92604. /** Billboard on X axis */
  92605. static readonly BILLBOARDMODE_X: number;
  92606. /** Billboard on Y axis */
  92607. static readonly BILLBOARDMODE_Y: number;
  92608. /** Billboard on Z axis */
  92609. static readonly BILLBOARDMODE_Z: number;
  92610. /** Billboard on all axes */
  92611. static readonly BILLBOARDMODE_ALL: number;
  92612. /** Billboard on using position instead of orientation */
  92613. static readonly BILLBOARDMODE_USE_POSITION: number;
  92614. /** @hidden */
  92615. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92616. /**
  92617. * The culling strategy to use to check whether the mesh must be rendered or not.
  92618. * This value can be changed at any time and will be used on the next render mesh selection.
  92619. * The possible values are :
  92620. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92621. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92622. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92623. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92624. * Please read each static variable documentation to get details about the culling process.
  92625. * */
  92626. cullingStrategy: number;
  92627. /**
  92628. * Gets the number of facets in the mesh
  92629. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92630. */
  92631. readonly facetNb: number;
  92632. /**
  92633. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92634. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92635. */
  92636. partitioningSubdivisions: number;
  92637. /**
  92638. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92639. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92641. */
  92642. partitioningBBoxRatio: number;
  92643. /**
  92644. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92645. * Works only for updatable meshes.
  92646. * Doesn't work with multi-materials
  92647. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92648. */
  92649. mustDepthSortFacets: boolean;
  92650. /**
  92651. * The location (Vector3) where the facet depth sort must be computed from.
  92652. * By default, the active camera position.
  92653. * Used only when facet depth sort is enabled
  92654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92655. */
  92656. facetDepthSortFrom: Vector3;
  92657. /**
  92658. * gets a boolean indicating if facetData is enabled
  92659. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92660. */
  92661. readonly isFacetDataEnabled: boolean;
  92662. /** @hidden */
  92663. _updateNonUniformScalingState(value: boolean): boolean;
  92664. /**
  92665. * An event triggered when this mesh collides with another one
  92666. */
  92667. onCollideObservable: Observable<AbstractMesh>;
  92668. /** Set a function to call when this mesh collides with another one */
  92669. onCollide: () => void;
  92670. /**
  92671. * An event triggered when the collision's position changes
  92672. */
  92673. onCollisionPositionChangeObservable: Observable<Vector3>;
  92674. /** Set a function to call when the collision's position changes */
  92675. onCollisionPositionChange: () => void;
  92676. /**
  92677. * An event triggered when material is changed
  92678. */
  92679. onMaterialChangedObservable: Observable<AbstractMesh>;
  92680. /**
  92681. * Gets or sets the orientation for POV movement & rotation
  92682. */
  92683. definedFacingForward: boolean;
  92684. /** @hidden */
  92685. _occlusionQuery: Nullable<WebGLQuery>;
  92686. /** @hidden */
  92687. _renderingGroup: Nullable<RenderingGroup>;
  92688. /**
  92689. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92690. */
  92691. /**
  92692. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92693. */
  92694. visibility: number;
  92695. /** Gets or sets the alpha index used to sort transparent meshes
  92696. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92697. */
  92698. alphaIndex: number;
  92699. /**
  92700. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92701. */
  92702. isVisible: boolean;
  92703. /**
  92704. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92705. */
  92706. isPickable: boolean;
  92707. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92708. showSubMeshesBoundingBox: boolean;
  92709. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92710. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92711. */
  92712. isBlocker: boolean;
  92713. /**
  92714. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92715. */
  92716. enablePointerMoveEvents: boolean;
  92717. /**
  92718. * Specifies the rendering group id for this mesh (0 by default)
  92719. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92720. */
  92721. renderingGroupId: number;
  92722. private _material;
  92723. /** Gets or sets current material */
  92724. material: Nullable<Material>;
  92725. /**
  92726. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92727. * @see http://doc.babylonjs.com/babylon101/shadows
  92728. */
  92729. receiveShadows: boolean;
  92730. /** Defines color to use when rendering outline */
  92731. outlineColor: Color3;
  92732. /** Define width to use when rendering outline */
  92733. outlineWidth: number;
  92734. /** Defines color to use when rendering overlay */
  92735. overlayColor: Color3;
  92736. /** Defines alpha to use when rendering overlay */
  92737. overlayAlpha: number;
  92738. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92739. hasVertexAlpha: boolean;
  92740. /** 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) */
  92741. useVertexColors: boolean;
  92742. /**
  92743. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92744. */
  92745. computeBonesUsingShaders: boolean;
  92746. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92747. numBoneInfluencers: number;
  92748. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92749. applyFog: boolean;
  92750. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92751. useOctreeForRenderingSelection: boolean;
  92752. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92753. useOctreeForPicking: boolean;
  92754. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92755. useOctreeForCollisions: boolean;
  92756. /**
  92757. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92758. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92759. */
  92760. layerMask: number;
  92761. /**
  92762. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92763. */
  92764. alwaysSelectAsActiveMesh: boolean;
  92765. /**
  92766. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92767. */
  92768. doNotSyncBoundingInfo: boolean;
  92769. /**
  92770. * Gets or sets the current action manager
  92771. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92772. */
  92773. actionManager: Nullable<AbstractActionManager>;
  92774. private _meshCollisionData;
  92775. /**
  92776. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92777. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92778. */
  92779. ellipsoid: Vector3;
  92780. /**
  92781. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92783. */
  92784. ellipsoidOffset: Vector3;
  92785. /**
  92786. * Gets or sets a collision mask used to mask collisions (default is -1).
  92787. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92788. */
  92789. collisionMask: number;
  92790. /**
  92791. * Gets or sets the current collision group mask (-1 by default).
  92792. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92793. */
  92794. collisionGroup: number;
  92795. /**
  92796. * Defines edge width used when edgesRenderer is enabled
  92797. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92798. */
  92799. edgesWidth: number;
  92800. /**
  92801. * Defines edge color used when edgesRenderer is enabled
  92802. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92803. */
  92804. edgesColor: Color4;
  92805. /** @hidden */
  92806. _edgesRenderer: Nullable<IEdgesRenderer>;
  92807. /** @hidden */
  92808. _masterMesh: Nullable<AbstractMesh>;
  92809. /** @hidden */
  92810. _boundingInfo: Nullable<BoundingInfo>;
  92811. /** @hidden */
  92812. _renderId: number;
  92813. /**
  92814. * Gets or sets the list of subMeshes
  92815. * @see http://doc.babylonjs.com/how_to/multi_materials
  92816. */
  92817. subMeshes: SubMesh[];
  92818. /** @hidden */
  92819. _intersectionsInProgress: AbstractMesh[];
  92820. /** @hidden */
  92821. _unIndexed: boolean;
  92822. /** @hidden */
  92823. _lightSources: Light[];
  92824. /** Gets the list of lights affecting that mesh */
  92825. readonly lightSources: Light[];
  92826. /** @hidden */
  92827. readonly _positions: Nullable<Vector3[]>;
  92828. /** @hidden */
  92829. _waitingData: {
  92830. lods: Nullable<any>;
  92831. actions: Nullable<any>;
  92832. freezeWorldMatrix: Nullable<boolean>;
  92833. };
  92834. /** @hidden */
  92835. _bonesTransformMatrices: Nullable<Float32Array>;
  92836. /** @hidden */
  92837. _transformMatrixTexture: Nullable<RawTexture>;
  92838. /**
  92839. * Gets or sets a skeleton to apply skining transformations
  92840. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92841. */
  92842. skeleton: Nullable<Skeleton>;
  92843. /**
  92844. * An event triggered when the mesh is rebuilt.
  92845. */
  92846. onRebuildObservable: Observable<AbstractMesh>;
  92847. /**
  92848. * Creates a new AbstractMesh
  92849. * @param name defines the name of the mesh
  92850. * @param scene defines the hosting scene
  92851. */
  92852. constructor(name: string, scene?: Nullable<Scene>);
  92853. /**
  92854. * Returns the string "AbstractMesh"
  92855. * @returns "AbstractMesh"
  92856. */
  92857. getClassName(): string;
  92858. /**
  92859. * Gets a string representation of the current mesh
  92860. * @param fullDetails defines a boolean indicating if full details must be included
  92861. * @returns a string representation of the current mesh
  92862. */
  92863. toString(fullDetails?: boolean): string;
  92864. /**
  92865. * @hidden
  92866. */
  92867. protected _getEffectiveParent(): Nullable<Node>;
  92868. /** @hidden */
  92869. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92870. /** @hidden */
  92871. _rebuild(): void;
  92872. /** @hidden */
  92873. _resyncLightSources(): void;
  92874. /** @hidden */
  92875. _resyncLighSource(light: Light): void;
  92876. /** @hidden */
  92877. _unBindEffect(): void;
  92878. /** @hidden */
  92879. _removeLightSource(light: Light, dispose: boolean): void;
  92880. private _markSubMeshesAsDirty;
  92881. /** @hidden */
  92882. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92883. /** @hidden */
  92884. _markSubMeshesAsAttributesDirty(): void;
  92885. /** @hidden */
  92886. _markSubMeshesAsMiscDirty(): void;
  92887. /**
  92888. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92889. */
  92890. scaling: Vector3;
  92891. /**
  92892. * Returns true if the mesh is blocked. Implemented by child classes
  92893. */
  92894. readonly isBlocked: boolean;
  92895. /**
  92896. * Returns the mesh itself by default. Implemented by child classes
  92897. * @param camera defines the camera to use to pick the right LOD level
  92898. * @returns the currentAbstractMesh
  92899. */
  92900. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92901. /**
  92902. * Returns 0 by default. Implemented by child classes
  92903. * @returns an integer
  92904. */
  92905. getTotalVertices(): number;
  92906. /**
  92907. * Returns a positive integer : the total number of indices in this mesh geometry.
  92908. * @returns the numner of indices or zero if the mesh has no geometry.
  92909. */
  92910. getTotalIndices(): number;
  92911. /**
  92912. * Returns null by default. Implemented by child classes
  92913. * @returns null
  92914. */
  92915. getIndices(): Nullable<IndicesArray>;
  92916. /**
  92917. * Returns the array of the requested vertex data kind. Implemented by child classes
  92918. * @param kind defines the vertex data kind to use
  92919. * @returns null
  92920. */
  92921. getVerticesData(kind: string): Nullable<FloatArray>;
  92922. /**
  92923. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92924. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92925. * Note that a new underlying VertexBuffer object is created each call.
  92926. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92927. * @param kind defines vertex data kind:
  92928. * * VertexBuffer.PositionKind
  92929. * * VertexBuffer.UVKind
  92930. * * VertexBuffer.UV2Kind
  92931. * * VertexBuffer.UV3Kind
  92932. * * VertexBuffer.UV4Kind
  92933. * * VertexBuffer.UV5Kind
  92934. * * VertexBuffer.UV6Kind
  92935. * * VertexBuffer.ColorKind
  92936. * * VertexBuffer.MatricesIndicesKind
  92937. * * VertexBuffer.MatricesIndicesExtraKind
  92938. * * VertexBuffer.MatricesWeightsKind
  92939. * * VertexBuffer.MatricesWeightsExtraKind
  92940. * @param data defines the data source
  92941. * @param updatable defines if the data must be flagged as updatable (or static)
  92942. * @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
  92943. * @returns the current mesh
  92944. */
  92945. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92946. /**
  92947. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92948. * If the mesh has no geometry, it is simply returned as it is.
  92949. * @param kind defines vertex data kind:
  92950. * * VertexBuffer.PositionKind
  92951. * * VertexBuffer.UVKind
  92952. * * VertexBuffer.UV2Kind
  92953. * * VertexBuffer.UV3Kind
  92954. * * VertexBuffer.UV4Kind
  92955. * * VertexBuffer.UV5Kind
  92956. * * VertexBuffer.UV6Kind
  92957. * * VertexBuffer.ColorKind
  92958. * * VertexBuffer.MatricesIndicesKind
  92959. * * VertexBuffer.MatricesIndicesExtraKind
  92960. * * VertexBuffer.MatricesWeightsKind
  92961. * * VertexBuffer.MatricesWeightsExtraKind
  92962. * @param data defines the data source
  92963. * @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
  92964. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92965. * @returns the current mesh
  92966. */
  92967. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  92968. /**
  92969. * Sets the mesh indices,
  92970. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  92971. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  92972. * @param totalVertices Defines the total number of vertices
  92973. * @returns the current mesh
  92974. */
  92975. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  92976. /**
  92977. * Gets a boolean indicating if specific vertex data is present
  92978. * @param kind defines the vertex data kind to use
  92979. * @returns true is data kind is present
  92980. */
  92981. isVerticesDataPresent(kind: string): boolean;
  92982. /**
  92983. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  92984. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  92985. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  92986. * @returns a BoundingInfo
  92987. */
  92988. getBoundingInfo(): BoundingInfo;
  92989. /**
  92990. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  92991. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  92992. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  92993. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  92994. * @returns the current mesh
  92995. */
  92996. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  92997. /**
  92998. * Overwrite the current bounding info
  92999. * @param boundingInfo defines the new bounding info
  93000. * @returns the current mesh
  93001. */
  93002. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93003. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93004. readonly useBones: boolean;
  93005. /** @hidden */
  93006. _preActivate(): void;
  93007. /** @hidden */
  93008. _preActivateForIntermediateRendering(renderId: number): void;
  93009. /** @hidden */
  93010. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93011. /** @hidden */
  93012. _postActivate(): void;
  93013. /** @hidden */
  93014. _freeze(): void;
  93015. /** @hidden */
  93016. _unFreeze(): void;
  93017. /**
  93018. * Gets the current world matrix
  93019. * @returns a Matrix
  93020. */
  93021. getWorldMatrix(): Matrix;
  93022. /** @hidden */
  93023. _getWorldMatrixDeterminant(): number;
  93024. /**
  93025. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93026. */
  93027. readonly isAnInstance: boolean;
  93028. /**
  93029. * Gets a boolean indicating if this mesh has instances
  93030. */
  93031. readonly hasInstances: boolean;
  93032. /**
  93033. * Perform relative position change from the point of view of behind the front of the mesh.
  93034. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93035. * Supports definition of mesh facing forward or backward
  93036. * @param amountRight defines the distance on the right axis
  93037. * @param amountUp defines the distance on the up axis
  93038. * @param amountForward defines the distance on the forward axis
  93039. * @returns the current mesh
  93040. */
  93041. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93042. /**
  93043. * Calculate relative position change from the point of view of behind the front of the mesh.
  93044. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93045. * Supports definition of mesh facing forward or backward
  93046. * @param amountRight defines the distance on the right axis
  93047. * @param amountUp defines the distance on the up axis
  93048. * @param amountForward defines the distance on the forward axis
  93049. * @returns the new displacement vector
  93050. */
  93051. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93052. /**
  93053. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93054. * Supports definition of mesh facing forward or backward
  93055. * @param flipBack defines the flip
  93056. * @param twirlClockwise defines the twirl
  93057. * @param tiltRight defines the tilt
  93058. * @returns the current mesh
  93059. */
  93060. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93061. /**
  93062. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93063. * Supports definition of mesh facing forward or backward.
  93064. * @param flipBack defines the flip
  93065. * @param twirlClockwise defines the twirl
  93066. * @param tiltRight defines the tilt
  93067. * @returns the new rotation vector
  93068. */
  93069. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93070. /**
  93071. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93072. * This means the mesh underlying bounding box and sphere are recomputed.
  93073. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93074. * @returns the current mesh
  93075. */
  93076. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93077. /** @hidden */
  93078. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93079. /** @hidden */
  93080. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93081. /** @hidden */
  93082. _updateBoundingInfo(): AbstractMesh;
  93083. /** @hidden */
  93084. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93085. /** @hidden */
  93086. protected _afterComputeWorldMatrix(): void;
  93087. /** @hidden */
  93088. readonly _effectiveMesh: AbstractMesh;
  93089. /**
  93090. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93091. * A mesh is in the frustum if its bounding box intersects the frustum
  93092. * @param frustumPlanes defines the frustum to test
  93093. * @returns true if the mesh is in the frustum planes
  93094. */
  93095. isInFrustum(frustumPlanes: Plane[]): boolean;
  93096. /**
  93097. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93098. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93099. * @param frustumPlanes defines the frustum to test
  93100. * @returns true if the mesh is completely in the frustum planes
  93101. */
  93102. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93103. /**
  93104. * True if the mesh intersects another mesh or a SolidParticle object
  93105. * @param mesh defines a target mesh or SolidParticle to test
  93106. * @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)
  93107. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93108. * @returns true if there is an intersection
  93109. */
  93110. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93111. /**
  93112. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93113. * @param point defines the point to test
  93114. * @returns true if there is an intersection
  93115. */
  93116. intersectsPoint(point: Vector3): boolean;
  93117. /**
  93118. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93119. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93120. */
  93121. checkCollisions: boolean;
  93122. /**
  93123. * Gets Collider object used to compute collisions (not physics)
  93124. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93125. */
  93126. readonly collider: Nullable<Collider>;
  93127. /**
  93128. * Move the mesh using collision engine
  93129. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93130. * @param displacement defines the requested displacement vector
  93131. * @returns the current mesh
  93132. */
  93133. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93134. private _onCollisionPositionChange;
  93135. /** @hidden */
  93136. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93137. /** @hidden */
  93138. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93139. /** @hidden */
  93140. _checkCollision(collider: Collider): AbstractMesh;
  93141. /** @hidden */
  93142. _generatePointsArray(): boolean;
  93143. /**
  93144. * Checks if the passed Ray intersects with the mesh
  93145. * @param ray defines the ray to use
  93146. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93148. * @returns the picking info
  93149. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93150. */
  93151. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93152. /**
  93153. * Clones the current mesh
  93154. * @param name defines the mesh name
  93155. * @param newParent defines the new mesh parent
  93156. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93157. * @returns the new mesh
  93158. */
  93159. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93160. /**
  93161. * Disposes all the submeshes of the current meshnp
  93162. * @returns the current mesh
  93163. */
  93164. releaseSubMeshes(): AbstractMesh;
  93165. /**
  93166. * Releases resources associated with this abstract mesh.
  93167. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93168. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93169. */
  93170. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93171. /**
  93172. * Adds the passed mesh as a child to the current mesh
  93173. * @param mesh defines the child mesh
  93174. * @returns the current mesh
  93175. */
  93176. addChild(mesh: AbstractMesh): AbstractMesh;
  93177. /**
  93178. * Removes the passed mesh from the current mesh children list
  93179. * @param mesh defines the child mesh
  93180. * @returns the current mesh
  93181. */
  93182. removeChild(mesh: AbstractMesh): AbstractMesh;
  93183. /** @hidden */
  93184. private _initFacetData;
  93185. /**
  93186. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93187. * This method can be called within the render loop.
  93188. * 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
  93189. * @returns the current mesh
  93190. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93191. */
  93192. updateFacetData(): AbstractMesh;
  93193. /**
  93194. * Returns the facetLocalNormals array.
  93195. * The normals are expressed in the mesh local spac
  93196. * @returns an array of Vector3
  93197. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93198. */
  93199. getFacetLocalNormals(): Vector3[];
  93200. /**
  93201. * Returns the facetLocalPositions array.
  93202. * The facet positions are expressed in the mesh local space
  93203. * @returns an array of Vector3
  93204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93205. */
  93206. getFacetLocalPositions(): Vector3[];
  93207. /**
  93208. * Returns the facetLocalPartioning array
  93209. * @returns an array of array of numbers
  93210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93211. */
  93212. getFacetLocalPartitioning(): number[][];
  93213. /**
  93214. * Returns the i-th facet position in the world system.
  93215. * This method allocates a new Vector3 per call
  93216. * @param i defines the facet index
  93217. * @returns a new Vector3
  93218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93219. */
  93220. getFacetPosition(i: number): Vector3;
  93221. /**
  93222. * Sets the reference Vector3 with the i-th facet position in the world system
  93223. * @param i defines the facet index
  93224. * @param ref defines the target vector
  93225. * @returns the current mesh
  93226. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93227. */
  93228. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93229. /**
  93230. * Returns the i-th facet normal in the world system.
  93231. * This method allocates a new Vector3 per call
  93232. * @param i defines the facet index
  93233. * @returns a new Vector3
  93234. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93235. */
  93236. getFacetNormal(i: number): Vector3;
  93237. /**
  93238. * Sets the reference Vector3 with the i-th facet normal in the world system
  93239. * @param i defines the facet index
  93240. * @param ref defines the target vector
  93241. * @returns the current mesh
  93242. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93243. */
  93244. getFacetNormalToRef(i: number, ref: Vector3): this;
  93245. /**
  93246. * 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)
  93247. * @param x defines x coordinate
  93248. * @param y defines y coordinate
  93249. * @param z defines z coordinate
  93250. * @returns the array of facet indexes
  93251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93252. */
  93253. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93254. /**
  93255. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93256. * @param projected sets as the (x,y,z) world projection on the facet
  93257. * @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
  93258. * @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
  93259. * @param x defines x coordinate
  93260. * @param y defines y coordinate
  93261. * @param z defines z coordinate
  93262. * @returns the face index if found (or null instead)
  93263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93264. */
  93265. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93266. /**
  93267. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93268. * @param projected sets as the (x,y,z) local projection on the facet
  93269. * @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
  93270. * @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
  93271. * @param x defines x coordinate
  93272. * @param y defines y coordinate
  93273. * @param z defines z coordinate
  93274. * @returns the face index if found (or null instead)
  93275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93276. */
  93277. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93278. /**
  93279. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93280. * @returns the parameters
  93281. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93282. */
  93283. getFacetDataParameters(): any;
  93284. /**
  93285. * Disables the feature FacetData and frees the related memory
  93286. * @returns the current mesh
  93287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93288. */
  93289. disableFacetData(): AbstractMesh;
  93290. /**
  93291. * Updates the AbstractMesh indices array
  93292. * @param indices defines the data source
  93293. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93294. * @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)
  93295. * @returns the current mesh
  93296. */
  93297. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93298. /**
  93299. * Creates new normals data for the mesh
  93300. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93301. * @returns the current mesh
  93302. */
  93303. createNormals(updatable: boolean): AbstractMesh;
  93304. /**
  93305. * Align the mesh with a normal
  93306. * @param normal defines the normal to use
  93307. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93308. * @returns the current mesh
  93309. */
  93310. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93311. /** @hidden */
  93312. _checkOcclusionQuery(): boolean;
  93313. /**
  93314. * Disables the mesh edge rendering mode
  93315. * @returns the currentAbstractMesh
  93316. */
  93317. disableEdgesRendering(): AbstractMesh;
  93318. /**
  93319. * Enables the edge rendering mode on the mesh.
  93320. * This mode makes the mesh edges visible
  93321. * @param epsilon defines the maximal distance between two angles to detect a face
  93322. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93323. * @returns the currentAbstractMesh
  93324. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93325. */
  93326. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93327. }
  93328. }
  93329. declare module BABYLON {
  93330. /**
  93331. * Interface used to define ActionEvent
  93332. */
  93333. export interface IActionEvent {
  93334. /** The mesh or sprite that triggered the action */
  93335. source: any;
  93336. /** The X mouse cursor position at the time of the event */
  93337. pointerX: number;
  93338. /** The Y mouse cursor position at the time of the event */
  93339. pointerY: number;
  93340. /** The mesh that is currently pointed at (can be null) */
  93341. meshUnderPointer: Nullable<AbstractMesh>;
  93342. /** the original (browser) event that triggered the ActionEvent */
  93343. sourceEvent?: any;
  93344. /** additional data for the event */
  93345. additionalData?: any;
  93346. }
  93347. /**
  93348. * ActionEvent is the event being sent when an action is triggered.
  93349. */
  93350. export class ActionEvent implements IActionEvent {
  93351. /** The mesh or sprite that triggered the action */
  93352. source: any;
  93353. /** The X mouse cursor position at the time of the event */
  93354. pointerX: number;
  93355. /** The Y mouse cursor position at the time of the event */
  93356. pointerY: number;
  93357. /** The mesh that is currently pointed at (can be null) */
  93358. meshUnderPointer: Nullable<AbstractMesh>;
  93359. /** the original (browser) event that triggered the ActionEvent */
  93360. sourceEvent?: any;
  93361. /** additional data for the event */
  93362. additionalData?: any;
  93363. /**
  93364. * Creates a new ActionEvent
  93365. * @param source The mesh or sprite that triggered the action
  93366. * @param pointerX The X mouse cursor position at the time of the event
  93367. * @param pointerY The Y mouse cursor position at the time of the event
  93368. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93369. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93370. * @param additionalData additional data for the event
  93371. */
  93372. constructor(
  93373. /** The mesh or sprite that triggered the action */
  93374. source: any,
  93375. /** The X mouse cursor position at the time of the event */
  93376. pointerX: number,
  93377. /** The Y mouse cursor position at the time of the event */
  93378. pointerY: number,
  93379. /** The mesh that is currently pointed at (can be null) */
  93380. meshUnderPointer: Nullable<AbstractMesh>,
  93381. /** the original (browser) event that triggered the ActionEvent */
  93382. sourceEvent?: any,
  93383. /** additional data for the event */
  93384. additionalData?: any);
  93385. /**
  93386. * Helper function to auto-create an ActionEvent from a source mesh.
  93387. * @param source The source mesh that triggered the event
  93388. * @param evt The original (browser) event
  93389. * @param additionalData additional data for the event
  93390. * @returns the new ActionEvent
  93391. */
  93392. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93393. /**
  93394. * Helper function to auto-create an ActionEvent from a source sprite
  93395. * @param source The source sprite that triggered the event
  93396. * @param scene Scene associated with the sprite
  93397. * @param evt The original (browser) event
  93398. * @param additionalData additional data for the event
  93399. * @returns the new ActionEvent
  93400. */
  93401. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93402. /**
  93403. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93404. * @param scene the scene where the event occurred
  93405. * @param evt The original (browser) event
  93406. * @returns the new ActionEvent
  93407. */
  93408. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93409. /**
  93410. * Helper function to auto-create an ActionEvent from a primitive
  93411. * @param prim defines the target primitive
  93412. * @param pointerPos defines the pointer position
  93413. * @param evt The original (browser) event
  93414. * @param additionalData additional data for the event
  93415. * @returns the new ActionEvent
  93416. */
  93417. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93418. }
  93419. }
  93420. declare module BABYLON {
  93421. /**
  93422. * Abstract class used to decouple action Manager from scene and meshes.
  93423. * Do not instantiate.
  93424. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93425. */
  93426. export abstract class AbstractActionManager implements IDisposable {
  93427. /** Gets the list of active triggers */
  93428. static Triggers: {
  93429. [key: string]: number;
  93430. };
  93431. /** Gets the cursor to use when hovering items */
  93432. hoverCursor: string;
  93433. /** Gets the list of actions */
  93434. actions: IAction[];
  93435. /**
  93436. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93437. */
  93438. isRecursive: boolean;
  93439. /**
  93440. * Releases all associated resources
  93441. */
  93442. abstract dispose(): void;
  93443. /**
  93444. * Does this action manager has pointer triggers
  93445. */
  93446. abstract readonly hasPointerTriggers: boolean;
  93447. /**
  93448. * Does this action manager has pick triggers
  93449. */
  93450. abstract readonly hasPickTriggers: boolean;
  93451. /**
  93452. * Process a specific trigger
  93453. * @param trigger defines the trigger to process
  93454. * @param evt defines the event details to be processed
  93455. */
  93456. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93457. /**
  93458. * Does this action manager handles actions of any of the given triggers
  93459. * @param triggers defines the triggers to be tested
  93460. * @return a boolean indicating whether one (or more) of the triggers is handled
  93461. */
  93462. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93463. /**
  93464. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93465. * speed.
  93466. * @param triggerA defines the trigger to be tested
  93467. * @param triggerB defines the trigger to be tested
  93468. * @return a boolean indicating whether one (or more) of the triggers is handled
  93469. */
  93470. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93471. /**
  93472. * Does this action manager handles actions of a given trigger
  93473. * @param trigger defines the trigger to be tested
  93474. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93475. * @return whether the trigger is handled
  93476. */
  93477. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93478. /**
  93479. * Serialize this manager to a JSON object
  93480. * @param name defines the property name to store this manager
  93481. * @returns a JSON representation of this manager
  93482. */
  93483. abstract serialize(name: string): any;
  93484. /**
  93485. * Registers an action to this action manager
  93486. * @param action defines the action to be registered
  93487. * @return the action amended (prepared) after registration
  93488. */
  93489. abstract registerAction(action: IAction): Nullable<IAction>;
  93490. /**
  93491. * Unregisters an action to this action manager
  93492. * @param action defines the action to be unregistered
  93493. * @return a boolean indicating whether the action has been unregistered
  93494. */
  93495. abstract unregisterAction(action: IAction): Boolean;
  93496. /**
  93497. * Does exist one action manager with at least one trigger
  93498. **/
  93499. static readonly HasTriggers: boolean;
  93500. /**
  93501. * Does exist one action manager with at least one pick trigger
  93502. **/
  93503. static readonly HasPickTriggers: boolean;
  93504. /**
  93505. * Does exist one action manager that handles actions of a given trigger
  93506. * @param trigger defines the trigger to be tested
  93507. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93508. **/
  93509. static HasSpecificTrigger(trigger: number): boolean;
  93510. }
  93511. }
  93512. declare module BABYLON {
  93513. /**
  93514. * Defines how a node can be built from a string name.
  93515. */
  93516. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93517. /**
  93518. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93519. */
  93520. export class Node implements IBehaviorAware<Node> {
  93521. /** @hidden */
  93522. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93523. private static _NodeConstructors;
  93524. /**
  93525. * Add a new node constructor
  93526. * @param type defines the type name of the node to construct
  93527. * @param constructorFunc defines the constructor function
  93528. */
  93529. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93530. /**
  93531. * Returns a node constructor based on type name
  93532. * @param type defines the type name
  93533. * @param name defines the new node name
  93534. * @param scene defines the hosting scene
  93535. * @param options defines optional options to transmit to constructors
  93536. * @returns the new constructor or null
  93537. */
  93538. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93539. /**
  93540. * Gets or sets the name of the node
  93541. */
  93542. name: string;
  93543. /**
  93544. * Gets or sets the id of the node
  93545. */
  93546. id: string;
  93547. /**
  93548. * Gets or sets the unique id of the node
  93549. */
  93550. uniqueId: number;
  93551. /**
  93552. * Gets or sets a string used to store user defined state for the node
  93553. */
  93554. state: string;
  93555. /**
  93556. * Gets or sets an object used to store user defined information for the node
  93557. */
  93558. metadata: any;
  93559. /**
  93560. * For internal use only. Please do not use.
  93561. */
  93562. reservedDataStore: any;
  93563. /**
  93564. * List of inspectable custom properties (used by the Inspector)
  93565. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93566. */
  93567. inspectableCustomProperties: IInspectable[];
  93568. private _doNotSerialize;
  93569. /**
  93570. * Gets or sets a boolean used to define if the node must be serialized
  93571. */
  93572. doNotSerialize: boolean;
  93573. /** @hidden */
  93574. _isDisposed: boolean;
  93575. /**
  93576. * Gets a list of Animations associated with the node
  93577. */
  93578. animations: Animation[];
  93579. protected _ranges: {
  93580. [name: string]: Nullable<AnimationRange>;
  93581. };
  93582. /**
  93583. * Callback raised when the node is ready to be used
  93584. */
  93585. onReady: Nullable<(node: Node) => void>;
  93586. private _isEnabled;
  93587. private _isParentEnabled;
  93588. private _isReady;
  93589. /** @hidden */
  93590. _currentRenderId: number;
  93591. private _parentUpdateId;
  93592. /** @hidden */
  93593. _childUpdateId: number;
  93594. /** @hidden */
  93595. _waitingParentId: Nullable<string>;
  93596. /** @hidden */
  93597. _scene: Scene;
  93598. /** @hidden */
  93599. _cache: any;
  93600. private _parentNode;
  93601. private _children;
  93602. /** @hidden */
  93603. _worldMatrix: Matrix;
  93604. /** @hidden */
  93605. _worldMatrixDeterminant: number;
  93606. /** @hidden */
  93607. _worldMatrixDeterminantIsDirty: boolean;
  93608. /** @hidden */
  93609. private _sceneRootNodesIndex;
  93610. /**
  93611. * Gets a boolean indicating if the node has been disposed
  93612. * @returns true if the node was disposed
  93613. */
  93614. isDisposed(): boolean;
  93615. /**
  93616. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93617. * @see https://doc.babylonjs.com/how_to/parenting
  93618. */
  93619. parent: Nullable<Node>;
  93620. private addToSceneRootNodes;
  93621. private removeFromSceneRootNodes;
  93622. private _animationPropertiesOverride;
  93623. /**
  93624. * Gets or sets the animation properties override
  93625. */
  93626. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93627. /**
  93628. * Gets a string idenfifying the name of the class
  93629. * @returns "Node" string
  93630. */
  93631. getClassName(): string;
  93632. /** @hidden */
  93633. readonly _isNode: boolean;
  93634. /**
  93635. * An event triggered when the mesh is disposed
  93636. */
  93637. onDisposeObservable: Observable<Node>;
  93638. private _onDisposeObserver;
  93639. /**
  93640. * Sets a callback that will be raised when the node will be disposed
  93641. */
  93642. onDispose: () => void;
  93643. /**
  93644. * Creates a new Node
  93645. * @param name the name and id to be given to this node
  93646. * @param scene the scene this node will be added to
  93647. * @param addToRootNodes the node will be added to scene.rootNodes
  93648. */
  93649. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93650. /**
  93651. * Gets the scene of the node
  93652. * @returns a scene
  93653. */
  93654. getScene(): Scene;
  93655. /**
  93656. * Gets the engine of the node
  93657. * @returns a Engine
  93658. */
  93659. getEngine(): Engine;
  93660. private _behaviors;
  93661. /**
  93662. * Attach a behavior to the node
  93663. * @see http://doc.babylonjs.com/features/behaviour
  93664. * @param behavior defines the behavior to attach
  93665. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93666. * @returns the current Node
  93667. */
  93668. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93669. /**
  93670. * Remove an attached behavior
  93671. * @see http://doc.babylonjs.com/features/behaviour
  93672. * @param behavior defines the behavior to attach
  93673. * @returns the current Node
  93674. */
  93675. removeBehavior(behavior: Behavior<Node>): Node;
  93676. /**
  93677. * Gets the list of attached behaviors
  93678. * @see http://doc.babylonjs.com/features/behaviour
  93679. */
  93680. readonly behaviors: Behavior<Node>[];
  93681. /**
  93682. * Gets an attached behavior by name
  93683. * @param name defines the name of the behavior to look for
  93684. * @see http://doc.babylonjs.com/features/behaviour
  93685. * @returns null if behavior was not found else the requested behavior
  93686. */
  93687. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93688. /**
  93689. * Returns the latest update of the World matrix
  93690. * @returns a Matrix
  93691. */
  93692. getWorldMatrix(): Matrix;
  93693. /** @hidden */
  93694. _getWorldMatrixDeterminant(): number;
  93695. /**
  93696. * Returns directly the latest state of the mesh World matrix.
  93697. * A Matrix is returned.
  93698. */
  93699. readonly worldMatrixFromCache: Matrix;
  93700. /** @hidden */
  93701. _initCache(): void;
  93702. /** @hidden */
  93703. updateCache(force?: boolean): void;
  93704. /** @hidden */
  93705. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93706. /** @hidden */
  93707. _updateCache(ignoreParentClass?: boolean): void;
  93708. /** @hidden */
  93709. _isSynchronized(): boolean;
  93710. /** @hidden */
  93711. _markSyncedWithParent(): void;
  93712. /** @hidden */
  93713. isSynchronizedWithParent(): boolean;
  93714. /** @hidden */
  93715. isSynchronized(): boolean;
  93716. /**
  93717. * Is this node ready to be used/rendered
  93718. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93719. * @return true if the node is ready
  93720. */
  93721. isReady(completeCheck?: boolean): boolean;
  93722. /**
  93723. * Is this node enabled?
  93724. * 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
  93725. * @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
  93726. * @return whether this node (and its parent) is enabled
  93727. */
  93728. isEnabled(checkAncestors?: boolean): boolean;
  93729. /** @hidden */
  93730. protected _syncParentEnabledState(): void;
  93731. /**
  93732. * Set the enabled state of this node
  93733. * @param value defines the new enabled state
  93734. */
  93735. setEnabled(value: boolean): void;
  93736. /**
  93737. * Is this node a descendant of the given node?
  93738. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93739. * @param ancestor defines the parent node to inspect
  93740. * @returns a boolean indicating if this node is a descendant of the given node
  93741. */
  93742. isDescendantOf(ancestor: Node): boolean;
  93743. /** @hidden */
  93744. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93745. /**
  93746. * Will return all nodes that have this node as ascendant
  93747. * @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
  93748. * @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
  93749. * @return all children nodes of all types
  93750. */
  93751. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93752. /**
  93753. * Get all child-meshes of this node
  93754. * @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)
  93755. * @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
  93756. * @returns an array of AbstractMesh
  93757. */
  93758. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93759. /**
  93760. * Get all direct children of this node
  93761. * @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
  93762. * @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)
  93763. * @returns an array of Node
  93764. */
  93765. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93766. /** @hidden */
  93767. _setReady(state: boolean): void;
  93768. /**
  93769. * Get an animation by name
  93770. * @param name defines the name of the animation to look for
  93771. * @returns null if not found else the requested animation
  93772. */
  93773. getAnimationByName(name: string): Nullable<Animation>;
  93774. /**
  93775. * Creates an animation range for this node
  93776. * @param name defines the name of the range
  93777. * @param from defines the starting key
  93778. * @param to defines the end key
  93779. */
  93780. createAnimationRange(name: string, from: number, to: number): void;
  93781. /**
  93782. * Delete a specific animation range
  93783. * @param name defines the name of the range to delete
  93784. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93785. */
  93786. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93787. /**
  93788. * Get an animation range by name
  93789. * @param name defines the name of the animation range to look for
  93790. * @returns null if not found else the requested animation range
  93791. */
  93792. getAnimationRange(name: string): Nullable<AnimationRange>;
  93793. /**
  93794. * Gets the list of all animation ranges defined on this node
  93795. * @returns an array
  93796. */
  93797. getAnimationRanges(): Nullable<AnimationRange>[];
  93798. /**
  93799. * Will start the animation sequence
  93800. * @param name defines the range frames for animation sequence
  93801. * @param loop defines if the animation should loop (false by default)
  93802. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93803. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93804. * @returns the object created for this animation. If range does not exist, it will return null
  93805. */
  93806. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93807. /**
  93808. * Serialize animation ranges into a JSON compatible object
  93809. * @returns serialization object
  93810. */
  93811. serializeAnimationRanges(): any;
  93812. /**
  93813. * Computes the world matrix of the node
  93814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93815. * @returns the world matrix
  93816. */
  93817. computeWorldMatrix(force?: boolean): Matrix;
  93818. /**
  93819. * Releases resources associated with this node.
  93820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93822. */
  93823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93824. /**
  93825. * Parse animation range data from a serialization object and store them into a given node
  93826. * @param node defines where to store the animation ranges
  93827. * @param parsedNode defines the serialization object to read data from
  93828. * @param scene defines the hosting scene
  93829. */
  93830. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93831. /**
  93832. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93833. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93834. * @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
  93835. * @returns the new bounding vectors
  93836. */
  93837. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93838. min: Vector3;
  93839. max: Vector3;
  93840. };
  93841. }
  93842. }
  93843. declare module BABYLON {
  93844. /**
  93845. * @hidden
  93846. */
  93847. export class _IAnimationState {
  93848. key: number;
  93849. repeatCount: number;
  93850. workValue?: any;
  93851. loopMode?: number;
  93852. offsetValue?: any;
  93853. highLimitValue?: any;
  93854. }
  93855. /**
  93856. * Class used to store any kind of animation
  93857. */
  93858. export class Animation {
  93859. /**Name of the animation */
  93860. name: string;
  93861. /**Property to animate */
  93862. targetProperty: string;
  93863. /**The frames per second of the animation */
  93864. framePerSecond: number;
  93865. /**The data type of the animation */
  93866. dataType: number;
  93867. /**The loop mode of the animation */
  93868. loopMode?: number | undefined;
  93869. /**Specifies if blending should be enabled */
  93870. enableBlending?: boolean | undefined;
  93871. /**
  93872. * Use matrix interpolation instead of using direct key value when animating matrices
  93873. */
  93874. static AllowMatricesInterpolation: boolean;
  93875. /**
  93876. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93877. */
  93878. static AllowMatrixDecomposeForInterpolation: boolean;
  93879. /**
  93880. * Stores the key frames of the animation
  93881. */
  93882. private _keys;
  93883. /**
  93884. * Stores the easing function of the animation
  93885. */
  93886. private _easingFunction;
  93887. /**
  93888. * @hidden Internal use only
  93889. */
  93890. _runtimeAnimations: RuntimeAnimation[];
  93891. /**
  93892. * The set of event that will be linked to this animation
  93893. */
  93894. private _events;
  93895. /**
  93896. * Stores an array of target property paths
  93897. */
  93898. targetPropertyPath: string[];
  93899. /**
  93900. * Stores the blending speed of the animation
  93901. */
  93902. blendingSpeed: number;
  93903. /**
  93904. * Stores the animation ranges for the animation
  93905. */
  93906. private _ranges;
  93907. /**
  93908. * @hidden Internal use
  93909. */
  93910. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93911. /**
  93912. * Sets up an animation
  93913. * @param property The property to animate
  93914. * @param animationType The animation type to apply
  93915. * @param framePerSecond The frames per second of the animation
  93916. * @param easingFunction The easing function used in the animation
  93917. * @returns The created animation
  93918. */
  93919. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93920. /**
  93921. * Create and start an animation on a node
  93922. * @param name defines the name of the global animation that will be run on all nodes
  93923. * @param node defines the root node where the animation will take place
  93924. * @param targetProperty defines property to animate
  93925. * @param framePerSecond defines the number of frame per second yo use
  93926. * @param totalFrame defines the number of frames in total
  93927. * @param from defines the initial value
  93928. * @param to defines the final value
  93929. * @param loopMode defines which loop mode you want to use (off by default)
  93930. * @param easingFunction defines the easing function to use (linear by default)
  93931. * @param onAnimationEnd defines the callback to call when animation end
  93932. * @returns the animatable created for this animation
  93933. */
  93934. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93935. /**
  93936. * Create and start an animation on a node and its descendants
  93937. * @param name defines the name of the global animation that will be run on all nodes
  93938. * @param node defines the root node where the animation will take place
  93939. * @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
  93940. * @param targetProperty defines property to animate
  93941. * @param framePerSecond defines the number of frame per second to use
  93942. * @param totalFrame defines the number of frames in total
  93943. * @param from defines the initial value
  93944. * @param to defines the final value
  93945. * @param loopMode defines which loop mode you want to use (off by default)
  93946. * @param easingFunction defines the easing function to use (linear by default)
  93947. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93948. * @returns the list of animatables created for all nodes
  93949. * @example https://www.babylonjs-playground.com/#MH0VLI
  93950. */
  93951. 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[]>;
  93952. /**
  93953. * Creates a new animation, merges it with the existing animations and starts it
  93954. * @param name Name of the animation
  93955. * @param node Node which contains the scene that begins the animations
  93956. * @param targetProperty Specifies which property to animate
  93957. * @param framePerSecond The frames per second of the animation
  93958. * @param totalFrame The total number of frames
  93959. * @param from The frame at the beginning of the animation
  93960. * @param to The frame at the end of the animation
  93961. * @param loopMode Specifies the loop mode of the animation
  93962. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93963. * @param onAnimationEnd Callback to run once the animation is complete
  93964. * @returns Nullable animation
  93965. */
  93966. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93967. /**
  93968. * Transition property of an host to the target Value
  93969. * @param property The property to transition
  93970. * @param targetValue The target Value of the property
  93971. * @param host The object where the property to animate belongs
  93972. * @param scene Scene used to run the animation
  93973. * @param frameRate Framerate (in frame/s) to use
  93974. * @param transition The transition type we want to use
  93975. * @param duration The duration of the animation, in milliseconds
  93976. * @param onAnimationEnd Callback trigger at the end of the animation
  93977. * @returns Nullable animation
  93978. */
  93979. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  93980. /**
  93981. * Return the array of runtime animations currently using this animation
  93982. */
  93983. readonly runtimeAnimations: RuntimeAnimation[];
  93984. /**
  93985. * Specifies if any of the runtime animations are currently running
  93986. */
  93987. readonly hasRunningRuntimeAnimations: boolean;
  93988. /**
  93989. * Initializes the animation
  93990. * @param name Name of the animation
  93991. * @param targetProperty Property to animate
  93992. * @param framePerSecond The frames per second of the animation
  93993. * @param dataType The data type of the animation
  93994. * @param loopMode The loop mode of the animation
  93995. * @param enableBlending Specifies if blending should be enabled
  93996. */
  93997. constructor(
  93998. /**Name of the animation */
  93999. name: string,
  94000. /**Property to animate */
  94001. targetProperty: string,
  94002. /**The frames per second of the animation */
  94003. framePerSecond: number,
  94004. /**The data type of the animation */
  94005. dataType: number,
  94006. /**The loop mode of the animation */
  94007. loopMode?: number | undefined,
  94008. /**Specifies if blending should be enabled */
  94009. enableBlending?: boolean | undefined);
  94010. /**
  94011. * Converts the animation to a string
  94012. * @param fullDetails support for multiple levels of logging within scene loading
  94013. * @returns String form of the animation
  94014. */
  94015. toString(fullDetails?: boolean): string;
  94016. /**
  94017. * Add an event to this animation
  94018. * @param event Event to add
  94019. */
  94020. addEvent(event: AnimationEvent): void;
  94021. /**
  94022. * Remove all events found at the given frame
  94023. * @param frame The frame to remove events from
  94024. */
  94025. removeEvents(frame: number): void;
  94026. /**
  94027. * Retrieves all the events from the animation
  94028. * @returns Events from the animation
  94029. */
  94030. getEvents(): AnimationEvent[];
  94031. /**
  94032. * Creates an animation range
  94033. * @param name Name of the animation range
  94034. * @param from Starting frame of the animation range
  94035. * @param to Ending frame of the animation
  94036. */
  94037. createRange(name: string, from: number, to: number): void;
  94038. /**
  94039. * Deletes an animation range by name
  94040. * @param name Name of the animation range to delete
  94041. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94042. */
  94043. deleteRange(name: string, deleteFrames?: boolean): void;
  94044. /**
  94045. * Gets the animation range by name, or null if not defined
  94046. * @param name Name of the animation range
  94047. * @returns Nullable animation range
  94048. */
  94049. getRange(name: string): Nullable<AnimationRange>;
  94050. /**
  94051. * Gets the key frames from the animation
  94052. * @returns The key frames of the animation
  94053. */
  94054. getKeys(): Array<IAnimationKey>;
  94055. /**
  94056. * Gets the highest frame rate of the animation
  94057. * @returns Highest frame rate of the animation
  94058. */
  94059. getHighestFrame(): number;
  94060. /**
  94061. * Gets the easing function of the animation
  94062. * @returns Easing function of the animation
  94063. */
  94064. getEasingFunction(): IEasingFunction;
  94065. /**
  94066. * Sets the easing function of the animation
  94067. * @param easingFunction A custom mathematical formula for animation
  94068. */
  94069. setEasingFunction(easingFunction: EasingFunction): void;
  94070. /**
  94071. * Interpolates a scalar linearly
  94072. * @param startValue Start value of the animation curve
  94073. * @param endValue End value of the animation curve
  94074. * @param gradient Scalar amount to interpolate
  94075. * @returns Interpolated scalar value
  94076. */
  94077. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94078. /**
  94079. * Interpolates a scalar cubically
  94080. * @param startValue Start value of the animation curve
  94081. * @param outTangent End tangent of the animation
  94082. * @param endValue End value of the animation curve
  94083. * @param inTangent Start tangent of the animation curve
  94084. * @param gradient Scalar amount to interpolate
  94085. * @returns Interpolated scalar value
  94086. */
  94087. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94088. /**
  94089. * Interpolates a quaternion using a spherical linear interpolation
  94090. * @param startValue Start value of the animation curve
  94091. * @param endValue End value of the animation curve
  94092. * @param gradient Scalar amount to interpolate
  94093. * @returns Interpolated quaternion value
  94094. */
  94095. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94096. /**
  94097. * Interpolates a quaternion cubically
  94098. * @param startValue Start value of the animation curve
  94099. * @param outTangent End tangent of the animation curve
  94100. * @param endValue End value of the animation curve
  94101. * @param inTangent Start tangent of the animation curve
  94102. * @param gradient Scalar amount to interpolate
  94103. * @returns Interpolated quaternion value
  94104. */
  94105. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94106. /**
  94107. * Interpolates a Vector3 linearl
  94108. * @param startValue Start value of the animation curve
  94109. * @param endValue End value of the animation curve
  94110. * @param gradient Scalar amount to interpolate
  94111. * @returns Interpolated scalar value
  94112. */
  94113. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94114. /**
  94115. * Interpolates a Vector3 cubically
  94116. * @param startValue Start value of the animation curve
  94117. * @param outTangent End tangent of the animation
  94118. * @param endValue End value of the animation curve
  94119. * @param inTangent Start tangent of the animation curve
  94120. * @param gradient Scalar amount to interpolate
  94121. * @returns InterpolatedVector3 value
  94122. */
  94123. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94124. /**
  94125. * Interpolates a Vector2 linearly
  94126. * @param startValue Start value of the animation curve
  94127. * @param endValue End value of the animation curve
  94128. * @param gradient Scalar amount to interpolate
  94129. * @returns Interpolated Vector2 value
  94130. */
  94131. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94132. /**
  94133. * Interpolates a Vector2 cubically
  94134. * @param startValue Start value of the animation curve
  94135. * @param outTangent End tangent of the animation
  94136. * @param endValue End value of the animation curve
  94137. * @param inTangent Start tangent of the animation curve
  94138. * @param gradient Scalar amount to interpolate
  94139. * @returns Interpolated Vector2 value
  94140. */
  94141. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94142. /**
  94143. * Interpolates a size linearly
  94144. * @param startValue Start value of the animation curve
  94145. * @param endValue End value of the animation curve
  94146. * @param gradient Scalar amount to interpolate
  94147. * @returns Interpolated Size value
  94148. */
  94149. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94150. /**
  94151. * Interpolates a Color3 linearly
  94152. * @param startValue Start value of the animation curve
  94153. * @param endValue End value of the animation curve
  94154. * @param gradient Scalar amount to interpolate
  94155. * @returns Interpolated Color3 value
  94156. */
  94157. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94158. /**
  94159. * @hidden Internal use only
  94160. */
  94161. _getKeyValue(value: any): any;
  94162. /**
  94163. * @hidden Internal use only
  94164. */
  94165. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94166. /**
  94167. * Defines the function to use to interpolate matrices
  94168. * @param startValue defines the start matrix
  94169. * @param endValue defines the end matrix
  94170. * @param gradient defines the gradient between both matrices
  94171. * @param result defines an optional target matrix where to store the interpolation
  94172. * @returns the interpolated matrix
  94173. */
  94174. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94175. /**
  94176. * Makes a copy of the animation
  94177. * @returns Cloned animation
  94178. */
  94179. clone(): Animation;
  94180. /**
  94181. * Sets the key frames of the animation
  94182. * @param values The animation key frames to set
  94183. */
  94184. setKeys(values: Array<IAnimationKey>): void;
  94185. /**
  94186. * Serializes the animation to an object
  94187. * @returns Serialized object
  94188. */
  94189. serialize(): any;
  94190. /**
  94191. * Float animation type
  94192. */
  94193. private static _ANIMATIONTYPE_FLOAT;
  94194. /**
  94195. * Vector3 animation type
  94196. */
  94197. private static _ANIMATIONTYPE_VECTOR3;
  94198. /**
  94199. * Quaternion animation type
  94200. */
  94201. private static _ANIMATIONTYPE_QUATERNION;
  94202. /**
  94203. * Matrix animation type
  94204. */
  94205. private static _ANIMATIONTYPE_MATRIX;
  94206. /**
  94207. * Color3 animation type
  94208. */
  94209. private static _ANIMATIONTYPE_COLOR3;
  94210. /**
  94211. * Vector2 animation type
  94212. */
  94213. private static _ANIMATIONTYPE_VECTOR2;
  94214. /**
  94215. * Size animation type
  94216. */
  94217. private static _ANIMATIONTYPE_SIZE;
  94218. /**
  94219. * Relative Loop Mode
  94220. */
  94221. private static _ANIMATIONLOOPMODE_RELATIVE;
  94222. /**
  94223. * Cycle Loop Mode
  94224. */
  94225. private static _ANIMATIONLOOPMODE_CYCLE;
  94226. /**
  94227. * Constant Loop Mode
  94228. */
  94229. private static _ANIMATIONLOOPMODE_CONSTANT;
  94230. /**
  94231. * Get the float animation type
  94232. */
  94233. static readonly ANIMATIONTYPE_FLOAT: number;
  94234. /**
  94235. * Get the Vector3 animation type
  94236. */
  94237. static readonly ANIMATIONTYPE_VECTOR3: number;
  94238. /**
  94239. * Get the Vector2 animation type
  94240. */
  94241. static readonly ANIMATIONTYPE_VECTOR2: number;
  94242. /**
  94243. * Get the Size animation type
  94244. */
  94245. static readonly ANIMATIONTYPE_SIZE: number;
  94246. /**
  94247. * Get the Quaternion animation type
  94248. */
  94249. static readonly ANIMATIONTYPE_QUATERNION: number;
  94250. /**
  94251. * Get the Matrix animation type
  94252. */
  94253. static readonly ANIMATIONTYPE_MATRIX: number;
  94254. /**
  94255. * Get the Color3 animation type
  94256. */
  94257. static readonly ANIMATIONTYPE_COLOR3: number;
  94258. /**
  94259. * Get the Relative Loop Mode
  94260. */
  94261. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94262. /**
  94263. * Get the Cycle Loop Mode
  94264. */
  94265. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94266. /**
  94267. * Get the Constant Loop Mode
  94268. */
  94269. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94270. /** @hidden */
  94271. static _UniversalLerp(left: any, right: any, amount: number): any;
  94272. /**
  94273. * Parses an animation object and creates an animation
  94274. * @param parsedAnimation Parsed animation object
  94275. * @returns Animation object
  94276. */
  94277. static Parse(parsedAnimation: any): Animation;
  94278. /**
  94279. * Appends the serialized animations from the source animations
  94280. * @param source Source containing the animations
  94281. * @param destination Target to store the animations
  94282. */
  94283. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94284. }
  94285. }
  94286. declare module BABYLON {
  94287. /**
  94288. * Interface containing an array of animations
  94289. */
  94290. export interface IAnimatable {
  94291. /**
  94292. * Array of animations
  94293. */
  94294. animations: Nullable<Array<Animation>>;
  94295. }
  94296. }
  94297. declare module BABYLON {
  94298. /**
  94299. * This represents all the required information to add a fresnel effect on a material:
  94300. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94301. */
  94302. export class FresnelParameters {
  94303. private _isEnabled;
  94304. /**
  94305. * Define if the fresnel effect is enable or not.
  94306. */
  94307. isEnabled: boolean;
  94308. /**
  94309. * Define the color used on edges (grazing angle)
  94310. */
  94311. leftColor: Color3;
  94312. /**
  94313. * Define the color used on center
  94314. */
  94315. rightColor: Color3;
  94316. /**
  94317. * Define bias applied to computed fresnel term
  94318. */
  94319. bias: number;
  94320. /**
  94321. * Defined the power exponent applied to fresnel term
  94322. */
  94323. power: number;
  94324. /**
  94325. * Clones the current fresnel and its valuues
  94326. * @returns a clone fresnel configuration
  94327. */
  94328. clone(): FresnelParameters;
  94329. /**
  94330. * Serializes the current fresnel parameters to a JSON representation.
  94331. * @return the JSON serialization
  94332. */
  94333. serialize(): any;
  94334. /**
  94335. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94336. * @param parsedFresnelParameters Define the JSON representation
  94337. * @returns the parsed parameters
  94338. */
  94339. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94340. }
  94341. }
  94342. declare module BABYLON {
  94343. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94344. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94345. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94346. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94347. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94348. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94349. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94350. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94351. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94352. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94353. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94354. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94355. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94356. /**
  94357. * Decorator used to define property that can be serialized as reference to a camera
  94358. * @param sourceName defines the name of the property to decorate
  94359. */
  94360. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94361. /**
  94362. * Class used to help serialization objects
  94363. */
  94364. export class SerializationHelper {
  94365. /** @hidden */
  94366. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94367. /** @hidden */
  94368. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94369. /** @hidden */
  94370. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94371. /** @hidden */
  94372. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94373. /**
  94374. * Appends the serialized animations from the source animations
  94375. * @param source Source containing the animations
  94376. * @param destination Target to store the animations
  94377. */
  94378. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94379. /**
  94380. * Static function used to serialized a specific entity
  94381. * @param entity defines the entity to serialize
  94382. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94383. * @returns a JSON compatible object representing the serialization of the entity
  94384. */
  94385. static Serialize<T>(entity: T, serializationObject?: any): any;
  94386. /**
  94387. * Creates a new entity from a serialization data object
  94388. * @param creationFunction defines a function used to instanciated the new entity
  94389. * @param source defines the source serialization data
  94390. * @param scene defines the hosting scene
  94391. * @param rootUrl defines the root url for resources
  94392. * @returns a new entity
  94393. */
  94394. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94395. /**
  94396. * Clones an object
  94397. * @param creationFunction defines the function used to instanciate the new object
  94398. * @param source defines the source object
  94399. * @returns the cloned object
  94400. */
  94401. static Clone<T>(creationFunction: () => T, source: T): T;
  94402. /**
  94403. * Instanciates a new object based on a source one (some data will be shared between both object)
  94404. * @param creationFunction defines the function used to instanciate the new object
  94405. * @param source defines the source object
  94406. * @returns the new object
  94407. */
  94408. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94409. }
  94410. }
  94411. declare module BABYLON {
  94412. /**
  94413. * Class used to manipulate GUIDs
  94414. */
  94415. export class GUID {
  94416. /**
  94417. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94418. * Be aware Math.random() could cause collisions, but:
  94419. * "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"
  94420. * @returns a pseudo random id
  94421. */
  94422. static RandomId(): string;
  94423. }
  94424. }
  94425. declare module BABYLON {
  94426. /**
  94427. * Base class of all the textures in babylon.
  94428. * It groups all the common properties the materials, post process, lights... might need
  94429. * in order to make a correct use of the texture.
  94430. */
  94431. export class BaseTexture implements IAnimatable {
  94432. /**
  94433. * Default anisotropic filtering level for the application.
  94434. * It is set to 4 as a good tradeoff between perf and quality.
  94435. */
  94436. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94437. /**
  94438. * Gets or sets the unique id of the texture
  94439. */
  94440. uniqueId: number;
  94441. /**
  94442. * Define the name of the texture.
  94443. */
  94444. name: string;
  94445. /**
  94446. * Gets or sets an object used to store user defined information.
  94447. */
  94448. metadata: any;
  94449. /**
  94450. * For internal use only. Please do not use.
  94451. */
  94452. reservedDataStore: any;
  94453. private _hasAlpha;
  94454. /**
  94455. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94456. */
  94457. hasAlpha: boolean;
  94458. /**
  94459. * Defines if the alpha value should be determined via the rgb values.
  94460. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94461. */
  94462. getAlphaFromRGB: boolean;
  94463. /**
  94464. * Intensity or strength of the texture.
  94465. * It is commonly used by materials to fine tune the intensity of the texture
  94466. */
  94467. level: number;
  94468. /**
  94469. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94470. * This is part of the texture as textures usually maps to one uv set.
  94471. */
  94472. coordinatesIndex: number;
  94473. private _coordinatesMode;
  94474. /**
  94475. * How a texture is mapped.
  94476. *
  94477. * | Value | Type | Description |
  94478. * | ----- | ----------------------------------- | ----------- |
  94479. * | 0 | EXPLICIT_MODE | |
  94480. * | 1 | SPHERICAL_MODE | |
  94481. * | 2 | PLANAR_MODE | |
  94482. * | 3 | CUBIC_MODE | |
  94483. * | 4 | PROJECTION_MODE | |
  94484. * | 5 | SKYBOX_MODE | |
  94485. * | 6 | INVCUBIC_MODE | |
  94486. * | 7 | EQUIRECTANGULAR_MODE | |
  94487. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94488. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94489. */
  94490. coordinatesMode: number;
  94491. /**
  94492. * | Value | Type | Description |
  94493. * | ----- | ------------------ | ----------- |
  94494. * | 0 | CLAMP_ADDRESSMODE | |
  94495. * | 1 | WRAP_ADDRESSMODE | |
  94496. * | 2 | MIRROR_ADDRESSMODE | |
  94497. */
  94498. wrapU: number;
  94499. /**
  94500. * | Value | Type | Description |
  94501. * | ----- | ------------------ | ----------- |
  94502. * | 0 | CLAMP_ADDRESSMODE | |
  94503. * | 1 | WRAP_ADDRESSMODE | |
  94504. * | 2 | MIRROR_ADDRESSMODE | |
  94505. */
  94506. wrapV: number;
  94507. /**
  94508. * | Value | Type | Description |
  94509. * | ----- | ------------------ | ----------- |
  94510. * | 0 | CLAMP_ADDRESSMODE | |
  94511. * | 1 | WRAP_ADDRESSMODE | |
  94512. * | 2 | MIRROR_ADDRESSMODE | |
  94513. */
  94514. wrapR: number;
  94515. /**
  94516. * With compliant hardware and browser (supporting anisotropic filtering)
  94517. * this defines the level of anisotropic filtering in the texture.
  94518. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94519. */
  94520. anisotropicFilteringLevel: number;
  94521. /**
  94522. * Define if the texture is a cube texture or if false a 2d texture.
  94523. */
  94524. isCube: boolean;
  94525. /**
  94526. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94527. */
  94528. is3D: boolean;
  94529. /**
  94530. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94531. * HDR texture are usually stored in linear space.
  94532. * This only impacts the PBR and Background materials
  94533. */
  94534. gammaSpace: boolean;
  94535. /**
  94536. * Gets or sets whether or not the texture contains RGBD data.
  94537. */
  94538. isRGBD: boolean;
  94539. /**
  94540. * Is Z inverted in the texture (useful in a cube texture).
  94541. */
  94542. invertZ: boolean;
  94543. /**
  94544. * Are mip maps generated for this texture or not.
  94545. */
  94546. readonly noMipmap: boolean;
  94547. /**
  94548. * @hidden
  94549. */
  94550. lodLevelInAlpha: boolean;
  94551. /**
  94552. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94553. */
  94554. lodGenerationOffset: number;
  94555. /**
  94556. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94557. */
  94558. lodGenerationScale: number;
  94559. /**
  94560. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94561. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94562. * average roughness values.
  94563. */
  94564. linearSpecularLOD: boolean;
  94565. /**
  94566. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94567. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94568. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94569. */
  94570. irradianceTexture: Nullable<BaseTexture>;
  94571. /**
  94572. * Define if the texture is a render target.
  94573. */
  94574. isRenderTarget: boolean;
  94575. /**
  94576. * Define the unique id of the texture in the scene.
  94577. */
  94578. readonly uid: string;
  94579. /**
  94580. * Return a string representation of the texture.
  94581. * @returns the texture as a string
  94582. */
  94583. toString(): string;
  94584. /**
  94585. * Get the class name of the texture.
  94586. * @returns "BaseTexture"
  94587. */
  94588. getClassName(): string;
  94589. /**
  94590. * Define the list of animation attached to the texture.
  94591. */
  94592. animations: Animation[];
  94593. /**
  94594. * An event triggered when the texture is disposed.
  94595. */
  94596. onDisposeObservable: Observable<BaseTexture>;
  94597. private _onDisposeObserver;
  94598. /**
  94599. * Callback triggered when the texture has been disposed.
  94600. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94601. */
  94602. onDispose: () => void;
  94603. /**
  94604. * Define the current state of the loading sequence when in delayed load mode.
  94605. */
  94606. delayLoadState: number;
  94607. private _scene;
  94608. /** @hidden */
  94609. _texture: Nullable<InternalTexture>;
  94610. private _uid;
  94611. /**
  94612. * Define if the texture is preventinga material to render or not.
  94613. * If not and the texture is not ready, the engine will use a default black texture instead.
  94614. */
  94615. readonly isBlocking: boolean;
  94616. /**
  94617. * Instantiates a new BaseTexture.
  94618. * Base class of all the textures in babylon.
  94619. * It groups all the common properties the materials, post process, lights... might need
  94620. * in order to make a correct use of the texture.
  94621. * @param scene Define the scene the texture blongs to
  94622. */
  94623. constructor(scene: Nullable<Scene>);
  94624. /**
  94625. * Get the scene the texture belongs to.
  94626. * @returns the scene or null if undefined
  94627. */
  94628. getScene(): Nullable<Scene>;
  94629. /**
  94630. * Get the texture transform matrix used to offset tile the texture for istance.
  94631. * @returns the transformation matrix
  94632. */
  94633. getTextureMatrix(): Matrix;
  94634. /**
  94635. * Get the texture reflection matrix used to rotate/transform the reflection.
  94636. * @returns the reflection matrix
  94637. */
  94638. getReflectionTextureMatrix(): Matrix;
  94639. /**
  94640. * Get the underlying lower level texture from Babylon.
  94641. * @returns the insternal texture
  94642. */
  94643. getInternalTexture(): Nullable<InternalTexture>;
  94644. /**
  94645. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94646. * @returns true if ready or not blocking
  94647. */
  94648. isReadyOrNotBlocking(): boolean;
  94649. /**
  94650. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94651. * @returns true if fully ready
  94652. */
  94653. isReady(): boolean;
  94654. private _cachedSize;
  94655. /**
  94656. * Get the size of the texture.
  94657. * @returns the texture size.
  94658. */
  94659. getSize(): ISize;
  94660. /**
  94661. * Get the base size of the texture.
  94662. * It can be different from the size if the texture has been resized for POT for instance
  94663. * @returns the base size
  94664. */
  94665. getBaseSize(): ISize;
  94666. /**
  94667. * Update the sampling mode of the texture.
  94668. * Default is Trilinear mode.
  94669. *
  94670. * | Value | Type | Description |
  94671. * | ----- | ------------------ | ----------- |
  94672. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94673. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94674. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94675. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94676. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94677. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94678. * | 7 | NEAREST_LINEAR | |
  94679. * | 8 | NEAREST_NEAREST | |
  94680. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94681. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94682. * | 11 | LINEAR_LINEAR | |
  94683. * | 12 | LINEAR_NEAREST | |
  94684. *
  94685. * > _mag_: magnification filter (close to the viewer)
  94686. * > _min_: minification filter (far from the viewer)
  94687. * > _mip_: filter used between mip map levels
  94688. *@param samplingMode Define the new sampling mode of the texture
  94689. */
  94690. updateSamplingMode(samplingMode: number): void;
  94691. /**
  94692. * Scales the texture if is `canRescale()`
  94693. * @param ratio the resize factor we want to use to rescale
  94694. */
  94695. scale(ratio: number): void;
  94696. /**
  94697. * Get if the texture can rescale.
  94698. */
  94699. readonly canRescale: boolean;
  94700. /** @hidden */
  94701. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94702. /** @hidden */
  94703. _rebuild(): void;
  94704. /**
  94705. * Triggers the load sequence in delayed load mode.
  94706. */
  94707. delayLoad(): void;
  94708. /**
  94709. * Clones the texture.
  94710. * @returns the cloned texture
  94711. */
  94712. clone(): Nullable<BaseTexture>;
  94713. /**
  94714. * Get the texture underlying type (INT, FLOAT...)
  94715. */
  94716. readonly textureType: number;
  94717. /**
  94718. * Get the texture underlying format (RGB, RGBA...)
  94719. */
  94720. readonly textureFormat: number;
  94721. /**
  94722. * Indicates that textures need to be re-calculated for all materials
  94723. */
  94724. protected _markAllSubMeshesAsTexturesDirty(): void;
  94725. /**
  94726. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94727. * This will returns an RGBA array buffer containing either in values (0-255) or
  94728. * float values (0-1) depending of the underlying buffer type.
  94729. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94730. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94731. * @param buffer defines a user defined buffer to fill with data (can be null)
  94732. * @returns The Array buffer containing the pixels data.
  94733. */
  94734. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94735. /**
  94736. * Release and destroy the underlying lower level texture aka internalTexture.
  94737. */
  94738. releaseInternalTexture(): void;
  94739. /** @hidden */
  94740. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94741. /** @hidden */
  94742. readonly _lodTextureMid: Nullable<BaseTexture>;
  94743. /** @hidden */
  94744. readonly _lodTextureLow: Nullable<BaseTexture>;
  94745. /**
  94746. * Dispose the texture and release its associated resources.
  94747. */
  94748. dispose(): void;
  94749. /**
  94750. * Serialize the texture into a JSON representation that can be parsed later on.
  94751. * @returns the JSON representation of the texture
  94752. */
  94753. serialize(): any;
  94754. /**
  94755. * Helper function to be called back once a list of texture contains only ready textures.
  94756. * @param textures Define the list of textures to wait for
  94757. * @param callback Define the callback triggered once the entire list will be ready
  94758. */
  94759. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94760. }
  94761. }
  94762. declare module BABYLON {
  94763. /**
  94764. * Options to be used when creating an effect.
  94765. */
  94766. export interface IEffectCreationOptions {
  94767. /**
  94768. * Atrributes that will be used in the shader.
  94769. */
  94770. attributes: string[];
  94771. /**
  94772. * Uniform varible names that will be set in the shader.
  94773. */
  94774. uniformsNames: string[];
  94775. /**
  94776. * Uniform buffer varible names that will be set in the shader.
  94777. */
  94778. uniformBuffersNames: string[];
  94779. /**
  94780. * Sampler texture variable names that will be set in the shader.
  94781. */
  94782. samplers: string[];
  94783. /**
  94784. * Define statements that will be set in the shader.
  94785. */
  94786. defines: any;
  94787. /**
  94788. * Possible fallbacks for this effect to improve performance when needed.
  94789. */
  94790. fallbacks: Nullable<IEffectFallbacks>;
  94791. /**
  94792. * Callback that will be called when the shader is compiled.
  94793. */
  94794. onCompiled: Nullable<(effect: Effect) => void>;
  94795. /**
  94796. * Callback that will be called if an error occurs during shader compilation.
  94797. */
  94798. onError: Nullable<(effect: Effect, errors: string) => void>;
  94799. /**
  94800. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94801. */
  94802. indexParameters?: any;
  94803. /**
  94804. * Max number of lights that can be used in the shader.
  94805. */
  94806. maxSimultaneousLights?: number;
  94807. /**
  94808. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94809. */
  94810. transformFeedbackVaryings?: Nullable<string[]>;
  94811. }
  94812. /**
  94813. * Effect containing vertex and fragment shader that can be executed on an object.
  94814. */
  94815. export class Effect implements IDisposable {
  94816. /**
  94817. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94818. */
  94819. static ShadersRepository: string;
  94820. /**
  94821. * Name of the effect.
  94822. */
  94823. name: any;
  94824. /**
  94825. * String container all the define statements that should be set on the shader.
  94826. */
  94827. defines: string;
  94828. /**
  94829. * Callback that will be called when the shader is compiled.
  94830. */
  94831. onCompiled: Nullable<(effect: Effect) => void>;
  94832. /**
  94833. * Callback that will be called if an error occurs during shader compilation.
  94834. */
  94835. onError: Nullable<(effect: Effect, errors: string) => void>;
  94836. /**
  94837. * Callback that will be called when effect is bound.
  94838. */
  94839. onBind: Nullable<(effect: Effect) => void>;
  94840. /**
  94841. * Unique ID of the effect.
  94842. */
  94843. uniqueId: number;
  94844. /**
  94845. * Observable that will be called when the shader is compiled.
  94846. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94847. */
  94848. onCompileObservable: Observable<Effect>;
  94849. /**
  94850. * Observable that will be called if an error occurs during shader compilation.
  94851. */
  94852. onErrorObservable: Observable<Effect>;
  94853. /** @hidden */
  94854. _onBindObservable: Nullable<Observable<Effect>>;
  94855. /**
  94856. * Observable that will be called when effect is bound.
  94857. */
  94858. readonly onBindObservable: Observable<Effect>;
  94859. /** @hidden */
  94860. _bonesComputationForcedToCPU: boolean;
  94861. private static _uniqueIdSeed;
  94862. private _engine;
  94863. private _uniformBuffersNames;
  94864. private _uniformsNames;
  94865. private _samplerList;
  94866. private _samplers;
  94867. private _isReady;
  94868. private _compilationError;
  94869. private _allFallbacksProcessed;
  94870. private _attributesNames;
  94871. private _attributes;
  94872. private _uniforms;
  94873. /**
  94874. * Key for the effect.
  94875. * @hidden
  94876. */
  94877. _key: string;
  94878. private _indexParameters;
  94879. private _fallbacks;
  94880. private _vertexSourceCode;
  94881. private _fragmentSourceCode;
  94882. private _vertexSourceCodeOverride;
  94883. private _fragmentSourceCodeOverride;
  94884. private _transformFeedbackVaryings;
  94885. /**
  94886. * Compiled shader to webGL program.
  94887. * @hidden
  94888. */
  94889. _pipelineContext: Nullable<IPipelineContext>;
  94890. private _valueCache;
  94891. private static _baseCache;
  94892. /**
  94893. * Instantiates an effect.
  94894. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94895. * @param baseName Name of the effect.
  94896. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94897. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94898. * @param samplers List of sampler variables that will be passed to the shader.
  94899. * @param engine Engine to be used to render the effect
  94900. * @param defines Define statements to be added to the shader.
  94901. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94902. * @param onCompiled Callback that will be called when the shader is compiled.
  94903. * @param onError Callback that will be called if an error occurs during shader compilation.
  94904. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94905. */
  94906. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94907. private _useFinalCode;
  94908. /**
  94909. * Unique key for this effect
  94910. */
  94911. readonly key: string;
  94912. /**
  94913. * If the effect has been compiled and prepared.
  94914. * @returns if the effect is compiled and prepared.
  94915. */
  94916. isReady(): boolean;
  94917. private _isReadyInternal;
  94918. /**
  94919. * The engine the effect was initialized with.
  94920. * @returns the engine.
  94921. */
  94922. getEngine(): Engine;
  94923. /**
  94924. * The pipeline context for this effect
  94925. * @returns the associated pipeline context
  94926. */
  94927. getPipelineContext(): Nullable<IPipelineContext>;
  94928. /**
  94929. * The set of names of attribute variables for the shader.
  94930. * @returns An array of attribute names.
  94931. */
  94932. getAttributesNames(): string[];
  94933. /**
  94934. * Returns the attribute at the given index.
  94935. * @param index The index of the attribute.
  94936. * @returns The location of the attribute.
  94937. */
  94938. getAttributeLocation(index: number): number;
  94939. /**
  94940. * Returns the attribute based on the name of the variable.
  94941. * @param name of the attribute to look up.
  94942. * @returns the attribute location.
  94943. */
  94944. getAttributeLocationByName(name: string): number;
  94945. /**
  94946. * The number of attributes.
  94947. * @returns the numnber of attributes.
  94948. */
  94949. getAttributesCount(): number;
  94950. /**
  94951. * Gets the index of a uniform variable.
  94952. * @param uniformName of the uniform to look up.
  94953. * @returns the index.
  94954. */
  94955. getUniformIndex(uniformName: string): number;
  94956. /**
  94957. * Returns the attribute based on the name of the variable.
  94958. * @param uniformName of the uniform to look up.
  94959. * @returns the location of the uniform.
  94960. */
  94961. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94962. /**
  94963. * Returns an array of sampler variable names
  94964. * @returns The array of sampler variable neames.
  94965. */
  94966. getSamplers(): string[];
  94967. /**
  94968. * The error from the last compilation.
  94969. * @returns the error string.
  94970. */
  94971. getCompilationError(): string;
  94972. /**
  94973. * Gets a boolean indicating that all fallbacks were used during compilation
  94974. * @returns true if all fallbacks were used
  94975. */
  94976. allFallbacksProcessed(): boolean;
  94977. /**
  94978. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  94979. * @param func The callback to be used.
  94980. */
  94981. executeWhenCompiled(func: (effect: Effect) => void): void;
  94982. private _checkIsReady;
  94983. private _loadShader;
  94984. /**
  94985. * Recompiles the webGL program
  94986. * @param vertexSourceCode The source code for the vertex shader.
  94987. * @param fragmentSourceCode The source code for the fragment shader.
  94988. * @param onCompiled Callback called when completed.
  94989. * @param onError Callback called on error.
  94990. * @hidden
  94991. */
  94992. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  94993. /**
  94994. * Prepares the effect
  94995. * @hidden
  94996. */
  94997. _prepareEffect(): void;
  94998. private _processCompilationErrors;
  94999. /**
  95000. * Checks if the effect is supported. (Must be called after compilation)
  95001. */
  95002. readonly isSupported: boolean;
  95003. /**
  95004. * Binds a texture to the engine to be used as output of the shader.
  95005. * @param channel Name of the output variable.
  95006. * @param texture Texture to bind.
  95007. * @hidden
  95008. */
  95009. _bindTexture(channel: string, texture: InternalTexture): void;
  95010. /**
  95011. * Sets a texture on the engine to be used in the shader.
  95012. * @param channel Name of the sampler variable.
  95013. * @param texture Texture to set.
  95014. */
  95015. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95016. /**
  95017. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95018. * @param channel Name of the sampler variable.
  95019. * @param texture Texture to set.
  95020. */
  95021. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95022. /**
  95023. * Sets an array of textures on the engine to be used in the shader.
  95024. * @param channel Name of the variable.
  95025. * @param textures Textures to set.
  95026. */
  95027. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95028. /**
  95029. * 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)
  95030. * @param channel Name of the sampler variable.
  95031. * @param postProcess Post process to get the input texture from.
  95032. */
  95033. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95034. /**
  95035. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95036. * 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)
  95037. * @param channel Name of the sampler variable.
  95038. * @param postProcess Post process to get the output texture from.
  95039. */
  95040. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95041. /** @hidden */
  95042. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95043. /** @hidden */
  95044. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95045. /** @hidden */
  95046. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95047. /** @hidden */
  95048. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95049. /**
  95050. * Binds a buffer to a uniform.
  95051. * @param buffer Buffer to bind.
  95052. * @param name Name of the uniform variable to bind to.
  95053. */
  95054. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95055. /**
  95056. * Binds block to a uniform.
  95057. * @param blockName Name of the block to bind.
  95058. * @param index Index to bind.
  95059. */
  95060. bindUniformBlock(blockName: string, index: number): void;
  95061. /**
  95062. * Sets an interger value on a uniform variable.
  95063. * @param uniformName Name of the variable.
  95064. * @param value Value to be set.
  95065. * @returns this effect.
  95066. */
  95067. setInt(uniformName: string, value: number): Effect;
  95068. /**
  95069. * Sets an int array on a uniform variable.
  95070. * @param uniformName Name of the variable.
  95071. * @param array array to be set.
  95072. * @returns this effect.
  95073. */
  95074. setIntArray(uniformName: string, array: Int32Array): Effect;
  95075. /**
  95076. * 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)
  95077. * @param uniformName Name of the variable.
  95078. * @param array array to be set.
  95079. * @returns this effect.
  95080. */
  95081. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95082. /**
  95083. * 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)
  95084. * @param uniformName Name of the variable.
  95085. * @param array array to be set.
  95086. * @returns this effect.
  95087. */
  95088. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95089. /**
  95090. * 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)
  95091. * @param uniformName Name of the variable.
  95092. * @param array array to be set.
  95093. * @returns this effect.
  95094. */
  95095. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95096. /**
  95097. * Sets an float array on a uniform variable.
  95098. * @param uniformName Name of the variable.
  95099. * @param array array to be set.
  95100. * @returns this effect.
  95101. */
  95102. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95103. /**
  95104. * 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)
  95105. * @param uniformName Name of the variable.
  95106. * @param array array to be set.
  95107. * @returns this effect.
  95108. */
  95109. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95110. /**
  95111. * 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)
  95112. * @param uniformName Name of the variable.
  95113. * @param array array to be set.
  95114. * @returns this effect.
  95115. */
  95116. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95117. /**
  95118. * 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)
  95119. * @param uniformName Name of the variable.
  95120. * @param array array to be set.
  95121. * @returns this effect.
  95122. */
  95123. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95124. /**
  95125. * Sets an array on a uniform variable.
  95126. * @param uniformName Name of the variable.
  95127. * @param array array to be set.
  95128. * @returns this effect.
  95129. */
  95130. setArray(uniformName: string, array: number[]): Effect;
  95131. /**
  95132. * 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)
  95133. * @param uniformName Name of the variable.
  95134. * @param array array to be set.
  95135. * @returns this effect.
  95136. */
  95137. setArray2(uniformName: string, array: number[]): Effect;
  95138. /**
  95139. * 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)
  95140. * @param uniformName Name of the variable.
  95141. * @param array array to be set.
  95142. * @returns this effect.
  95143. */
  95144. setArray3(uniformName: string, array: number[]): Effect;
  95145. /**
  95146. * 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)
  95147. * @param uniformName Name of the variable.
  95148. * @param array array to be set.
  95149. * @returns this effect.
  95150. */
  95151. setArray4(uniformName: string, array: number[]): Effect;
  95152. /**
  95153. * Sets matrices on a uniform variable.
  95154. * @param uniformName Name of the variable.
  95155. * @param matrices matrices to be set.
  95156. * @returns this effect.
  95157. */
  95158. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95159. /**
  95160. * Sets matrix on a uniform variable.
  95161. * @param uniformName Name of the variable.
  95162. * @param matrix matrix to be set.
  95163. * @returns this effect.
  95164. */
  95165. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95166. /**
  95167. * 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)
  95168. * @param uniformName Name of the variable.
  95169. * @param matrix matrix to be set.
  95170. * @returns this effect.
  95171. */
  95172. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95173. /**
  95174. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95175. * @param uniformName Name of the variable.
  95176. * @param matrix matrix to be set.
  95177. * @returns this effect.
  95178. */
  95179. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95180. /**
  95181. * Sets a float on a uniform variable.
  95182. * @param uniformName Name of the variable.
  95183. * @param value value to be set.
  95184. * @returns this effect.
  95185. */
  95186. setFloat(uniformName: string, value: number): Effect;
  95187. /**
  95188. * Sets a boolean on a uniform variable.
  95189. * @param uniformName Name of the variable.
  95190. * @param bool value to be set.
  95191. * @returns this effect.
  95192. */
  95193. setBool(uniformName: string, bool: boolean): Effect;
  95194. /**
  95195. * Sets a Vector2 on a uniform variable.
  95196. * @param uniformName Name of the variable.
  95197. * @param vector2 vector2 to be set.
  95198. * @returns this effect.
  95199. */
  95200. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95201. /**
  95202. * Sets a float2 on a uniform variable.
  95203. * @param uniformName Name of the variable.
  95204. * @param x First float in float2.
  95205. * @param y Second float in float2.
  95206. * @returns this effect.
  95207. */
  95208. setFloat2(uniformName: string, x: number, y: number): Effect;
  95209. /**
  95210. * Sets a Vector3 on a uniform variable.
  95211. * @param uniformName Name of the variable.
  95212. * @param vector3 Value to be set.
  95213. * @returns this effect.
  95214. */
  95215. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95216. /**
  95217. * Sets a float3 on a uniform variable.
  95218. * @param uniformName Name of the variable.
  95219. * @param x First float in float3.
  95220. * @param y Second float in float3.
  95221. * @param z Third float in float3.
  95222. * @returns this effect.
  95223. */
  95224. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95225. /**
  95226. * Sets a Vector4 on a uniform variable.
  95227. * @param uniformName Name of the variable.
  95228. * @param vector4 Value to be set.
  95229. * @returns this effect.
  95230. */
  95231. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95232. /**
  95233. * Sets a float4 on a uniform variable.
  95234. * @param uniformName Name of the variable.
  95235. * @param x First float in float4.
  95236. * @param y Second float in float4.
  95237. * @param z Third float in float4.
  95238. * @param w Fourth float in float4.
  95239. * @returns this effect.
  95240. */
  95241. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95242. /**
  95243. * Sets a Color3 on a uniform variable.
  95244. * @param uniformName Name of the variable.
  95245. * @param color3 Value to be set.
  95246. * @returns this effect.
  95247. */
  95248. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95249. /**
  95250. * Sets a Color4 on a uniform variable.
  95251. * @param uniformName Name of the variable.
  95252. * @param color3 Value to be set.
  95253. * @param alpha Alpha value to be set.
  95254. * @returns this effect.
  95255. */
  95256. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95257. /**
  95258. * Sets a Color4 on a uniform variable
  95259. * @param uniformName defines the name of the variable
  95260. * @param color4 defines the value to be set
  95261. * @returns this effect.
  95262. */
  95263. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95264. /** Release all associated resources */
  95265. dispose(): void;
  95266. /**
  95267. * This function will add a new shader to the shader store
  95268. * @param name the name of the shader
  95269. * @param pixelShader optional pixel shader content
  95270. * @param vertexShader optional vertex shader content
  95271. */
  95272. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95273. /**
  95274. * Store of each shader (The can be looked up using effect.key)
  95275. */
  95276. static ShadersStore: {
  95277. [key: string]: string;
  95278. };
  95279. /**
  95280. * Store of each included file for a shader (The can be looked up using effect.key)
  95281. */
  95282. static IncludesShadersStore: {
  95283. [key: string]: string;
  95284. };
  95285. /**
  95286. * Resets the cache of effects.
  95287. */
  95288. static ResetCache(): void;
  95289. }
  95290. }
  95291. declare module BABYLON {
  95292. /**
  95293. * Class used to describe the capabilities of the engine relatively to the current browser
  95294. */
  95295. export class EngineCapabilities {
  95296. /** Maximum textures units per fragment shader */
  95297. maxTexturesImageUnits: number;
  95298. /** Maximum texture units per vertex shader */
  95299. maxVertexTextureImageUnits: number;
  95300. /** Maximum textures units in the entire pipeline */
  95301. maxCombinedTexturesImageUnits: number;
  95302. /** Maximum texture size */
  95303. maxTextureSize: number;
  95304. /** Maximum cube texture size */
  95305. maxCubemapTextureSize: number;
  95306. /** Maximum render texture size */
  95307. maxRenderTextureSize: number;
  95308. /** Maximum number of vertex attributes */
  95309. maxVertexAttribs: number;
  95310. /** Maximum number of varyings */
  95311. maxVaryingVectors: number;
  95312. /** Maximum number of uniforms per vertex shader */
  95313. maxVertexUniformVectors: number;
  95314. /** Maximum number of uniforms per fragment shader */
  95315. maxFragmentUniformVectors: number;
  95316. /** Defines if standard derivates (dx/dy) are supported */
  95317. standardDerivatives: boolean;
  95318. /** Defines if s3tc texture compression is supported */
  95319. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95320. /** Defines if pvrtc texture compression is supported */
  95321. pvrtc: any;
  95322. /** Defines if etc1 texture compression is supported */
  95323. etc1: any;
  95324. /** Defines if etc2 texture compression is supported */
  95325. etc2: any;
  95326. /** Defines if astc texture compression is supported */
  95327. astc: any;
  95328. /** Defines if float textures are supported */
  95329. textureFloat: boolean;
  95330. /** Defines if vertex array objects are supported */
  95331. vertexArrayObject: boolean;
  95332. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95333. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95334. /** Gets the maximum level of anisotropy supported */
  95335. maxAnisotropy: number;
  95336. /** Defines if instancing is supported */
  95337. instancedArrays: boolean;
  95338. /** Defines if 32 bits indices are supported */
  95339. uintIndices: boolean;
  95340. /** Defines if high precision shaders are supported */
  95341. highPrecisionShaderSupported: boolean;
  95342. /** Defines if depth reading in the fragment shader is supported */
  95343. fragmentDepthSupported: boolean;
  95344. /** Defines if float texture linear filtering is supported*/
  95345. textureFloatLinearFiltering: boolean;
  95346. /** Defines if rendering to float textures is supported */
  95347. textureFloatRender: boolean;
  95348. /** Defines if half float textures are supported*/
  95349. textureHalfFloat: boolean;
  95350. /** Defines if half float texture linear filtering is supported*/
  95351. textureHalfFloatLinearFiltering: boolean;
  95352. /** Defines if rendering to half float textures is supported */
  95353. textureHalfFloatRender: boolean;
  95354. /** Defines if textureLOD shader command is supported */
  95355. textureLOD: boolean;
  95356. /** Defines if draw buffers extension is supported */
  95357. drawBuffersExtension: boolean;
  95358. /** Defines if depth textures are supported */
  95359. depthTextureExtension: boolean;
  95360. /** Defines if float color buffer are supported */
  95361. colorBufferFloat: boolean;
  95362. /** Gets disjoint timer query extension (null if not supported) */
  95363. timerQuery: EXT_disjoint_timer_query;
  95364. /** Defines if timestamp can be used with timer query */
  95365. canUseTimestampForTimerQuery: boolean;
  95366. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95367. multiview: any;
  95368. /** Function used to let the system compiles shaders in background */
  95369. parallelShaderCompile: {
  95370. COMPLETION_STATUS_KHR: number;
  95371. };
  95372. /** Max number of texture samples for MSAA */
  95373. maxMSAASamples: number;
  95374. /** Defines if the blend min max extension is supported */
  95375. blendMinMax: boolean;
  95376. }
  95377. }
  95378. declare module BABYLON {
  95379. /**
  95380. * @hidden
  95381. **/
  95382. export class DepthCullingState {
  95383. private _isDepthTestDirty;
  95384. private _isDepthMaskDirty;
  95385. private _isDepthFuncDirty;
  95386. private _isCullFaceDirty;
  95387. private _isCullDirty;
  95388. private _isZOffsetDirty;
  95389. private _isFrontFaceDirty;
  95390. private _depthTest;
  95391. private _depthMask;
  95392. private _depthFunc;
  95393. private _cull;
  95394. private _cullFace;
  95395. private _zOffset;
  95396. private _frontFace;
  95397. /**
  95398. * Initializes the state.
  95399. */
  95400. constructor();
  95401. readonly isDirty: boolean;
  95402. zOffset: number;
  95403. cullFace: Nullable<number>;
  95404. cull: Nullable<boolean>;
  95405. depthFunc: Nullable<number>;
  95406. depthMask: boolean;
  95407. depthTest: boolean;
  95408. frontFace: Nullable<number>;
  95409. reset(): void;
  95410. apply(gl: WebGLRenderingContext): void;
  95411. }
  95412. }
  95413. declare module BABYLON {
  95414. /**
  95415. * @hidden
  95416. **/
  95417. export class StencilState {
  95418. /** 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 */
  95419. static readonly ALWAYS: number;
  95420. /** Passed to stencilOperation to specify that stencil value must be kept */
  95421. static readonly KEEP: number;
  95422. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95423. static readonly REPLACE: number;
  95424. private _isStencilTestDirty;
  95425. private _isStencilMaskDirty;
  95426. private _isStencilFuncDirty;
  95427. private _isStencilOpDirty;
  95428. private _stencilTest;
  95429. private _stencilMask;
  95430. private _stencilFunc;
  95431. private _stencilFuncRef;
  95432. private _stencilFuncMask;
  95433. private _stencilOpStencilFail;
  95434. private _stencilOpDepthFail;
  95435. private _stencilOpStencilDepthPass;
  95436. readonly isDirty: boolean;
  95437. stencilFunc: number;
  95438. stencilFuncRef: number;
  95439. stencilFuncMask: number;
  95440. stencilOpStencilFail: number;
  95441. stencilOpDepthFail: number;
  95442. stencilOpStencilDepthPass: number;
  95443. stencilMask: number;
  95444. stencilTest: boolean;
  95445. constructor();
  95446. reset(): void;
  95447. apply(gl: WebGLRenderingContext): void;
  95448. }
  95449. }
  95450. declare module BABYLON {
  95451. /**
  95452. * @hidden
  95453. **/
  95454. export class AlphaState {
  95455. private _isAlphaBlendDirty;
  95456. private _isBlendFunctionParametersDirty;
  95457. private _isBlendEquationParametersDirty;
  95458. private _isBlendConstantsDirty;
  95459. private _alphaBlend;
  95460. private _blendFunctionParameters;
  95461. private _blendEquationParameters;
  95462. private _blendConstants;
  95463. /**
  95464. * Initializes the state.
  95465. */
  95466. constructor();
  95467. readonly isDirty: boolean;
  95468. alphaBlend: boolean;
  95469. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95470. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95471. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95472. reset(): void;
  95473. apply(gl: WebGLRenderingContext): void;
  95474. }
  95475. }
  95476. declare module BABYLON {
  95477. /** @hidden */
  95478. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95479. attributeProcessor(attribute: string): string;
  95480. varyingProcessor(varying: string, isFragment: boolean): string;
  95481. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95482. }
  95483. }
  95484. declare module BABYLON {
  95485. /**
  95486. * Interface for attribute information associated with buffer instanciation
  95487. */
  95488. export class InstancingAttributeInfo {
  95489. /**
  95490. * Index/offset of the attribute in the vertex shader
  95491. */
  95492. index: number;
  95493. /**
  95494. * size of the attribute, 1, 2, 3 or 4
  95495. */
  95496. attributeSize: number;
  95497. /**
  95498. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95499. * default is FLOAT
  95500. */
  95501. attribyteType: number;
  95502. /**
  95503. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95504. */
  95505. normalized: boolean;
  95506. /**
  95507. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95508. */
  95509. offset: number;
  95510. /**
  95511. * Name of the GLSL attribute, for debugging purpose only
  95512. */
  95513. attributeName: string;
  95514. }
  95515. }
  95516. declare module BABYLON {
  95517. interface ThinEngine {
  95518. /**
  95519. * Update a video texture
  95520. * @param texture defines the texture to update
  95521. * @param video defines the video element to use
  95522. * @param invertY defines if data must be stored with Y axis inverted
  95523. */
  95524. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95525. }
  95526. }
  95527. declare module BABYLON {
  95528. /**
  95529. * Settings for finer control over video usage
  95530. */
  95531. export interface VideoTextureSettings {
  95532. /**
  95533. * Applies `autoplay` to video, if specified
  95534. */
  95535. autoPlay?: boolean;
  95536. /**
  95537. * Applies `loop` to video, if specified
  95538. */
  95539. loop?: boolean;
  95540. /**
  95541. * Automatically updates internal texture from video at every frame in the render loop
  95542. */
  95543. autoUpdateTexture: boolean;
  95544. /**
  95545. * Image src displayed during the video loading or until the user interacts with the video.
  95546. */
  95547. poster?: string;
  95548. }
  95549. /**
  95550. * If you want to display a video in your scene, this is the special texture for that.
  95551. * This special texture works similar to other textures, with the exception of a few parameters.
  95552. * @see https://doc.babylonjs.com/how_to/video_texture
  95553. */
  95554. export class VideoTexture extends Texture {
  95555. /**
  95556. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95557. */
  95558. readonly autoUpdateTexture: boolean;
  95559. /**
  95560. * The video instance used by the texture internally
  95561. */
  95562. readonly video: HTMLVideoElement;
  95563. private _onUserActionRequestedObservable;
  95564. /**
  95565. * Event triggerd when a dom action is required by the user to play the video.
  95566. * This happens due to recent changes in browser policies preventing video to auto start.
  95567. */
  95568. readonly onUserActionRequestedObservable: Observable<Texture>;
  95569. private _generateMipMaps;
  95570. private _engine;
  95571. private _stillImageCaptured;
  95572. private _displayingPosterTexture;
  95573. private _settings;
  95574. private _createInternalTextureOnEvent;
  95575. private _frameId;
  95576. /**
  95577. * Creates a video texture.
  95578. * If you want to display a video in your scene, this is the special texture for that.
  95579. * This special texture works similar to other textures, with the exception of a few parameters.
  95580. * @see https://doc.babylonjs.com/how_to/video_texture
  95581. * @param name optional name, will detect from video source, if not defined
  95582. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95583. * @param scene is obviously the current scene.
  95584. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95585. * @param invertY is false by default but can be used to invert video on Y axis
  95586. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95587. * @param settings allows finer control over video usage
  95588. */
  95589. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95590. private _getName;
  95591. private _getVideo;
  95592. private _createInternalTexture;
  95593. private reset;
  95594. /**
  95595. * @hidden Internal method to initiate `update`.
  95596. */
  95597. _rebuild(): void;
  95598. /**
  95599. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95600. */
  95601. update(): void;
  95602. /**
  95603. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95604. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95605. */
  95606. updateTexture(isVisible: boolean): void;
  95607. protected _updateInternalTexture: () => void;
  95608. /**
  95609. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95610. * @param url New url.
  95611. */
  95612. updateURL(url: string): void;
  95613. /**
  95614. * Dispose the texture and release its associated resources.
  95615. */
  95616. dispose(): void;
  95617. /**
  95618. * Creates a video texture straight from a stream.
  95619. * @param scene Define the scene the texture should be created in
  95620. * @param stream Define the stream the texture should be created from
  95621. * @returns The created video texture as a promise
  95622. */
  95623. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95624. /**
  95625. * Creates a video texture straight from your WebCam video feed.
  95626. * @param scene Define the scene the texture should be created in
  95627. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95628. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95629. * @returns The created video texture as a promise
  95630. */
  95631. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95632. minWidth: number;
  95633. maxWidth: number;
  95634. minHeight: number;
  95635. maxHeight: number;
  95636. deviceId: string;
  95637. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95638. /**
  95639. * Creates a video texture straight from your WebCam video feed.
  95640. * @param scene Define the scene the texture should be created in
  95641. * @param onReady Define a callback to triggered once the texture will be ready
  95642. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95643. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95644. */
  95645. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95646. minWidth: number;
  95647. maxWidth: number;
  95648. minHeight: number;
  95649. maxHeight: number;
  95650. deviceId: string;
  95651. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95652. }
  95653. }
  95654. declare module BABYLON {
  95655. /**
  95656. * Defines the interface used by objects working like Scene
  95657. * @hidden
  95658. */
  95659. interface ISceneLike {
  95660. _addPendingData(data: any): void;
  95661. _removePendingData(data: any): void;
  95662. offlineProvider: IOfflineProvider;
  95663. }
  95664. /** Interface defining initialization parameters for Engine class */
  95665. export interface EngineOptions extends WebGLContextAttributes {
  95666. /**
  95667. * Defines if the engine should no exceed a specified device ratio
  95668. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95669. */
  95670. limitDeviceRatio?: number;
  95671. /**
  95672. * Defines if webvr should be enabled automatically
  95673. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95674. */
  95675. autoEnableWebVR?: boolean;
  95676. /**
  95677. * Defines if webgl2 should be turned off even if supported
  95678. * @see http://doc.babylonjs.com/features/webgl2
  95679. */
  95680. disableWebGL2Support?: boolean;
  95681. /**
  95682. * Defines if webaudio should be initialized as well
  95683. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95684. */
  95685. audioEngine?: boolean;
  95686. /**
  95687. * Defines if animations should run using a deterministic lock step
  95688. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95689. */
  95690. deterministicLockstep?: boolean;
  95691. /** Defines the maximum steps to use with deterministic lock step mode */
  95692. lockstepMaxSteps?: number;
  95693. /**
  95694. * Defines that engine should ignore context lost events
  95695. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95696. */
  95697. doNotHandleContextLost?: boolean;
  95698. /**
  95699. * Defines that engine should ignore modifying touch action attribute and style
  95700. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95701. */
  95702. doNotHandleTouchAction?: boolean;
  95703. /**
  95704. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95705. */
  95706. useHighPrecisionFloats?: boolean;
  95707. }
  95708. /**
  95709. * The base engine class (root of all engines)
  95710. */
  95711. export class ThinEngine {
  95712. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95713. static ExceptionList: ({
  95714. key: string;
  95715. capture: string;
  95716. captureConstraint: number;
  95717. targets: string[];
  95718. } | {
  95719. key: string;
  95720. capture: null;
  95721. captureConstraint: null;
  95722. targets: string[];
  95723. })[];
  95724. /** @hidden */
  95725. static _TextureLoaders: IInternalTextureLoader[];
  95726. /**
  95727. * Returns the current npm package of the sdk
  95728. */
  95729. static readonly NpmPackage: string;
  95730. /**
  95731. * Returns the current version of the framework
  95732. */
  95733. static readonly Version: string;
  95734. /**
  95735. * Returns a string describing the current engine
  95736. */
  95737. readonly description: string;
  95738. /**
  95739. * Gets or sets the epsilon value used by collision engine
  95740. */
  95741. static CollisionsEpsilon: number;
  95742. /**
  95743. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95744. */
  95745. static ShadersRepository: string;
  95746. /** @hidden */
  95747. _shaderProcessor: IShaderProcessor;
  95748. /**
  95749. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95750. */
  95751. forcePOTTextures: boolean;
  95752. /**
  95753. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95754. */
  95755. isFullscreen: boolean;
  95756. /**
  95757. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95758. */
  95759. cullBackFaces: boolean;
  95760. /**
  95761. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95762. */
  95763. renderEvenInBackground: boolean;
  95764. /**
  95765. * Gets or sets a boolean indicating that cache can be kept between frames
  95766. */
  95767. preventCacheWipeBetweenFrames: boolean;
  95768. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95769. validateShaderPrograms: boolean;
  95770. /**
  95771. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95772. */
  95773. disableUniformBuffers: boolean;
  95774. /** @hidden */
  95775. _uniformBuffers: UniformBuffer[];
  95776. /**
  95777. * Gets a boolean indicating that the engine supports uniform buffers
  95778. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95779. */
  95780. readonly supportsUniformBuffers: boolean;
  95781. /** @hidden */
  95782. _gl: WebGLRenderingContext;
  95783. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95784. protected _windowIsBackground: boolean;
  95785. protected _webGLVersion: number;
  95786. protected _highPrecisionShadersAllowed: boolean;
  95787. /** @hidden */
  95788. readonly _shouldUseHighPrecisionShader: boolean;
  95789. /**
  95790. * Gets a boolean indicating that only power of 2 textures are supported
  95791. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95792. */
  95793. readonly needPOTTextures: boolean;
  95794. /** @hidden */
  95795. _badOS: boolean;
  95796. /** @hidden */
  95797. _badDesktopOS: boolean;
  95798. private _hardwareScalingLevel;
  95799. /** @hidden */
  95800. _caps: EngineCapabilities;
  95801. private _isStencilEnable;
  95802. protected _colorWrite: boolean;
  95803. private _glVersion;
  95804. private _glRenderer;
  95805. private _glVendor;
  95806. /** @hidden */
  95807. _videoTextureSupported: boolean;
  95808. protected _renderingQueueLaunched: boolean;
  95809. protected _activeRenderLoops: (() => void)[];
  95810. /**
  95811. * Observable signaled when a context lost event is raised
  95812. */
  95813. onContextLostObservable: Observable<ThinEngine>;
  95814. /**
  95815. * Observable signaled when a context restored event is raised
  95816. */
  95817. onContextRestoredObservable: Observable<ThinEngine>;
  95818. private _onContextLost;
  95819. private _onContextRestored;
  95820. protected _contextWasLost: boolean;
  95821. /** @hidden */
  95822. _doNotHandleContextLost: boolean;
  95823. /**
  95824. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95825. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95826. */
  95827. doNotHandleContextLost: boolean;
  95828. /**
  95829. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95830. */
  95831. disableVertexArrayObjects: boolean;
  95832. /** @hidden */
  95833. protected _depthCullingState: DepthCullingState;
  95834. /** @hidden */
  95835. protected _stencilState: StencilState;
  95836. /** @hidden */
  95837. protected _alphaState: AlphaState;
  95838. /** @hidden */
  95839. _internalTexturesCache: InternalTexture[];
  95840. /** @hidden */
  95841. protected _activeChannel: number;
  95842. private _currentTextureChannel;
  95843. /** @hidden */
  95844. protected _boundTexturesCache: {
  95845. [key: string]: Nullable<InternalTexture>;
  95846. };
  95847. /** @hidden */
  95848. protected _currentEffect: Nullable<Effect>;
  95849. /** @hidden */
  95850. protected _currentProgram: Nullable<WebGLProgram>;
  95851. private _compiledEffects;
  95852. private _vertexAttribArraysEnabled;
  95853. /** @hidden */
  95854. protected _cachedViewport: Nullable<IViewportLike>;
  95855. private _cachedVertexArrayObject;
  95856. /** @hidden */
  95857. protected _cachedVertexBuffers: any;
  95858. /** @hidden */
  95859. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95860. /** @hidden */
  95861. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95862. /** @hidden */
  95863. _currentRenderTarget: Nullable<InternalTexture>;
  95864. private _uintIndicesCurrentlySet;
  95865. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95866. /** @hidden */
  95867. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95868. private _currentBufferPointers;
  95869. private _currentInstanceLocations;
  95870. private _currentInstanceBuffers;
  95871. private _textureUnits;
  95872. /** @hidden */
  95873. _workingCanvas: Nullable<HTMLCanvasElement>;
  95874. /** @hidden */
  95875. _workingContext: Nullable<CanvasRenderingContext2D>;
  95876. /** @hidden */
  95877. _bindedRenderFunction: any;
  95878. private _vaoRecordInProgress;
  95879. private _mustWipeVertexAttributes;
  95880. private _emptyTexture;
  95881. private _emptyCubeTexture;
  95882. private _emptyTexture3D;
  95883. /** @hidden */
  95884. _frameHandler: number;
  95885. private _nextFreeTextureSlots;
  95886. private _maxSimultaneousTextures;
  95887. private _activeRequests;
  95888. protected _texturesSupported: string[];
  95889. /** @hidden */
  95890. _textureFormatInUse: Nullable<string>;
  95891. protected readonly _supportsHardwareTextureRescaling: boolean;
  95892. /**
  95893. * Gets the list of texture formats supported
  95894. */
  95895. readonly texturesSupported: Array<string>;
  95896. /**
  95897. * Gets the list of texture formats in use
  95898. */
  95899. readonly textureFormatInUse: Nullable<string>;
  95900. /**
  95901. * Gets the current viewport
  95902. */
  95903. readonly currentViewport: Nullable<IViewportLike>;
  95904. /**
  95905. * Gets the default empty texture
  95906. */
  95907. readonly emptyTexture: InternalTexture;
  95908. /**
  95909. * Gets the default empty 3D texture
  95910. */
  95911. readonly emptyTexture3D: InternalTexture;
  95912. /**
  95913. * Gets the default empty cube texture
  95914. */
  95915. readonly emptyCubeTexture: InternalTexture;
  95916. /**
  95917. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95918. */
  95919. readonly premultipliedAlpha: boolean;
  95920. /**
  95921. * Observable event triggered before each texture is initialized
  95922. */
  95923. onBeforeTextureInitObservable: Observable<Texture>;
  95924. /**
  95925. * Creates a new engine
  95926. * @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
  95927. * @param antialias defines enable antialiasing (default: false)
  95928. * @param options defines further options to be sent to the getContext() function
  95929. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95930. */
  95931. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95932. private _rebuildInternalTextures;
  95933. private _rebuildEffects;
  95934. /**
  95935. * Gets a boolean indicating if all created effects are ready
  95936. * @returns true if all effects are ready
  95937. */
  95938. areAllEffectsReady(): boolean;
  95939. protected _rebuildBuffers(): void;
  95940. private _initGLContext;
  95941. /**
  95942. * Gets version of the current webGL context
  95943. */
  95944. readonly webGLVersion: number;
  95945. /**
  95946. * Gets a string idenfifying the name of the class
  95947. * @returns "Engine" string
  95948. */
  95949. getClassName(): string;
  95950. /**
  95951. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95952. */
  95953. readonly isStencilEnable: boolean;
  95954. /** @hidden */
  95955. _prepareWorkingCanvas(): void;
  95956. /**
  95957. * Reset the texture cache to empty state
  95958. */
  95959. resetTextureCache(): void;
  95960. /**
  95961. * Gets an object containing information about the current webGL context
  95962. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95963. */
  95964. getGlInfo(): {
  95965. vendor: string;
  95966. renderer: string;
  95967. version: string;
  95968. };
  95969. /**
  95970. * Defines the hardware scaling level.
  95971. * By default the hardware scaling level is computed from the window device ratio.
  95972. * 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.
  95973. * @param level defines the level to use
  95974. */
  95975. setHardwareScalingLevel(level: number): void;
  95976. /**
  95977. * Gets the current hardware scaling level.
  95978. * By default the hardware scaling level is computed from the window device ratio.
  95979. * 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.
  95980. * @returns a number indicating the current hardware scaling level
  95981. */
  95982. getHardwareScalingLevel(): number;
  95983. /**
  95984. * Gets the list of loaded textures
  95985. * @returns an array containing all loaded textures
  95986. */
  95987. getLoadedTexturesCache(): InternalTexture[];
  95988. /**
  95989. * Gets the object containing all engine capabilities
  95990. * @returns the EngineCapabilities object
  95991. */
  95992. getCaps(): EngineCapabilities;
  95993. /**
  95994. * stop executing a render loop function and remove it from the execution array
  95995. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  95996. */
  95997. stopRenderLoop(renderFunction?: () => void): void;
  95998. /** @hidden */
  95999. _renderLoop(): void;
  96000. /**
  96001. * Gets the HTML canvas attached with the current webGL context
  96002. * @returns a HTML canvas
  96003. */
  96004. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96005. /**
  96006. * Gets host window
  96007. * @returns the host window object
  96008. */
  96009. getHostWindow(): Window;
  96010. /**
  96011. * Gets the current render width
  96012. * @param useScreen defines if screen size must be used (or the current render target if any)
  96013. * @returns a number defining the current render width
  96014. */
  96015. getRenderWidth(useScreen?: boolean): number;
  96016. /**
  96017. * Gets the current render height
  96018. * @param useScreen defines if screen size must be used (or the current render target if any)
  96019. * @returns a number defining the current render height
  96020. */
  96021. getRenderHeight(useScreen?: boolean): number;
  96022. /**
  96023. * Can be used to override the current requestAnimationFrame requester.
  96024. * @hidden
  96025. */
  96026. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96027. /**
  96028. * Register and execute a render loop. The engine can have more than one render function
  96029. * @param renderFunction defines the function to continuously execute
  96030. */
  96031. runRenderLoop(renderFunction: () => void): void;
  96032. /**
  96033. * Clear the current render buffer or the current render target (if any is set up)
  96034. * @param color defines the color to use
  96035. * @param backBuffer defines if the back buffer must be cleared
  96036. * @param depth defines if the depth buffer must be cleared
  96037. * @param stencil defines if the stencil buffer must be cleared
  96038. */
  96039. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96040. private _viewportCached;
  96041. /** @hidden */
  96042. _viewport(x: number, y: number, width: number, height: number): void;
  96043. /**
  96044. * Set the WebGL's viewport
  96045. * @param viewport defines the viewport element to be used
  96046. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96047. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96048. */
  96049. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96050. /**
  96051. * Begin a new frame
  96052. */
  96053. beginFrame(): void;
  96054. /**
  96055. * Enf the current frame
  96056. */
  96057. endFrame(): void;
  96058. /**
  96059. * Resize the view according to the canvas' size
  96060. */
  96061. resize(): void;
  96062. /**
  96063. * Force a specific size of the canvas
  96064. * @param width defines the new canvas' width
  96065. * @param height defines the new canvas' height
  96066. */
  96067. setSize(width: number, height: number): void;
  96068. /**
  96069. * Binds the frame buffer to the specified texture.
  96070. * @param texture The texture to render to or null for the default canvas
  96071. * @param faceIndex The face of the texture to render to in case of cube texture
  96072. * @param requiredWidth The width of the target to render to
  96073. * @param requiredHeight The height of the target to render to
  96074. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96075. * @param depthStencilTexture The depth stencil texture to use to render
  96076. * @param lodLevel defines le lod level to bind to the frame buffer
  96077. */
  96078. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96079. /** @hidden */
  96080. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96081. /**
  96082. * Unbind the current render target texture from the webGL context
  96083. * @param texture defines the render target texture to unbind
  96084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96086. */
  96087. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96088. /**
  96089. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96090. */
  96091. flushFramebuffer(): void;
  96092. /**
  96093. * Unbind the current render target and bind the default framebuffer
  96094. */
  96095. restoreDefaultFramebuffer(): void;
  96096. private _resetVertexBufferBinding;
  96097. /**
  96098. * Creates a vertex buffer
  96099. * @param data the data for the vertex buffer
  96100. * @returns the new WebGL static buffer
  96101. */
  96102. createVertexBuffer(data: DataArray): DataBuffer;
  96103. private _createVertexBuffer;
  96104. /**
  96105. * Creates a dynamic vertex buffer
  96106. * @param data the data for the dynamic vertex buffer
  96107. * @returns the new WebGL dynamic buffer
  96108. */
  96109. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96110. /**
  96111. * Updates a dynamic vertex buffer.
  96112. * @param vertexBuffer the vertex buffer to update
  96113. * @param data the data used to update the vertex buffer
  96114. * @param byteOffset the byte offset of the data
  96115. * @param byteLength the byte length of the data
  96116. */
  96117. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96118. protected _resetIndexBufferBinding(): void;
  96119. /**
  96120. * Creates a new index buffer
  96121. * @param indices defines the content of the index buffer
  96122. * @param updatable defines if the index buffer must be updatable
  96123. * @returns a new webGL buffer
  96124. */
  96125. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96126. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96127. /**
  96128. * Bind a webGL buffer to the webGL context
  96129. * @param buffer defines the buffer to bind
  96130. */
  96131. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96132. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96133. private bindBuffer;
  96134. /**
  96135. * update the bound buffer with the given data
  96136. * @param data defines the data to update
  96137. */
  96138. updateArrayBuffer(data: Float32Array): void;
  96139. private _vertexAttribPointer;
  96140. private _bindIndexBufferWithCache;
  96141. private _bindVertexBuffersAttributes;
  96142. /**
  96143. * Records a vertex array object
  96144. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96145. * @param vertexBuffers defines the list of vertex buffers to store
  96146. * @param indexBuffer defines the index buffer to store
  96147. * @param effect defines the effect to store
  96148. * @returns the new vertex array object
  96149. */
  96150. recordVertexArrayObject(vertexBuffers: {
  96151. [key: string]: VertexBuffer;
  96152. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96153. /**
  96154. * Bind a specific vertex array object
  96155. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96156. * @param vertexArrayObject defines the vertex array object to bind
  96157. * @param indexBuffer defines the index buffer to bind
  96158. */
  96159. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96160. /**
  96161. * Bind webGl buffers directly to the webGL context
  96162. * @param vertexBuffer defines the vertex buffer to bind
  96163. * @param indexBuffer defines the index buffer to bind
  96164. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96165. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96166. * @param effect defines the effect associated with the vertex buffer
  96167. */
  96168. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96169. private _unbindVertexArrayObject;
  96170. /**
  96171. * Bind a list of vertex buffers to the webGL context
  96172. * @param vertexBuffers defines the list of vertex buffers to bind
  96173. * @param indexBuffer defines the index buffer to bind
  96174. * @param effect defines the effect associated with the vertex buffers
  96175. */
  96176. bindBuffers(vertexBuffers: {
  96177. [key: string]: Nullable<VertexBuffer>;
  96178. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96179. /**
  96180. * Unbind all instance attributes
  96181. */
  96182. unbindInstanceAttributes(): void;
  96183. /**
  96184. * Release and free the memory of a vertex array object
  96185. * @param vao defines the vertex array object to delete
  96186. */
  96187. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96188. /** @hidden */
  96189. _releaseBuffer(buffer: DataBuffer): boolean;
  96190. protected _deleteBuffer(buffer: DataBuffer): void;
  96191. /**
  96192. * Creates a webGL buffer to use with instanciation
  96193. * @param capacity defines the size of the buffer
  96194. * @returns the webGL buffer
  96195. */
  96196. createInstancesBuffer(capacity: number): DataBuffer;
  96197. /**
  96198. * Delete a webGL buffer used with instanciation
  96199. * @param buffer defines the webGL buffer to delete
  96200. */
  96201. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96202. /**
  96203. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96204. * @param instancesBuffer defines the webGL buffer to update and bind
  96205. * @param data defines the data to store in the buffer
  96206. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96207. */
  96208. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96209. /**
  96210. * Apply all cached states (depth, culling, stencil and alpha)
  96211. */
  96212. applyStates(): void;
  96213. /**
  96214. * Send a draw order
  96215. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96216. * @param indexStart defines the starting index
  96217. * @param indexCount defines the number of index to draw
  96218. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96219. */
  96220. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96221. /**
  96222. * Draw a list of points
  96223. * @param verticesStart defines the index of first vertex to draw
  96224. * @param verticesCount defines the count of vertices to draw
  96225. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96226. */
  96227. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96228. /**
  96229. * Draw a list of unindexed primitives
  96230. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96231. * @param verticesStart defines the index of first vertex to draw
  96232. * @param verticesCount defines the count of vertices to draw
  96233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96234. */
  96235. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96236. /**
  96237. * Draw a list of indexed primitives
  96238. * @param fillMode defines the primitive to use
  96239. * @param indexStart defines the starting index
  96240. * @param indexCount defines the number of index to draw
  96241. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96242. */
  96243. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96244. /**
  96245. * Draw a list of unindexed primitives
  96246. * @param fillMode defines the primitive to use
  96247. * @param verticesStart defines the index of first vertex to draw
  96248. * @param verticesCount defines the count of vertices to draw
  96249. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96250. */
  96251. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96252. private _drawMode;
  96253. /** @hidden */
  96254. protected _reportDrawCall(): void;
  96255. /** @hidden */
  96256. _releaseEffect(effect: Effect): void;
  96257. /** @hidden */
  96258. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96259. /**
  96260. * Create a new effect (used to store vertex/fragment shaders)
  96261. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96262. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96263. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96264. * @param samplers defines an array of string used to represent textures
  96265. * @param defines defines the string containing the defines to use to compile the shaders
  96266. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96267. * @param onCompiled defines a function to call when the effect creation is successful
  96268. * @param onError defines a function to call when the effect creation has failed
  96269. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96270. * @returns the new Effect
  96271. */
  96272. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96273. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96274. private _compileShader;
  96275. private _compileRawShader;
  96276. /**
  96277. * Directly creates a webGL program
  96278. * @param pipelineContext defines the pipeline context to attach to
  96279. * @param vertexCode defines the vertex shader code to use
  96280. * @param fragmentCode defines the fragment shader code to use
  96281. * @param context defines the webGL context to use (if not set, the current one will be used)
  96282. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96283. * @returns the new webGL program
  96284. */
  96285. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96286. /**
  96287. * Creates a webGL program
  96288. * @param pipelineContext defines the pipeline context to attach to
  96289. * @param vertexCode defines the vertex shader code to use
  96290. * @param fragmentCode defines the fragment shader code to use
  96291. * @param defines defines the string containing the defines to use to compile the shaders
  96292. * @param context defines the webGL context to use (if not set, the current one will be used)
  96293. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96294. * @returns the new webGL program
  96295. */
  96296. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96297. /**
  96298. * Creates a new pipeline context
  96299. * @returns the new pipeline
  96300. */
  96301. createPipelineContext(): IPipelineContext;
  96302. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96303. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96304. /** @hidden */
  96305. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96306. /** @hidden */
  96307. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96308. /** @hidden */
  96309. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96310. /**
  96311. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96312. * @param pipelineContext defines the pipeline context to use
  96313. * @param uniformsNames defines the list of uniform names
  96314. * @returns an array of webGL uniform locations
  96315. */
  96316. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96317. /**
  96318. * Gets the lsit of active attributes for a given webGL program
  96319. * @param pipelineContext defines the pipeline context to use
  96320. * @param attributesNames defines the list of attribute names to get
  96321. * @returns an array of indices indicating the offset of each attribute
  96322. */
  96323. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96324. /**
  96325. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96326. * @param effect defines the effect to activate
  96327. */
  96328. enableEffect(effect: Nullable<Effect>): void;
  96329. /**
  96330. * Set the value of an uniform to an array of int32
  96331. * @param uniform defines the webGL uniform location where to store the value
  96332. * @param array defines the array of int32 to store
  96333. */
  96334. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96335. /**
  96336. * Set the value of an uniform to an array of int32 (stored as vec2)
  96337. * @param uniform defines the webGL uniform location where to store the value
  96338. * @param array defines the array of int32 to store
  96339. */
  96340. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96341. /**
  96342. * Set the value of an uniform to an array of int32 (stored as vec3)
  96343. * @param uniform defines the webGL uniform location where to store the value
  96344. * @param array defines the array of int32 to store
  96345. */
  96346. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96347. /**
  96348. * Set the value of an uniform to an array of int32 (stored as vec4)
  96349. * @param uniform defines the webGL uniform location where to store the value
  96350. * @param array defines the array of int32 to store
  96351. */
  96352. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96353. /**
  96354. * Set the value of an uniform to an array of float32
  96355. * @param uniform defines the webGL uniform location where to store the value
  96356. * @param array defines the array of float32 to store
  96357. */
  96358. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96359. /**
  96360. * Set the value of an uniform to an array of float32 (stored as vec2)
  96361. * @param uniform defines the webGL uniform location where to store the value
  96362. * @param array defines the array of float32 to store
  96363. */
  96364. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96365. /**
  96366. * Set the value of an uniform to an array of float32 (stored as vec3)
  96367. * @param uniform defines the webGL uniform location where to store the value
  96368. * @param array defines the array of float32 to store
  96369. */
  96370. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96371. /**
  96372. * Set the value of an uniform to an array of float32 (stored as vec4)
  96373. * @param uniform defines the webGL uniform location where to store the value
  96374. * @param array defines the array of float32 to store
  96375. */
  96376. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96377. /**
  96378. * Set the value of an uniform to an array of number
  96379. * @param uniform defines the webGL uniform location where to store the value
  96380. * @param array defines the array of number to store
  96381. */
  96382. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96383. /**
  96384. * Set the value of an uniform to an array of number (stored as vec2)
  96385. * @param uniform defines the webGL uniform location where to store the value
  96386. * @param array defines the array of number to store
  96387. */
  96388. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96389. /**
  96390. * Set the value of an uniform to an array of number (stored as vec3)
  96391. * @param uniform defines the webGL uniform location where to store the value
  96392. * @param array defines the array of number to store
  96393. */
  96394. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96395. /**
  96396. * Set the value of an uniform to an array of number (stored as vec4)
  96397. * @param uniform defines the webGL uniform location where to store the value
  96398. * @param array defines the array of number to store
  96399. */
  96400. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96401. /**
  96402. * Set the value of an uniform to an array of float32 (stored as matrices)
  96403. * @param uniform defines the webGL uniform location where to store the value
  96404. * @param matrices defines the array of float32 to store
  96405. */
  96406. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96407. /**
  96408. * Set the value of an uniform to a matrix (3x3)
  96409. * @param uniform defines the webGL uniform location where to store the value
  96410. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96411. */
  96412. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96413. /**
  96414. * Set the value of an uniform to a matrix (2x2)
  96415. * @param uniform defines the webGL uniform location where to store the value
  96416. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96417. */
  96418. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96419. /**
  96420. * Set the value of an uniform to a number (int)
  96421. * @param uniform defines the webGL uniform location where to store the value
  96422. * @param value defines the int number to store
  96423. */
  96424. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96425. /**
  96426. * Set the value of an uniform to a number (float)
  96427. * @param uniform defines the webGL uniform location where to store the value
  96428. * @param value defines the float number to store
  96429. */
  96430. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96431. /**
  96432. * Set the value of an uniform to a vec2
  96433. * @param uniform defines the webGL uniform location where to store the value
  96434. * @param x defines the 1st component of the value
  96435. * @param y defines the 2nd component of the value
  96436. */
  96437. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96438. /**
  96439. * Set the value of an uniform to a vec3
  96440. * @param uniform defines the webGL uniform location where to store the value
  96441. * @param x defines the 1st component of the value
  96442. * @param y defines the 2nd component of the value
  96443. * @param z defines the 3rd component of the value
  96444. */
  96445. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96446. /**
  96447. * Set the value of an uniform to a boolean
  96448. * @param uniform defines the webGL uniform location where to store the value
  96449. * @param bool defines the boolean to store
  96450. */
  96451. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96452. /**
  96453. * Set the value of an uniform to a vec4
  96454. * @param uniform defines the webGL uniform location where to store the value
  96455. * @param x defines the 1st component of the value
  96456. * @param y defines the 2nd component of the value
  96457. * @param z defines the 3rd component of the value
  96458. * @param w defines the 4th component of the value
  96459. */
  96460. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96461. /**
  96462. * Sets a Color4 on a uniform variable
  96463. * @param uniform defines the uniform location
  96464. * @param color4 defines the value to be set
  96465. */
  96466. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96467. /**
  96468. * Gets the depth culling state manager
  96469. */
  96470. readonly depthCullingState: DepthCullingState;
  96471. /**
  96472. * Gets the alpha state manager
  96473. */
  96474. readonly alphaState: AlphaState;
  96475. /**
  96476. * Gets the stencil state manager
  96477. */
  96478. readonly stencilState: StencilState;
  96479. /**
  96480. * Clears the list of texture accessible through engine.
  96481. * This can help preventing texture load conflict due to name collision.
  96482. */
  96483. clearInternalTexturesCache(): void;
  96484. /**
  96485. * Force the entire cache to be cleared
  96486. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96487. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96488. */
  96489. wipeCaches(bruteForce?: boolean): void;
  96490. /** @hidden */
  96491. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96492. min: number;
  96493. mag: number;
  96494. };
  96495. /** @hidden */
  96496. _createTexture(): WebGLTexture;
  96497. /**
  96498. * Usually called from Texture.ts.
  96499. * Passed information to create a WebGLTexture
  96500. * @param urlArg defines a value which contains one of the following:
  96501. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96502. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96503. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96505. * @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)
  96506. * @param scene needed for loading to the correct scene
  96507. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96508. * @param onLoad optional callback to be called upon successful completion
  96509. * @param onError optional callback to be called upon failure
  96510. * @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
  96511. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96512. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96513. * @param forcedExtension defines the extension to use to pick the right loader
  96514. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96515. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96516. */
  96517. 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;
  96518. /**
  96519. * @hidden
  96520. */
  96521. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96522. /**
  96523. * Creates a raw texture
  96524. * @param data defines the data to store in the texture
  96525. * @param width defines the width of the texture
  96526. * @param height defines the height of the texture
  96527. * @param format defines the format of the data
  96528. * @param generateMipMaps defines if the engine should generate the mip levels
  96529. * @param invertY defines if data must be stored with Y axis inverted
  96530. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96531. * @param compression defines the compression used (null by default)
  96532. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96533. * @returns the raw texture inside an InternalTexture
  96534. */
  96535. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96536. /**
  96537. * Creates a new raw cube texture
  96538. * @param data defines the array of data to use to create each face
  96539. * @param size defines the size of the textures
  96540. * @param format defines the format of the data
  96541. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96542. * @param generateMipMaps defines if the engine should generate the mip levels
  96543. * @param invertY defines if data must be stored with Y axis inverted
  96544. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96545. * @param compression defines the compression used (null by default)
  96546. * @returns the cube texture as an InternalTexture
  96547. */
  96548. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96549. /**
  96550. * Creates a new raw 3D texture
  96551. * @param data defines the data used to create the texture
  96552. * @param width defines the width of the texture
  96553. * @param height defines the height of the texture
  96554. * @param depth defines the depth of the texture
  96555. * @param format defines the format of the texture
  96556. * @param generateMipMaps defines if the engine must generate mip levels
  96557. * @param invertY defines if data must be stored with Y axis inverted
  96558. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96559. * @param compression defines the compressed used (can be null)
  96560. * @param textureType defines the compressed used (can be null)
  96561. * @returns a new raw 3D texture (stored in an InternalTexture)
  96562. */
  96563. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96564. private _unpackFlipYCached;
  96565. /**
  96566. * In case you are sharing the context with other applications, it might
  96567. * be interested to not cache the unpack flip y state to ensure a consistent
  96568. * value would be set.
  96569. */
  96570. enableUnpackFlipYCached: boolean;
  96571. /** @hidden */
  96572. _unpackFlipY(value: boolean): void;
  96573. /** @hidden */
  96574. _getUnpackAlignement(): number;
  96575. /**
  96576. * Update the sampling mode of a given texture
  96577. * @param samplingMode defines the required sampling mode
  96578. * @param texture defines the texture to update
  96579. */
  96580. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96581. /**
  96582. * Updates a depth texture Comparison Mode and Function.
  96583. * If the comparison Function is equal to 0, the mode will be set to none.
  96584. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96585. * @param texture The texture to set the comparison function for
  96586. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96587. */
  96588. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96589. /** @hidden */
  96590. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96591. width: number;
  96592. height: number;
  96593. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96594. /**
  96595. * Creates a depth stencil texture.
  96596. * This is only available in WebGL 2 or with the depth texture extension available.
  96597. * @param size The size of face edge in the texture.
  96598. * @param options The options defining the texture.
  96599. * @returns The texture
  96600. */
  96601. createDepthStencilTexture(size: number | {
  96602. width: number;
  96603. height: number;
  96604. }, options: DepthTextureCreationOptions): InternalTexture;
  96605. /**
  96606. * Creates a depth stencil texture.
  96607. * This is only available in WebGL 2 or with the depth texture extension available.
  96608. * @param size The size of face edge in the texture.
  96609. * @param options The options defining the texture.
  96610. * @returns The texture
  96611. */
  96612. private _createDepthStencilTexture;
  96613. /** @hidden */
  96614. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96615. /** @hidden */
  96616. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96617. /** @hidden */
  96618. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96619. /** @hidden */
  96620. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96621. /**
  96622. * @hidden
  96623. */
  96624. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96625. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96626. private _prepareWebGLTexture;
  96627. /** @hidden */
  96628. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96629. /** @hidden */
  96630. _releaseFramebufferObjects(texture: InternalTexture): void;
  96631. /** @hidden */
  96632. _releaseTexture(texture: InternalTexture): void;
  96633. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96634. protected _setProgram(program: WebGLProgram): void;
  96635. protected _boundUniforms: {
  96636. [key: number]: WebGLUniformLocation;
  96637. };
  96638. /**
  96639. * Binds an effect to the webGL context
  96640. * @param effect defines the effect to bind
  96641. */
  96642. bindSamplers(effect: Effect): void;
  96643. private _activateCurrentTexture;
  96644. /** @hidden */
  96645. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96646. /** @hidden */
  96647. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96648. /**
  96649. * Unbind all textures from the webGL context
  96650. */
  96651. unbindAllTextures(): void;
  96652. /**
  96653. * Sets a texture to the according uniform.
  96654. * @param channel The texture channel
  96655. * @param uniform The uniform to set
  96656. * @param texture The texture to apply
  96657. */
  96658. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96659. private _bindSamplerUniformToChannel;
  96660. private _getTextureWrapMode;
  96661. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96662. /**
  96663. * Sets an array of texture to the webGL context
  96664. * @param channel defines the channel where the texture array must be set
  96665. * @param uniform defines the associated uniform location
  96666. * @param textures defines the array of textures to bind
  96667. */
  96668. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96669. /** @hidden */
  96670. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96671. private _setTextureParameterFloat;
  96672. private _setTextureParameterInteger;
  96673. /**
  96674. * Unbind all vertex attributes from the webGL context
  96675. */
  96676. unbindAllAttributes(): void;
  96677. /**
  96678. * 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
  96679. */
  96680. releaseEffects(): void;
  96681. /**
  96682. * Dispose and release all associated resources
  96683. */
  96684. dispose(): void;
  96685. /**
  96686. * Attach a new callback raised when context lost event is fired
  96687. * @param callback defines the callback to call
  96688. */
  96689. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96690. /**
  96691. * Attach a new callback raised when context restored event is fired
  96692. * @param callback defines the callback to call
  96693. */
  96694. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96695. /**
  96696. * Get the current error code of the webGL context
  96697. * @returns the error code
  96698. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96699. */
  96700. getError(): number;
  96701. private _canRenderToFloatFramebuffer;
  96702. private _canRenderToHalfFloatFramebuffer;
  96703. private _canRenderToFramebuffer;
  96704. /** @hidden */
  96705. _getWebGLTextureType(type: number): number;
  96706. /** @hidden */
  96707. _getInternalFormat(format: number): number;
  96708. /** @hidden */
  96709. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96710. /** @hidden */
  96711. _getRGBAMultiSampleBufferFormat(type: number): number;
  96712. /** @hidden */
  96713. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  96714. /**
  96715. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96716. * @returns true if the engine can be created
  96717. * @ignorenaming
  96718. */
  96719. static isSupported(): boolean;
  96720. /**
  96721. * Find the next highest power of two.
  96722. * @param x Number to start search from.
  96723. * @return Next highest power of two.
  96724. */
  96725. static CeilingPOT(x: number): number;
  96726. /**
  96727. * Find the next lowest power of two.
  96728. * @param x Number to start search from.
  96729. * @return Next lowest power of two.
  96730. */
  96731. static FloorPOT(x: number): number;
  96732. /**
  96733. * Find the nearest power of two.
  96734. * @param x Number to start search from.
  96735. * @return Next nearest power of two.
  96736. */
  96737. static NearestPOT(x: number): number;
  96738. /**
  96739. * Get the closest exponent of two
  96740. * @param value defines the value to approximate
  96741. * @param max defines the maximum value to return
  96742. * @param mode defines how to define the closest value
  96743. * @returns closest exponent of two of the given value
  96744. */
  96745. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96746. /**
  96747. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96748. * @param func - the function to be called
  96749. * @param requester - the object that will request the next frame. Falls back to window.
  96750. * @returns frame number
  96751. */
  96752. static QueueNewFrame(func: () => void, requester?: any): number;
  96753. }
  96754. }
  96755. declare module BABYLON {
  96756. /**
  96757. * Class representing spherical harmonics coefficients to the 3rd degree
  96758. */
  96759. export class SphericalHarmonics {
  96760. /**
  96761. * Defines whether or not the harmonics have been prescaled for rendering.
  96762. */
  96763. preScaled: boolean;
  96764. /**
  96765. * The l0,0 coefficients of the spherical harmonics
  96766. */
  96767. l00: Vector3;
  96768. /**
  96769. * The l1,-1 coefficients of the spherical harmonics
  96770. */
  96771. l1_1: Vector3;
  96772. /**
  96773. * The l1,0 coefficients of the spherical harmonics
  96774. */
  96775. l10: Vector3;
  96776. /**
  96777. * The l1,1 coefficients of the spherical harmonics
  96778. */
  96779. l11: Vector3;
  96780. /**
  96781. * The l2,-2 coefficients of the spherical harmonics
  96782. */
  96783. l2_2: Vector3;
  96784. /**
  96785. * The l2,-1 coefficients of the spherical harmonics
  96786. */
  96787. l2_1: Vector3;
  96788. /**
  96789. * The l2,0 coefficients of the spherical harmonics
  96790. */
  96791. l20: Vector3;
  96792. /**
  96793. * The l2,1 coefficients of the spherical harmonics
  96794. */
  96795. l21: Vector3;
  96796. /**
  96797. * The l2,2 coefficients of the spherical harmonics
  96798. */
  96799. l22: Vector3;
  96800. /**
  96801. * Adds a light to the spherical harmonics
  96802. * @param direction the direction of the light
  96803. * @param color the color of the light
  96804. * @param deltaSolidAngle the delta solid angle of the light
  96805. */
  96806. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96807. /**
  96808. * Scales the spherical harmonics by the given amount
  96809. * @param scale the amount to scale
  96810. */
  96811. scaleInPlace(scale: number): void;
  96812. /**
  96813. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96814. *
  96815. * ```
  96816. * E_lm = A_l * L_lm
  96817. * ```
  96818. *
  96819. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96820. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96821. * the scaling factors are given in equation 9.
  96822. */
  96823. convertIncidentRadianceToIrradiance(): void;
  96824. /**
  96825. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96826. *
  96827. * ```
  96828. * L = (1/pi) * E * rho
  96829. * ```
  96830. *
  96831. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96832. */
  96833. convertIrradianceToLambertianRadiance(): void;
  96834. /**
  96835. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96836. * required operations at run time.
  96837. *
  96838. * This is simply done by scaling back the SH with Ylm constants parameter.
  96839. * The trigonometric part being applied by the shader at run time.
  96840. */
  96841. preScaleForRendering(): void;
  96842. /**
  96843. * Constructs a spherical harmonics from an array.
  96844. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96845. * @returns the spherical harmonics
  96846. */
  96847. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96848. /**
  96849. * Gets the spherical harmonics from polynomial
  96850. * @param polynomial the spherical polynomial
  96851. * @returns the spherical harmonics
  96852. */
  96853. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96854. }
  96855. /**
  96856. * Class representing spherical polynomial coefficients to the 3rd degree
  96857. */
  96858. export class SphericalPolynomial {
  96859. private _harmonics;
  96860. /**
  96861. * The spherical harmonics used to create the polynomials.
  96862. */
  96863. readonly preScaledHarmonics: SphericalHarmonics;
  96864. /**
  96865. * The x coefficients of the spherical polynomial
  96866. */
  96867. x: Vector3;
  96868. /**
  96869. * The y coefficients of the spherical polynomial
  96870. */
  96871. y: Vector3;
  96872. /**
  96873. * The z coefficients of the spherical polynomial
  96874. */
  96875. z: Vector3;
  96876. /**
  96877. * The xx coefficients of the spherical polynomial
  96878. */
  96879. xx: Vector3;
  96880. /**
  96881. * The yy coefficients of the spherical polynomial
  96882. */
  96883. yy: Vector3;
  96884. /**
  96885. * The zz coefficients of the spherical polynomial
  96886. */
  96887. zz: Vector3;
  96888. /**
  96889. * The xy coefficients of the spherical polynomial
  96890. */
  96891. xy: Vector3;
  96892. /**
  96893. * The yz coefficients of the spherical polynomial
  96894. */
  96895. yz: Vector3;
  96896. /**
  96897. * The zx coefficients of the spherical polynomial
  96898. */
  96899. zx: Vector3;
  96900. /**
  96901. * Adds an ambient color to the spherical polynomial
  96902. * @param color the color to add
  96903. */
  96904. addAmbient(color: Color3): void;
  96905. /**
  96906. * Scales the spherical polynomial by the given amount
  96907. * @param scale the amount to scale
  96908. */
  96909. scaleInPlace(scale: number): void;
  96910. /**
  96911. * Gets the spherical polynomial from harmonics
  96912. * @param harmonics the spherical harmonics
  96913. * @returns the spherical polynomial
  96914. */
  96915. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96916. /**
  96917. * Constructs a spherical polynomial from an array.
  96918. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96919. * @returns the spherical polynomial
  96920. */
  96921. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96922. }
  96923. }
  96924. declare module BABYLON {
  96925. /**
  96926. * Defines the source of the internal texture
  96927. */
  96928. export enum InternalTextureSource {
  96929. /**
  96930. * The source of the texture data is unknown
  96931. */
  96932. Unknown = 0,
  96933. /**
  96934. * Texture data comes from an URL
  96935. */
  96936. Url = 1,
  96937. /**
  96938. * Texture data is only used for temporary storage
  96939. */
  96940. Temp = 2,
  96941. /**
  96942. * Texture data comes from raw data (ArrayBuffer)
  96943. */
  96944. Raw = 3,
  96945. /**
  96946. * Texture content is dynamic (video or dynamic texture)
  96947. */
  96948. Dynamic = 4,
  96949. /**
  96950. * Texture content is generated by rendering to it
  96951. */
  96952. RenderTarget = 5,
  96953. /**
  96954. * Texture content is part of a multi render target process
  96955. */
  96956. MultiRenderTarget = 6,
  96957. /**
  96958. * Texture data comes from a cube data file
  96959. */
  96960. Cube = 7,
  96961. /**
  96962. * Texture data comes from a raw cube data
  96963. */
  96964. CubeRaw = 8,
  96965. /**
  96966. * Texture data come from a prefiltered cube data file
  96967. */
  96968. CubePrefiltered = 9,
  96969. /**
  96970. * Texture content is raw 3D data
  96971. */
  96972. Raw3D = 10,
  96973. /**
  96974. * Texture content is a depth texture
  96975. */
  96976. Depth = 11,
  96977. /**
  96978. * Texture data comes from a raw cube data encoded with RGBD
  96979. */
  96980. CubeRawRGBD = 12
  96981. }
  96982. /**
  96983. * Class used to store data associated with WebGL texture data for the engine
  96984. * This class should not be used directly
  96985. */
  96986. export class InternalTexture {
  96987. /** @hidden */
  96988. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  96989. /**
  96990. * Defines if the texture is ready
  96991. */
  96992. isReady: boolean;
  96993. /**
  96994. * Defines if the texture is a cube texture
  96995. */
  96996. isCube: boolean;
  96997. /**
  96998. * Defines if the texture contains 3D data
  96999. */
  97000. is3D: boolean;
  97001. /**
  97002. * Defines if the texture contains multiview data
  97003. */
  97004. isMultiview: boolean;
  97005. /**
  97006. * Gets the URL used to load this texture
  97007. */
  97008. url: string;
  97009. /**
  97010. * Gets the sampling mode of the texture
  97011. */
  97012. samplingMode: number;
  97013. /**
  97014. * Gets a boolean indicating if the texture needs mipmaps generation
  97015. */
  97016. generateMipMaps: boolean;
  97017. /**
  97018. * Gets the number of samples used by the texture (WebGL2+ only)
  97019. */
  97020. samples: number;
  97021. /**
  97022. * Gets the type of the texture (int, float...)
  97023. */
  97024. type: number;
  97025. /**
  97026. * Gets the format of the texture (RGB, RGBA...)
  97027. */
  97028. format: number;
  97029. /**
  97030. * Observable called when the texture is loaded
  97031. */
  97032. onLoadedObservable: Observable<InternalTexture>;
  97033. /**
  97034. * Gets the width of the texture
  97035. */
  97036. width: number;
  97037. /**
  97038. * Gets the height of the texture
  97039. */
  97040. height: number;
  97041. /**
  97042. * Gets the depth of the texture
  97043. */
  97044. depth: number;
  97045. /**
  97046. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97047. */
  97048. baseWidth: number;
  97049. /**
  97050. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97051. */
  97052. baseHeight: number;
  97053. /**
  97054. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97055. */
  97056. baseDepth: number;
  97057. /**
  97058. * Gets a boolean indicating if the texture is inverted on Y axis
  97059. */
  97060. invertY: boolean;
  97061. /** @hidden */
  97062. _invertVScale: boolean;
  97063. /** @hidden */
  97064. _associatedChannel: number;
  97065. /** @hidden */
  97066. _source: InternalTextureSource;
  97067. /** @hidden */
  97068. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97069. /** @hidden */
  97070. _bufferView: Nullable<ArrayBufferView>;
  97071. /** @hidden */
  97072. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97073. /** @hidden */
  97074. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97075. /** @hidden */
  97076. _size: number;
  97077. /** @hidden */
  97078. _extension: string;
  97079. /** @hidden */
  97080. _files: Nullable<string[]>;
  97081. /** @hidden */
  97082. _workingCanvas: Nullable<HTMLCanvasElement>;
  97083. /** @hidden */
  97084. _workingContext: Nullable<CanvasRenderingContext2D>;
  97085. /** @hidden */
  97086. _framebuffer: Nullable<WebGLFramebuffer>;
  97087. /** @hidden */
  97088. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97089. /** @hidden */
  97090. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97091. /** @hidden */
  97092. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97093. /** @hidden */
  97094. _attachments: Nullable<number[]>;
  97095. /** @hidden */
  97096. _cachedCoordinatesMode: Nullable<number>;
  97097. /** @hidden */
  97098. _cachedWrapU: Nullable<number>;
  97099. /** @hidden */
  97100. _cachedWrapV: Nullable<number>;
  97101. /** @hidden */
  97102. _cachedWrapR: Nullable<number>;
  97103. /** @hidden */
  97104. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97105. /** @hidden */
  97106. _isDisabled: boolean;
  97107. /** @hidden */
  97108. _compression: Nullable<string>;
  97109. /** @hidden */
  97110. _generateStencilBuffer: boolean;
  97111. /** @hidden */
  97112. _generateDepthBuffer: boolean;
  97113. /** @hidden */
  97114. _comparisonFunction: number;
  97115. /** @hidden */
  97116. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97117. /** @hidden */
  97118. _lodGenerationScale: number;
  97119. /** @hidden */
  97120. _lodGenerationOffset: number;
  97121. /** @hidden */
  97122. _colorTextureArray: Nullable<WebGLTexture>;
  97123. /** @hidden */
  97124. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97125. /** @hidden */
  97126. _lodTextureHigh: Nullable<BaseTexture>;
  97127. /** @hidden */
  97128. _lodTextureMid: Nullable<BaseTexture>;
  97129. /** @hidden */
  97130. _lodTextureLow: Nullable<BaseTexture>;
  97131. /** @hidden */
  97132. _isRGBD: boolean;
  97133. /** @hidden */
  97134. _linearSpecularLOD: boolean;
  97135. /** @hidden */
  97136. _irradianceTexture: Nullable<BaseTexture>;
  97137. /** @hidden */
  97138. _webGLTexture: Nullable<WebGLTexture>;
  97139. /** @hidden */
  97140. _references: number;
  97141. private _engine;
  97142. /**
  97143. * Gets the Engine the texture belongs to.
  97144. * @returns The babylon engine
  97145. */
  97146. getEngine(): ThinEngine;
  97147. /**
  97148. * Gets the data source type of the texture
  97149. */
  97150. readonly source: InternalTextureSource;
  97151. /**
  97152. * Creates a new InternalTexture
  97153. * @param engine defines the engine to use
  97154. * @param source defines the type of data that will be used
  97155. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97156. */
  97157. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97158. /**
  97159. * Increments the number of references (ie. the number of Texture that point to it)
  97160. */
  97161. incrementReferences(): void;
  97162. /**
  97163. * Change the size of the texture (not the size of the content)
  97164. * @param width defines the new width
  97165. * @param height defines the new height
  97166. * @param depth defines the new depth (1 by default)
  97167. */
  97168. updateSize(width: int, height: int, depth?: int): void;
  97169. /** @hidden */
  97170. _rebuild(): void;
  97171. /** @hidden */
  97172. _swapAndDie(target: InternalTexture): void;
  97173. /**
  97174. * Dispose the current allocated resources
  97175. */
  97176. dispose(): void;
  97177. }
  97178. }
  97179. declare module BABYLON {
  97180. /**
  97181. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97182. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97183. */
  97184. export class Analyser {
  97185. /**
  97186. * Gets or sets the smoothing
  97187. * @ignorenaming
  97188. */
  97189. SMOOTHING: number;
  97190. /**
  97191. * Gets or sets the FFT table size
  97192. * @ignorenaming
  97193. */
  97194. FFT_SIZE: number;
  97195. /**
  97196. * Gets or sets the bar graph amplitude
  97197. * @ignorenaming
  97198. */
  97199. BARGRAPHAMPLITUDE: number;
  97200. /**
  97201. * Gets or sets the position of the debug canvas
  97202. * @ignorenaming
  97203. */
  97204. DEBUGCANVASPOS: {
  97205. x: number;
  97206. y: number;
  97207. };
  97208. /**
  97209. * Gets or sets the debug canvas size
  97210. * @ignorenaming
  97211. */
  97212. DEBUGCANVASSIZE: {
  97213. width: number;
  97214. height: number;
  97215. };
  97216. private _byteFreqs;
  97217. private _byteTime;
  97218. private _floatFreqs;
  97219. private _webAudioAnalyser;
  97220. private _debugCanvas;
  97221. private _debugCanvasContext;
  97222. private _scene;
  97223. private _registerFunc;
  97224. private _audioEngine;
  97225. /**
  97226. * Creates a new analyser
  97227. * @param scene defines hosting scene
  97228. */
  97229. constructor(scene: Scene);
  97230. /**
  97231. * Get the number of data values you will have to play with for the visualization
  97232. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97233. * @returns a number
  97234. */
  97235. getFrequencyBinCount(): number;
  97236. /**
  97237. * Gets the current frequency data as a byte array
  97238. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97239. * @returns a Uint8Array
  97240. */
  97241. getByteFrequencyData(): Uint8Array;
  97242. /**
  97243. * Gets the current waveform as a byte array
  97244. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97245. * @returns a Uint8Array
  97246. */
  97247. getByteTimeDomainData(): Uint8Array;
  97248. /**
  97249. * Gets the current frequency data as a float array
  97250. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97251. * @returns a Float32Array
  97252. */
  97253. getFloatFrequencyData(): Float32Array;
  97254. /**
  97255. * Renders the debug canvas
  97256. */
  97257. drawDebugCanvas(): void;
  97258. /**
  97259. * Stops rendering the debug canvas and removes it
  97260. */
  97261. stopDebugCanvas(): void;
  97262. /**
  97263. * Connects two audio nodes
  97264. * @param inputAudioNode defines first node to connect
  97265. * @param outputAudioNode defines second node to connect
  97266. */
  97267. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97268. /**
  97269. * Releases all associated resources
  97270. */
  97271. dispose(): void;
  97272. }
  97273. }
  97274. declare module BABYLON {
  97275. /**
  97276. * This represents an audio engine and it is responsible
  97277. * to play, synchronize and analyse sounds throughout the application.
  97278. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97279. */
  97280. export interface IAudioEngine extends IDisposable {
  97281. /**
  97282. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97283. */
  97284. readonly canUseWebAudio: boolean;
  97285. /**
  97286. * Gets the current AudioContext if available.
  97287. */
  97288. readonly audioContext: Nullable<AudioContext>;
  97289. /**
  97290. * The master gain node defines the global audio volume of your audio engine.
  97291. */
  97292. readonly masterGain: GainNode;
  97293. /**
  97294. * Gets whether or not mp3 are supported by your browser.
  97295. */
  97296. readonly isMP3supported: boolean;
  97297. /**
  97298. * Gets whether or not ogg are supported by your browser.
  97299. */
  97300. readonly isOGGsupported: boolean;
  97301. /**
  97302. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97303. * @ignoreNaming
  97304. */
  97305. WarnedWebAudioUnsupported: boolean;
  97306. /**
  97307. * Defines if the audio engine relies on a custom unlocked button.
  97308. * In this case, the embedded button will not be displayed.
  97309. */
  97310. useCustomUnlockedButton: boolean;
  97311. /**
  97312. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97313. */
  97314. readonly unlocked: boolean;
  97315. /**
  97316. * Event raised when audio has been unlocked on the browser.
  97317. */
  97318. onAudioUnlockedObservable: Observable<AudioEngine>;
  97319. /**
  97320. * Event raised when audio has been locked on the browser.
  97321. */
  97322. onAudioLockedObservable: Observable<AudioEngine>;
  97323. /**
  97324. * Flags the audio engine in Locked state.
  97325. * This happens due to new browser policies preventing audio to autoplay.
  97326. */
  97327. lock(): void;
  97328. /**
  97329. * Unlocks the audio engine once a user action has been done on the dom.
  97330. * This is helpful to resume play once browser policies have been satisfied.
  97331. */
  97332. unlock(): void;
  97333. }
  97334. /**
  97335. * This represents the default audio engine used in babylon.
  97336. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97337. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97338. */
  97339. export class AudioEngine implements IAudioEngine {
  97340. private _audioContext;
  97341. private _audioContextInitialized;
  97342. private _muteButton;
  97343. private _hostElement;
  97344. /**
  97345. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97346. */
  97347. canUseWebAudio: boolean;
  97348. /**
  97349. * The master gain node defines the global audio volume of your audio engine.
  97350. */
  97351. masterGain: GainNode;
  97352. /**
  97353. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97354. * @ignoreNaming
  97355. */
  97356. WarnedWebAudioUnsupported: boolean;
  97357. /**
  97358. * Gets whether or not mp3 are supported by your browser.
  97359. */
  97360. isMP3supported: boolean;
  97361. /**
  97362. * Gets whether or not ogg are supported by your browser.
  97363. */
  97364. isOGGsupported: boolean;
  97365. /**
  97366. * Gets whether audio has been unlocked on the device.
  97367. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97368. * a user interaction has happened.
  97369. */
  97370. unlocked: boolean;
  97371. /**
  97372. * Defines if the audio engine relies on a custom unlocked button.
  97373. * In this case, the embedded button will not be displayed.
  97374. */
  97375. useCustomUnlockedButton: boolean;
  97376. /**
  97377. * Event raised when audio has been unlocked on the browser.
  97378. */
  97379. onAudioUnlockedObservable: Observable<AudioEngine>;
  97380. /**
  97381. * Event raised when audio has been locked on the browser.
  97382. */
  97383. onAudioLockedObservable: Observable<AudioEngine>;
  97384. /**
  97385. * Gets the current AudioContext if available.
  97386. */
  97387. readonly audioContext: Nullable<AudioContext>;
  97388. private _connectedAnalyser;
  97389. /**
  97390. * Instantiates a new audio engine.
  97391. *
  97392. * There should be only one per page as some browsers restrict the number
  97393. * of audio contexts you can create.
  97394. * @param hostElement defines the host element where to display the mute icon if necessary
  97395. */
  97396. constructor(hostElement?: Nullable<HTMLElement>);
  97397. /**
  97398. * Flags the audio engine in Locked state.
  97399. * This happens due to new browser policies preventing audio to autoplay.
  97400. */
  97401. lock(): void;
  97402. /**
  97403. * Unlocks the audio engine once a user action has been done on the dom.
  97404. * This is helpful to resume play once browser policies have been satisfied.
  97405. */
  97406. unlock(): void;
  97407. private _resumeAudioContext;
  97408. private _initializeAudioContext;
  97409. private _tryToRun;
  97410. private _triggerRunningState;
  97411. private _triggerSuspendedState;
  97412. private _displayMuteButton;
  97413. private _moveButtonToTopLeft;
  97414. private _onResize;
  97415. private _hideMuteButton;
  97416. /**
  97417. * Destroy and release the resources associated with the audio ccontext.
  97418. */
  97419. dispose(): void;
  97420. /**
  97421. * Gets the global volume sets on the master gain.
  97422. * @returns the global volume if set or -1 otherwise
  97423. */
  97424. getGlobalVolume(): number;
  97425. /**
  97426. * Sets the global volume of your experience (sets on the master gain).
  97427. * @param newVolume Defines the new global volume of the application
  97428. */
  97429. setGlobalVolume(newVolume: number): void;
  97430. /**
  97431. * Connect the audio engine to an audio analyser allowing some amazing
  97432. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97434. * @param analyser The analyser to connect to the engine
  97435. */
  97436. connectToAnalyser(analyser: Analyser): void;
  97437. }
  97438. }
  97439. declare module BABYLON {
  97440. /**
  97441. * Interface used to present a loading screen while loading a scene
  97442. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97443. */
  97444. export interface ILoadingScreen {
  97445. /**
  97446. * Function called to display the loading screen
  97447. */
  97448. displayLoadingUI: () => void;
  97449. /**
  97450. * Function called to hide the loading screen
  97451. */
  97452. hideLoadingUI: () => void;
  97453. /**
  97454. * Gets or sets the color to use for the background
  97455. */
  97456. loadingUIBackgroundColor: string;
  97457. /**
  97458. * Gets or sets the text to display while loading
  97459. */
  97460. loadingUIText: string;
  97461. }
  97462. /**
  97463. * Class used for the default loading screen
  97464. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97465. */
  97466. export class DefaultLoadingScreen implements ILoadingScreen {
  97467. private _renderingCanvas;
  97468. private _loadingText;
  97469. private _loadingDivBackgroundColor;
  97470. private _loadingDiv;
  97471. private _loadingTextDiv;
  97472. /** Gets or sets the logo url to use for the default loading screen */
  97473. static DefaultLogoUrl: string;
  97474. /** Gets or sets the spinner url to use for the default loading screen */
  97475. static DefaultSpinnerUrl: string;
  97476. /**
  97477. * Creates a new default loading screen
  97478. * @param _renderingCanvas defines the canvas used to render the scene
  97479. * @param _loadingText defines the default text to display
  97480. * @param _loadingDivBackgroundColor defines the default background color
  97481. */
  97482. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97483. /**
  97484. * Function called to display the loading screen
  97485. */
  97486. displayLoadingUI(): void;
  97487. /**
  97488. * Function called to hide the loading screen
  97489. */
  97490. hideLoadingUI(): void;
  97491. /**
  97492. * Gets or sets the text to display while loading
  97493. */
  97494. loadingUIText: string;
  97495. /**
  97496. * Gets or sets the color to use for the background
  97497. */
  97498. loadingUIBackgroundColor: string;
  97499. private _resizeLoadingUI;
  97500. }
  97501. }
  97502. declare module BABYLON {
  97503. /**
  97504. * Interface for any object that can request an animation frame
  97505. */
  97506. export interface ICustomAnimationFrameRequester {
  97507. /**
  97508. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97509. */
  97510. renderFunction?: Function;
  97511. /**
  97512. * Called to request the next frame to render to
  97513. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97514. */
  97515. requestAnimationFrame: Function;
  97516. /**
  97517. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97518. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97519. */
  97520. requestID?: number;
  97521. }
  97522. }
  97523. declare module BABYLON {
  97524. /**
  97525. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97526. */
  97527. export class PerformanceMonitor {
  97528. private _enabled;
  97529. private _rollingFrameTime;
  97530. private _lastFrameTimeMs;
  97531. /**
  97532. * constructor
  97533. * @param frameSampleSize The number of samples required to saturate the sliding window
  97534. */
  97535. constructor(frameSampleSize?: number);
  97536. /**
  97537. * Samples current frame
  97538. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97539. */
  97540. sampleFrame(timeMs?: number): void;
  97541. /**
  97542. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97543. */
  97544. readonly averageFrameTime: number;
  97545. /**
  97546. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97547. */
  97548. readonly averageFrameTimeVariance: number;
  97549. /**
  97550. * Returns the frame time of the most recent frame
  97551. */
  97552. readonly instantaneousFrameTime: number;
  97553. /**
  97554. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97555. */
  97556. readonly averageFPS: number;
  97557. /**
  97558. * Returns the average framerate in frames per second using the most recent frame time
  97559. */
  97560. readonly instantaneousFPS: number;
  97561. /**
  97562. * Returns true if enough samples have been taken to completely fill the sliding window
  97563. */
  97564. readonly isSaturated: boolean;
  97565. /**
  97566. * Enables contributions to the sliding window sample set
  97567. */
  97568. enable(): void;
  97569. /**
  97570. * Disables contributions to the sliding window sample set
  97571. * Samples will not be interpolated over the disabled period
  97572. */
  97573. disable(): void;
  97574. /**
  97575. * Returns true if sampling is enabled
  97576. */
  97577. readonly isEnabled: boolean;
  97578. /**
  97579. * Resets performance monitor
  97580. */
  97581. reset(): void;
  97582. }
  97583. /**
  97584. * RollingAverage
  97585. *
  97586. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97587. */
  97588. export class RollingAverage {
  97589. /**
  97590. * Current average
  97591. */
  97592. average: number;
  97593. /**
  97594. * Current variance
  97595. */
  97596. variance: number;
  97597. protected _samples: Array<number>;
  97598. protected _sampleCount: number;
  97599. protected _pos: number;
  97600. protected _m2: number;
  97601. /**
  97602. * constructor
  97603. * @param length The number of samples required to saturate the sliding window
  97604. */
  97605. constructor(length: number);
  97606. /**
  97607. * Adds a sample to the sample set
  97608. * @param v The sample value
  97609. */
  97610. add(v: number): void;
  97611. /**
  97612. * Returns previously added values or null if outside of history or outside the sliding window domain
  97613. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97614. * @return Value previously recorded with add() or null if outside of range
  97615. */
  97616. history(i: number): number;
  97617. /**
  97618. * Returns true if enough samples have been taken to completely fill the sliding window
  97619. * @return true if sample-set saturated
  97620. */
  97621. isSaturated(): boolean;
  97622. /**
  97623. * Resets the rolling average (equivalent to 0 samples taken so far)
  97624. */
  97625. reset(): void;
  97626. /**
  97627. * Wraps a value around the sample range boundaries
  97628. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97629. * @return Wrapped position in sample range
  97630. */
  97631. protected _wrapPosition(i: number): number;
  97632. }
  97633. }
  97634. declare module BABYLON {
  97635. /**
  97636. * This class is used to track a performance counter which is number based.
  97637. * The user has access to many properties which give statistics of different nature.
  97638. *
  97639. * The implementer can track two kinds of Performance Counter: time and count.
  97640. * 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.
  97641. * 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.
  97642. */
  97643. export class PerfCounter {
  97644. /**
  97645. * Gets or sets a global boolean to turn on and off all the counters
  97646. */
  97647. static Enabled: boolean;
  97648. /**
  97649. * Returns the smallest value ever
  97650. */
  97651. readonly min: number;
  97652. /**
  97653. * Returns the biggest value ever
  97654. */
  97655. readonly max: number;
  97656. /**
  97657. * Returns the average value since the performance counter is running
  97658. */
  97659. readonly average: number;
  97660. /**
  97661. * Returns the average value of the last second the counter was monitored
  97662. */
  97663. readonly lastSecAverage: number;
  97664. /**
  97665. * Returns the current value
  97666. */
  97667. readonly current: number;
  97668. /**
  97669. * Gets the accumulated total
  97670. */
  97671. readonly total: number;
  97672. /**
  97673. * Gets the total value count
  97674. */
  97675. readonly count: number;
  97676. /**
  97677. * Creates a new counter
  97678. */
  97679. constructor();
  97680. /**
  97681. * Call this method to start monitoring a new frame.
  97682. * 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.
  97683. */
  97684. fetchNewFrame(): void;
  97685. /**
  97686. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97687. * @param newCount the count value to add to the monitored count
  97688. * @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.
  97689. */
  97690. addCount(newCount: number, fetchResult: boolean): void;
  97691. /**
  97692. * Start monitoring this performance counter
  97693. */
  97694. beginMonitoring(): void;
  97695. /**
  97696. * Compute the time lapsed since the previous beginMonitoring() call.
  97697. * @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
  97698. */
  97699. endMonitoring(newFrame?: boolean): void;
  97700. private _fetchResult;
  97701. private _startMonitoringTime;
  97702. private _min;
  97703. private _max;
  97704. private _average;
  97705. private _current;
  97706. private _totalValueCount;
  97707. private _totalAccumulated;
  97708. private _lastSecAverage;
  97709. private _lastSecAccumulated;
  97710. private _lastSecTime;
  97711. private _lastSecValueCount;
  97712. }
  97713. }
  97714. declare module BABYLON {
  97715. /**
  97716. * Defines the interface used by display changed events
  97717. */
  97718. export interface IDisplayChangedEventArgs {
  97719. /** Gets the vrDisplay object (if any) */
  97720. vrDisplay: Nullable<any>;
  97721. /** Gets a boolean indicating if webVR is supported */
  97722. vrSupported: boolean;
  97723. }
  97724. /**
  97725. * Defines the interface used by objects containing a viewport (like a camera)
  97726. */
  97727. interface IViewportOwnerLike {
  97728. /**
  97729. * Gets or sets the viewport
  97730. */
  97731. viewport: IViewportLike;
  97732. }
  97733. /**
  97734. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97735. */
  97736. export class Engine extends ThinEngine {
  97737. /** Defines that alpha blending is disabled */
  97738. static readonly ALPHA_DISABLE: number;
  97739. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97740. static readonly ALPHA_ADD: number;
  97741. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97742. static readonly ALPHA_COMBINE: number;
  97743. /** Defines that alpha blending to DEST - SRC * DEST */
  97744. static readonly ALPHA_SUBTRACT: number;
  97745. /** Defines that alpha blending to SRC * DEST */
  97746. static readonly ALPHA_MULTIPLY: number;
  97747. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97748. static readonly ALPHA_MAXIMIZED: number;
  97749. /** Defines that alpha blending to SRC + DEST */
  97750. static readonly ALPHA_ONEONE: number;
  97751. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97752. static readonly ALPHA_PREMULTIPLIED: number;
  97753. /**
  97754. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97755. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97756. */
  97757. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97758. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97759. static readonly ALPHA_INTERPOLATE: number;
  97760. /**
  97761. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97762. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97763. */
  97764. static readonly ALPHA_SCREENMODE: number;
  97765. /** Defines that the ressource is not delayed*/
  97766. static readonly DELAYLOADSTATE_NONE: number;
  97767. /** Defines that the ressource was successfully delay loaded */
  97768. static readonly DELAYLOADSTATE_LOADED: number;
  97769. /** Defines that the ressource is currently delay loading */
  97770. static readonly DELAYLOADSTATE_LOADING: number;
  97771. /** Defines that the ressource is delayed and has not started loading */
  97772. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97773. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97774. static readonly NEVER: number;
  97775. /** 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 */
  97776. static readonly ALWAYS: number;
  97777. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97778. static readonly LESS: number;
  97779. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97780. static readonly EQUAL: number;
  97781. /** 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 */
  97782. static readonly LEQUAL: number;
  97783. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97784. static readonly GREATER: number;
  97785. /** 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 */
  97786. static readonly GEQUAL: number;
  97787. /** 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 */
  97788. static readonly NOTEQUAL: number;
  97789. /** Passed to stencilOperation to specify that stencil value must be kept */
  97790. static readonly KEEP: number;
  97791. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97792. static readonly REPLACE: number;
  97793. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97794. static readonly INCR: number;
  97795. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97796. static readonly DECR: number;
  97797. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97798. static readonly INVERT: number;
  97799. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97800. static readonly INCR_WRAP: number;
  97801. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97802. static readonly DECR_WRAP: number;
  97803. /** Texture is not repeating outside of 0..1 UVs */
  97804. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97805. /** Texture is repeating outside of 0..1 UVs */
  97806. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97807. /** Texture is repeating and mirrored */
  97808. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97809. /** ALPHA */
  97810. static readonly TEXTUREFORMAT_ALPHA: number;
  97811. /** LUMINANCE */
  97812. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97813. /** LUMINANCE_ALPHA */
  97814. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97815. /** RGB */
  97816. static readonly TEXTUREFORMAT_RGB: number;
  97817. /** RGBA */
  97818. static readonly TEXTUREFORMAT_RGBA: number;
  97819. /** RED */
  97820. static readonly TEXTUREFORMAT_RED: number;
  97821. /** RED (2nd reference) */
  97822. static readonly TEXTUREFORMAT_R: number;
  97823. /** RG */
  97824. static readonly TEXTUREFORMAT_RG: number;
  97825. /** RED_INTEGER */
  97826. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97827. /** RED_INTEGER (2nd reference) */
  97828. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97829. /** RG_INTEGER */
  97830. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97831. /** RGB_INTEGER */
  97832. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97833. /** RGBA_INTEGER */
  97834. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97835. /** UNSIGNED_BYTE */
  97836. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97837. /** UNSIGNED_BYTE (2nd reference) */
  97838. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97839. /** FLOAT */
  97840. static readonly TEXTURETYPE_FLOAT: number;
  97841. /** HALF_FLOAT */
  97842. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97843. /** BYTE */
  97844. static readonly TEXTURETYPE_BYTE: number;
  97845. /** SHORT */
  97846. static readonly TEXTURETYPE_SHORT: number;
  97847. /** UNSIGNED_SHORT */
  97848. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97849. /** INT */
  97850. static readonly TEXTURETYPE_INT: number;
  97851. /** UNSIGNED_INT */
  97852. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97853. /** UNSIGNED_SHORT_4_4_4_4 */
  97854. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97855. /** UNSIGNED_SHORT_5_5_5_1 */
  97856. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97857. /** UNSIGNED_SHORT_5_6_5 */
  97858. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97859. /** UNSIGNED_INT_2_10_10_10_REV */
  97860. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97861. /** UNSIGNED_INT_24_8 */
  97862. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97863. /** UNSIGNED_INT_10F_11F_11F_REV */
  97864. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97865. /** UNSIGNED_INT_5_9_9_9_REV */
  97866. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97867. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97868. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97869. /** nearest is mag = nearest and min = nearest and mip = linear */
  97870. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97871. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97872. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97873. /** Trilinear is mag = linear and min = linear and mip = linear */
  97874. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97875. /** nearest is mag = nearest and min = nearest and mip = linear */
  97876. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97877. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97878. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97879. /** Trilinear is mag = linear and min = linear and mip = linear */
  97880. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97881. /** mag = nearest and min = nearest and mip = nearest */
  97882. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97883. /** mag = nearest and min = linear and mip = nearest */
  97884. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97885. /** mag = nearest and min = linear and mip = linear */
  97886. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97887. /** mag = nearest and min = linear and mip = none */
  97888. static readonly TEXTURE_NEAREST_LINEAR: number;
  97889. /** mag = nearest and min = nearest and mip = none */
  97890. static readonly TEXTURE_NEAREST_NEAREST: number;
  97891. /** mag = linear and min = nearest and mip = nearest */
  97892. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97893. /** mag = linear and min = nearest and mip = linear */
  97894. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97895. /** mag = linear and min = linear and mip = none */
  97896. static readonly TEXTURE_LINEAR_LINEAR: number;
  97897. /** mag = linear and min = nearest and mip = none */
  97898. static readonly TEXTURE_LINEAR_NEAREST: number;
  97899. /** Explicit coordinates mode */
  97900. static readonly TEXTURE_EXPLICIT_MODE: number;
  97901. /** Spherical coordinates mode */
  97902. static readonly TEXTURE_SPHERICAL_MODE: number;
  97903. /** Planar coordinates mode */
  97904. static readonly TEXTURE_PLANAR_MODE: number;
  97905. /** Cubic coordinates mode */
  97906. static readonly TEXTURE_CUBIC_MODE: number;
  97907. /** Projection coordinates mode */
  97908. static readonly TEXTURE_PROJECTION_MODE: number;
  97909. /** Skybox coordinates mode */
  97910. static readonly TEXTURE_SKYBOX_MODE: number;
  97911. /** Inverse Cubic coordinates mode */
  97912. static readonly TEXTURE_INVCUBIC_MODE: number;
  97913. /** Equirectangular coordinates mode */
  97914. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97915. /** Equirectangular Fixed coordinates mode */
  97916. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97917. /** Equirectangular Fixed Mirrored coordinates mode */
  97918. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97919. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97920. static readonly SCALEMODE_FLOOR: number;
  97921. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97922. static readonly SCALEMODE_NEAREST: number;
  97923. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97924. static readonly SCALEMODE_CEILING: number;
  97925. /**
  97926. * Returns the current npm package of the sdk
  97927. */
  97928. static readonly NpmPackage: string;
  97929. /**
  97930. * Returns the current version of the framework
  97931. */
  97932. static readonly Version: string;
  97933. /** Gets the list of created engines */
  97934. static readonly Instances: Engine[];
  97935. /**
  97936. * Gets the latest created engine
  97937. */
  97938. static readonly LastCreatedEngine: Nullable<Engine>;
  97939. /**
  97940. * Gets the latest created scene
  97941. */
  97942. static readonly LastCreatedScene: Nullable<Scene>;
  97943. /**
  97944. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97945. * @param flag defines which part of the materials must be marked as dirty
  97946. * @param predicate defines a predicate used to filter which materials should be affected
  97947. */
  97948. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97949. /**
  97950. * Method called to create the default loading screen.
  97951. * This can be overriden in your own app.
  97952. * @param canvas The rendering canvas element
  97953. * @returns The loading screen
  97954. */
  97955. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97956. /**
  97957. * Method called to create the default rescale post process on each engine.
  97958. */
  97959. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97960. /**
  97961. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97962. **/
  97963. enableOfflineSupport: boolean;
  97964. /**
  97965. * 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)
  97966. **/
  97967. disableManifestCheck: boolean;
  97968. /**
  97969. * Gets the list of created scenes
  97970. */
  97971. scenes: Scene[];
  97972. /**
  97973. * Event raised when a new scene is created
  97974. */
  97975. onNewSceneAddedObservable: Observable<Scene>;
  97976. /**
  97977. * Gets the list of created postprocesses
  97978. */
  97979. postProcesses: PostProcess[];
  97980. /**
  97981. * Gets a boolean indicating if the pointer is currently locked
  97982. */
  97983. isPointerLock: boolean;
  97984. /**
  97985. * Observable event triggered each time the rendering canvas is resized
  97986. */
  97987. onResizeObservable: Observable<Engine>;
  97988. /**
  97989. * Observable event triggered each time the canvas loses focus
  97990. */
  97991. onCanvasBlurObservable: Observable<Engine>;
  97992. /**
  97993. * Observable event triggered each time the canvas gains focus
  97994. */
  97995. onCanvasFocusObservable: Observable<Engine>;
  97996. /**
  97997. * Observable event triggered each time the canvas receives pointerout event
  97998. */
  97999. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98000. /**
  98001. * Observable raised when the engine begins a new frame
  98002. */
  98003. onBeginFrameObservable: Observable<Engine>;
  98004. /**
  98005. * If set, will be used to request the next animation frame for the render loop
  98006. */
  98007. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98008. /**
  98009. * Observable raised when the engine ends the current frame
  98010. */
  98011. onEndFrameObservable: Observable<Engine>;
  98012. /**
  98013. * Observable raised when the engine is about to compile a shader
  98014. */
  98015. onBeforeShaderCompilationObservable: Observable<Engine>;
  98016. /**
  98017. * Observable raised when the engine has jsut compiled a shader
  98018. */
  98019. onAfterShaderCompilationObservable: Observable<Engine>;
  98020. /**
  98021. * Gets the audio engine
  98022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98023. * @ignorenaming
  98024. */
  98025. static audioEngine: IAudioEngine;
  98026. /**
  98027. * Default AudioEngine factory responsible of creating the Audio Engine.
  98028. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98029. */
  98030. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98031. /**
  98032. * Default offline support factory responsible of creating a tool used to store data locally.
  98033. * By default, this will create a Database object if the workload has been embedded.
  98034. */
  98035. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98036. private _loadingScreen;
  98037. private _pointerLockRequested;
  98038. private _dummyFramebuffer;
  98039. private _rescalePostProcess;
  98040. /** @hidden */
  98041. protected _alphaMode: number;
  98042. /** @hidden */
  98043. protected _alphaEquation: number;
  98044. private _deterministicLockstep;
  98045. private _lockstepMaxSteps;
  98046. protected readonly _supportsHardwareTextureRescaling: boolean;
  98047. private _fps;
  98048. private _deltaTime;
  98049. /** @hidden */
  98050. _drawCalls: PerfCounter;
  98051. /**
  98052. * Turn this value on if you want to pause FPS computation when in background
  98053. */
  98054. disablePerformanceMonitorInBackground: boolean;
  98055. private _performanceMonitor;
  98056. /**
  98057. * Gets the performance monitor attached to this engine
  98058. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98059. */
  98060. readonly performanceMonitor: PerformanceMonitor;
  98061. private _onFocus;
  98062. private _onBlur;
  98063. private _onCanvasPointerOut;
  98064. private _onCanvasBlur;
  98065. private _onCanvasFocus;
  98066. private _onFullscreenChange;
  98067. private _onPointerLockChange;
  98068. /**
  98069. * Creates a new engine
  98070. * @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
  98071. * @param antialias defines enable antialiasing (default: false)
  98072. * @param options defines further options to be sent to the getContext() function
  98073. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98074. */
  98075. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98076. /**
  98077. * Gets current aspect ratio
  98078. * @param viewportOwner defines the camera to use to get the aspect ratio
  98079. * @param useScreen defines if screen size must be used (or the current render target if any)
  98080. * @returns a number defining the aspect ratio
  98081. */
  98082. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98083. /**
  98084. * Gets current screen aspect ratio
  98085. * @returns a number defining the aspect ratio
  98086. */
  98087. getScreenAspectRatio(): number;
  98088. /**
  98089. * Gets host document
  98090. * @returns the host document object
  98091. */
  98092. getHostDocument(): Document;
  98093. /**
  98094. * Gets the client rect of the HTML canvas attached with the current webGL context
  98095. * @returns a client rectanglee
  98096. */
  98097. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98098. /**
  98099. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98100. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98101. * @returns true if engine is in deterministic lock step mode
  98102. */
  98103. isDeterministicLockStep(): boolean;
  98104. /**
  98105. * Gets the max steps when engine is running in deterministic lock step
  98106. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98107. * @returns the max steps
  98108. */
  98109. getLockstepMaxSteps(): number;
  98110. /**
  98111. * Force the mipmap generation for the given render target texture
  98112. * @param texture defines the render target texture to use
  98113. */
  98114. generateMipMapsForCubemap(texture: InternalTexture): void;
  98115. /** States */
  98116. /**
  98117. * Set various states to the webGL context
  98118. * @param culling defines backface culling state
  98119. * @param zOffset defines the value to apply to zOffset (0 by default)
  98120. * @param force defines if states must be applied even if cache is up to date
  98121. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98122. */
  98123. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98124. /**
  98125. * Set the z offset to apply to current rendering
  98126. * @param value defines the offset to apply
  98127. */
  98128. setZOffset(value: number): void;
  98129. /**
  98130. * Gets the current value of the zOffset
  98131. * @returns the current zOffset state
  98132. */
  98133. getZOffset(): number;
  98134. /**
  98135. * Enable or disable depth buffering
  98136. * @param enable defines the state to set
  98137. */
  98138. setDepthBuffer(enable: boolean): void;
  98139. /**
  98140. * Gets a boolean indicating if depth writing is enabled
  98141. * @returns the current depth writing state
  98142. */
  98143. getDepthWrite(): boolean;
  98144. /**
  98145. * Enable or disable depth writing
  98146. * @param enable defines the state to set
  98147. */
  98148. setDepthWrite(enable: boolean): void;
  98149. /**
  98150. * Enable or disable color writing
  98151. * @param enable defines the state to set
  98152. */
  98153. setColorWrite(enable: boolean): void;
  98154. /**
  98155. * Gets a boolean indicating if color writing is enabled
  98156. * @returns the current color writing state
  98157. */
  98158. getColorWrite(): boolean;
  98159. /**
  98160. * Sets alpha constants used by some alpha blending modes
  98161. * @param r defines the red component
  98162. * @param g defines the green component
  98163. * @param b defines the blue component
  98164. * @param a defines the alpha component
  98165. */
  98166. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98167. /**
  98168. * Sets the current alpha mode
  98169. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98170. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98171. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98172. */
  98173. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98174. /**
  98175. * Gets the current alpha mode
  98176. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98177. * @returns the current alpha mode
  98178. */
  98179. getAlphaMode(): number;
  98180. /**
  98181. * Sets the current alpha equation
  98182. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98183. */
  98184. setAlphaEquation(equation: number): void;
  98185. /**
  98186. * Gets the current alpha equation.
  98187. * @returns the current alpha equation
  98188. */
  98189. getAlphaEquation(): number;
  98190. /**
  98191. * Gets a boolean indicating if stencil buffer is enabled
  98192. * @returns the current stencil buffer state
  98193. */
  98194. getStencilBuffer(): boolean;
  98195. /**
  98196. * Enable or disable the stencil buffer
  98197. * @param enable defines if the stencil buffer must be enabled or disabled
  98198. */
  98199. setStencilBuffer(enable: boolean): void;
  98200. /**
  98201. * Gets the current stencil mask
  98202. * @returns a number defining the new stencil mask to use
  98203. */
  98204. getStencilMask(): number;
  98205. /**
  98206. * Sets the current stencil mask
  98207. * @param mask defines the new stencil mask to use
  98208. */
  98209. setStencilMask(mask: number): void;
  98210. /**
  98211. * Gets the current stencil function
  98212. * @returns a number defining the stencil function to use
  98213. */
  98214. getStencilFunction(): number;
  98215. /**
  98216. * Gets the current stencil reference value
  98217. * @returns a number defining the stencil reference value to use
  98218. */
  98219. getStencilFunctionReference(): number;
  98220. /**
  98221. * Gets the current stencil mask
  98222. * @returns a number defining the stencil mask to use
  98223. */
  98224. getStencilFunctionMask(): number;
  98225. /**
  98226. * Sets the current stencil function
  98227. * @param stencilFunc defines the new stencil function to use
  98228. */
  98229. setStencilFunction(stencilFunc: number): void;
  98230. /**
  98231. * Sets the current stencil reference
  98232. * @param reference defines the new stencil reference to use
  98233. */
  98234. setStencilFunctionReference(reference: number): void;
  98235. /**
  98236. * Sets the current stencil mask
  98237. * @param mask defines the new stencil mask to use
  98238. */
  98239. setStencilFunctionMask(mask: number): void;
  98240. /**
  98241. * Gets the current stencil operation when stencil fails
  98242. * @returns a number defining stencil operation to use when stencil fails
  98243. */
  98244. getStencilOperationFail(): number;
  98245. /**
  98246. * Gets the current stencil operation when depth fails
  98247. * @returns a number defining stencil operation to use when depth fails
  98248. */
  98249. getStencilOperationDepthFail(): number;
  98250. /**
  98251. * Gets the current stencil operation when stencil passes
  98252. * @returns a number defining stencil operation to use when stencil passes
  98253. */
  98254. getStencilOperationPass(): number;
  98255. /**
  98256. * Sets the stencil operation to use when stencil fails
  98257. * @param operation defines the stencil operation to use when stencil fails
  98258. */
  98259. setStencilOperationFail(operation: number): void;
  98260. /**
  98261. * Sets the stencil operation to use when depth fails
  98262. * @param operation defines the stencil operation to use when depth fails
  98263. */
  98264. setStencilOperationDepthFail(operation: number): void;
  98265. /**
  98266. * Sets the stencil operation to use when stencil passes
  98267. * @param operation defines the stencil operation to use when stencil passes
  98268. */
  98269. setStencilOperationPass(operation: number): void;
  98270. /**
  98271. * Sets a boolean indicating if the dithering state is enabled or disabled
  98272. * @param value defines the dithering state
  98273. */
  98274. setDitheringState(value: boolean): void;
  98275. /**
  98276. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98277. * @param value defines the rasterizer state
  98278. */
  98279. setRasterizerState(value: boolean): void;
  98280. /**
  98281. * Gets the current depth function
  98282. * @returns a number defining the depth function
  98283. */
  98284. getDepthFunction(): Nullable<number>;
  98285. /**
  98286. * Sets the current depth function
  98287. * @param depthFunc defines the function to use
  98288. */
  98289. setDepthFunction(depthFunc: number): void;
  98290. /**
  98291. * Sets the current depth function to GREATER
  98292. */
  98293. setDepthFunctionToGreater(): void;
  98294. /**
  98295. * Sets the current depth function to GEQUAL
  98296. */
  98297. setDepthFunctionToGreaterOrEqual(): void;
  98298. /**
  98299. * Sets the current depth function to LESS
  98300. */
  98301. setDepthFunctionToLess(): void;
  98302. /**
  98303. * Sets the current depth function to LEQUAL
  98304. */
  98305. setDepthFunctionToLessOrEqual(): void;
  98306. private _cachedStencilBuffer;
  98307. private _cachedStencilFunction;
  98308. private _cachedStencilMask;
  98309. private _cachedStencilOperationPass;
  98310. private _cachedStencilOperationFail;
  98311. private _cachedStencilOperationDepthFail;
  98312. private _cachedStencilReference;
  98313. /**
  98314. * Caches the the state of the stencil buffer
  98315. */
  98316. cacheStencilState(): void;
  98317. /**
  98318. * Restores the state of the stencil buffer
  98319. */
  98320. restoreStencilState(): void;
  98321. /**
  98322. * Directly set the WebGL Viewport
  98323. * @param x defines the x coordinate of the viewport (in screen space)
  98324. * @param y defines the y coordinate of the viewport (in screen space)
  98325. * @param width defines the width of the viewport (in screen space)
  98326. * @param height defines the height of the viewport (in screen space)
  98327. * @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
  98328. */
  98329. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98330. /**
  98331. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98332. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98333. * @param y defines the y-coordinate of the corner of the clear rectangle
  98334. * @param width defines the width of the clear rectangle
  98335. * @param height defines the height of the clear rectangle
  98336. * @param clearColor defines the clear color
  98337. */
  98338. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98339. /**
  98340. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98341. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98342. * @param y defines the y-coordinate of the corner of the clear rectangle
  98343. * @param width defines the width of the clear rectangle
  98344. * @param height defines the height of the clear rectangle
  98345. */
  98346. enableScissor(x: number, y: number, width: number, height: number): void;
  98347. /**
  98348. * Disable previously set scissor test rectangle
  98349. */
  98350. disableScissor(): void;
  98351. protected _reportDrawCall(): void;
  98352. /**
  98353. * Initializes a webVR display and starts listening to display change events
  98354. * The onVRDisplayChangedObservable will be notified upon these changes
  98355. * @returns The onVRDisplayChangedObservable
  98356. */
  98357. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98358. /** @hidden */
  98359. _prepareVRComponent(): void;
  98360. /** @hidden */
  98361. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98362. /** @hidden */
  98363. _submitVRFrame(): void;
  98364. /**
  98365. * Call this function to leave webVR mode
  98366. * Will do nothing if webVR is not supported or if there is no webVR device
  98367. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98368. */
  98369. disableVR(): void;
  98370. /**
  98371. * Gets a boolean indicating that the system is in VR mode and is presenting
  98372. * @returns true if VR mode is engaged
  98373. */
  98374. isVRPresenting(): boolean;
  98375. /** @hidden */
  98376. _requestVRFrame(): void;
  98377. /** @hidden */
  98378. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98379. /**
  98380. * Gets the source code of the vertex shader associated with a specific webGL program
  98381. * @param program defines the program to use
  98382. * @returns a string containing the source code of the vertex shader associated with the program
  98383. */
  98384. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98385. /**
  98386. * Gets the source code of the fragment shader associated with a specific webGL program
  98387. * @param program defines the program to use
  98388. * @returns a string containing the source code of the fragment shader associated with the program
  98389. */
  98390. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98391. /**
  98392. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98393. * @param x defines the x coordinate of the rectangle where pixels must be read
  98394. * @param y defines the y coordinate of the rectangle where pixels must be read
  98395. * @param width defines the width of the rectangle where pixels must be read
  98396. * @param height defines the height of the rectangle where pixels must be read
  98397. * @returns a Uint8Array containing RGBA colors
  98398. */
  98399. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98400. /**
  98401. * Sets a depth stencil texture from a render target to the according uniform.
  98402. * @param channel The texture channel
  98403. * @param uniform The uniform to set
  98404. * @param texture The render target texture containing the depth stencil texture to apply
  98405. */
  98406. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98407. /**
  98408. * Sets a texture to the webGL context from a postprocess
  98409. * @param channel defines the channel to use
  98410. * @param postProcess defines the source postprocess
  98411. */
  98412. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98413. /**
  98414. * Binds the output of the passed in post process to the texture channel specified
  98415. * @param channel The channel the texture should be bound to
  98416. * @param postProcess The post process which's output should be bound
  98417. */
  98418. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98419. /** @hidden */
  98420. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98421. protected _rebuildBuffers(): void;
  98422. _renderLoop(): void;
  98423. /**
  98424. * Toggle full screen mode
  98425. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98426. */
  98427. switchFullscreen(requestPointerLock: boolean): void;
  98428. /**
  98429. * Enters full screen mode
  98430. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98431. */
  98432. enterFullscreen(requestPointerLock: boolean): void;
  98433. /**
  98434. * Exits full screen mode
  98435. */
  98436. exitFullscreen(): void;
  98437. /**
  98438. * Enters Pointerlock mode
  98439. */
  98440. enterPointerlock(): void;
  98441. /**
  98442. * Exits Pointerlock mode
  98443. */
  98444. exitPointerlock(): void;
  98445. /**
  98446. * Begin a new frame
  98447. */
  98448. beginFrame(): void;
  98449. /**
  98450. * Enf the current frame
  98451. */
  98452. endFrame(): void;
  98453. resize(): void;
  98454. /**
  98455. * Set the compressed texture format to use, based on the formats you have, and the formats
  98456. * supported by the hardware / browser.
  98457. *
  98458. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98459. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98460. * to API arguments needed to compressed textures. This puts the burden on the container
  98461. * generator to house the arcane code for determining these for current & future formats.
  98462. *
  98463. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98464. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98465. *
  98466. * Note: The result of this call is not taken into account when a texture is base64.
  98467. *
  98468. * @param formatsAvailable defines the list of those format families you have created
  98469. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98470. *
  98471. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98472. * @returns The extension selected.
  98473. */
  98474. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98475. /**
  98476. * Force a specific size of the canvas
  98477. * @param width defines the new canvas' width
  98478. * @param height defines the new canvas' height
  98479. */
  98480. setSize(width: number, height: number): void;
  98481. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98482. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98483. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98484. _releaseTexture(texture: InternalTexture): void;
  98485. /**
  98486. * @hidden
  98487. * Rescales a texture
  98488. * @param source input texutre
  98489. * @param destination destination texture
  98490. * @param scene scene to use to render the resize
  98491. * @param internalFormat format to use when resizing
  98492. * @param onComplete callback to be called when resize has completed
  98493. */
  98494. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98495. /**
  98496. * Gets the current framerate
  98497. * @returns a number representing the framerate
  98498. */
  98499. getFps(): number;
  98500. /**
  98501. * Gets the time spent between current and previous frame
  98502. * @returns a number representing the delta time in ms
  98503. */
  98504. getDeltaTime(): number;
  98505. private _measureFps;
  98506. /**
  98507. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98508. * @param renderTarget The render target to set the frame buffer for
  98509. */
  98510. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98511. /**
  98512. * Update a dynamic index buffer
  98513. * @param indexBuffer defines the target index buffer
  98514. * @param indices defines the data to update
  98515. * @param offset defines the offset in the target index buffer where update should start
  98516. */
  98517. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98518. /**
  98519. * Updates the sample count of a render target texture
  98520. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98521. * @param texture defines the texture to update
  98522. * @param samples defines the sample count to set
  98523. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98524. */
  98525. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98526. /** @hidden */
  98527. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98528. dispose(): void;
  98529. private _disableTouchAction;
  98530. /**
  98531. * Display the loading screen
  98532. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98533. */
  98534. displayLoadingUI(): void;
  98535. /**
  98536. * Hide the loading screen
  98537. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98538. */
  98539. hideLoadingUI(): void;
  98540. /**
  98541. * Gets the current loading screen object
  98542. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98543. */
  98544. /**
  98545. * Sets the current loading screen object
  98546. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98547. */
  98548. loadingScreen: ILoadingScreen;
  98549. /**
  98550. * Sets the current loading screen text
  98551. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98552. */
  98553. loadingUIText: string;
  98554. /**
  98555. * Sets the current loading screen background color
  98556. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98557. */
  98558. loadingUIBackgroundColor: string;
  98559. /** Pointerlock and fullscreen */
  98560. /**
  98561. * Ask the browser to promote the current element to pointerlock mode
  98562. * @param element defines the DOM element to promote
  98563. */
  98564. static _RequestPointerlock(element: HTMLElement): void;
  98565. /**
  98566. * Asks the browser to exit pointerlock mode
  98567. */
  98568. static _ExitPointerlock(): void;
  98569. /**
  98570. * Ask the browser to promote the current element to fullscreen rendering mode
  98571. * @param element defines the DOM element to promote
  98572. */
  98573. static _RequestFullscreen(element: HTMLElement): void;
  98574. /**
  98575. * Asks the browser to exit fullscreen mode
  98576. */
  98577. static _ExitFullscreen(): void;
  98578. }
  98579. }
  98580. declare module BABYLON {
  98581. /**
  98582. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98583. * during the life time of the application.
  98584. */
  98585. export class EngineStore {
  98586. /** Gets the list of created engines */
  98587. static Instances: Engine[];
  98588. /** @hidden */
  98589. static _LastCreatedScene: Nullable<Scene>;
  98590. /**
  98591. * Gets the latest created engine
  98592. */
  98593. static readonly LastCreatedEngine: Nullable<Engine>;
  98594. /**
  98595. * Gets the latest created scene
  98596. */
  98597. static readonly LastCreatedScene: Nullable<Scene>;
  98598. /**
  98599. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98600. * @ignorenaming
  98601. */
  98602. static UseFallbackTexture: boolean;
  98603. /**
  98604. * Texture content used if a texture cannot loaded
  98605. * @ignorenaming
  98606. */
  98607. static FallbackTexture: string;
  98608. }
  98609. }
  98610. declare module BABYLON {
  98611. /**
  98612. * Helper class that provides a small promise polyfill
  98613. */
  98614. export class PromisePolyfill {
  98615. /**
  98616. * Static function used to check if the polyfill is required
  98617. * If this is the case then the function will inject the polyfill to window.Promise
  98618. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98619. */
  98620. static Apply(force?: boolean): void;
  98621. }
  98622. }
  98623. declare module BABYLON {
  98624. /**
  98625. * Interface for screenshot methods with describe argument called `size` as object with options
  98626. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98627. */
  98628. export interface IScreenshotSize {
  98629. /**
  98630. * number in pixels for canvas height
  98631. */
  98632. height?: number;
  98633. /**
  98634. * multiplier allowing render at a higher or lower resolution
  98635. * If value is defined then height and width will be ignored and taken from camera
  98636. */
  98637. precision?: number;
  98638. /**
  98639. * number in pixels for canvas width
  98640. */
  98641. width?: number;
  98642. }
  98643. }
  98644. declare module BABYLON {
  98645. interface IColor4Like {
  98646. r: float;
  98647. g: float;
  98648. b: float;
  98649. a: float;
  98650. }
  98651. /**
  98652. * Class containing a set of static utilities functions
  98653. */
  98654. export class Tools {
  98655. /**
  98656. * Gets or sets the base URL to use to load assets
  98657. */
  98658. static BaseUrl: string;
  98659. /**
  98660. * Enable/Disable Custom HTTP Request Headers globally.
  98661. * default = false
  98662. * @see CustomRequestHeaders
  98663. */
  98664. static UseCustomRequestHeaders: boolean;
  98665. /**
  98666. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98667. * i.e. when loading files, where the server/service expects an Authorization header
  98668. */
  98669. static CustomRequestHeaders: {
  98670. [key: string]: string;
  98671. };
  98672. /**
  98673. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98674. */
  98675. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98676. /**
  98677. * Default behaviour for cors in the application.
  98678. * It can be a string if the expected behavior is identical in the entire app.
  98679. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98680. */
  98681. static CorsBehavior: string | ((url: string | string[]) => string);
  98682. /**
  98683. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98684. * @ignorenaming
  98685. */
  98686. static UseFallbackTexture: boolean;
  98687. /**
  98688. * Use this object to register external classes like custom textures or material
  98689. * to allow the laoders to instantiate them
  98690. */
  98691. static RegisteredExternalClasses: {
  98692. [key: string]: Object;
  98693. };
  98694. /**
  98695. * Texture content used if a texture cannot loaded
  98696. * @ignorenaming
  98697. */
  98698. static fallbackTexture: string;
  98699. /**
  98700. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98701. * @param u defines the coordinate on X axis
  98702. * @param v defines the coordinate on Y axis
  98703. * @param width defines the width of the source data
  98704. * @param height defines the height of the source data
  98705. * @param pixels defines the source byte array
  98706. * @param color defines the output color
  98707. */
  98708. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98709. /**
  98710. * Interpolates between a and b via alpha
  98711. * @param a The lower value (returned when alpha = 0)
  98712. * @param b The upper value (returned when alpha = 1)
  98713. * @param alpha The interpolation-factor
  98714. * @return The mixed value
  98715. */
  98716. static Mix(a: number, b: number, alpha: number): number;
  98717. /**
  98718. * Tries to instantiate a new object from a given class name
  98719. * @param className defines the class name to instantiate
  98720. * @returns the new object or null if the system was not able to do the instantiation
  98721. */
  98722. static Instantiate(className: string): any;
  98723. /**
  98724. * Provides a slice function that will work even on IE
  98725. * @param data defines the array to slice
  98726. * @param start defines the start of the data (optional)
  98727. * @param end defines the end of the data (optional)
  98728. * @returns the new sliced array
  98729. */
  98730. static Slice<T>(data: T, start?: number, end?: number): T;
  98731. /**
  98732. * Polyfill for setImmediate
  98733. * @param action defines the action to execute after the current execution block
  98734. */
  98735. static SetImmediate(action: () => void): void;
  98736. /**
  98737. * Function indicating if a number is an exponent of 2
  98738. * @param value defines the value to test
  98739. * @returns true if the value is an exponent of 2
  98740. */
  98741. static IsExponentOfTwo(value: number): boolean;
  98742. private static _tmpFloatArray;
  98743. /**
  98744. * Returns the nearest 32-bit single precision float representation of a Number
  98745. * @param value A Number. If the parameter is of a different type, it will get converted
  98746. * to a number or to NaN if it cannot be converted
  98747. * @returns number
  98748. */
  98749. static FloatRound(value: number): number;
  98750. /**
  98751. * Extracts the filename from a path
  98752. * @param path defines the path to use
  98753. * @returns the filename
  98754. */
  98755. static GetFilename(path: string): string;
  98756. /**
  98757. * Extracts the "folder" part of a path (everything before the filename).
  98758. * @param uri The URI to extract the info from
  98759. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98760. * @returns The "folder" part of the path
  98761. */
  98762. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98763. /**
  98764. * Extracts text content from a DOM element hierarchy
  98765. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98766. */
  98767. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98768. /**
  98769. * Convert an angle in radians to degrees
  98770. * @param angle defines the angle to convert
  98771. * @returns the angle in degrees
  98772. */
  98773. static ToDegrees(angle: number): number;
  98774. /**
  98775. * Convert an angle in degrees to radians
  98776. * @param angle defines the angle to convert
  98777. * @returns the angle in radians
  98778. */
  98779. static ToRadians(angle: number): number;
  98780. /**
  98781. * Encode a buffer to a base64 string
  98782. * @param buffer defines the buffer to encode
  98783. * @returns the encoded string
  98784. */
  98785. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98786. /**
  98787. * Returns an array if obj is not an array
  98788. * @param obj defines the object to evaluate as an array
  98789. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98790. * @returns either obj directly if obj is an array or a new array containing obj
  98791. */
  98792. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98793. /**
  98794. * Gets the pointer prefix to use
  98795. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98796. */
  98797. static GetPointerPrefix(): string;
  98798. /**
  98799. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98800. * @param url define the url we are trying
  98801. * @param element define the dom element where to configure the cors policy
  98802. */
  98803. static SetCorsBehavior(url: string | string[], element: {
  98804. crossOrigin: string | null;
  98805. }): void;
  98806. /**
  98807. * Removes unwanted characters from an url
  98808. * @param url defines the url to clean
  98809. * @returns the cleaned url
  98810. */
  98811. static CleanUrl(url: string): string;
  98812. /**
  98813. * Gets or sets a function used to pre-process url before using them to load assets
  98814. */
  98815. static PreprocessUrl: (url: string) => string;
  98816. /**
  98817. * Loads an image as an HTMLImageElement.
  98818. * @param input url string, ArrayBuffer, or Blob to load
  98819. * @param onLoad callback called when the image successfully loads
  98820. * @param onError callback called when the image fails to load
  98821. * @param offlineProvider offline provider for caching
  98822. * @returns the HTMLImageElement of the loaded image
  98823. */
  98824. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98825. /**
  98826. * Loads a file
  98827. * @param url url string, ArrayBuffer, or Blob to load
  98828. * @param onSuccess callback called when the file successfully loads
  98829. * @param onProgress callback called while file is loading (if the server supports this mode)
  98830. * @param offlineProvider defines the offline provider for caching
  98831. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98832. * @param onError callback called when the file fails to load
  98833. * @returns a file request object
  98834. */
  98835. 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;
  98836. /**
  98837. * Loads a file from a url
  98838. * @param url the file url to load
  98839. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98840. */
  98841. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98842. /**
  98843. * Load a script (identified by an url). When the url returns, the
  98844. * content of this file is added into a new script element, attached to the DOM (body element)
  98845. * @param scriptUrl defines the url of the script to laod
  98846. * @param onSuccess defines the callback called when the script is loaded
  98847. * @param onError defines the callback to call if an error occurs
  98848. * @param scriptId defines the id of the script element
  98849. */
  98850. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98851. /**
  98852. * Load an asynchronous script (identified by an url). When the url returns, the
  98853. * content of this file is added into a new script element, attached to the DOM (body element)
  98854. * @param scriptUrl defines the url of the script to laod
  98855. * @param scriptId defines the id of the script element
  98856. * @returns a promise request object
  98857. */
  98858. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98859. /**
  98860. * Loads a file from a blob
  98861. * @param fileToLoad defines the blob to use
  98862. * @param callback defines the callback to call when data is loaded
  98863. * @param progressCallback defines the callback to call during loading process
  98864. * @returns a file request object
  98865. */
  98866. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98867. /**
  98868. * Loads a file
  98869. * @param fileToLoad defines the file to load
  98870. * @param callback defines the callback to call when data is loaded
  98871. * @param progressCallBack defines the callback to call during loading process
  98872. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98873. * @returns a file request object
  98874. */
  98875. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98876. /**
  98877. * Creates a data url from a given string content
  98878. * @param content defines the content to convert
  98879. * @returns the new data url link
  98880. */
  98881. static FileAsURL(content: string): string;
  98882. /**
  98883. * Format the given number to a specific decimal format
  98884. * @param value defines the number to format
  98885. * @param decimals defines the number of decimals to use
  98886. * @returns the formatted string
  98887. */
  98888. static Format(value: number, decimals?: number): string;
  98889. /**
  98890. * Tries to copy an object by duplicating every property
  98891. * @param source defines the source object
  98892. * @param destination defines the target object
  98893. * @param doNotCopyList defines a list of properties to avoid
  98894. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98895. */
  98896. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98897. /**
  98898. * Gets a boolean indicating if the given object has no own property
  98899. * @param obj defines the object to test
  98900. * @returns true if object has no own property
  98901. */
  98902. static IsEmpty(obj: any): boolean;
  98903. /**
  98904. * Function used to register events at window level
  98905. * @param windowElement defines the Window object to use
  98906. * @param events defines the events to register
  98907. */
  98908. static RegisterTopRootEvents(windowElement: Window, events: {
  98909. name: string;
  98910. handler: Nullable<(e: FocusEvent) => any>;
  98911. }[]): void;
  98912. /**
  98913. * Function used to unregister events from window level
  98914. * @param windowElement defines the Window object to use
  98915. * @param events defines the events to unregister
  98916. */
  98917. static UnregisterTopRootEvents(windowElement: Window, events: {
  98918. name: string;
  98919. handler: Nullable<(e: FocusEvent) => any>;
  98920. }[]): void;
  98921. /**
  98922. * @ignore
  98923. */
  98924. static _ScreenshotCanvas: HTMLCanvasElement;
  98925. /**
  98926. * Dumps the current bound framebuffer
  98927. * @param width defines the rendering width
  98928. * @param height defines the rendering height
  98929. * @param engine defines the hosting engine
  98930. * @param successCallback defines the callback triggered once the data are available
  98931. * @param mimeType defines the mime type of the result
  98932. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98933. */
  98934. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98935. /**
  98936. * Converts the canvas data to blob.
  98937. * This acts as a polyfill for browsers not supporting the to blob function.
  98938. * @param canvas Defines the canvas to extract the data from
  98939. * @param successCallback Defines the callback triggered once the data are available
  98940. * @param mimeType Defines the mime type of the result
  98941. */
  98942. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98943. /**
  98944. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98945. * @param successCallback defines the callback triggered once the data are available
  98946. * @param mimeType defines the mime type of the result
  98947. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98948. */
  98949. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98950. /**
  98951. * Downloads a blob in the browser
  98952. * @param blob defines the blob to download
  98953. * @param fileName defines the name of the downloaded file
  98954. */
  98955. static Download(blob: Blob, fileName: string): void;
  98956. /**
  98957. * Captures a screenshot of the current rendering
  98958. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98959. * @param engine defines the rendering engine
  98960. * @param camera defines the source camera
  98961. * @param size This parameter can be set to a single number or to an object with the
  98962. * following (optional) properties: precision, width, height. If a single number is passed,
  98963. * it will be used for both width and height. If an object is passed, the screenshot size
  98964. * will be derived from the parameters. The precision property is a multiplier allowing
  98965. * rendering at a higher or lower resolution
  98966. * @param successCallback defines the callback receives a single parameter which contains the
  98967. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  98968. * src parameter of an <img> to display it
  98969. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98970. * Check your browser for supported MIME types
  98971. */
  98972. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  98973. /**
  98974. * Captures a screenshot of the current rendering
  98975. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98976. * @param engine defines the rendering engine
  98977. * @param camera defines the source camera
  98978. * @param size This parameter can be set to a single number or to an object with the
  98979. * following (optional) properties: precision, width, height. If a single number is passed,
  98980. * it will be used for both width and height. If an object is passed, the screenshot size
  98981. * will be derived from the parameters. The precision property is a multiplier allowing
  98982. * rendering at a higher or lower resolution
  98983. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  98984. * Check your browser for supported MIME types
  98985. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  98986. * to the src parameter of an <img> to display it
  98987. */
  98988. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  98989. /**
  98990. * Generates an image screenshot from the specified camera.
  98991. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98992. * @param engine The engine to use for rendering
  98993. * @param camera The camera to use for rendering
  98994. * @param size This parameter can be set to a single number or to an object with the
  98995. * following (optional) properties: precision, width, height. If a single number is passed,
  98996. * it will be used for both width and height. If an object is passed, the screenshot size
  98997. * will be derived from the parameters. The precision property is a multiplier allowing
  98998. * rendering at a higher or lower resolution
  98999. * @param successCallback The callback receives a single parameter which contains the
  99000. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99001. * src parameter of an <img> to display it
  99002. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99003. * Check your browser for supported MIME types
  99004. * @param samples Texture samples (default: 1)
  99005. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99006. * @param fileName A name for for the downloaded file.
  99007. */
  99008. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99009. /**
  99010. * Generates an image screenshot from the specified camera.
  99011. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99012. * @param engine The engine to use for rendering
  99013. * @param camera The camera to use for rendering
  99014. * @param size This parameter can be set to a single number or to an object with the
  99015. * following (optional) properties: precision, width, height. If a single number is passed,
  99016. * it will be used for both width and height. If an object is passed, the screenshot size
  99017. * will be derived from the parameters. The precision property is a multiplier allowing
  99018. * rendering at a higher or lower resolution
  99019. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99020. * Check your browser for supported MIME types
  99021. * @param samples Texture samples (default: 1)
  99022. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99023. * @param fileName A name for for the downloaded file.
  99024. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99025. * to the src parameter of an <img> to display it
  99026. */
  99027. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99028. /**
  99029. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99030. * Be aware Math.random() could cause collisions, but:
  99031. * "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"
  99032. * @returns a pseudo random id
  99033. */
  99034. static RandomId(): string;
  99035. /**
  99036. * Test if the given uri is a base64 string
  99037. * @param uri The uri to test
  99038. * @return True if the uri is a base64 string or false otherwise
  99039. */
  99040. static IsBase64(uri: string): boolean;
  99041. /**
  99042. * Decode the given base64 uri.
  99043. * @param uri The uri to decode
  99044. * @return The decoded base64 data.
  99045. */
  99046. static DecodeBase64(uri: string): ArrayBuffer;
  99047. /**
  99048. * Gets the absolute url.
  99049. * @param url the input url
  99050. * @return the absolute url
  99051. */
  99052. static GetAbsoluteUrl(url: string): string;
  99053. /**
  99054. * No log
  99055. */
  99056. static readonly NoneLogLevel: number;
  99057. /**
  99058. * Only message logs
  99059. */
  99060. static readonly MessageLogLevel: number;
  99061. /**
  99062. * Only warning logs
  99063. */
  99064. static readonly WarningLogLevel: number;
  99065. /**
  99066. * Only error logs
  99067. */
  99068. static readonly ErrorLogLevel: number;
  99069. /**
  99070. * All logs
  99071. */
  99072. static readonly AllLogLevel: number;
  99073. /**
  99074. * Gets a value indicating the number of loading errors
  99075. * @ignorenaming
  99076. */
  99077. static readonly errorsCount: number;
  99078. /**
  99079. * Callback called when a new log is added
  99080. */
  99081. static OnNewCacheEntry: (entry: string) => void;
  99082. /**
  99083. * Log a message to the console
  99084. * @param message defines the message to log
  99085. */
  99086. static Log(message: string): void;
  99087. /**
  99088. * Write a warning message to the console
  99089. * @param message defines the message to log
  99090. */
  99091. static Warn(message: string): void;
  99092. /**
  99093. * Write an error message to the console
  99094. * @param message defines the message to log
  99095. */
  99096. static Error(message: string): void;
  99097. /**
  99098. * Gets current log cache (list of logs)
  99099. */
  99100. static readonly LogCache: string;
  99101. /**
  99102. * Clears the log cache
  99103. */
  99104. static ClearLogCache(): void;
  99105. /**
  99106. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99107. */
  99108. static LogLevels: number;
  99109. /**
  99110. * Checks if the window object exists
  99111. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99112. */
  99113. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99114. /**
  99115. * No performance log
  99116. */
  99117. static readonly PerformanceNoneLogLevel: number;
  99118. /**
  99119. * Use user marks to log performance
  99120. */
  99121. static readonly PerformanceUserMarkLogLevel: number;
  99122. /**
  99123. * Log performance to the console
  99124. */
  99125. static readonly PerformanceConsoleLogLevel: number;
  99126. private static _performance;
  99127. /**
  99128. * Sets the current performance log level
  99129. */
  99130. static PerformanceLogLevel: number;
  99131. private static _StartPerformanceCounterDisabled;
  99132. private static _EndPerformanceCounterDisabled;
  99133. private static _StartUserMark;
  99134. private static _EndUserMark;
  99135. private static _StartPerformanceConsole;
  99136. private static _EndPerformanceConsole;
  99137. /**
  99138. * Starts a performance counter
  99139. */
  99140. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99141. /**
  99142. * Ends a specific performance coutner
  99143. */
  99144. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99145. /**
  99146. * Gets either window.performance.now() if supported or Date.now() else
  99147. */
  99148. static readonly Now: number;
  99149. /**
  99150. * This method will return the name of the class used to create the instance of the given object.
  99151. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99152. * @param object the object to get the class name from
  99153. * @param isType defines if the object is actually a type
  99154. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99155. */
  99156. static GetClassName(object: any, isType?: boolean): string;
  99157. /**
  99158. * Gets the first element of an array satisfying a given predicate
  99159. * @param array defines the array to browse
  99160. * @param predicate defines the predicate to use
  99161. * @returns null if not found or the element
  99162. */
  99163. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99164. /**
  99165. * This method will return the name of the full name of the class, including its owning module (if any).
  99166. * 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).
  99167. * @param object the object to get the class name from
  99168. * @param isType defines if the object is actually a type
  99169. * @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.
  99170. * @ignorenaming
  99171. */
  99172. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99173. /**
  99174. * Returns a promise that resolves after the given amount of time.
  99175. * @param delay Number of milliseconds to delay
  99176. * @returns Promise that resolves after the given amount of time
  99177. */
  99178. static DelayAsync(delay: number): Promise<void>;
  99179. }
  99180. /**
  99181. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99182. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99183. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99184. * @param name The name of the class, case should be preserved
  99185. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99186. */
  99187. export function className(name: string, module?: string): (target: Object) => void;
  99188. /**
  99189. * An implementation of a loop for asynchronous functions.
  99190. */
  99191. export class AsyncLoop {
  99192. /**
  99193. * Defines the number of iterations for the loop
  99194. */
  99195. iterations: number;
  99196. /**
  99197. * Defines the current index of the loop.
  99198. */
  99199. index: number;
  99200. private _done;
  99201. private _fn;
  99202. private _successCallback;
  99203. /**
  99204. * Constructor.
  99205. * @param iterations the number of iterations.
  99206. * @param func the function to run each iteration
  99207. * @param successCallback the callback that will be called upon succesful execution
  99208. * @param offset starting offset.
  99209. */
  99210. constructor(
  99211. /**
  99212. * Defines the number of iterations for the loop
  99213. */
  99214. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99215. /**
  99216. * Execute the next iteration. Must be called after the last iteration was finished.
  99217. */
  99218. executeNext(): void;
  99219. /**
  99220. * Break the loop and run the success callback.
  99221. */
  99222. breakLoop(): void;
  99223. /**
  99224. * Create and run an async loop.
  99225. * @param iterations the number of iterations.
  99226. * @param fn the function to run each iteration
  99227. * @param successCallback the callback that will be called upon succesful execution
  99228. * @param offset starting offset.
  99229. * @returns the created async loop object
  99230. */
  99231. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99232. /**
  99233. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99234. * @param iterations total number of iterations
  99235. * @param syncedIterations number of synchronous iterations in each async iteration.
  99236. * @param fn the function to call each iteration.
  99237. * @param callback a success call back that will be called when iterating stops.
  99238. * @param breakFunction a break condition (optional)
  99239. * @param timeout timeout settings for the setTimeout function. default - 0.
  99240. * @returns the created async loop object
  99241. */
  99242. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99243. }
  99244. }
  99245. declare module BABYLON {
  99246. /**
  99247. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99248. * The underlying implementation relies on an associative array to ensure the best performances.
  99249. * The value can be anything including 'null' but except 'undefined'
  99250. */
  99251. export class StringDictionary<T> {
  99252. /**
  99253. * This will clear this dictionary and copy the content from the 'source' one.
  99254. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99255. * @param source the dictionary to take the content from and copy to this dictionary
  99256. */
  99257. copyFrom(source: StringDictionary<T>): void;
  99258. /**
  99259. * Get a value based from its key
  99260. * @param key the given key to get the matching value from
  99261. * @return the value if found, otherwise undefined is returned
  99262. */
  99263. get(key: string): T | undefined;
  99264. /**
  99265. * Get a value from its key or add it if it doesn't exist.
  99266. * This method will ensure you that a given key/data will be present in the dictionary.
  99267. * @param key the given key to get the matching value from
  99268. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99269. * The factory will only be invoked if there's no data for the given key.
  99270. * @return the value corresponding to the key.
  99271. */
  99272. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99273. /**
  99274. * Get a value from its key if present in the dictionary otherwise add it
  99275. * @param key the key to get the value from
  99276. * @param val if there's no such key/value pair in the dictionary add it with this value
  99277. * @return the value corresponding to the key
  99278. */
  99279. getOrAdd(key: string, val: T): T;
  99280. /**
  99281. * Check if there's a given key in the dictionary
  99282. * @param key the key to check for
  99283. * @return true if the key is present, false otherwise
  99284. */
  99285. contains(key: string): boolean;
  99286. /**
  99287. * Add a new key and its corresponding value
  99288. * @param key the key to add
  99289. * @param value the value corresponding to the key
  99290. * @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
  99291. */
  99292. add(key: string, value: T): boolean;
  99293. /**
  99294. * Update a specific value associated to a key
  99295. * @param key defines the key to use
  99296. * @param value defines the value to store
  99297. * @returns true if the value was updated (or false if the key was not found)
  99298. */
  99299. set(key: string, value: T): boolean;
  99300. /**
  99301. * Get the element of the given key and remove it from the dictionary
  99302. * @param key defines the key to search
  99303. * @returns the value associated with the key or null if not found
  99304. */
  99305. getAndRemove(key: string): Nullable<T>;
  99306. /**
  99307. * Remove a key/value from the dictionary.
  99308. * @param key the key to remove
  99309. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99310. */
  99311. remove(key: string): boolean;
  99312. /**
  99313. * Clear the whole content of the dictionary
  99314. */
  99315. clear(): void;
  99316. /**
  99317. * Gets the current count
  99318. */
  99319. readonly count: number;
  99320. /**
  99321. * Execute a callback on each key/val of the dictionary.
  99322. * Note that you can remove any element in this dictionary in the callback implementation
  99323. * @param callback the callback to execute on a given key/value pair
  99324. */
  99325. forEach(callback: (key: string, val: T) => void): void;
  99326. /**
  99327. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99328. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99329. * Note that you can remove any element in this dictionary in the callback implementation
  99330. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99331. * @returns the first item
  99332. */
  99333. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99334. private _count;
  99335. private _data;
  99336. }
  99337. }
  99338. declare module BABYLON {
  99339. /** @hidden */
  99340. export interface ICollisionCoordinator {
  99341. createCollider(): Collider;
  99342. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99343. init(scene: Scene): void;
  99344. }
  99345. /** @hidden */
  99346. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99347. private _scene;
  99348. private _scaledPosition;
  99349. private _scaledVelocity;
  99350. private _finalPosition;
  99351. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99352. createCollider(): Collider;
  99353. init(scene: Scene): void;
  99354. private _collideWithWorld;
  99355. }
  99356. }
  99357. declare module BABYLON {
  99358. /**
  99359. * Class used to manage all inputs for the scene.
  99360. */
  99361. export class InputManager {
  99362. /** The distance in pixel that you have to move to prevent some events */
  99363. static DragMovementThreshold: number;
  99364. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99365. static LongPressDelay: number;
  99366. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99367. static DoubleClickDelay: number;
  99368. /** If you need to check double click without raising a single click at first click, enable this flag */
  99369. static ExclusiveDoubleClickMode: boolean;
  99370. private _wheelEventName;
  99371. private _onPointerMove;
  99372. private _onPointerDown;
  99373. private _onPointerUp;
  99374. private _initClickEvent;
  99375. private _initActionManager;
  99376. private _delayedSimpleClick;
  99377. private _delayedSimpleClickTimeout;
  99378. private _previousDelayedSimpleClickTimeout;
  99379. private _meshPickProceed;
  99380. private _previousButtonPressed;
  99381. private _currentPickResult;
  99382. private _previousPickResult;
  99383. private _totalPointersPressed;
  99384. private _doubleClickOccured;
  99385. private _pointerOverMesh;
  99386. private _pickedDownMesh;
  99387. private _pickedUpMesh;
  99388. private _pointerX;
  99389. private _pointerY;
  99390. private _unTranslatedPointerX;
  99391. private _unTranslatedPointerY;
  99392. private _startingPointerPosition;
  99393. private _previousStartingPointerPosition;
  99394. private _startingPointerTime;
  99395. private _previousStartingPointerTime;
  99396. private _pointerCaptures;
  99397. private _onKeyDown;
  99398. private _onKeyUp;
  99399. private _onCanvasFocusObserver;
  99400. private _onCanvasBlurObserver;
  99401. private _scene;
  99402. /**
  99403. * Creates a new InputManager
  99404. * @param scene defines the hosting scene
  99405. */
  99406. constructor(scene: Scene);
  99407. /**
  99408. * Gets the mesh that is currently under the pointer
  99409. */
  99410. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99411. /**
  99412. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99413. */
  99414. readonly unTranslatedPointer: Vector2;
  99415. /**
  99416. * Gets or sets the current on-screen X position of the pointer
  99417. */
  99418. pointerX: number;
  99419. /**
  99420. * Gets or sets the current on-screen Y position of the pointer
  99421. */
  99422. pointerY: number;
  99423. private _updatePointerPosition;
  99424. private _processPointerMove;
  99425. private _setRayOnPointerInfo;
  99426. private _checkPrePointerObservable;
  99427. /**
  99428. * Use this method to simulate a pointer move on a mesh
  99429. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99430. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99431. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99432. */
  99433. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99434. /**
  99435. * Use this method to simulate a pointer down on a mesh
  99436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99439. */
  99440. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99441. private _processPointerDown;
  99442. /** @hidden */
  99443. _isPointerSwiping(): boolean;
  99444. /**
  99445. * Use this method to simulate a pointer up on a mesh
  99446. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99447. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99448. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99449. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99450. */
  99451. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99452. private _processPointerUp;
  99453. /**
  99454. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99455. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99456. * @returns true if the pointer was captured
  99457. */
  99458. isPointerCaptured(pointerId?: number): boolean;
  99459. /**
  99460. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99461. * @param attachUp defines if you want to attach events to pointerup
  99462. * @param attachDown defines if you want to attach events to pointerdown
  99463. * @param attachMove defines if you want to attach events to pointermove
  99464. */
  99465. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99466. /**
  99467. * Detaches all event handlers
  99468. */
  99469. detachControl(): void;
  99470. /**
  99471. * Force the value of meshUnderPointer
  99472. * @param mesh defines the mesh to use
  99473. */
  99474. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99475. /**
  99476. * Gets the mesh under the pointer
  99477. * @returns a Mesh or null if no mesh is under the pointer
  99478. */
  99479. getPointerOverMesh(): Nullable<AbstractMesh>;
  99480. }
  99481. }
  99482. declare module BABYLON {
  99483. /**
  99484. * Helper class used to generate session unique ID
  99485. */
  99486. export class UniqueIdGenerator {
  99487. private static _UniqueIdCounter;
  99488. /**
  99489. * Gets an unique (relatively to the current scene) Id
  99490. */
  99491. static readonly UniqueId: number;
  99492. }
  99493. }
  99494. declare module BABYLON {
  99495. /**
  99496. * This class defines the direct association between an animation and a target
  99497. */
  99498. export class TargetedAnimation {
  99499. /**
  99500. * Animation to perform
  99501. */
  99502. animation: Animation;
  99503. /**
  99504. * Target to animate
  99505. */
  99506. target: any;
  99507. /**
  99508. * Serialize the object
  99509. * @returns the JSON object representing the current entity
  99510. */
  99511. serialize(): any;
  99512. }
  99513. /**
  99514. * Use this class to create coordinated animations on multiple targets
  99515. */
  99516. export class AnimationGroup implements IDisposable {
  99517. /** The name of the animation group */
  99518. name: string;
  99519. private _scene;
  99520. private _targetedAnimations;
  99521. private _animatables;
  99522. private _from;
  99523. private _to;
  99524. private _isStarted;
  99525. private _isPaused;
  99526. private _speedRatio;
  99527. private _loopAnimation;
  99528. /**
  99529. * Gets or sets the unique id of the node
  99530. */
  99531. uniqueId: number;
  99532. /**
  99533. * This observable will notify when one animation have ended
  99534. */
  99535. onAnimationEndObservable: Observable<TargetedAnimation>;
  99536. /**
  99537. * Observer raised when one animation loops
  99538. */
  99539. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99540. /**
  99541. * This observable will notify when all animations have ended.
  99542. */
  99543. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99544. /**
  99545. * This observable will notify when all animations have paused.
  99546. */
  99547. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99548. /**
  99549. * This observable will notify when all animations are playing.
  99550. */
  99551. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99552. /**
  99553. * Gets the first frame
  99554. */
  99555. readonly from: number;
  99556. /**
  99557. * Gets the last frame
  99558. */
  99559. readonly to: number;
  99560. /**
  99561. * Define if the animations are started
  99562. */
  99563. readonly isStarted: boolean;
  99564. /**
  99565. * Gets a value indicating that the current group is playing
  99566. */
  99567. readonly isPlaying: boolean;
  99568. /**
  99569. * Gets or sets the speed ratio to use for all animations
  99570. */
  99571. /**
  99572. * Gets or sets the speed ratio to use for all animations
  99573. */
  99574. speedRatio: number;
  99575. /**
  99576. * Gets or sets if all animations should loop or not
  99577. */
  99578. loopAnimation: boolean;
  99579. /**
  99580. * Gets the targeted animations for this animation group
  99581. */
  99582. readonly targetedAnimations: Array<TargetedAnimation>;
  99583. /**
  99584. * returning the list of animatables controlled by this animation group.
  99585. */
  99586. readonly animatables: Array<Animatable>;
  99587. /**
  99588. * Instantiates a new Animation Group.
  99589. * This helps managing several animations at once.
  99590. * @see http://doc.babylonjs.com/how_to/group
  99591. * @param name Defines the name of the group
  99592. * @param scene Defines the scene the group belongs to
  99593. */
  99594. constructor(
  99595. /** The name of the animation group */
  99596. name: string, scene?: Nullable<Scene>);
  99597. /**
  99598. * Add an animation (with its target) in the group
  99599. * @param animation defines the animation we want to add
  99600. * @param target defines the target of the animation
  99601. * @returns the TargetedAnimation object
  99602. */
  99603. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99604. /**
  99605. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99606. * It can add constant keys at begin or end
  99607. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99608. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99609. * @returns the animation group
  99610. */
  99611. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99612. /**
  99613. * Start all animations on given targets
  99614. * @param loop defines if animations must loop
  99615. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99616. * @param from defines the from key (optional)
  99617. * @param to defines the to key (optional)
  99618. * @returns the current animation group
  99619. */
  99620. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99621. /**
  99622. * Pause all animations
  99623. * @returns the animation group
  99624. */
  99625. pause(): AnimationGroup;
  99626. /**
  99627. * Play all animations to initial state
  99628. * This function will start() the animations if they were not started or will restart() them if they were paused
  99629. * @param loop defines if animations must loop
  99630. * @returns the animation group
  99631. */
  99632. play(loop?: boolean): AnimationGroup;
  99633. /**
  99634. * Reset all animations to initial state
  99635. * @returns the animation group
  99636. */
  99637. reset(): AnimationGroup;
  99638. /**
  99639. * Restart animations from key 0
  99640. * @returns the animation group
  99641. */
  99642. restart(): AnimationGroup;
  99643. /**
  99644. * Stop all animations
  99645. * @returns the animation group
  99646. */
  99647. stop(): AnimationGroup;
  99648. /**
  99649. * Set animation weight for all animatables
  99650. * @param weight defines the weight to use
  99651. * @return the animationGroup
  99652. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99653. */
  99654. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99655. /**
  99656. * Synchronize and normalize all animatables with a source animatable
  99657. * @param root defines the root animatable to synchronize with
  99658. * @return the animationGroup
  99659. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99660. */
  99661. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99662. /**
  99663. * Goes to a specific frame in this animation group
  99664. * @param frame the frame number to go to
  99665. * @return the animationGroup
  99666. */
  99667. goToFrame(frame: number): AnimationGroup;
  99668. /**
  99669. * Dispose all associated resources
  99670. */
  99671. dispose(): void;
  99672. private _checkAnimationGroupEnded;
  99673. /**
  99674. * Clone the current animation group and returns a copy
  99675. * @param newName defines the name of the new group
  99676. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99677. * @returns the new aniamtion group
  99678. */
  99679. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99680. /**
  99681. * Serializes the animationGroup to an object
  99682. * @returns Serialized object
  99683. */
  99684. serialize(): any;
  99685. /**
  99686. * Returns a new AnimationGroup object parsed from the source provided.
  99687. * @param parsedAnimationGroup defines the source
  99688. * @param scene defines the scene that will receive the animationGroup
  99689. * @returns a new AnimationGroup
  99690. */
  99691. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99692. /**
  99693. * Returns the string "AnimationGroup"
  99694. * @returns "AnimationGroup"
  99695. */
  99696. getClassName(): string;
  99697. /**
  99698. * Creates a detailled string about the object
  99699. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99700. * @returns a string representing the object
  99701. */
  99702. toString(fullDetails?: boolean): string;
  99703. }
  99704. }
  99705. declare module BABYLON {
  99706. /**
  99707. * Define an interface for all classes that will hold resources
  99708. */
  99709. export interface IDisposable {
  99710. /**
  99711. * Releases all held resources
  99712. */
  99713. dispose(): void;
  99714. }
  99715. /** Interface defining initialization parameters for Scene class */
  99716. export interface SceneOptions {
  99717. /**
  99718. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99719. * It will improve performance when the number of geometries becomes important.
  99720. */
  99721. useGeometryUniqueIdsMap?: boolean;
  99722. /**
  99723. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99724. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99725. */
  99726. useMaterialMeshMap?: boolean;
  99727. /**
  99728. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99729. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99730. */
  99731. useClonedMeshhMap?: boolean;
  99732. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99733. virtual?: boolean;
  99734. }
  99735. /**
  99736. * Represents a scene to be rendered by the engine.
  99737. * @see http://doc.babylonjs.com/features/scene
  99738. */
  99739. export class Scene extends AbstractScene implements IAnimatable {
  99740. /** The fog is deactivated */
  99741. static readonly FOGMODE_NONE: number;
  99742. /** The fog density is following an exponential function */
  99743. static readonly FOGMODE_EXP: number;
  99744. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99745. static readonly FOGMODE_EXP2: number;
  99746. /** The fog density is following a linear function. */
  99747. static readonly FOGMODE_LINEAR: number;
  99748. /**
  99749. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99750. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99751. */
  99752. static MinDeltaTime: number;
  99753. /**
  99754. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99755. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99756. */
  99757. static MaxDeltaTime: number;
  99758. /**
  99759. * Factory used to create the default material.
  99760. * @param name The name of the material to create
  99761. * @param scene The scene to create the material for
  99762. * @returns The default material
  99763. */
  99764. static DefaultMaterialFactory(scene: Scene): Material;
  99765. /**
  99766. * Factory used to create the a collision coordinator.
  99767. * @returns The collision coordinator
  99768. */
  99769. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99770. /** @hidden */
  99771. _inputManager: InputManager;
  99772. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99773. cameraToUseForPointers: Nullable<Camera>;
  99774. /** @hidden */
  99775. readonly _isScene: boolean;
  99776. /**
  99777. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99778. */
  99779. autoClear: boolean;
  99780. /**
  99781. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99782. */
  99783. autoClearDepthAndStencil: boolean;
  99784. /**
  99785. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99786. */
  99787. clearColor: Color4;
  99788. /**
  99789. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99790. */
  99791. ambientColor: Color3;
  99792. /**
  99793. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99794. * It should only be one of the following (if not the default embedded one):
  99795. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99796. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99797. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99798. * The material properties need to be setup according to the type of texture in use.
  99799. */
  99800. environmentBRDFTexture: BaseTexture;
  99801. /** @hidden */
  99802. protected _environmentTexture: Nullable<BaseTexture>;
  99803. /**
  99804. * Texture used in all pbr material as the reflection texture.
  99805. * As in the majority of the scene they are the same (exception for multi room and so on),
  99806. * this is easier to reference from here than from all the materials.
  99807. */
  99808. /**
  99809. * Texture used in all pbr material as the reflection texture.
  99810. * As in the majority of the scene they are the same (exception for multi room and so on),
  99811. * this is easier to set here than in all the materials.
  99812. */
  99813. environmentTexture: Nullable<BaseTexture>;
  99814. /** @hidden */
  99815. protected _environmentIntensity: number;
  99816. /**
  99817. * Intensity of the environment in all pbr material.
  99818. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99819. * As in the majority of the scene they are the same (exception for multi room and so on),
  99820. * this is easier to reference from here than from all the materials.
  99821. */
  99822. /**
  99823. * Intensity of the environment in all pbr material.
  99824. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99825. * As in the majority of the scene they are the same (exception for multi room and so on),
  99826. * this is easier to set here than in all the materials.
  99827. */
  99828. environmentIntensity: number;
  99829. /** @hidden */
  99830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99831. /**
  99832. * Default image processing configuration used either in the rendering
  99833. * Forward main pass or through the imageProcessingPostProcess if present.
  99834. * As in the majority of the scene they are the same (exception for multi camera),
  99835. * this is easier to reference from here than from all the materials and post process.
  99836. *
  99837. * No setter as we it is a shared configuration, you can set the values instead.
  99838. */
  99839. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99840. private _forceWireframe;
  99841. /**
  99842. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99843. */
  99844. forceWireframe: boolean;
  99845. private _forcePointsCloud;
  99846. /**
  99847. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99848. */
  99849. forcePointsCloud: boolean;
  99850. /**
  99851. * Gets or sets the active clipplane 1
  99852. */
  99853. clipPlane: Nullable<Plane>;
  99854. /**
  99855. * Gets or sets the active clipplane 2
  99856. */
  99857. clipPlane2: Nullable<Plane>;
  99858. /**
  99859. * Gets or sets the active clipplane 3
  99860. */
  99861. clipPlane3: Nullable<Plane>;
  99862. /**
  99863. * Gets or sets the active clipplane 4
  99864. */
  99865. clipPlane4: Nullable<Plane>;
  99866. /**
  99867. * Gets or sets a boolean indicating if animations are enabled
  99868. */
  99869. animationsEnabled: boolean;
  99870. private _animationPropertiesOverride;
  99871. /**
  99872. * Gets or sets the animation properties override
  99873. */
  99874. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99875. /**
  99876. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99877. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99878. */
  99879. useConstantAnimationDeltaTime: boolean;
  99880. /**
  99881. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99882. * Please note that it requires to run a ray cast through the scene on every frame
  99883. */
  99884. constantlyUpdateMeshUnderPointer: boolean;
  99885. /**
  99886. * Defines the HTML cursor to use when hovering over interactive elements
  99887. */
  99888. hoverCursor: string;
  99889. /**
  99890. * Defines the HTML default cursor to use (empty by default)
  99891. */
  99892. defaultCursor: string;
  99893. /**
  99894. * This is used to call preventDefault() on pointer down
  99895. * in order to block unwanted artifacts like system double clicks
  99896. */
  99897. preventDefaultOnPointerDown: boolean;
  99898. /**
  99899. * This is used to call preventDefault() on pointer up
  99900. * in order to block unwanted artifacts like system double clicks
  99901. */
  99902. preventDefaultOnPointerUp: boolean;
  99903. /**
  99904. * Gets or sets user defined metadata
  99905. */
  99906. metadata: any;
  99907. /**
  99908. * For internal use only. Please do not use.
  99909. */
  99910. reservedDataStore: any;
  99911. /**
  99912. * Gets the name of the plugin used to load this scene (null by default)
  99913. */
  99914. loadingPluginName: string;
  99915. /**
  99916. * Use this array to add regular expressions used to disable offline support for specific urls
  99917. */
  99918. disableOfflineSupportExceptionRules: RegExp[];
  99919. /**
  99920. * An event triggered when the scene is disposed.
  99921. */
  99922. onDisposeObservable: Observable<Scene>;
  99923. private _onDisposeObserver;
  99924. /** Sets a function to be executed when this scene is disposed. */
  99925. onDispose: () => void;
  99926. /**
  99927. * An event triggered before rendering the scene (right after animations and physics)
  99928. */
  99929. onBeforeRenderObservable: Observable<Scene>;
  99930. private _onBeforeRenderObserver;
  99931. /** Sets a function to be executed before rendering this scene */
  99932. beforeRender: Nullable<() => void>;
  99933. /**
  99934. * An event triggered after rendering the scene
  99935. */
  99936. onAfterRenderObservable: Observable<Scene>;
  99937. /**
  99938. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99939. */
  99940. onAfterRenderCameraObservable: Observable<Camera>;
  99941. private _onAfterRenderObserver;
  99942. /** Sets a function to be executed after rendering this scene */
  99943. afterRender: Nullable<() => void>;
  99944. /**
  99945. * An event triggered before animating the scene
  99946. */
  99947. onBeforeAnimationsObservable: Observable<Scene>;
  99948. /**
  99949. * An event triggered after animations processing
  99950. */
  99951. onAfterAnimationsObservable: Observable<Scene>;
  99952. /**
  99953. * An event triggered before draw calls are ready to be sent
  99954. */
  99955. onBeforeDrawPhaseObservable: Observable<Scene>;
  99956. /**
  99957. * An event triggered after draw calls have been sent
  99958. */
  99959. onAfterDrawPhaseObservable: Observable<Scene>;
  99960. /**
  99961. * An event triggered when the scene is ready
  99962. */
  99963. onReadyObservable: Observable<Scene>;
  99964. /**
  99965. * An event triggered before rendering a camera
  99966. */
  99967. onBeforeCameraRenderObservable: Observable<Camera>;
  99968. private _onBeforeCameraRenderObserver;
  99969. /** Sets a function to be executed before rendering a camera*/
  99970. beforeCameraRender: () => void;
  99971. /**
  99972. * An event triggered after rendering a camera
  99973. */
  99974. onAfterCameraRenderObservable: Observable<Camera>;
  99975. private _onAfterCameraRenderObserver;
  99976. /** Sets a function to be executed after rendering a camera*/
  99977. afterCameraRender: () => void;
  99978. /**
  99979. * An event triggered when active meshes evaluation is about to start
  99980. */
  99981. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  99982. /**
  99983. * An event triggered when active meshes evaluation is done
  99984. */
  99985. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  99986. /**
  99987. * An event triggered when particles rendering is about to start
  99988. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99989. */
  99990. onBeforeParticlesRenderingObservable: Observable<Scene>;
  99991. /**
  99992. * An event triggered when particles rendering is done
  99993. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  99994. */
  99995. onAfterParticlesRenderingObservable: Observable<Scene>;
  99996. /**
  99997. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  99998. */
  99999. onDataLoadedObservable: Observable<Scene>;
  100000. /**
  100001. * An event triggered when a camera is created
  100002. */
  100003. onNewCameraAddedObservable: Observable<Camera>;
  100004. /**
  100005. * An event triggered when a camera is removed
  100006. */
  100007. onCameraRemovedObservable: Observable<Camera>;
  100008. /**
  100009. * An event triggered when a light is created
  100010. */
  100011. onNewLightAddedObservable: Observable<Light>;
  100012. /**
  100013. * An event triggered when a light is removed
  100014. */
  100015. onLightRemovedObservable: Observable<Light>;
  100016. /**
  100017. * An event triggered when a geometry is created
  100018. */
  100019. onNewGeometryAddedObservable: Observable<Geometry>;
  100020. /**
  100021. * An event triggered when a geometry is removed
  100022. */
  100023. onGeometryRemovedObservable: Observable<Geometry>;
  100024. /**
  100025. * An event triggered when a transform node is created
  100026. */
  100027. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100028. /**
  100029. * An event triggered when a transform node is removed
  100030. */
  100031. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100032. /**
  100033. * An event triggered when a mesh is created
  100034. */
  100035. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100036. /**
  100037. * An event triggered when a mesh is removed
  100038. */
  100039. onMeshRemovedObservable: Observable<AbstractMesh>;
  100040. /**
  100041. * An event triggered when a skeleton is created
  100042. */
  100043. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100044. /**
  100045. * An event triggered when a skeleton is removed
  100046. */
  100047. onSkeletonRemovedObservable: Observable<Skeleton>;
  100048. /**
  100049. * An event triggered when a material is created
  100050. */
  100051. onNewMaterialAddedObservable: Observable<Material>;
  100052. /**
  100053. * An event triggered when a material is removed
  100054. */
  100055. onMaterialRemovedObservable: Observable<Material>;
  100056. /**
  100057. * An event triggered when a texture is created
  100058. */
  100059. onNewTextureAddedObservable: Observable<BaseTexture>;
  100060. /**
  100061. * An event triggered when a texture is removed
  100062. */
  100063. onTextureRemovedObservable: Observable<BaseTexture>;
  100064. /**
  100065. * An event triggered when render targets are about to be rendered
  100066. * Can happen multiple times per frame.
  100067. */
  100068. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100069. /**
  100070. * An event triggered when render targets were rendered.
  100071. * Can happen multiple times per frame.
  100072. */
  100073. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100074. /**
  100075. * An event triggered before calculating deterministic simulation step
  100076. */
  100077. onBeforeStepObservable: Observable<Scene>;
  100078. /**
  100079. * An event triggered after calculating deterministic simulation step
  100080. */
  100081. onAfterStepObservable: Observable<Scene>;
  100082. /**
  100083. * An event triggered when the activeCamera property is updated
  100084. */
  100085. onActiveCameraChanged: Observable<Scene>;
  100086. /**
  100087. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100088. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100089. * 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)
  100090. */
  100091. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100092. /**
  100093. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100094. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100095. * 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)
  100096. */
  100097. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100098. /**
  100099. * This Observable will when a mesh has been imported into the scene.
  100100. */
  100101. onMeshImportedObservable: Observable<AbstractMesh>;
  100102. /**
  100103. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100104. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100105. */
  100106. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100107. /** @hidden */
  100108. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100109. /**
  100110. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100111. */
  100112. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100113. /**
  100114. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100115. */
  100116. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100117. /**
  100118. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100119. */
  100120. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100121. /** Callback called when a pointer move is detected */
  100122. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100123. /** Callback called when a pointer down is detected */
  100124. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100125. /** Callback called when a pointer up is detected */
  100126. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100127. /** Callback called when a pointer pick is detected */
  100128. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100129. /**
  100130. * 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).
  100131. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100132. */
  100133. onPrePointerObservable: Observable<PointerInfoPre>;
  100134. /**
  100135. * Observable event triggered each time an input event is received from the rendering canvas
  100136. */
  100137. onPointerObservable: Observable<PointerInfo>;
  100138. /**
  100139. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100140. */
  100141. readonly unTranslatedPointer: Vector2;
  100142. /**
  100143. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100144. */
  100145. static DragMovementThreshold: number;
  100146. /**
  100147. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100148. */
  100149. static LongPressDelay: number;
  100150. /**
  100151. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100152. */
  100153. static DoubleClickDelay: number;
  100154. /** If you need to check double click without raising a single click at first click, enable this flag */
  100155. static ExclusiveDoubleClickMode: boolean;
  100156. /** @hidden */
  100157. _mirroredCameraPosition: Nullable<Vector3>;
  100158. /**
  100159. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100160. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100161. */
  100162. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100163. /**
  100164. * Observable event triggered each time an keyboard event is received from the hosting window
  100165. */
  100166. onKeyboardObservable: Observable<KeyboardInfo>;
  100167. private _useRightHandedSystem;
  100168. /**
  100169. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100170. */
  100171. useRightHandedSystem: boolean;
  100172. private _timeAccumulator;
  100173. private _currentStepId;
  100174. private _currentInternalStep;
  100175. /**
  100176. * Sets the step Id used by deterministic lock step
  100177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100178. * @param newStepId defines the step Id
  100179. */
  100180. setStepId(newStepId: number): void;
  100181. /**
  100182. * Gets the step Id used by deterministic lock step
  100183. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100184. * @returns the step Id
  100185. */
  100186. getStepId(): number;
  100187. /**
  100188. * Gets the internal step used by deterministic lock step
  100189. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100190. * @returns the internal step
  100191. */
  100192. getInternalStep(): number;
  100193. private _fogEnabled;
  100194. /**
  100195. * Gets or sets a boolean indicating if fog is enabled on this scene
  100196. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100197. * (Default is true)
  100198. */
  100199. fogEnabled: boolean;
  100200. private _fogMode;
  100201. /**
  100202. * Gets or sets the fog mode to use
  100203. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100204. * | mode | value |
  100205. * | --- | --- |
  100206. * | FOGMODE_NONE | 0 |
  100207. * | FOGMODE_EXP | 1 |
  100208. * | FOGMODE_EXP2 | 2 |
  100209. * | FOGMODE_LINEAR | 3 |
  100210. */
  100211. fogMode: number;
  100212. /**
  100213. * Gets or sets the fog color to use
  100214. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100215. * (Default is Color3(0.2, 0.2, 0.3))
  100216. */
  100217. fogColor: Color3;
  100218. /**
  100219. * Gets or sets the fog density to use
  100220. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100221. * (Default is 0.1)
  100222. */
  100223. fogDensity: number;
  100224. /**
  100225. * Gets or sets the fog start distance to use
  100226. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100227. * (Default is 0)
  100228. */
  100229. fogStart: number;
  100230. /**
  100231. * Gets or sets the fog end distance to use
  100232. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100233. * (Default is 1000)
  100234. */
  100235. fogEnd: number;
  100236. private _shadowsEnabled;
  100237. /**
  100238. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100239. */
  100240. shadowsEnabled: boolean;
  100241. private _lightsEnabled;
  100242. /**
  100243. * Gets or sets a boolean indicating if lights are enabled on this scene
  100244. */
  100245. lightsEnabled: boolean;
  100246. /** All of the active cameras added to this scene. */
  100247. activeCameras: Camera[];
  100248. /** @hidden */
  100249. _activeCamera: Nullable<Camera>;
  100250. /** Gets or sets the current active camera */
  100251. activeCamera: Nullable<Camera>;
  100252. private _defaultMaterial;
  100253. /** The default material used on meshes when no material is affected */
  100254. /** The default material used on meshes when no material is affected */
  100255. defaultMaterial: Material;
  100256. private _texturesEnabled;
  100257. /**
  100258. * Gets or sets a boolean indicating if textures are enabled on this scene
  100259. */
  100260. texturesEnabled: boolean;
  100261. /**
  100262. * Gets or sets a boolean indicating if particles are enabled on this scene
  100263. */
  100264. particlesEnabled: boolean;
  100265. /**
  100266. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100267. */
  100268. spritesEnabled: boolean;
  100269. private _skeletonsEnabled;
  100270. /**
  100271. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100272. */
  100273. skeletonsEnabled: boolean;
  100274. /**
  100275. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100276. */
  100277. lensFlaresEnabled: boolean;
  100278. /**
  100279. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100280. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100281. */
  100282. collisionsEnabled: boolean;
  100283. private _collisionCoordinator;
  100284. /** @hidden */
  100285. readonly collisionCoordinator: ICollisionCoordinator;
  100286. /**
  100287. * Defines the gravity applied to this scene (used only for collisions)
  100288. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100289. */
  100290. gravity: Vector3;
  100291. /**
  100292. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100293. */
  100294. postProcessesEnabled: boolean;
  100295. /**
  100296. * The list of postprocesses added to the scene
  100297. */
  100298. postProcesses: PostProcess[];
  100299. /**
  100300. * Gets the current postprocess manager
  100301. */
  100302. postProcessManager: PostProcessManager;
  100303. /**
  100304. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100305. */
  100306. renderTargetsEnabled: boolean;
  100307. /**
  100308. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100309. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100310. */
  100311. dumpNextRenderTargets: boolean;
  100312. /**
  100313. * The list of user defined render targets added to the scene
  100314. */
  100315. customRenderTargets: RenderTargetTexture[];
  100316. /**
  100317. * Defines if texture loading must be delayed
  100318. * If true, textures will only be loaded when they need to be rendered
  100319. */
  100320. useDelayedTextureLoading: boolean;
  100321. /**
  100322. * Gets the list of meshes imported to the scene through SceneLoader
  100323. */
  100324. importedMeshesFiles: String[];
  100325. /**
  100326. * Gets or sets a boolean indicating if probes are enabled on this scene
  100327. */
  100328. probesEnabled: boolean;
  100329. /**
  100330. * Gets or sets the current offline provider to use to store scene data
  100331. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100332. */
  100333. offlineProvider: IOfflineProvider;
  100334. /**
  100335. * Gets or sets the action manager associated with the scene
  100336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100337. */
  100338. actionManager: AbstractActionManager;
  100339. private _meshesForIntersections;
  100340. /**
  100341. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100342. */
  100343. proceduralTexturesEnabled: boolean;
  100344. private _engine;
  100345. private _totalVertices;
  100346. /** @hidden */
  100347. _activeIndices: PerfCounter;
  100348. /** @hidden */
  100349. _activeParticles: PerfCounter;
  100350. /** @hidden */
  100351. _activeBones: PerfCounter;
  100352. private _animationRatio;
  100353. /** @hidden */
  100354. _animationTimeLast: number;
  100355. /** @hidden */
  100356. _animationTime: number;
  100357. /**
  100358. * Gets or sets a general scale for animation speed
  100359. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100360. */
  100361. animationTimeScale: number;
  100362. /** @hidden */
  100363. _cachedMaterial: Nullable<Material>;
  100364. /** @hidden */
  100365. _cachedEffect: Nullable<Effect>;
  100366. /** @hidden */
  100367. _cachedVisibility: Nullable<number>;
  100368. private _renderId;
  100369. private _frameId;
  100370. private _executeWhenReadyTimeoutId;
  100371. private _intermediateRendering;
  100372. private _viewUpdateFlag;
  100373. private _projectionUpdateFlag;
  100374. /** @hidden */
  100375. _toBeDisposed: Nullable<IDisposable>[];
  100376. private _activeRequests;
  100377. /** @hidden */
  100378. _pendingData: any[];
  100379. private _isDisposed;
  100380. /**
  100381. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100382. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100383. */
  100384. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100385. private _activeMeshes;
  100386. private _processedMaterials;
  100387. private _renderTargets;
  100388. /** @hidden */
  100389. _activeParticleSystems: SmartArray<IParticleSystem>;
  100390. private _activeSkeletons;
  100391. private _softwareSkinnedMeshes;
  100392. private _renderingManager;
  100393. /** @hidden */
  100394. _activeAnimatables: Animatable[];
  100395. private _transformMatrix;
  100396. private _sceneUbo;
  100397. /** @hidden */
  100398. _viewMatrix: Matrix;
  100399. private _projectionMatrix;
  100400. /** @hidden */
  100401. _forcedViewPosition: Nullable<Vector3>;
  100402. /** @hidden */
  100403. _frustumPlanes: Plane[];
  100404. /**
  100405. * Gets the list of frustum planes (built from the active camera)
  100406. */
  100407. readonly frustumPlanes: Plane[];
  100408. /**
  100409. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100410. * This is useful if there are more lights that the maximum simulteanous authorized
  100411. */
  100412. requireLightSorting: boolean;
  100413. /** @hidden */
  100414. readonly useMaterialMeshMap: boolean;
  100415. /** @hidden */
  100416. readonly useClonedMeshhMap: boolean;
  100417. private _externalData;
  100418. private _uid;
  100419. /**
  100420. * @hidden
  100421. * Backing store of defined scene components.
  100422. */
  100423. _components: ISceneComponent[];
  100424. /**
  100425. * @hidden
  100426. * Backing store of defined scene components.
  100427. */
  100428. _serializableComponents: ISceneSerializableComponent[];
  100429. /**
  100430. * List of components to register on the next registration step.
  100431. */
  100432. private _transientComponents;
  100433. /**
  100434. * Registers the transient components if needed.
  100435. */
  100436. private _registerTransientComponents;
  100437. /**
  100438. * @hidden
  100439. * Add a component to the scene.
  100440. * Note that the ccomponent could be registered on th next frame if this is called after
  100441. * the register component stage.
  100442. * @param component Defines the component to add to the scene
  100443. */
  100444. _addComponent(component: ISceneComponent): void;
  100445. /**
  100446. * @hidden
  100447. * Gets a component from the scene.
  100448. * @param name defines the name of the component to retrieve
  100449. * @returns the component or null if not present
  100450. */
  100451. _getComponent(name: string): Nullable<ISceneComponent>;
  100452. /**
  100453. * @hidden
  100454. * Defines the actions happening before camera updates.
  100455. */
  100456. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100457. /**
  100458. * @hidden
  100459. * Defines the actions happening before clear the canvas.
  100460. */
  100461. _beforeClearStage: Stage<SimpleStageAction>;
  100462. /**
  100463. * @hidden
  100464. * Defines the actions when collecting render targets for the frame.
  100465. */
  100466. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100467. /**
  100468. * @hidden
  100469. * Defines the actions happening for one camera in the frame.
  100470. */
  100471. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100472. /**
  100473. * @hidden
  100474. * Defines the actions happening during the per mesh ready checks.
  100475. */
  100476. _isReadyForMeshStage: Stage<MeshStageAction>;
  100477. /**
  100478. * @hidden
  100479. * Defines the actions happening before evaluate active mesh checks.
  100480. */
  100481. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100482. /**
  100483. * @hidden
  100484. * Defines the actions happening during the evaluate sub mesh checks.
  100485. */
  100486. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100487. /**
  100488. * @hidden
  100489. * Defines the actions happening during the active mesh stage.
  100490. */
  100491. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100492. /**
  100493. * @hidden
  100494. * Defines the actions happening during the per camera render target step.
  100495. */
  100496. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100497. /**
  100498. * @hidden
  100499. * Defines the actions happening just before the active camera is drawing.
  100500. */
  100501. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100502. /**
  100503. * @hidden
  100504. * Defines the actions happening just before a render target is drawing.
  100505. */
  100506. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100507. /**
  100508. * @hidden
  100509. * Defines the actions happening just before a rendering group is drawing.
  100510. */
  100511. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100512. /**
  100513. * @hidden
  100514. * Defines the actions happening just before a mesh is drawing.
  100515. */
  100516. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100517. /**
  100518. * @hidden
  100519. * Defines the actions happening just after a mesh has been drawn.
  100520. */
  100521. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100522. /**
  100523. * @hidden
  100524. * Defines the actions happening just after a rendering group has been drawn.
  100525. */
  100526. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100527. /**
  100528. * @hidden
  100529. * Defines the actions happening just after the active camera has been drawn.
  100530. */
  100531. _afterCameraDrawStage: Stage<CameraStageAction>;
  100532. /**
  100533. * @hidden
  100534. * Defines the actions happening just after a render target has been drawn.
  100535. */
  100536. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100537. /**
  100538. * @hidden
  100539. * Defines the actions happening just after rendering all cameras and computing intersections.
  100540. */
  100541. _afterRenderStage: Stage<SimpleStageAction>;
  100542. /**
  100543. * @hidden
  100544. * Defines the actions happening when a pointer move event happens.
  100545. */
  100546. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100547. /**
  100548. * @hidden
  100549. * Defines the actions happening when a pointer down event happens.
  100550. */
  100551. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100552. /**
  100553. * @hidden
  100554. * Defines the actions happening when a pointer up event happens.
  100555. */
  100556. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100557. /**
  100558. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100559. */
  100560. private geometriesByUniqueId;
  100561. /**
  100562. * Creates a new Scene
  100563. * @param engine defines the engine to use to render this scene
  100564. * @param options defines the scene options
  100565. */
  100566. constructor(engine: Engine, options?: SceneOptions);
  100567. /**
  100568. * Gets a string idenfifying the name of the class
  100569. * @returns "Scene" string
  100570. */
  100571. getClassName(): string;
  100572. private _defaultMeshCandidates;
  100573. /**
  100574. * @hidden
  100575. */
  100576. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100577. private _defaultSubMeshCandidates;
  100578. /**
  100579. * @hidden
  100580. */
  100581. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100582. /**
  100583. * Sets the default candidate providers for the scene.
  100584. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100585. * and getCollidingSubMeshCandidates to their default function
  100586. */
  100587. setDefaultCandidateProviders(): void;
  100588. /**
  100589. * Gets the mesh that is currently under the pointer
  100590. */
  100591. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100592. /**
  100593. * Gets or sets the current on-screen X position of the pointer
  100594. */
  100595. pointerX: number;
  100596. /**
  100597. * Gets or sets the current on-screen Y position of the pointer
  100598. */
  100599. pointerY: number;
  100600. /**
  100601. * Gets the cached material (ie. the latest rendered one)
  100602. * @returns the cached material
  100603. */
  100604. getCachedMaterial(): Nullable<Material>;
  100605. /**
  100606. * Gets the cached effect (ie. the latest rendered one)
  100607. * @returns the cached effect
  100608. */
  100609. getCachedEffect(): Nullable<Effect>;
  100610. /**
  100611. * Gets the cached visibility state (ie. the latest rendered one)
  100612. * @returns the cached visibility state
  100613. */
  100614. getCachedVisibility(): Nullable<number>;
  100615. /**
  100616. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100617. * @param material defines the current material
  100618. * @param effect defines the current effect
  100619. * @param visibility defines the current visibility state
  100620. * @returns true if one parameter is not cached
  100621. */
  100622. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100623. /**
  100624. * Gets the engine associated with the scene
  100625. * @returns an Engine
  100626. */
  100627. getEngine(): Engine;
  100628. /**
  100629. * Gets the total number of vertices rendered per frame
  100630. * @returns the total number of vertices rendered per frame
  100631. */
  100632. getTotalVertices(): number;
  100633. /**
  100634. * Gets the performance counter for total vertices
  100635. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100636. */
  100637. readonly totalVerticesPerfCounter: PerfCounter;
  100638. /**
  100639. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100640. * @returns the total number of active indices rendered per frame
  100641. */
  100642. getActiveIndices(): number;
  100643. /**
  100644. * Gets the performance counter for active indices
  100645. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100646. */
  100647. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100648. /**
  100649. * Gets the total number of active particles rendered per frame
  100650. * @returns the total number of active particles rendered per frame
  100651. */
  100652. getActiveParticles(): number;
  100653. /**
  100654. * Gets the performance counter for active particles
  100655. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100656. */
  100657. readonly activeParticlesPerfCounter: PerfCounter;
  100658. /**
  100659. * Gets the total number of active bones rendered per frame
  100660. * @returns the total number of active bones rendered per frame
  100661. */
  100662. getActiveBones(): number;
  100663. /**
  100664. * Gets the performance counter for active bones
  100665. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100666. */
  100667. readonly activeBonesPerfCounter: PerfCounter;
  100668. /**
  100669. * Gets the array of active meshes
  100670. * @returns an array of AbstractMesh
  100671. */
  100672. getActiveMeshes(): SmartArray<AbstractMesh>;
  100673. /**
  100674. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100675. * @returns a number
  100676. */
  100677. getAnimationRatio(): number;
  100678. /**
  100679. * Gets an unique Id for the current render phase
  100680. * @returns a number
  100681. */
  100682. getRenderId(): number;
  100683. /**
  100684. * Gets an unique Id for the current frame
  100685. * @returns a number
  100686. */
  100687. getFrameId(): number;
  100688. /** Call this function if you want to manually increment the render Id*/
  100689. incrementRenderId(): void;
  100690. private _createUbo;
  100691. /**
  100692. * Use this method to simulate a pointer move on a mesh
  100693. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100694. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100695. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100696. * @returns the current scene
  100697. */
  100698. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100699. /**
  100700. * Use this method to simulate a pointer down on a mesh
  100701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100704. * @returns the current scene
  100705. */
  100706. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100707. /**
  100708. * Use this method to simulate a pointer up on a mesh
  100709. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100710. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100711. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100712. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100713. * @returns the current scene
  100714. */
  100715. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100716. /**
  100717. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100718. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100719. * @returns true if the pointer was captured
  100720. */
  100721. isPointerCaptured(pointerId?: number): boolean;
  100722. /**
  100723. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100724. * @param attachUp defines if you want to attach events to pointerup
  100725. * @param attachDown defines if you want to attach events to pointerdown
  100726. * @param attachMove defines if you want to attach events to pointermove
  100727. */
  100728. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100729. /** Detaches all event handlers*/
  100730. detachControl(): void;
  100731. /**
  100732. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100733. * Delay loaded resources are not taking in account
  100734. * @return true if all required resources are ready
  100735. */
  100736. isReady(): boolean;
  100737. /** Resets all cached information relative to material (including effect and visibility) */
  100738. resetCachedMaterial(): void;
  100739. /**
  100740. * Registers a function to be called before every frame render
  100741. * @param func defines the function to register
  100742. */
  100743. registerBeforeRender(func: () => void): void;
  100744. /**
  100745. * Unregisters a function called before every frame render
  100746. * @param func defines the function to unregister
  100747. */
  100748. unregisterBeforeRender(func: () => void): void;
  100749. /**
  100750. * Registers a function to be called after every frame render
  100751. * @param func defines the function to register
  100752. */
  100753. registerAfterRender(func: () => void): void;
  100754. /**
  100755. * Unregisters a function called after every frame render
  100756. * @param func defines the function to unregister
  100757. */
  100758. unregisterAfterRender(func: () => void): void;
  100759. private _executeOnceBeforeRender;
  100760. /**
  100761. * The provided function will run before render once and will be disposed afterwards.
  100762. * A timeout delay can be provided so that the function will be executed in N ms.
  100763. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100764. * @param func The function to be executed.
  100765. * @param timeout optional delay in ms
  100766. */
  100767. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100768. /** @hidden */
  100769. _addPendingData(data: any): void;
  100770. /** @hidden */
  100771. _removePendingData(data: any): void;
  100772. /**
  100773. * Returns the number of items waiting to be loaded
  100774. * @returns the number of items waiting to be loaded
  100775. */
  100776. getWaitingItemsCount(): number;
  100777. /**
  100778. * Returns a boolean indicating if the scene is still loading data
  100779. */
  100780. readonly isLoading: boolean;
  100781. /**
  100782. * Registers a function to be executed when the scene is ready
  100783. * @param {Function} func - the function to be executed
  100784. */
  100785. executeWhenReady(func: () => void): void;
  100786. /**
  100787. * Returns a promise that resolves when the scene is ready
  100788. * @returns A promise that resolves when the scene is ready
  100789. */
  100790. whenReadyAsync(): Promise<void>;
  100791. /** @hidden */
  100792. _checkIsReady(): void;
  100793. /**
  100794. * Gets all animatable attached to the scene
  100795. */
  100796. readonly animatables: Animatable[];
  100797. /**
  100798. * Resets the last animation time frame.
  100799. * Useful to override when animations start running when loading a scene for the first time.
  100800. */
  100801. resetLastAnimationTimeFrame(): void;
  100802. /**
  100803. * Gets the current view matrix
  100804. * @returns a Matrix
  100805. */
  100806. getViewMatrix(): Matrix;
  100807. /**
  100808. * Gets the current projection matrix
  100809. * @returns a Matrix
  100810. */
  100811. getProjectionMatrix(): Matrix;
  100812. /**
  100813. * Gets the current transform matrix
  100814. * @returns a Matrix made of View * Projection
  100815. */
  100816. getTransformMatrix(): Matrix;
  100817. /**
  100818. * Sets the current transform matrix
  100819. * @param viewL defines the View matrix to use
  100820. * @param projectionL defines the Projection matrix to use
  100821. * @param viewR defines the right View matrix to use (if provided)
  100822. * @param projectionR defines the right Projection matrix to use (if provided)
  100823. */
  100824. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100825. /**
  100826. * Gets the uniform buffer used to store scene data
  100827. * @returns a UniformBuffer
  100828. */
  100829. getSceneUniformBuffer(): UniformBuffer;
  100830. /**
  100831. * Gets an unique (relatively to the current scene) Id
  100832. * @returns an unique number for the scene
  100833. */
  100834. getUniqueId(): number;
  100835. /**
  100836. * Add a mesh to the list of scene's meshes
  100837. * @param newMesh defines the mesh to add
  100838. * @param recursive if all child meshes should also be added to the scene
  100839. */
  100840. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100841. /**
  100842. * Remove a mesh for the list of scene's meshes
  100843. * @param toRemove defines the mesh to remove
  100844. * @param recursive if all child meshes should also be removed from the scene
  100845. * @returns the index where the mesh was in the mesh list
  100846. */
  100847. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100848. /**
  100849. * Add a transform node to the list of scene's transform nodes
  100850. * @param newTransformNode defines the transform node to add
  100851. */
  100852. addTransformNode(newTransformNode: TransformNode): void;
  100853. /**
  100854. * Remove a transform node for the list of scene's transform nodes
  100855. * @param toRemove defines the transform node to remove
  100856. * @returns the index where the transform node was in the transform node list
  100857. */
  100858. removeTransformNode(toRemove: TransformNode): number;
  100859. /**
  100860. * Remove a skeleton for the list of scene's skeletons
  100861. * @param toRemove defines the skeleton to remove
  100862. * @returns the index where the skeleton was in the skeleton list
  100863. */
  100864. removeSkeleton(toRemove: Skeleton): number;
  100865. /**
  100866. * Remove a morph target for the list of scene's morph targets
  100867. * @param toRemove defines the morph target to remove
  100868. * @returns the index where the morph target was in the morph target list
  100869. */
  100870. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100871. /**
  100872. * Remove a light for the list of scene's lights
  100873. * @param toRemove defines the light to remove
  100874. * @returns the index where the light was in the light list
  100875. */
  100876. removeLight(toRemove: Light): number;
  100877. /**
  100878. * Remove a camera for the list of scene's cameras
  100879. * @param toRemove defines the camera to remove
  100880. * @returns the index where the camera was in the camera list
  100881. */
  100882. removeCamera(toRemove: Camera): number;
  100883. /**
  100884. * Remove a particle system for the list of scene's particle systems
  100885. * @param toRemove defines the particle system to remove
  100886. * @returns the index where the particle system was in the particle system list
  100887. */
  100888. removeParticleSystem(toRemove: IParticleSystem): number;
  100889. /**
  100890. * Remove a animation for the list of scene's animations
  100891. * @param toRemove defines the animation to remove
  100892. * @returns the index where the animation was in the animation list
  100893. */
  100894. removeAnimation(toRemove: Animation): number;
  100895. /**
  100896. * Will stop the animation of the given target
  100897. * @param target - the target
  100898. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100899. * @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)
  100900. */
  100901. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100902. /**
  100903. * Removes the given animation group from this scene.
  100904. * @param toRemove The animation group to remove
  100905. * @returns The index of the removed animation group
  100906. */
  100907. removeAnimationGroup(toRemove: AnimationGroup): number;
  100908. /**
  100909. * Removes the given multi-material from this scene.
  100910. * @param toRemove The multi-material to remove
  100911. * @returns The index of the removed multi-material
  100912. */
  100913. removeMultiMaterial(toRemove: MultiMaterial): number;
  100914. /**
  100915. * Removes the given material from this scene.
  100916. * @param toRemove The material to remove
  100917. * @returns The index of the removed material
  100918. */
  100919. removeMaterial(toRemove: Material): number;
  100920. /**
  100921. * Removes the given action manager from this scene.
  100922. * @param toRemove The action manager to remove
  100923. * @returns The index of the removed action manager
  100924. */
  100925. removeActionManager(toRemove: AbstractActionManager): number;
  100926. /**
  100927. * Removes the given texture from this scene.
  100928. * @param toRemove The texture to remove
  100929. * @returns The index of the removed texture
  100930. */
  100931. removeTexture(toRemove: BaseTexture): number;
  100932. /**
  100933. * Adds the given light to this scene
  100934. * @param newLight The light to add
  100935. */
  100936. addLight(newLight: Light): void;
  100937. /**
  100938. * Sorts the list list based on light priorities
  100939. */
  100940. sortLightsByPriority(): void;
  100941. /**
  100942. * Adds the given camera to this scene
  100943. * @param newCamera The camera to add
  100944. */
  100945. addCamera(newCamera: Camera): void;
  100946. /**
  100947. * Adds the given skeleton to this scene
  100948. * @param newSkeleton The skeleton to add
  100949. */
  100950. addSkeleton(newSkeleton: Skeleton): void;
  100951. /**
  100952. * Adds the given particle system to this scene
  100953. * @param newParticleSystem The particle system to add
  100954. */
  100955. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100956. /**
  100957. * Adds the given animation to this scene
  100958. * @param newAnimation The animation to add
  100959. */
  100960. addAnimation(newAnimation: Animation): void;
  100961. /**
  100962. * Adds the given animation group to this scene.
  100963. * @param newAnimationGroup The animation group to add
  100964. */
  100965. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  100966. /**
  100967. * Adds the given multi-material to this scene
  100968. * @param newMultiMaterial The multi-material to add
  100969. */
  100970. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  100971. /**
  100972. * Adds the given material to this scene
  100973. * @param newMaterial The material to add
  100974. */
  100975. addMaterial(newMaterial: Material): void;
  100976. /**
  100977. * Adds the given morph target to this scene
  100978. * @param newMorphTargetManager The morph target to add
  100979. */
  100980. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  100981. /**
  100982. * Adds the given geometry to this scene
  100983. * @param newGeometry The geometry to add
  100984. */
  100985. addGeometry(newGeometry: Geometry): void;
  100986. /**
  100987. * Adds the given action manager to this scene
  100988. * @param newActionManager The action manager to add
  100989. */
  100990. addActionManager(newActionManager: AbstractActionManager): void;
  100991. /**
  100992. * Adds the given texture to this scene.
  100993. * @param newTexture The texture to add
  100994. */
  100995. addTexture(newTexture: BaseTexture): void;
  100996. /**
  100997. * Switch active camera
  100998. * @param newCamera defines the new active camera
  100999. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101000. */
  101001. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101002. /**
  101003. * sets the active camera of the scene using its ID
  101004. * @param id defines the camera's ID
  101005. * @return the new active camera or null if none found.
  101006. */
  101007. setActiveCameraByID(id: string): Nullable<Camera>;
  101008. /**
  101009. * sets the active camera of the scene using its name
  101010. * @param name defines the camera's name
  101011. * @returns the new active camera or null if none found.
  101012. */
  101013. setActiveCameraByName(name: string): Nullable<Camera>;
  101014. /**
  101015. * get an animation group using its name
  101016. * @param name defines the material's name
  101017. * @return the animation group or null if none found.
  101018. */
  101019. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101020. /**
  101021. * Get a material using its unique id
  101022. * @param uniqueId defines the material's unique id
  101023. * @return the material or null if none found.
  101024. */
  101025. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101026. /**
  101027. * get a material using its id
  101028. * @param id defines the material's ID
  101029. * @return the material or null if none found.
  101030. */
  101031. getMaterialByID(id: string): Nullable<Material>;
  101032. /**
  101033. * Gets a the last added material using a given id
  101034. * @param id defines the material's ID
  101035. * @return the last material with the given id or null if none found.
  101036. */
  101037. getLastMaterialByID(id: string): Nullable<Material>;
  101038. /**
  101039. * Gets a material using its name
  101040. * @param name defines the material's name
  101041. * @return the material or null if none found.
  101042. */
  101043. getMaterialByName(name: string): Nullable<Material>;
  101044. /**
  101045. * Get a texture using its unique id
  101046. * @param uniqueId defines the texture's unique id
  101047. * @return the texture or null if none found.
  101048. */
  101049. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101050. /**
  101051. * Gets a camera using its id
  101052. * @param id defines the id to look for
  101053. * @returns the camera or null if not found
  101054. */
  101055. getCameraByID(id: string): Nullable<Camera>;
  101056. /**
  101057. * Gets a camera using its unique id
  101058. * @param uniqueId defines the unique id to look for
  101059. * @returns the camera or null if not found
  101060. */
  101061. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101062. /**
  101063. * Gets a camera using its name
  101064. * @param name defines the camera's name
  101065. * @return the camera or null if none found.
  101066. */
  101067. getCameraByName(name: string): Nullable<Camera>;
  101068. /**
  101069. * Gets a bone using its id
  101070. * @param id defines the bone's id
  101071. * @return the bone or null if not found
  101072. */
  101073. getBoneByID(id: string): Nullable<Bone>;
  101074. /**
  101075. * Gets a bone using its id
  101076. * @param name defines the bone's name
  101077. * @return the bone or null if not found
  101078. */
  101079. getBoneByName(name: string): Nullable<Bone>;
  101080. /**
  101081. * Gets a light node using its name
  101082. * @param name defines the the light's name
  101083. * @return the light or null if none found.
  101084. */
  101085. getLightByName(name: string): Nullable<Light>;
  101086. /**
  101087. * Gets a light node using its id
  101088. * @param id defines the light's id
  101089. * @return the light or null if none found.
  101090. */
  101091. getLightByID(id: string): Nullable<Light>;
  101092. /**
  101093. * Gets a light node using its scene-generated unique ID
  101094. * @param uniqueId defines the light's unique id
  101095. * @return the light or null if none found.
  101096. */
  101097. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101098. /**
  101099. * Gets a particle system by id
  101100. * @param id defines the particle system id
  101101. * @return the corresponding system or null if none found
  101102. */
  101103. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101104. /**
  101105. * Gets a geometry using its ID
  101106. * @param id defines the geometry's id
  101107. * @return the geometry or null if none found.
  101108. */
  101109. getGeometryByID(id: string): Nullable<Geometry>;
  101110. private _getGeometryByUniqueID;
  101111. /**
  101112. * Add a new geometry to this scene
  101113. * @param geometry defines the geometry to be added to the scene.
  101114. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101115. * @return a boolean defining if the geometry was added or not
  101116. */
  101117. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101118. /**
  101119. * Removes an existing geometry
  101120. * @param geometry defines the geometry to be removed from the scene
  101121. * @return a boolean defining if the geometry was removed or not
  101122. */
  101123. removeGeometry(geometry: Geometry): boolean;
  101124. /**
  101125. * Gets the list of geometries attached to the scene
  101126. * @returns an array of Geometry
  101127. */
  101128. getGeometries(): Geometry[];
  101129. /**
  101130. * Gets the first added mesh found of a given ID
  101131. * @param id defines the id to search for
  101132. * @return the mesh found or null if not found at all
  101133. */
  101134. getMeshByID(id: string): Nullable<AbstractMesh>;
  101135. /**
  101136. * Gets a list of meshes using their id
  101137. * @param id defines the id to search for
  101138. * @returns a list of meshes
  101139. */
  101140. getMeshesByID(id: string): Array<AbstractMesh>;
  101141. /**
  101142. * Gets the first added transform node found of a given ID
  101143. * @param id defines the id to search for
  101144. * @return the found transform node or null if not found at all.
  101145. */
  101146. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101147. /**
  101148. * Gets a transform node with its auto-generated unique id
  101149. * @param uniqueId efines the unique id to search for
  101150. * @return the found transform node or null if not found at all.
  101151. */
  101152. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101153. /**
  101154. * Gets a list of transform nodes using their id
  101155. * @param id defines the id to search for
  101156. * @returns a list of transform nodes
  101157. */
  101158. getTransformNodesByID(id: string): Array<TransformNode>;
  101159. /**
  101160. * Gets a mesh with its auto-generated unique id
  101161. * @param uniqueId defines the unique id to search for
  101162. * @return the found mesh or null if not found at all.
  101163. */
  101164. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101165. /**
  101166. * Gets a the last added mesh using a given id
  101167. * @param id defines the id to search for
  101168. * @return the found mesh or null if not found at all.
  101169. */
  101170. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101171. /**
  101172. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101173. * @param id defines the id to search for
  101174. * @return the found node or null if not found at all
  101175. */
  101176. getLastEntryByID(id: string): Nullable<Node>;
  101177. /**
  101178. * Gets a node (Mesh, Camera, Light) using a given id
  101179. * @param id defines the id to search for
  101180. * @return the found node or null if not found at all
  101181. */
  101182. getNodeByID(id: string): Nullable<Node>;
  101183. /**
  101184. * Gets a node (Mesh, Camera, Light) using a given name
  101185. * @param name defines the name to search for
  101186. * @return the found node or null if not found at all.
  101187. */
  101188. getNodeByName(name: string): Nullable<Node>;
  101189. /**
  101190. * Gets a mesh using a given name
  101191. * @param name defines the name to search for
  101192. * @return the found mesh or null if not found at all.
  101193. */
  101194. getMeshByName(name: string): Nullable<AbstractMesh>;
  101195. /**
  101196. * Gets a transform node using a given name
  101197. * @param name defines the name to search for
  101198. * @return the found transform node or null if not found at all.
  101199. */
  101200. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101201. /**
  101202. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101203. * @param id defines the id to search for
  101204. * @return the found skeleton or null if not found at all.
  101205. */
  101206. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101207. /**
  101208. * Gets a skeleton using a given auto generated unique id
  101209. * @param uniqueId defines the unique id to search for
  101210. * @return the found skeleton or null if not found at all.
  101211. */
  101212. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101213. /**
  101214. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101215. * @param id defines the id to search for
  101216. * @return the found skeleton or null if not found at all.
  101217. */
  101218. getSkeletonById(id: string): Nullable<Skeleton>;
  101219. /**
  101220. * Gets a skeleton using a given name
  101221. * @param name defines the name to search for
  101222. * @return the found skeleton or null if not found at all.
  101223. */
  101224. getSkeletonByName(name: string): Nullable<Skeleton>;
  101225. /**
  101226. * Gets a morph target manager 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 morph target manager or null if not found at all.
  101229. */
  101230. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101231. /**
  101232. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101233. * @param id defines the id to search for
  101234. * @return the found morph target or null if not found at all.
  101235. */
  101236. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101237. /**
  101238. * Gets a boolean indicating if the given mesh is active
  101239. * @param mesh defines the mesh to look for
  101240. * @returns true if the mesh is in the active list
  101241. */
  101242. isActiveMesh(mesh: AbstractMesh): boolean;
  101243. /**
  101244. * Return a unique id as a string which can serve as an identifier for the scene
  101245. */
  101246. readonly uid: string;
  101247. /**
  101248. * Add an externaly attached data from its key.
  101249. * This method call will fail and return false, if such key already exists.
  101250. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101251. * @param key the unique key that identifies the data
  101252. * @param data the data object to associate to the key for this Engine instance
  101253. * @return true if no such key were already present and the data was added successfully, false otherwise
  101254. */
  101255. addExternalData<T>(key: string, data: T): boolean;
  101256. /**
  101257. * Get an externaly attached data from its key
  101258. * @param key the unique key that identifies the data
  101259. * @return the associated data, if present (can be null), or undefined if not present
  101260. */
  101261. getExternalData<T>(key: string): Nullable<T>;
  101262. /**
  101263. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101264. * @param key the unique key that identifies the data
  101265. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101266. * @return the associated data, can be null if the factory returned null.
  101267. */
  101268. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101269. /**
  101270. * Remove an externaly attached data from the Engine instance
  101271. * @param key the unique key that identifies the data
  101272. * @return true if the data was successfully removed, false if it doesn't exist
  101273. */
  101274. removeExternalData(key: string): boolean;
  101275. private _evaluateSubMesh;
  101276. /**
  101277. * Clear the processed materials smart array preventing retention point in material dispose.
  101278. */
  101279. freeProcessedMaterials(): void;
  101280. private _preventFreeActiveMeshesAndRenderingGroups;
  101281. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101282. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101283. * when disposing several meshes in a row or a hierarchy of meshes.
  101284. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101285. */
  101286. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101287. /**
  101288. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101289. */
  101290. freeActiveMeshes(): void;
  101291. /**
  101292. * Clear the info related to rendering groups preventing retention points during dispose.
  101293. */
  101294. freeRenderingGroups(): void;
  101295. /** @hidden */
  101296. _isInIntermediateRendering(): boolean;
  101297. /**
  101298. * Lambda returning the list of potentially active meshes.
  101299. */
  101300. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101301. /**
  101302. * Lambda returning the list of potentially active sub meshes.
  101303. */
  101304. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101305. /**
  101306. * Lambda returning the list of potentially intersecting sub meshes.
  101307. */
  101308. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101309. /**
  101310. * Lambda returning the list of potentially colliding sub meshes.
  101311. */
  101312. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101313. private _activeMeshesFrozen;
  101314. /**
  101315. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101316. * @returns the current scene
  101317. */
  101318. freezeActiveMeshes(): Scene;
  101319. /**
  101320. * Use this function to restart evaluating active meshes on every frame
  101321. * @returns the current scene
  101322. */
  101323. unfreezeActiveMeshes(): Scene;
  101324. private _evaluateActiveMeshes;
  101325. private _activeMesh;
  101326. /**
  101327. * Update the transform matrix to update from the current active camera
  101328. * @param force defines a boolean used to force the update even if cache is up to date
  101329. */
  101330. updateTransformMatrix(force?: boolean): void;
  101331. private _bindFrameBuffer;
  101332. /** @hidden */
  101333. _allowPostProcessClearColor: boolean;
  101334. /** @hidden */
  101335. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101336. private _processSubCameras;
  101337. private _checkIntersections;
  101338. /** @hidden */
  101339. _advancePhysicsEngineStep(step: number): void;
  101340. /**
  101341. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101342. */
  101343. getDeterministicFrameTime: () => number;
  101344. /** @hidden */
  101345. _animate(): void;
  101346. /** Execute all animations (for a frame) */
  101347. animate(): void;
  101348. /**
  101349. * Render the scene
  101350. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101351. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101352. */
  101353. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101354. /**
  101355. * Freeze all materials
  101356. * A frozen material will not be updatable but should be faster to render
  101357. */
  101358. freezeMaterials(): void;
  101359. /**
  101360. * Unfreeze all materials
  101361. * A frozen material will not be updatable but should be faster to render
  101362. */
  101363. unfreezeMaterials(): void;
  101364. /**
  101365. * Releases all held ressources
  101366. */
  101367. dispose(): void;
  101368. /**
  101369. * Gets if the scene is already disposed
  101370. */
  101371. readonly isDisposed: boolean;
  101372. /**
  101373. * Call this function to reduce memory footprint of the scene.
  101374. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101375. */
  101376. clearCachedVertexData(): void;
  101377. /**
  101378. * This function will remove the local cached buffer data from texture.
  101379. * It will save memory but will prevent the texture from being rebuilt
  101380. */
  101381. cleanCachedTextureBuffer(): void;
  101382. /**
  101383. * Get the world extend vectors with an optional filter
  101384. *
  101385. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101386. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101387. */
  101388. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101389. min: Vector3;
  101390. max: Vector3;
  101391. };
  101392. /**
  101393. * Creates a ray that can be used to pick in the scene
  101394. * @param x defines the x coordinate of the origin (on-screen)
  101395. * @param y defines the y coordinate of the origin (on-screen)
  101396. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101397. * @param camera defines the camera to use for the picking
  101398. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101399. * @returns a Ray
  101400. */
  101401. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101402. /**
  101403. * Creates a ray that can be used to pick in the scene
  101404. * @param x defines the x coordinate of the origin (on-screen)
  101405. * @param y defines the y coordinate of the origin (on-screen)
  101406. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101407. * @param result defines the ray where to store the picking ray
  101408. * @param camera defines the camera to use for the picking
  101409. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101410. * @returns the current scene
  101411. */
  101412. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101413. /**
  101414. * Creates a ray that can be used to pick in the scene
  101415. * @param x defines the x coordinate of the origin (on-screen)
  101416. * @param y defines the y coordinate of the origin (on-screen)
  101417. * @param camera defines the camera to use for the picking
  101418. * @returns a Ray
  101419. */
  101420. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101421. /**
  101422. * Creates a ray that can be used to pick in the scene
  101423. * @param x defines the x coordinate of the origin (on-screen)
  101424. * @param y defines the y coordinate of the origin (on-screen)
  101425. * @param result defines the ray where to store the picking ray
  101426. * @param camera defines the camera to use for the picking
  101427. * @returns the current scene
  101428. */
  101429. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101430. /** Launch a ray to try to pick a mesh in the scene
  101431. * @param x position on screen
  101432. * @param y position on screen
  101433. * @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
  101434. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101435. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101436. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101437. * @returns a PickingInfo
  101438. */
  101439. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101440. /** Use the given ray to pick a mesh in the scene
  101441. * @param ray The ray to use to pick meshes
  101442. * @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
  101443. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101444. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101445. * @returns a PickingInfo
  101446. */
  101447. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101448. /**
  101449. * Launch a ray to try to pick a mesh in the scene
  101450. * @param x X position on screen
  101451. * @param y Y position on screen
  101452. * @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
  101453. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101454. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101455. * @returns an array of PickingInfo
  101456. */
  101457. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101458. /**
  101459. * Launch a ray to try to pick a mesh in the scene
  101460. * @param ray Ray to use
  101461. * @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
  101462. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101463. * @returns an array of PickingInfo
  101464. */
  101465. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101466. /**
  101467. * Force the value of meshUnderPointer
  101468. * @param mesh defines the mesh to use
  101469. */
  101470. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101471. /**
  101472. * Gets the mesh under the pointer
  101473. * @returns a Mesh or null if no mesh is under the pointer
  101474. */
  101475. getPointerOverMesh(): Nullable<AbstractMesh>;
  101476. /** @hidden */
  101477. _rebuildGeometries(): void;
  101478. /** @hidden */
  101479. _rebuildTextures(): void;
  101480. private _getByTags;
  101481. /**
  101482. * Get a list of meshes by tags
  101483. * @param tagsQuery defines the tags query to use
  101484. * @param forEach defines a predicate used to filter results
  101485. * @returns an array of Mesh
  101486. */
  101487. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101488. /**
  101489. * Get a list of cameras by tags
  101490. * @param tagsQuery defines the tags query to use
  101491. * @param forEach defines a predicate used to filter results
  101492. * @returns an array of Camera
  101493. */
  101494. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101495. /**
  101496. * Get a list of lights by tags
  101497. * @param tagsQuery defines the tags query to use
  101498. * @param forEach defines a predicate used to filter results
  101499. * @returns an array of Light
  101500. */
  101501. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101502. /**
  101503. * Get a list of materials by tags
  101504. * @param tagsQuery defines the tags query to use
  101505. * @param forEach defines a predicate used to filter results
  101506. * @returns an array of Material
  101507. */
  101508. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101509. /**
  101510. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101511. * This allowed control for front to back rendering or reversly depending of the special needs.
  101512. *
  101513. * @param renderingGroupId The rendering group id corresponding to its index
  101514. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101515. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101516. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101517. */
  101518. 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;
  101519. /**
  101520. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101521. *
  101522. * @param renderingGroupId The rendering group id corresponding to its index
  101523. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101524. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101525. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101526. */
  101527. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101528. /**
  101529. * Gets the current auto clear configuration for one rendering group of the rendering
  101530. * manager.
  101531. * @param index the rendering group index to get the information for
  101532. * @returns The auto clear setup for the requested rendering group
  101533. */
  101534. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101535. private _blockMaterialDirtyMechanism;
  101536. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101537. blockMaterialDirtyMechanism: boolean;
  101538. /**
  101539. * Will flag all materials as dirty to trigger new shader compilation
  101540. * @param flag defines the flag used to specify which material part must be marked as dirty
  101541. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101542. */
  101543. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101544. /** @hidden */
  101545. _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;
  101546. /** @hidden */
  101547. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101548. }
  101549. }
  101550. declare module BABYLON {
  101551. /**
  101552. * Set of assets to keep when moving a scene into an asset container.
  101553. */
  101554. export class KeepAssets extends AbstractScene {
  101555. }
  101556. /**
  101557. * Container with a set of assets that can be added or removed from a scene.
  101558. */
  101559. export class AssetContainer extends AbstractScene {
  101560. /**
  101561. * The scene the AssetContainer belongs to.
  101562. */
  101563. scene: Scene;
  101564. /**
  101565. * Instantiates an AssetContainer.
  101566. * @param scene The scene the AssetContainer belongs to.
  101567. */
  101568. constructor(scene: Scene);
  101569. /**
  101570. * Adds all the assets from the container to the scene.
  101571. */
  101572. addAllToScene(): void;
  101573. /**
  101574. * Removes all the assets in the container from the scene
  101575. */
  101576. removeAllFromScene(): void;
  101577. /**
  101578. * Disposes all the assets in the container
  101579. */
  101580. dispose(): void;
  101581. private _moveAssets;
  101582. /**
  101583. * Removes all the assets contained in the scene and adds them to the container.
  101584. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101585. */
  101586. moveAllFromScene(keepAssets?: KeepAssets): void;
  101587. /**
  101588. * 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.
  101589. * @returns the root mesh
  101590. */
  101591. createRootMesh(): Mesh;
  101592. }
  101593. }
  101594. declare module BABYLON {
  101595. /**
  101596. * Defines how the parser contract is defined.
  101597. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101598. */
  101599. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101600. /**
  101601. * Defines how the individual parser contract is defined.
  101602. * These parser can parse an individual asset
  101603. */
  101604. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101605. /**
  101606. * Base class of the scene acting as a container for the different elements composing a scene.
  101607. * This class is dynamically extended by the different components of the scene increasing
  101608. * flexibility and reducing coupling
  101609. */
  101610. export abstract class AbstractScene {
  101611. /**
  101612. * Stores the list of available parsers in the application.
  101613. */
  101614. private static _BabylonFileParsers;
  101615. /**
  101616. * Stores the list of available individual parsers in the application.
  101617. */
  101618. private static _IndividualBabylonFileParsers;
  101619. /**
  101620. * Adds a parser in the list of available ones
  101621. * @param name Defines the name of the parser
  101622. * @param parser Defines the parser to add
  101623. */
  101624. static AddParser(name: string, parser: BabylonFileParser): void;
  101625. /**
  101626. * Gets a general parser from the list of avaialble ones
  101627. * @param name Defines the name of the parser
  101628. * @returns the requested parser or null
  101629. */
  101630. static GetParser(name: string): Nullable<BabylonFileParser>;
  101631. /**
  101632. * Adds n individual parser in the list of available ones
  101633. * @param name Defines the name of the parser
  101634. * @param parser Defines the parser to add
  101635. */
  101636. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101637. /**
  101638. * Gets an individual parser from the list of avaialble ones
  101639. * @param name Defines the name of the parser
  101640. * @returns the requested parser or null
  101641. */
  101642. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101643. /**
  101644. * Parser json data and populate both a scene and its associated container object
  101645. * @param jsonData Defines the data to parse
  101646. * @param scene Defines the scene to parse the data for
  101647. * @param container Defines the container attached to the parsing sequence
  101648. * @param rootUrl Defines the root url of the data
  101649. */
  101650. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101651. /**
  101652. * Gets the list of root nodes (ie. nodes with no parent)
  101653. */
  101654. rootNodes: Node[];
  101655. /** All of the cameras added to this scene
  101656. * @see http://doc.babylonjs.com/babylon101/cameras
  101657. */
  101658. cameras: Camera[];
  101659. /**
  101660. * All of the lights added to this scene
  101661. * @see http://doc.babylonjs.com/babylon101/lights
  101662. */
  101663. lights: Light[];
  101664. /**
  101665. * All of the (abstract) meshes added to this scene
  101666. */
  101667. meshes: AbstractMesh[];
  101668. /**
  101669. * The list of skeletons added to the scene
  101670. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101671. */
  101672. skeletons: Skeleton[];
  101673. /**
  101674. * All of the particle systems added to this scene
  101675. * @see http://doc.babylonjs.com/babylon101/particles
  101676. */
  101677. particleSystems: IParticleSystem[];
  101678. /**
  101679. * Gets a list of Animations associated with the scene
  101680. */
  101681. animations: Animation[];
  101682. /**
  101683. * All of the animation groups added to this scene
  101684. * @see http://doc.babylonjs.com/how_to/group
  101685. */
  101686. animationGroups: AnimationGroup[];
  101687. /**
  101688. * All of the multi-materials added to this scene
  101689. * @see http://doc.babylonjs.com/how_to/multi_materials
  101690. */
  101691. multiMaterials: MultiMaterial[];
  101692. /**
  101693. * All of the materials added to this scene
  101694. * In the context of a Scene, it is not supposed to be modified manually.
  101695. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101696. * Note also that the order of the Material wihin the array is not significant and might change.
  101697. * @see http://doc.babylonjs.com/babylon101/materials
  101698. */
  101699. materials: Material[];
  101700. /**
  101701. * The list of morph target managers added to the scene
  101702. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101703. */
  101704. morphTargetManagers: MorphTargetManager[];
  101705. /**
  101706. * The list of geometries used in the scene.
  101707. */
  101708. geometries: Geometry[];
  101709. /**
  101710. * All of the tranform nodes added to this scene
  101711. * In the context of a Scene, it is not supposed to be modified manually.
  101712. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101713. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101714. * @see http://doc.babylonjs.com/how_to/transformnode
  101715. */
  101716. transformNodes: TransformNode[];
  101717. /**
  101718. * ActionManagers available on the scene.
  101719. */
  101720. actionManagers: AbstractActionManager[];
  101721. /**
  101722. * Textures to keep.
  101723. */
  101724. textures: BaseTexture[];
  101725. /**
  101726. * Environment texture for the scene
  101727. */
  101728. environmentTexture: Nullable<BaseTexture>;
  101729. }
  101730. }
  101731. declare module BABYLON {
  101732. /**
  101733. * Interface used to define options for Sound class
  101734. */
  101735. export interface ISoundOptions {
  101736. /**
  101737. * Does the sound autoplay once loaded.
  101738. */
  101739. autoplay?: boolean;
  101740. /**
  101741. * Does the sound loop after it finishes playing once.
  101742. */
  101743. loop?: boolean;
  101744. /**
  101745. * Sound's volume
  101746. */
  101747. volume?: number;
  101748. /**
  101749. * Is it a spatial sound?
  101750. */
  101751. spatialSound?: boolean;
  101752. /**
  101753. * Maximum distance to hear that sound
  101754. */
  101755. maxDistance?: number;
  101756. /**
  101757. * Uses user defined attenuation function
  101758. */
  101759. useCustomAttenuation?: boolean;
  101760. /**
  101761. * Define the roll off factor of spatial sounds.
  101762. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101763. */
  101764. rolloffFactor?: number;
  101765. /**
  101766. * Define the reference distance the sound should be heard perfectly.
  101767. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101768. */
  101769. refDistance?: number;
  101770. /**
  101771. * Define the distance attenuation model the sound will follow.
  101772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101773. */
  101774. distanceModel?: string;
  101775. /**
  101776. * Defines the playback speed (1 by default)
  101777. */
  101778. playbackRate?: number;
  101779. /**
  101780. * Defines if the sound is from a streaming source
  101781. */
  101782. streaming?: boolean;
  101783. /**
  101784. * Defines an optional length (in seconds) inside the sound file
  101785. */
  101786. length?: number;
  101787. /**
  101788. * Defines an optional offset (in seconds) inside the sound file
  101789. */
  101790. offset?: number;
  101791. /**
  101792. * If true, URLs will not be required to state the audio file codec to use.
  101793. */
  101794. skipCodecCheck?: boolean;
  101795. }
  101796. /**
  101797. * Defines a sound that can be played in the application.
  101798. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101799. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101800. */
  101801. export class Sound {
  101802. /**
  101803. * The name of the sound in the scene.
  101804. */
  101805. name: string;
  101806. /**
  101807. * Does the sound autoplay once loaded.
  101808. */
  101809. autoplay: boolean;
  101810. /**
  101811. * Does the sound loop after it finishes playing once.
  101812. */
  101813. loop: boolean;
  101814. /**
  101815. * Does the sound use a custom attenuation curve to simulate the falloff
  101816. * happening when the source gets further away from the camera.
  101817. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101818. */
  101819. useCustomAttenuation: boolean;
  101820. /**
  101821. * The sound track id this sound belongs to.
  101822. */
  101823. soundTrackId: number;
  101824. /**
  101825. * Is this sound currently played.
  101826. */
  101827. isPlaying: boolean;
  101828. /**
  101829. * Is this sound currently paused.
  101830. */
  101831. isPaused: boolean;
  101832. /**
  101833. * Does this sound enables spatial sound.
  101834. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101835. */
  101836. spatialSound: boolean;
  101837. /**
  101838. * Define the reference distance the sound should be heard perfectly.
  101839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101840. */
  101841. refDistance: number;
  101842. /**
  101843. * Define the roll off factor of spatial sounds.
  101844. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101845. */
  101846. rolloffFactor: number;
  101847. /**
  101848. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101849. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101850. */
  101851. maxDistance: number;
  101852. /**
  101853. * Define the distance attenuation model the sound will follow.
  101854. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101855. */
  101856. distanceModel: string;
  101857. /**
  101858. * @hidden
  101859. * Back Compat
  101860. **/
  101861. onended: () => any;
  101862. /**
  101863. * Observable event when the current playing sound finishes.
  101864. */
  101865. onEndedObservable: Observable<Sound>;
  101866. private _panningModel;
  101867. private _playbackRate;
  101868. private _streaming;
  101869. private _startTime;
  101870. private _startOffset;
  101871. private _position;
  101872. /** @hidden */
  101873. _positionInEmitterSpace: boolean;
  101874. private _localDirection;
  101875. private _volume;
  101876. private _isReadyToPlay;
  101877. private _isDirectional;
  101878. private _readyToPlayCallback;
  101879. private _audioBuffer;
  101880. private _soundSource;
  101881. private _streamingSource;
  101882. private _soundPanner;
  101883. private _soundGain;
  101884. private _inputAudioNode;
  101885. private _outputAudioNode;
  101886. private _coneInnerAngle;
  101887. private _coneOuterAngle;
  101888. private _coneOuterGain;
  101889. private _scene;
  101890. private _connectedTransformNode;
  101891. private _customAttenuationFunction;
  101892. private _registerFunc;
  101893. private _isOutputConnected;
  101894. private _htmlAudioElement;
  101895. private _urlType;
  101896. private _length?;
  101897. private _offset?;
  101898. /** @hidden */
  101899. static _SceneComponentInitialization: (scene: Scene) => void;
  101900. /**
  101901. * Create a sound and attach it to a scene
  101902. * @param name Name of your sound
  101903. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101904. * @param scene defines the scene the sound belongs to
  101905. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101906. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101907. */
  101908. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101909. /**
  101910. * Release the sound and its associated resources
  101911. */
  101912. dispose(): void;
  101913. /**
  101914. * Gets if the sounds is ready to be played or not.
  101915. * @returns true if ready, otherwise false
  101916. */
  101917. isReady(): boolean;
  101918. private _soundLoaded;
  101919. /**
  101920. * Sets the data of the sound from an audiobuffer
  101921. * @param audioBuffer The audioBuffer containing the data
  101922. */
  101923. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101924. /**
  101925. * Updates the current sounds options such as maxdistance, loop...
  101926. * @param options A JSON object containing values named as the object properties
  101927. */
  101928. updateOptions(options: ISoundOptions): void;
  101929. private _createSpatialParameters;
  101930. private _updateSpatialParameters;
  101931. /**
  101932. * Switch the panning model to HRTF:
  101933. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101935. */
  101936. switchPanningModelToHRTF(): void;
  101937. /**
  101938. * Switch the panning model to Equal Power:
  101939. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101940. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101941. */
  101942. switchPanningModelToEqualPower(): void;
  101943. private _switchPanningModel;
  101944. /**
  101945. * Connect this sound to a sound track audio node like gain...
  101946. * @param soundTrackAudioNode the sound track audio node to connect to
  101947. */
  101948. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101949. /**
  101950. * Transform this sound into a directional source
  101951. * @param coneInnerAngle Size of the inner cone in degree
  101952. * @param coneOuterAngle Size of the outer cone in degree
  101953. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101954. */
  101955. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101956. /**
  101957. * Gets or sets the inner angle for the directional cone.
  101958. */
  101959. /**
  101960. * Gets or sets the inner angle for the directional cone.
  101961. */
  101962. directionalConeInnerAngle: number;
  101963. /**
  101964. * Gets or sets the outer angle for the directional cone.
  101965. */
  101966. /**
  101967. * Gets or sets the outer angle for the directional cone.
  101968. */
  101969. directionalConeOuterAngle: number;
  101970. /**
  101971. * Sets the position of the emitter if spatial sound is enabled
  101972. * @param newPosition Defines the new posisiton
  101973. */
  101974. setPosition(newPosition: Vector3): void;
  101975. /**
  101976. * Sets the local direction of the emitter if spatial sound is enabled
  101977. * @param newLocalDirection Defines the new local direction
  101978. */
  101979. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  101980. private _updateDirection;
  101981. /** @hidden */
  101982. updateDistanceFromListener(): void;
  101983. /**
  101984. * Sets a new custom attenuation function for the sound.
  101985. * @param callback Defines the function used for the attenuation
  101986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101987. */
  101988. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  101989. /**
  101990. * Play the sound
  101991. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  101992. * @param offset (optional) Start the sound at a specific time in seconds
  101993. * @param length (optional) Sound duration (in seconds)
  101994. */
  101995. play(time?: number, offset?: number, length?: number): void;
  101996. private _onended;
  101997. /**
  101998. * Stop the sound
  101999. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102000. */
  102001. stop(time?: number): void;
  102002. /**
  102003. * Put the sound in pause
  102004. */
  102005. pause(): void;
  102006. /**
  102007. * Sets a dedicated volume for this sounds
  102008. * @param newVolume Define the new volume of the sound
  102009. * @param time Define time for gradual change to new volume
  102010. */
  102011. setVolume(newVolume: number, time?: number): void;
  102012. /**
  102013. * Set the sound play back rate
  102014. * @param newPlaybackRate Define the playback rate the sound should be played at
  102015. */
  102016. setPlaybackRate(newPlaybackRate: number): void;
  102017. /**
  102018. * Gets the volume of the sound.
  102019. * @returns the volume of the sound
  102020. */
  102021. getVolume(): number;
  102022. /**
  102023. * Attach the sound to a dedicated mesh
  102024. * @param transformNode The transform node to connect the sound with
  102025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102026. */
  102027. attachToMesh(transformNode: TransformNode): void;
  102028. /**
  102029. * Detach the sound from the previously attached mesh
  102030. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102031. */
  102032. detachFromMesh(): void;
  102033. private _onRegisterAfterWorldMatrixUpdate;
  102034. /**
  102035. * Clone the current sound in the scene.
  102036. * @returns the new sound clone
  102037. */
  102038. clone(): Nullable<Sound>;
  102039. /**
  102040. * Gets the current underlying audio buffer containing the data
  102041. * @returns the audio buffer
  102042. */
  102043. getAudioBuffer(): Nullable<AudioBuffer>;
  102044. /**
  102045. * Serializes the Sound in a JSON representation
  102046. * @returns the JSON representation of the sound
  102047. */
  102048. serialize(): any;
  102049. /**
  102050. * Parse a JSON representation of a sound to innstantiate in a given scene
  102051. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102052. * @param scene Define the scene the new parsed sound should be created in
  102053. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102054. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102055. * @returns the newly parsed sound
  102056. */
  102057. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102058. }
  102059. }
  102060. declare module BABYLON {
  102061. /**
  102062. * This defines an action helpful to play a defined sound on a triggered action.
  102063. */
  102064. export class PlaySoundAction extends Action {
  102065. private _sound;
  102066. /**
  102067. * Instantiate the action
  102068. * @param triggerOptions defines the trigger options
  102069. * @param sound defines the sound to play
  102070. * @param condition defines the trigger related conditions
  102071. */
  102072. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102073. /** @hidden */
  102074. _prepare(): void;
  102075. /**
  102076. * Execute the action and play the sound.
  102077. */
  102078. execute(): void;
  102079. /**
  102080. * Serializes the actions and its related information.
  102081. * @param parent defines the object to serialize in
  102082. * @returns the serialized object
  102083. */
  102084. serialize(parent: any): any;
  102085. }
  102086. /**
  102087. * This defines an action helpful to stop a defined sound on a triggered action.
  102088. */
  102089. export class StopSoundAction extends Action {
  102090. private _sound;
  102091. /**
  102092. * Instantiate the action
  102093. * @param triggerOptions defines the trigger options
  102094. * @param sound defines the sound to stop
  102095. * @param condition defines the trigger related conditions
  102096. */
  102097. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102098. /** @hidden */
  102099. _prepare(): void;
  102100. /**
  102101. * Execute the action and stop the sound.
  102102. */
  102103. execute(): void;
  102104. /**
  102105. * Serializes the actions and its related information.
  102106. * @param parent defines the object to serialize in
  102107. * @returns the serialized object
  102108. */
  102109. serialize(parent: any): any;
  102110. }
  102111. }
  102112. declare module BABYLON {
  102113. /**
  102114. * This defines an action responsible to change the value of a property
  102115. * by interpolating between its current value and the newly set one once triggered.
  102116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102117. */
  102118. export class InterpolateValueAction extends Action {
  102119. /**
  102120. * Defines the path of the property where the value should be interpolated
  102121. */
  102122. propertyPath: string;
  102123. /**
  102124. * Defines the target value at the end of the interpolation.
  102125. */
  102126. value: any;
  102127. /**
  102128. * Defines the time it will take for the property to interpolate to the value.
  102129. */
  102130. duration: number;
  102131. /**
  102132. * Defines if the other scene animations should be stopped when the action has been triggered
  102133. */
  102134. stopOtherAnimations?: boolean;
  102135. /**
  102136. * Defines a callback raised once the interpolation animation has been done.
  102137. */
  102138. onInterpolationDone?: () => void;
  102139. /**
  102140. * Observable triggered once the interpolation animation has been done.
  102141. */
  102142. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102143. private _target;
  102144. private _effectiveTarget;
  102145. private _property;
  102146. /**
  102147. * Instantiate the action
  102148. * @param triggerOptions defines the trigger options
  102149. * @param target defines the object containing the value to interpolate
  102150. * @param propertyPath defines the path to the property in the target object
  102151. * @param value defines the target value at the end of the interpolation
  102152. * @param duration deines the time it will take for the property to interpolate to the value.
  102153. * @param condition defines the trigger related conditions
  102154. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102155. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102156. */
  102157. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102158. /** @hidden */
  102159. _prepare(): void;
  102160. /**
  102161. * Execute the action starts the value interpolation.
  102162. */
  102163. execute(): void;
  102164. /**
  102165. * Serializes the actions and its related information.
  102166. * @param parent defines the object to serialize in
  102167. * @returns the serialized object
  102168. */
  102169. serialize(parent: any): any;
  102170. }
  102171. }
  102172. declare module BABYLON {
  102173. /**
  102174. * Options allowed during the creation of a sound track.
  102175. */
  102176. export interface ISoundTrackOptions {
  102177. /**
  102178. * The volume the sound track should take during creation
  102179. */
  102180. volume?: number;
  102181. /**
  102182. * Define if the sound track is the main sound track of the scene
  102183. */
  102184. mainTrack?: boolean;
  102185. }
  102186. /**
  102187. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102188. * It will be also used in a future release to apply effects on a specific track.
  102189. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102190. */
  102191. export class SoundTrack {
  102192. /**
  102193. * The unique identifier of the sound track in the scene.
  102194. */
  102195. id: number;
  102196. /**
  102197. * The list of sounds included in the sound track.
  102198. */
  102199. soundCollection: Array<Sound>;
  102200. private _outputAudioNode;
  102201. private _scene;
  102202. private _isMainTrack;
  102203. private _connectedAnalyser;
  102204. private _options;
  102205. private _isInitialized;
  102206. /**
  102207. * Creates a new sound track.
  102208. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102209. * @param scene Define the scene the sound track belongs to
  102210. * @param options
  102211. */
  102212. constructor(scene: Scene, options?: ISoundTrackOptions);
  102213. private _initializeSoundTrackAudioGraph;
  102214. /**
  102215. * Release the sound track and its associated resources
  102216. */
  102217. dispose(): void;
  102218. /**
  102219. * Adds a sound to this sound track
  102220. * @param sound define the cound to add
  102221. * @ignoreNaming
  102222. */
  102223. AddSound(sound: Sound): void;
  102224. /**
  102225. * Removes a sound to this sound track
  102226. * @param sound define the cound to remove
  102227. * @ignoreNaming
  102228. */
  102229. RemoveSound(sound: Sound): void;
  102230. /**
  102231. * Set a global volume for the full sound track.
  102232. * @param newVolume Define the new volume of the sound track
  102233. */
  102234. setVolume(newVolume: number): void;
  102235. /**
  102236. * Switch the panning model to HRTF:
  102237. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102239. */
  102240. switchPanningModelToHRTF(): void;
  102241. /**
  102242. * Switch the panning model to Equal Power:
  102243. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102245. */
  102246. switchPanningModelToEqualPower(): void;
  102247. /**
  102248. * Connect the sound track to an audio analyser allowing some amazing
  102249. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102250. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102251. * @param analyser The analyser to connect to the engine
  102252. */
  102253. connectToAnalyser(analyser: Analyser): void;
  102254. }
  102255. }
  102256. declare module BABYLON {
  102257. interface AbstractScene {
  102258. /**
  102259. * The list of sounds used in the scene.
  102260. */
  102261. sounds: Nullable<Array<Sound>>;
  102262. }
  102263. interface Scene {
  102264. /**
  102265. * @hidden
  102266. * Backing field
  102267. */
  102268. _mainSoundTrack: SoundTrack;
  102269. /**
  102270. * The main sound track played by the scene.
  102271. * It cotains your primary collection of sounds.
  102272. */
  102273. mainSoundTrack: SoundTrack;
  102274. /**
  102275. * The list of sound tracks added to the scene
  102276. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102277. */
  102278. soundTracks: Nullable<Array<SoundTrack>>;
  102279. /**
  102280. * Gets a sound using a given name
  102281. * @param name defines the name to search for
  102282. * @return the found sound or null if not found at all.
  102283. */
  102284. getSoundByName(name: string): Nullable<Sound>;
  102285. /**
  102286. * Gets or sets if audio support is enabled
  102287. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102288. */
  102289. audioEnabled: boolean;
  102290. /**
  102291. * Gets or sets if audio will be output to headphones
  102292. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102293. */
  102294. headphone: boolean;
  102295. /**
  102296. * Gets or sets custom audio listener position provider
  102297. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102298. */
  102299. audioListenerPositionProvider: Nullable<() => Vector3>;
  102300. }
  102301. /**
  102302. * Defines the sound scene component responsible to manage any sounds
  102303. * in a given scene.
  102304. */
  102305. export class AudioSceneComponent implements ISceneSerializableComponent {
  102306. /**
  102307. * The component name helpfull to identify the component in the list of scene components.
  102308. */
  102309. readonly name: string;
  102310. /**
  102311. * The scene the component belongs to.
  102312. */
  102313. scene: Scene;
  102314. private _audioEnabled;
  102315. /**
  102316. * Gets whether audio is enabled or not.
  102317. * Please use related enable/disable method to switch state.
  102318. */
  102319. readonly audioEnabled: boolean;
  102320. private _headphone;
  102321. /**
  102322. * Gets whether audio is outputing to headphone or not.
  102323. * Please use the according Switch methods to change output.
  102324. */
  102325. readonly headphone: boolean;
  102326. private _audioListenerPositionProvider;
  102327. /**
  102328. * Gets the current audio listener position provider
  102329. */
  102330. /**
  102331. * Sets a custom listener position for all sounds in the scene
  102332. * By default, this is the position of the first active camera
  102333. */
  102334. audioListenerPositionProvider: Nullable<() => Vector3>;
  102335. /**
  102336. * Creates a new instance of the component for the given scene
  102337. * @param scene Defines the scene to register the component in
  102338. */
  102339. constructor(scene: Scene);
  102340. /**
  102341. * Registers the component in a given scene
  102342. */
  102343. register(): void;
  102344. /**
  102345. * Rebuilds the elements related to this component in case of
  102346. * context lost for instance.
  102347. */
  102348. rebuild(): void;
  102349. /**
  102350. * Serializes the component data to the specified json object
  102351. * @param serializationObject The object to serialize to
  102352. */
  102353. serialize(serializationObject: any): void;
  102354. /**
  102355. * Adds all the elements from the container to the scene
  102356. * @param container the container holding the elements
  102357. */
  102358. addFromContainer(container: AbstractScene): void;
  102359. /**
  102360. * Removes all the elements in the container from the scene
  102361. * @param container contains the elements to remove
  102362. * @param dispose if the removed element should be disposed (default: false)
  102363. */
  102364. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102365. /**
  102366. * Disposes the component and the associated ressources.
  102367. */
  102368. dispose(): void;
  102369. /**
  102370. * Disables audio in the associated scene.
  102371. */
  102372. disableAudio(): void;
  102373. /**
  102374. * Enables audio in the associated scene.
  102375. */
  102376. enableAudio(): void;
  102377. /**
  102378. * Switch audio to headphone output.
  102379. */
  102380. switchAudioModeForHeadphones(): void;
  102381. /**
  102382. * Switch audio to normal speakers.
  102383. */
  102384. switchAudioModeForNormalSpeakers(): void;
  102385. private _afterRender;
  102386. }
  102387. }
  102388. declare module BABYLON {
  102389. /**
  102390. * Wraps one or more Sound objects and selects one with random weight for playback.
  102391. */
  102392. export class WeightedSound {
  102393. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102394. loop: boolean;
  102395. private _coneInnerAngle;
  102396. private _coneOuterAngle;
  102397. private _volume;
  102398. /** A Sound is currently playing. */
  102399. isPlaying: boolean;
  102400. /** A Sound is currently paused. */
  102401. isPaused: boolean;
  102402. private _sounds;
  102403. private _weights;
  102404. private _currentIndex?;
  102405. /**
  102406. * Creates a new WeightedSound from the list of sounds given.
  102407. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102408. * @param sounds Array of Sounds that will be selected from.
  102409. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102410. */
  102411. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102412. /**
  102413. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102414. */
  102415. /**
  102416. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102417. */
  102418. directionalConeInnerAngle: number;
  102419. /**
  102420. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102421. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102422. */
  102423. /**
  102424. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102425. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102426. */
  102427. directionalConeOuterAngle: number;
  102428. /**
  102429. * Playback volume.
  102430. */
  102431. /**
  102432. * Playback volume.
  102433. */
  102434. volume: number;
  102435. private _onended;
  102436. /**
  102437. * Suspend playback
  102438. */
  102439. pause(): void;
  102440. /**
  102441. * Stop playback
  102442. */
  102443. stop(): void;
  102444. /**
  102445. * Start playback.
  102446. * @param startOffset Position the clip head at a specific time in seconds.
  102447. */
  102448. play(startOffset?: number): void;
  102449. }
  102450. }
  102451. declare module BABYLON {
  102452. /**
  102453. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102454. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102455. */
  102456. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102457. /**
  102458. * Gets the name of the behavior.
  102459. */
  102460. readonly name: string;
  102461. /**
  102462. * The easing function used by animations
  102463. */
  102464. static EasingFunction: BackEase;
  102465. /**
  102466. * The easing mode used by animations
  102467. */
  102468. static EasingMode: number;
  102469. /**
  102470. * The duration of the animation, in milliseconds
  102471. */
  102472. transitionDuration: number;
  102473. /**
  102474. * Length of the distance animated by the transition when lower radius is reached
  102475. */
  102476. lowerRadiusTransitionRange: number;
  102477. /**
  102478. * Length of the distance animated by the transition when upper radius is reached
  102479. */
  102480. upperRadiusTransitionRange: number;
  102481. private _autoTransitionRange;
  102482. /**
  102483. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102484. */
  102485. /**
  102486. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102487. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102488. */
  102489. autoTransitionRange: boolean;
  102490. private _attachedCamera;
  102491. private _onAfterCheckInputsObserver;
  102492. private _onMeshTargetChangedObserver;
  102493. /**
  102494. * Initializes the behavior.
  102495. */
  102496. init(): void;
  102497. /**
  102498. * Attaches the behavior to its arc rotate camera.
  102499. * @param camera Defines the camera to attach the behavior to
  102500. */
  102501. attach(camera: ArcRotateCamera): void;
  102502. /**
  102503. * Detaches the behavior from its current arc rotate camera.
  102504. */
  102505. detach(): void;
  102506. private _radiusIsAnimating;
  102507. private _radiusBounceTransition;
  102508. private _animatables;
  102509. private _cachedWheelPrecision;
  102510. /**
  102511. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102512. * @param radiusLimit The limit to check against.
  102513. * @return Bool to indicate if at limit.
  102514. */
  102515. private _isRadiusAtLimit;
  102516. /**
  102517. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102518. * @param radiusDelta The delta by which to animate to. Can be negative.
  102519. */
  102520. private _applyBoundRadiusAnimation;
  102521. /**
  102522. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102523. */
  102524. protected _clearAnimationLocks(): void;
  102525. /**
  102526. * Stops and removes all animations that have been applied to the camera
  102527. */
  102528. stopAllAnimations(): void;
  102529. }
  102530. }
  102531. declare module BABYLON {
  102532. /**
  102533. * 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.
  102534. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102535. */
  102536. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102537. /**
  102538. * Gets the name of the behavior.
  102539. */
  102540. readonly name: string;
  102541. private _mode;
  102542. private _radiusScale;
  102543. private _positionScale;
  102544. private _defaultElevation;
  102545. private _elevationReturnTime;
  102546. private _elevationReturnWaitTime;
  102547. private _zoomStopsAnimation;
  102548. private _framingTime;
  102549. /**
  102550. * The easing function used by animations
  102551. */
  102552. static EasingFunction: ExponentialEase;
  102553. /**
  102554. * The easing mode used by animations
  102555. */
  102556. static EasingMode: number;
  102557. /**
  102558. * Sets the current mode used by the behavior
  102559. */
  102560. /**
  102561. * Gets current mode used by the behavior.
  102562. */
  102563. mode: number;
  102564. /**
  102565. * Sets the scale applied to the radius (1 by default)
  102566. */
  102567. /**
  102568. * Gets the scale applied to the radius
  102569. */
  102570. radiusScale: number;
  102571. /**
  102572. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102573. */
  102574. /**
  102575. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102576. */
  102577. positionScale: number;
  102578. /**
  102579. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102580. * behaviour is triggered, in radians.
  102581. */
  102582. /**
  102583. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102584. * behaviour is triggered, in radians.
  102585. */
  102586. defaultElevation: number;
  102587. /**
  102588. * Sets the time (in milliseconds) taken to return to the default beta position.
  102589. * Negative value indicates camera should not return to default.
  102590. */
  102591. /**
  102592. * Gets the time (in milliseconds) taken to return to the default beta position.
  102593. * Negative value indicates camera should not return to default.
  102594. */
  102595. elevationReturnTime: number;
  102596. /**
  102597. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102598. */
  102599. /**
  102600. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102601. */
  102602. elevationReturnWaitTime: number;
  102603. /**
  102604. * Sets the flag that indicates if user zooming should stop animation.
  102605. */
  102606. /**
  102607. * Gets the flag that indicates if user zooming should stop animation.
  102608. */
  102609. zoomStopsAnimation: boolean;
  102610. /**
  102611. * Sets the transition time when framing the mesh, in milliseconds
  102612. */
  102613. /**
  102614. * Gets the transition time when framing the mesh, in milliseconds
  102615. */
  102616. framingTime: number;
  102617. /**
  102618. * Define if the behavior should automatically change the configured
  102619. * camera limits and sensibilities.
  102620. */
  102621. autoCorrectCameraLimitsAndSensibility: boolean;
  102622. private _onPrePointerObservableObserver;
  102623. private _onAfterCheckInputsObserver;
  102624. private _onMeshTargetChangedObserver;
  102625. private _attachedCamera;
  102626. private _isPointerDown;
  102627. private _lastInteractionTime;
  102628. /**
  102629. * Initializes the behavior.
  102630. */
  102631. init(): void;
  102632. /**
  102633. * Attaches the behavior to its arc rotate camera.
  102634. * @param camera Defines the camera to attach the behavior to
  102635. */
  102636. attach(camera: ArcRotateCamera): void;
  102637. /**
  102638. * Detaches the behavior from its current arc rotate camera.
  102639. */
  102640. detach(): void;
  102641. private _animatables;
  102642. private _betaIsAnimating;
  102643. private _betaTransition;
  102644. private _radiusTransition;
  102645. private _vectorTransition;
  102646. /**
  102647. * Targets the given mesh and updates zoom level accordingly.
  102648. * @param mesh The mesh to target.
  102649. * @param radius Optional. If a cached radius position already exists, overrides default.
  102650. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102651. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102652. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102653. */
  102654. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102655. /**
  102656. * Targets the given mesh with its children and updates zoom level accordingly.
  102657. * @param mesh The mesh to target.
  102658. * @param radius Optional. If a cached radius position already exists, overrides default.
  102659. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102660. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102661. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102662. */
  102663. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102664. /**
  102665. * Targets the given meshes with their children and updates zoom level accordingly.
  102666. * @param meshes The mesh to target.
  102667. * @param radius Optional. If a cached radius position already exists, overrides default.
  102668. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102669. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102670. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102671. */
  102672. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102673. /**
  102674. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102675. * @param minimumWorld Determines the smaller position of the bounding box extend
  102676. * @param maximumWorld Determines the bigger position of the bounding box extend
  102677. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102678. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102679. */
  102680. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102681. /**
  102682. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102683. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102684. * frustum width.
  102685. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102686. * to fully enclose the mesh in the viewing frustum.
  102687. */
  102688. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102689. /**
  102690. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102691. * is automatically returned to its default position (expected to be above ground plane).
  102692. */
  102693. private _maintainCameraAboveGround;
  102694. /**
  102695. * Returns the frustum slope based on the canvas ratio and camera FOV
  102696. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102697. */
  102698. private _getFrustumSlope;
  102699. /**
  102700. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102701. */
  102702. private _clearAnimationLocks;
  102703. /**
  102704. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102705. */
  102706. private _applyUserInteraction;
  102707. /**
  102708. * Stops and removes all animations that have been applied to the camera
  102709. */
  102710. stopAllAnimations(): void;
  102711. /**
  102712. * Gets a value indicating if the user is moving the camera
  102713. */
  102714. readonly isUserIsMoving: boolean;
  102715. /**
  102716. * The camera can move all the way towards the mesh.
  102717. */
  102718. static IgnoreBoundsSizeMode: number;
  102719. /**
  102720. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102721. */
  102722. static FitFrustumSidesMode: number;
  102723. }
  102724. }
  102725. declare module BABYLON {
  102726. /**
  102727. * Base class for Camera Pointer Inputs.
  102728. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102729. * for example usage.
  102730. */
  102731. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102732. /**
  102733. * Defines the camera the input is attached to.
  102734. */
  102735. abstract camera: Camera;
  102736. /**
  102737. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102738. */
  102739. protected _altKey: boolean;
  102740. protected _ctrlKey: boolean;
  102741. protected _metaKey: boolean;
  102742. protected _shiftKey: boolean;
  102743. /**
  102744. * Which mouse buttons were pressed at time of last mouse event.
  102745. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102746. */
  102747. protected _buttonsPressed: number;
  102748. /**
  102749. * Defines the buttons associated with the input to handle camera move.
  102750. */
  102751. buttons: number[];
  102752. /**
  102753. * Attach the input controls to a specific dom element to get the input from.
  102754. * @param element Defines the element the controls should be listened from
  102755. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102756. */
  102757. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102758. /**
  102759. * Detach the current controls from the specified dom element.
  102760. * @param element Defines the element to stop listening the inputs from
  102761. */
  102762. detachControl(element: Nullable<HTMLElement>): void;
  102763. /**
  102764. * Gets the class name of the current input.
  102765. * @returns the class name
  102766. */
  102767. getClassName(): string;
  102768. /**
  102769. * Get the friendly name associated with the input class.
  102770. * @returns the input friendly name
  102771. */
  102772. getSimpleName(): string;
  102773. /**
  102774. * Called on pointer POINTERDOUBLETAP event.
  102775. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102776. */
  102777. protected onDoubleTap(type: string): void;
  102778. /**
  102779. * Called on pointer POINTERMOVE event if only a single touch is active.
  102780. * Override this method to provide functionality.
  102781. */
  102782. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102783. /**
  102784. * Called on pointer POINTERMOVE event if multiple touches are active.
  102785. * Override this method to provide functionality.
  102786. */
  102787. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102788. /**
  102789. * Called on JS contextmenu event.
  102790. * Override this method to provide functionality.
  102791. */
  102792. protected onContextMenu(evt: PointerEvent): void;
  102793. /**
  102794. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102795. * press.
  102796. * Override this method to provide functionality.
  102797. */
  102798. protected onButtonDown(evt: PointerEvent): void;
  102799. /**
  102800. * Called each time a new POINTERUP event occurs. Ie, for each button
  102801. * release.
  102802. * Override this method to provide functionality.
  102803. */
  102804. protected onButtonUp(evt: PointerEvent): void;
  102805. /**
  102806. * Called when window becomes inactive.
  102807. * Override this method to provide functionality.
  102808. */
  102809. protected onLostFocus(): void;
  102810. private _pointerInput;
  102811. private _observer;
  102812. private _onLostFocus;
  102813. private pointA;
  102814. private pointB;
  102815. }
  102816. }
  102817. declare module BABYLON {
  102818. /**
  102819. * Manage the pointers inputs to control an arc rotate camera.
  102820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102821. */
  102822. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102823. /**
  102824. * Defines the camera the input is attached to.
  102825. */
  102826. camera: ArcRotateCamera;
  102827. /**
  102828. * Gets the class name of the current input.
  102829. * @returns the class name
  102830. */
  102831. getClassName(): string;
  102832. /**
  102833. * Defines the buttons associated with the input to handle camera move.
  102834. */
  102835. buttons: number[];
  102836. /**
  102837. * Defines the pointer angular sensibility along the X axis or how fast is
  102838. * the camera rotating.
  102839. */
  102840. angularSensibilityX: number;
  102841. /**
  102842. * Defines the pointer angular sensibility along the Y axis or how fast is
  102843. * the camera rotating.
  102844. */
  102845. angularSensibilityY: number;
  102846. /**
  102847. * Defines the pointer pinch precision or how fast is the camera zooming.
  102848. */
  102849. pinchPrecision: number;
  102850. /**
  102851. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102852. * from 0.
  102853. * It defines the percentage of current camera.radius to use as delta when
  102854. * pinch zoom is used.
  102855. */
  102856. pinchDeltaPercentage: number;
  102857. /**
  102858. * Defines the pointer panning sensibility or how fast is the camera moving.
  102859. */
  102860. panningSensibility: number;
  102861. /**
  102862. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102863. */
  102864. multiTouchPanning: boolean;
  102865. /**
  102866. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102867. * zoom (pinch) through multitouch.
  102868. */
  102869. multiTouchPanAndZoom: boolean;
  102870. /**
  102871. * Revers pinch action direction.
  102872. */
  102873. pinchInwards: boolean;
  102874. private _isPanClick;
  102875. private _twoFingerActivityCount;
  102876. private _isPinching;
  102877. /**
  102878. * Called on pointer POINTERMOVE event if only a single touch is active.
  102879. */
  102880. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102881. /**
  102882. * Called on pointer POINTERDOUBLETAP event.
  102883. */
  102884. protected onDoubleTap(type: string): void;
  102885. /**
  102886. * Called on pointer POINTERMOVE event if multiple touches are active.
  102887. */
  102888. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102889. /**
  102890. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102891. * press.
  102892. */
  102893. protected onButtonDown(evt: PointerEvent): void;
  102894. /**
  102895. * Called each time a new POINTERUP event occurs. Ie, for each button
  102896. * release.
  102897. */
  102898. protected onButtonUp(evt: PointerEvent): void;
  102899. /**
  102900. * Called when window becomes inactive.
  102901. */
  102902. protected onLostFocus(): void;
  102903. }
  102904. }
  102905. declare module BABYLON {
  102906. /**
  102907. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102909. */
  102910. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102911. /**
  102912. * Defines the camera the input is attached to.
  102913. */
  102914. camera: ArcRotateCamera;
  102915. /**
  102916. * Defines the list of key codes associated with the up action (increase alpha)
  102917. */
  102918. keysUp: number[];
  102919. /**
  102920. * Defines the list of key codes associated with the down action (decrease alpha)
  102921. */
  102922. keysDown: number[];
  102923. /**
  102924. * Defines the list of key codes associated with the left action (increase beta)
  102925. */
  102926. keysLeft: number[];
  102927. /**
  102928. * Defines the list of key codes associated with the right action (decrease beta)
  102929. */
  102930. keysRight: number[];
  102931. /**
  102932. * Defines the list of key codes associated with the reset action.
  102933. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102934. */
  102935. keysReset: number[];
  102936. /**
  102937. * Defines the panning sensibility of the inputs.
  102938. * (How fast is the camera paning)
  102939. */
  102940. panningSensibility: number;
  102941. /**
  102942. * Defines the zooming sensibility of the inputs.
  102943. * (How fast is the camera zooming)
  102944. */
  102945. zoomingSensibility: number;
  102946. /**
  102947. * Defines wether maintaining the alt key down switch the movement mode from
  102948. * orientation to zoom.
  102949. */
  102950. useAltToZoom: boolean;
  102951. /**
  102952. * Rotation speed of the camera
  102953. */
  102954. angularSpeed: number;
  102955. private _keys;
  102956. private _ctrlPressed;
  102957. private _altPressed;
  102958. private _onCanvasBlurObserver;
  102959. private _onKeyboardObserver;
  102960. private _engine;
  102961. private _scene;
  102962. /**
  102963. * Attach the input controls to a specific dom element to get the input from.
  102964. * @param element Defines the element the controls should be listened from
  102965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102966. */
  102967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102968. /**
  102969. * Detach the current controls from the specified dom element.
  102970. * @param element Defines the element to stop listening the inputs from
  102971. */
  102972. detachControl(element: Nullable<HTMLElement>): void;
  102973. /**
  102974. * Update the current camera state depending on the inputs that have been used this frame.
  102975. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  102976. */
  102977. checkInputs(): void;
  102978. /**
  102979. * Gets the class name of the current intput.
  102980. * @returns the class name
  102981. */
  102982. getClassName(): string;
  102983. /**
  102984. * Get the friendly name associated with the input class.
  102985. * @returns the input friendly name
  102986. */
  102987. getSimpleName(): string;
  102988. }
  102989. }
  102990. declare module BABYLON {
  102991. /**
  102992. * Manage the mouse wheel inputs to control an arc rotate camera.
  102993. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102994. */
  102995. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  102996. /**
  102997. * Defines the camera the input is attached to.
  102998. */
  102999. camera: ArcRotateCamera;
  103000. /**
  103001. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103002. */
  103003. wheelPrecision: number;
  103004. /**
  103005. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103006. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103007. */
  103008. wheelDeltaPercentage: number;
  103009. private _wheel;
  103010. private _observer;
  103011. private computeDeltaFromMouseWheelLegacyEvent;
  103012. /**
  103013. * Attach the input controls to a specific dom element to get the input from.
  103014. * @param element Defines the element the controls should be listened from
  103015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103016. */
  103017. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103018. /**
  103019. * Detach the current controls from the specified dom element.
  103020. * @param element Defines the element to stop listening the inputs from
  103021. */
  103022. detachControl(element: Nullable<HTMLElement>): void;
  103023. /**
  103024. * Gets the class name of the current intput.
  103025. * @returns the class name
  103026. */
  103027. getClassName(): string;
  103028. /**
  103029. * Get the friendly name associated with the input class.
  103030. * @returns the input friendly name
  103031. */
  103032. getSimpleName(): string;
  103033. }
  103034. }
  103035. declare module BABYLON {
  103036. /**
  103037. * Default Inputs manager for the ArcRotateCamera.
  103038. * It groups all the default supported inputs for ease of use.
  103039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103040. */
  103041. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103042. /**
  103043. * Instantiates a new ArcRotateCameraInputsManager.
  103044. * @param camera Defines the camera the inputs belong to
  103045. */
  103046. constructor(camera: ArcRotateCamera);
  103047. /**
  103048. * Add mouse wheel input support to the input manager.
  103049. * @returns the current input manager
  103050. */
  103051. addMouseWheel(): ArcRotateCameraInputsManager;
  103052. /**
  103053. * Add pointers input support to the input manager.
  103054. * @returns the current input manager
  103055. */
  103056. addPointers(): ArcRotateCameraInputsManager;
  103057. /**
  103058. * Add keyboard input support to the input manager.
  103059. * @returns the current input manager
  103060. */
  103061. addKeyboard(): ArcRotateCameraInputsManager;
  103062. }
  103063. }
  103064. declare module BABYLON {
  103065. /**
  103066. * This represents an orbital type of camera.
  103067. *
  103068. * 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.
  103069. * 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.
  103070. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103071. */
  103072. export class ArcRotateCamera extends TargetCamera {
  103073. /**
  103074. * Defines the rotation angle of the camera along the longitudinal axis.
  103075. */
  103076. alpha: number;
  103077. /**
  103078. * Defines the rotation angle of the camera along the latitudinal axis.
  103079. */
  103080. beta: number;
  103081. /**
  103082. * Defines the radius of the camera from it s target point.
  103083. */
  103084. radius: number;
  103085. protected _target: Vector3;
  103086. protected _targetHost: Nullable<AbstractMesh>;
  103087. /**
  103088. * Defines the target point of the camera.
  103089. * The camera looks towards it form the radius distance.
  103090. */
  103091. target: Vector3;
  103092. /**
  103093. * Define the current local position of the camera in the scene
  103094. */
  103095. position: Vector3;
  103096. protected _upVector: Vector3;
  103097. protected _upToYMatrix: Matrix;
  103098. protected _YToUpMatrix: Matrix;
  103099. /**
  103100. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103101. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103102. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103103. */
  103104. upVector: Vector3;
  103105. /**
  103106. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103107. */
  103108. setMatUp(): void;
  103109. /**
  103110. * Current inertia value on the longitudinal axis.
  103111. * The bigger this number the longer it will take for the camera to stop.
  103112. */
  103113. inertialAlphaOffset: number;
  103114. /**
  103115. * Current inertia value on the latitudinal axis.
  103116. * The bigger this number the longer it will take for the camera to stop.
  103117. */
  103118. inertialBetaOffset: number;
  103119. /**
  103120. * Current inertia value on the radius axis.
  103121. * The bigger this number the longer it will take for the camera to stop.
  103122. */
  103123. inertialRadiusOffset: number;
  103124. /**
  103125. * Minimum allowed angle on the longitudinal axis.
  103126. * This can help limiting how the Camera is able to move in the scene.
  103127. */
  103128. lowerAlphaLimit: Nullable<number>;
  103129. /**
  103130. * Maximum allowed angle on the longitudinal axis.
  103131. * This can help limiting how the Camera is able to move in the scene.
  103132. */
  103133. upperAlphaLimit: Nullable<number>;
  103134. /**
  103135. * Minimum allowed angle on the latitudinal axis.
  103136. * This can help limiting how the Camera is able to move in the scene.
  103137. */
  103138. lowerBetaLimit: number;
  103139. /**
  103140. * Maximum allowed angle on the latitudinal axis.
  103141. * This can help limiting how the Camera is able to move in the scene.
  103142. */
  103143. upperBetaLimit: number;
  103144. /**
  103145. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103146. * This can help limiting how the Camera is able to move in the scene.
  103147. */
  103148. lowerRadiusLimit: Nullable<number>;
  103149. /**
  103150. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103151. * This can help limiting how the Camera is able to move in the scene.
  103152. */
  103153. upperRadiusLimit: Nullable<number>;
  103154. /**
  103155. * Defines the current inertia value used during panning of the camera along the X axis.
  103156. */
  103157. inertialPanningX: number;
  103158. /**
  103159. * Defines the current inertia value used during panning of the camera along the Y axis.
  103160. */
  103161. inertialPanningY: number;
  103162. /**
  103163. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103164. * Basically if your fingers moves away from more than this distance you will be considered
  103165. * in pinch mode.
  103166. */
  103167. pinchToPanMaxDistance: number;
  103168. /**
  103169. * Defines the maximum distance the camera can pan.
  103170. * This could help keeping the cammera always in your scene.
  103171. */
  103172. panningDistanceLimit: Nullable<number>;
  103173. /**
  103174. * Defines the target of the camera before paning.
  103175. */
  103176. panningOriginTarget: Vector3;
  103177. /**
  103178. * Defines the value of the inertia used during panning.
  103179. * 0 would mean stop inertia and one would mean no decelleration at all.
  103180. */
  103181. panningInertia: number;
  103182. /**
  103183. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103184. */
  103185. angularSensibilityX: number;
  103186. /**
  103187. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103188. */
  103189. angularSensibilityY: number;
  103190. /**
  103191. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103192. */
  103193. pinchPrecision: number;
  103194. /**
  103195. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103196. * It will be used instead of pinchDeltaPrecision if different from 0.
  103197. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103198. */
  103199. pinchDeltaPercentage: number;
  103200. /**
  103201. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103202. */
  103203. panningSensibility: number;
  103204. /**
  103205. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103206. */
  103207. keysUp: number[];
  103208. /**
  103209. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103210. */
  103211. keysDown: number[];
  103212. /**
  103213. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103214. */
  103215. keysLeft: number[];
  103216. /**
  103217. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103218. */
  103219. keysRight: number[];
  103220. /**
  103221. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103222. */
  103223. wheelPrecision: number;
  103224. /**
  103225. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103226. * It will be used instead of pinchDeltaPrecision if different from 0.
  103227. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103228. */
  103229. wheelDeltaPercentage: number;
  103230. /**
  103231. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103232. */
  103233. zoomOnFactor: number;
  103234. /**
  103235. * Defines a screen offset for the camera position.
  103236. */
  103237. targetScreenOffset: Vector2;
  103238. /**
  103239. * Allows the camera to be completely reversed.
  103240. * If false the camera can not arrive upside down.
  103241. */
  103242. allowUpsideDown: boolean;
  103243. /**
  103244. * Define if double tap/click is used to restore the previously saved state of the camera.
  103245. */
  103246. useInputToRestoreState: boolean;
  103247. /** @hidden */
  103248. _viewMatrix: Matrix;
  103249. /** @hidden */
  103250. _useCtrlForPanning: boolean;
  103251. /** @hidden */
  103252. _panningMouseButton: number;
  103253. /**
  103254. * Defines the input associated to the camera.
  103255. */
  103256. inputs: ArcRotateCameraInputsManager;
  103257. /** @hidden */
  103258. _reset: () => void;
  103259. /**
  103260. * Defines the allowed panning axis.
  103261. */
  103262. panningAxis: Vector3;
  103263. protected _localDirection: Vector3;
  103264. protected _transformedDirection: Vector3;
  103265. private _bouncingBehavior;
  103266. /**
  103267. * Gets the bouncing behavior of the camera if it has been enabled.
  103268. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103269. */
  103270. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103271. /**
  103272. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103273. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103274. */
  103275. useBouncingBehavior: boolean;
  103276. private _framingBehavior;
  103277. /**
  103278. * Gets the framing behavior of the camera if it has been enabled.
  103279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103280. */
  103281. readonly framingBehavior: Nullable<FramingBehavior>;
  103282. /**
  103283. * Defines if the framing behavior of the camera is enabled on the camera.
  103284. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103285. */
  103286. useFramingBehavior: boolean;
  103287. private _autoRotationBehavior;
  103288. /**
  103289. * Gets the auto rotation behavior of the camera if it has been enabled.
  103290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103291. */
  103292. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103293. /**
  103294. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103295. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103296. */
  103297. useAutoRotationBehavior: boolean;
  103298. /**
  103299. * Observable triggered when the mesh target has been changed on the camera.
  103300. */
  103301. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103302. /**
  103303. * Event raised when the camera is colliding with a mesh.
  103304. */
  103305. onCollide: (collidedMesh: AbstractMesh) => void;
  103306. /**
  103307. * Defines whether the camera should check collision with the objects oh the scene.
  103308. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103309. */
  103310. checkCollisions: boolean;
  103311. /**
  103312. * Defines the collision radius of the camera.
  103313. * This simulates a sphere around the camera.
  103314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103315. */
  103316. collisionRadius: Vector3;
  103317. protected _collider: Collider;
  103318. protected _previousPosition: Vector3;
  103319. protected _collisionVelocity: Vector3;
  103320. protected _newPosition: Vector3;
  103321. protected _previousAlpha: number;
  103322. protected _previousBeta: number;
  103323. protected _previousRadius: number;
  103324. protected _collisionTriggered: boolean;
  103325. protected _targetBoundingCenter: Nullable<Vector3>;
  103326. private _computationVector;
  103327. /**
  103328. * Instantiates a new ArcRotateCamera in a given scene
  103329. * @param name Defines the name of the camera
  103330. * @param alpha Defines the camera rotation along the logitudinal axis
  103331. * @param beta Defines the camera rotation along the latitudinal axis
  103332. * @param radius Defines the camera distance from its target
  103333. * @param target Defines the camera target
  103334. * @param scene Defines the scene the camera belongs to
  103335. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103336. */
  103337. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103338. /** @hidden */
  103339. _initCache(): void;
  103340. /** @hidden */
  103341. _updateCache(ignoreParentClass?: boolean): void;
  103342. protected _getTargetPosition(): Vector3;
  103343. private _storedAlpha;
  103344. private _storedBeta;
  103345. private _storedRadius;
  103346. private _storedTarget;
  103347. private _storedTargetScreenOffset;
  103348. /**
  103349. * Stores the current state of the camera (alpha, beta, radius and target)
  103350. * @returns the camera itself
  103351. */
  103352. storeState(): Camera;
  103353. /**
  103354. * @hidden
  103355. * Restored camera state. You must call storeState() first
  103356. */
  103357. _restoreStateValues(): boolean;
  103358. /** @hidden */
  103359. _isSynchronizedViewMatrix(): boolean;
  103360. /**
  103361. * Attached controls to the current camera.
  103362. * @param element Defines the element the controls should be listened from
  103363. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103364. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103365. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103366. */
  103367. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103368. /**
  103369. * Detach the current controls from the camera.
  103370. * The camera will stop reacting to inputs.
  103371. * @param element Defines the element to stop listening the inputs from
  103372. */
  103373. detachControl(element: HTMLElement): void;
  103374. /** @hidden */
  103375. _checkInputs(): void;
  103376. protected _checkLimits(): void;
  103377. /**
  103378. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103379. */
  103380. rebuildAnglesAndRadius(): void;
  103381. /**
  103382. * Use a position to define the current camera related information like alpha, beta and radius
  103383. * @param position Defines the position to set the camera at
  103384. */
  103385. setPosition(position: Vector3): void;
  103386. /**
  103387. * Defines the target the camera should look at.
  103388. * This will automatically adapt alpha beta and radius to fit within the new target.
  103389. * @param target Defines the new target as a Vector or a mesh
  103390. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103391. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103392. */
  103393. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103394. /** @hidden */
  103395. _getViewMatrix(): Matrix;
  103396. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103397. /**
  103398. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103399. * @param meshes Defines the mesh to zoom on
  103400. * @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)
  103401. */
  103402. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103403. /**
  103404. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103405. * The target will be changed but the radius
  103406. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103407. * @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)
  103408. */
  103409. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103410. min: Vector3;
  103411. max: Vector3;
  103412. distance: number;
  103413. }, doNotUpdateMaxZ?: boolean): void;
  103414. /**
  103415. * @override
  103416. * Override Camera.createRigCamera
  103417. */
  103418. createRigCamera(name: string, cameraIndex: number): Camera;
  103419. /**
  103420. * @hidden
  103421. * @override
  103422. * Override Camera._updateRigCameras
  103423. */
  103424. _updateRigCameras(): void;
  103425. /**
  103426. * Destroy the camera and release the current resources hold by it.
  103427. */
  103428. dispose(): void;
  103429. /**
  103430. * Gets the current object class name.
  103431. * @return the class name
  103432. */
  103433. getClassName(): string;
  103434. }
  103435. }
  103436. declare module BABYLON {
  103437. /**
  103438. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103440. */
  103441. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103442. /**
  103443. * Gets the name of the behavior.
  103444. */
  103445. readonly name: string;
  103446. private _zoomStopsAnimation;
  103447. private _idleRotationSpeed;
  103448. private _idleRotationWaitTime;
  103449. private _idleRotationSpinupTime;
  103450. /**
  103451. * Sets the flag that indicates if user zooming should stop animation.
  103452. */
  103453. /**
  103454. * Gets the flag that indicates if user zooming should stop animation.
  103455. */
  103456. zoomStopsAnimation: boolean;
  103457. /**
  103458. * Sets the default speed at which the camera rotates around the model.
  103459. */
  103460. /**
  103461. * Gets the default speed at which the camera rotates around the model.
  103462. */
  103463. idleRotationSpeed: number;
  103464. /**
  103465. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103466. */
  103467. /**
  103468. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103469. */
  103470. idleRotationWaitTime: number;
  103471. /**
  103472. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103473. */
  103474. /**
  103475. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103476. */
  103477. idleRotationSpinupTime: number;
  103478. /**
  103479. * Gets a value indicating if the camera is currently rotating because of this behavior
  103480. */
  103481. readonly rotationInProgress: boolean;
  103482. private _onPrePointerObservableObserver;
  103483. private _onAfterCheckInputsObserver;
  103484. private _attachedCamera;
  103485. private _isPointerDown;
  103486. private _lastFrameTime;
  103487. private _lastInteractionTime;
  103488. private _cameraRotationSpeed;
  103489. /**
  103490. * Initializes the behavior.
  103491. */
  103492. init(): void;
  103493. /**
  103494. * Attaches the behavior to its arc rotate camera.
  103495. * @param camera Defines the camera to attach the behavior to
  103496. */
  103497. attach(camera: ArcRotateCamera): void;
  103498. /**
  103499. * Detaches the behavior from its current arc rotate camera.
  103500. */
  103501. detach(): void;
  103502. /**
  103503. * Returns true if user is scrolling.
  103504. * @return true if user is scrolling.
  103505. */
  103506. private _userIsZooming;
  103507. private _lastFrameRadius;
  103508. private _shouldAnimationStopForInteraction;
  103509. /**
  103510. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103511. */
  103512. private _applyUserInteraction;
  103513. private _userIsMoving;
  103514. }
  103515. }
  103516. declare module BABYLON {
  103517. /**
  103518. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103519. */
  103520. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103521. private ui;
  103522. /**
  103523. * The name of the behavior
  103524. */
  103525. name: string;
  103526. /**
  103527. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103528. */
  103529. distanceAwayFromFace: number;
  103530. /**
  103531. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103532. */
  103533. distanceAwayFromBottomOfFace: number;
  103534. private _faceVectors;
  103535. private _target;
  103536. private _scene;
  103537. private _onRenderObserver;
  103538. private _tmpMatrix;
  103539. private _tmpVector;
  103540. /**
  103541. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103542. * @param ui The transform node that should be attched to the mesh
  103543. */
  103544. constructor(ui: TransformNode);
  103545. /**
  103546. * Initializes the behavior
  103547. */
  103548. init(): void;
  103549. private _closestFace;
  103550. private _zeroVector;
  103551. private _lookAtTmpMatrix;
  103552. private _lookAtToRef;
  103553. /**
  103554. * Attaches the AttachToBoxBehavior to the passed in mesh
  103555. * @param target The mesh that the specified node will be attached to
  103556. */
  103557. attach(target: Mesh): void;
  103558. /**
  103559. * Detaches the behavior from the mesh
  103560. */
  103561. detach(): void;
  103562. }
  103563. }
  103564. declare module BABYLON {
  103565. /**
  103566. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103567. */
  103568. export class FadeInOutBehavior implements Behavior<Mesh> {
  103569. /**
  103570. * Time in milliseconds to delay before fading in (Default: 0)
  103571. */
  103572. delay: number;
  103573. /**
  103574. * Time in milliseconds for the mesh to fade in (Default: 300)
  103575. */
  103576. fadeInTime: number;
  103577. private _millisecondsPerFrame;
  103578. private _hovered;
  103579. private _hoverValue;
  103580. private _ownerNode;
  103581. /**
  103582. * Instatiates the FadeInOutBehavior
  103583. */
  103584. constructor();
  103585. /**
  103586. * The name of the behavior
  103587. */
  103588. readonly name: string;
  103589. /**
  103590. * Initializes the behavior
  103591. */
  103592. init(): void;
  103593. /**
  103594. * Attaches the fade behavior on the passed in mesh
  103595. * @param ownerNode The mesh that will be faded in/out once attached
  103596. */
  103597. attach(ownerNode: Mesh): void;
  103598. /**
  103599. * Detaches the behavior from the mesh
  103600. */
  103601. detach(): void;
  103602. /**
  103603. * Triggers the mesh to begin fading in or out
  103604. * @param value if the object should fade in or out (true to fade in)
  103605. */
  103606. fadeIn(value: boolean): void;
  103607. private _update;
  103608. private _setAllVisibility;
  103609. }
  103610. }
  103611. declare module BABYLON {
  103612. /**
  103613. * Class containing a set of static utilities functions for managing Pivots
  103614. * @hidden
  103615. */
  103616. export class PivotTools {
  103617. private static _PivotCached;
  103618. private static _OldPivotPoint;
  103619. private static _PivotTranslation;
  103620. private static _PivotTmpVector;
  103621. /** @hidden */
  103622. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103623. /** @hidden */
  103624. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103625. }
  103626. }
  103627. declare module BABYLON {
  103628. /**
  103629. * Class containing static functions to help procedurally build meshes
  103630. */
  103631. export class PlaneBuilder {
  103632. /**
  103633. * Creates a plane mesh
  103634. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103635. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103636. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103640. * @param name defines the name of the mesh
  103641. * @param options defines the options used to create the mesh
  103642. * @param scene defines the hosting scene
  103643. * @returns the plane mesh
  103644. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103645. */
  103646. static CreatePlane(name: string, options: {
  103647. size?: number;
  103648. width?: number;
  103649. height?: number;
  103650. sideOrientation?: number;
  103651. frontUVs?: Vector4;
  103652. backUVs?: Vector4;
  103653. updatable?: boolean;
  103654. sourcePlane?: Plane;
  103655. }, scene?: Nullable<Scene>): Mesh;
  103656. }
  103657. }
  103658. declare module BABYLON {
  103659. /**
  103660. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103661. */
  103662. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103663. private static _AnyMouseID;
  103664. /**
  103665. * Abstract mesh the behavior is set on
  103666. */
  103667. attachedNode: AbstractMesh;
  103668. private _dragPlane;
  103669. private _scene;
  103670. private _pointerObserver;
  103671. private _beforeRenderObserver;
  103672. private static _planeScene;
  103673. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103674. /**
  103675. * 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)
  103676. */
  103677. maxDragAngle: number;
  103678. /**
  103679. * @hidden
  103680. */
  103681. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103682. /**
  103683. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103684. */
  103685. currentDraggingPointerID: number;
  103686. /**
  103687. * The last position where the pointer hit the drag plane in world space
  103688. */
  103689. lastDragPosition: Vector3;
  103690. /**
  103691. * If the behavior is currently in a dragging state
  103692. */
  103693. dragging: boolean;
  103694. /**
  103695. * 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)
  103696. */
  103697. dragDeltaRatio: number;
  103698. /**
  103699. * If the drag plane orientation should be updated during the dragging (Default: true)
  103700. */
  103701. updateDragPlane: boolean;
  103702. private _debugMode;
  103703. private _moving;
  103704. /**
  103705. * Fires each time the attached mesh is dragged with the pointer
  103706. * * delta between last drag position and current drag position in world space
  103707. * * dragDistance along the drag axis
  103708. * * dragPlaneNormal normal of the current drag plane used during the drag
  103709. * * dragPlanePoint in world space where the drag intersects the drag plane
  103710. */
  103711. onDragObservable: Observable<{
  103712. delta: Vector3;
  103713. dragPlanePoint: Vector3;
  103714. dragPlaneNormal: Vector3;
  103715. dragDistance: number;
  103716. pointerId: number;
  103717. }>;
  103718. /**
  103719. * Fires each time a drag begins (eg. mouse down on mesh)
  103720. */
  103721. onDragStartObservable: Observable<{
  103722. dragPlanePoint: Vector3;
  103723. pointerId: number;
  103724. }>;
  103725. /**
  103726. * Fires each time a drag ends (eg. mouse release after drag)
  103727. */
  103728. onDragEndObservable: Observable<{
  103729. dragPlanePoint: Vector3;
  103730. pointerId: number;
  103731. }>;
  103732. /**
  103733. * If the attached mesh should be moved when dragged
  103734. */
  103735. moveAttached: boolean;
  103736. /**
  103737. * If the drag behavior will react to drag events (Default: true)
  103738. */
  103739. enabled: boolean;
  103740. /**
  103741. * If pointer events should start and release the drag (Default: true)
  103742. */
  103743. startAndReleaseDragOnPointerEvents: boolean;
  103744. /**
  103745. * If camera controls should be detached during the drag
  103746. */
  103747. detachCameraControls: boolean;
  103748. /**
  103749. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103750. */
  103751. useObjectOrienationForDragging: boolean;
  103752. private _options;
  103753. /**
  103754. * Creates a pointer drag behavior that can be attached to a mesh
  103755. * @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)
  103756. */
  103757. constructor(options?: {
  103758. dragAxis?: Vector3;
  103759. dragPlaneNormal?: Vector3;
  103760. });
  103761. /**
  103762. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103763. */
  103764. validateDrag: (targetPosition: Vector3) => boolean;
  103765. /**
  103766. * The name of the behavior
  103767. */
  103768. readonly name: string;
  103769. /**
  103770. * Initializes the behavior
  103771. */
  103772. init(): void;
  103773. private _tmpVector;
  103774. private _alternatePickedPoint;
  103775. private _worldDragAxis;
  103776. private _targetPosition;
  103777. private _attachedElement;
  103778. /**
  103779. * Attaches the drag behavior the passed in mesh
  103780. * @param ownerNode The mesh that will be dragged around once attached
  103781. * @param predicate Predicate to use for pick filtering
  103782. */
  103783. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103784. /**
  103785. * Force relase the drag action by code.
  103786. */
  103787. releaseDrag(): void;
  103788. private _startDragRay;
  103789. private _lastPointerRay;
  103790. /**
  103791. * Simulates the start of a pointer drag event on the behavior
  103792. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103793. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103794. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103795. */
  103796. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103797. private _startDrag;
  103798. private _dragDelta;
  103799. private _moveDrag;
  103800. private _pickWithRayOnDragPlane;
  103801. private _pointA;
  103802. private _pointB;
  103803. private _pointC;
  103804. private _lineA;
  103805. private _lineB;
  103806. private _localAxis;
  103807. private _lookAt;
  103808. private _updateDragPlanePosition;
  103809. /**
  103810. * Detaches the behavior from the mesh
  103811. */
  103812. detach(): void;
  103813. }
  103814. }
  103815. declare module BABYLON {
  103816. /**
  103817. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103818. */
  103819. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103820. private _dragBehaviorA;
  103821. private _dragBehaviorB;
  103822. private _startDistance;
  103823. private _initialScale;
  103824. private _targetScale;
  103825. private _ownerNode;
  103826. private _sceneRenderObserver;
  103827. /**
  103828. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103829. */
  103830. constructor();
  103831. /**
  103832. * The name of the behavior
  103833. */
  103834. readonly name: string;
  103835. /**
  103836. * Initializes the behavior
  103837. */
  103838. init(): void;
  103839. private _getCurrentDistance;
  103840. /**
  103841. * Attaches the scale behavior the passed in mesh
  103842. * @param ownerNode The mesh that will be scaled around once attached
  103843. */
  103844. attach(ownerNode: Mesh): void;
  103845. /**
  103846. * Detaches the behavior from the mesh
  103847. */
  103848. detach(): void;
  103849. }
  103850. }
  103851. declare module BABYLON {
  103852. /**
  103853. * 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
  103854. */
  103855. export class SixDofDragBehavior implements Behavior<Mesh> {
  103856. private static _virtualScene;
  103857. private _ownerNode;
  103858. private _sceneRenderObserver;
  103859. private _scene;
  103860. private _targetPosition;
  103861. private _virtualOriginMesh;
  103862. private _virtualDragMesh;
  103863. private _pointerObserver;
  103864. private _moving;
  103865. private _startingOrientation;
  103866. /**
  103867. * 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)
  103868. */
  103869. private zDragFactor;
  103870. /**
  103871. * If the object should rotate to face the drag origin
  103872. */
  103873. rotateDraggedObject: boolean;
  103874. /**
  103875. * If the behavior is currently in a dragging state
  103876. */
  103877. dragging: boolean;
  103878. /**
  103879. * 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)
  103880. */
  103881. dragDeltaRatio: number;
  103882. /**
  103883. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103884. */
  103885. currentDraggingPointerID: number;
  103886. /**
  103887. * If camera controls should be detached during the drag
  103888. */
  103889. detachCameraControls: boolean;
  103890. /**
  103891. * Fires each time a drag starts
  103892. */
  103893. onDragStartObservable: Observable<{}>;
  103894. /**
  103895. * Fires each time a drag ends (eg. mouse release after drag)
  103896. */
  103897. onDragEndObservable: Observable<{}>;
  103898. /**
  103899. * 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
  103900. */
  103901. constructor();
  103902. /**
  103903. * The name of the behavior
  103904. */
  103905. readonly name: string;
  103906. /**
  103907. * Initializes the behavior
  103908. */
  103909. init(): void;
  103910. /**
  103911. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103912. */
  103913. private readonly _pointerCamera;
  103914. /**
  103915. * Attaches the scale behavior the passed in mesh
  103916. * @param ownerNode The mesh that will be scaled around once attached
  103917. */
  103918. attach(ownerNode: Mesh): void;
  103919. /**
  103920. * Detaches the behavior from the mesh
  103921. */
  103922. detach(): void;
  103923. }
  103924. }
  103925. declare module BABYLON {
  103926. /**
  103927. * Class used to apply inverse kinematics to bones
  103928. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103929. */
  103930. export class BoneIKController {
  103931. private static _tmpVecs;
  103932. private static _tmpQuat;
  103933. private static _tmpMats;
  103934. /**
  103935. * Gets or sets the target mesh
  103936. */
  103937. targetMesh: AbstractMesh;
  103938. /** Gets or sets the mesh used as pole */
  103939. poleTargetMesh: AbstractMesh;
  103940. /**
  103941. * Gets or sets the bone used as pole
  103942. */
  103943. poleTargetBone: Nullable<Bone>;
  103944. /**
  103945. * Gets or sets the target position
  103946. */
  103947. targetPosition: Vector3;
  103948. /**
  103949. * Gets or sets the pole target position
  103950. */
  103951. poleTargetPosition: Vector3;
  103952. /**
  103953. * Gets or sets the pole target local offset
  103954. */
  103955. poleTargetLocalOffset: Vector3;
  103956. /**
  103957. * Gets or sets the pole angle
  103958. */
  103959. poleAngle: number;
  103960. /**
  103961. * Gets or sets the mesh associated with the controller
  103962. */
  103963. mesh: AbstractMesh;
  103964. /**
  103965. * 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)
  103966. */
  103967. slerpAmount: number;
  103968. private _bone1Quat;
  103969. private _bone1Mat;
  103970. private _bone2Ang;
  103971. private _bone1;
  103972. private _bone2;
  103973. private _bone1Length;
  103974. private _bone2Length;
  103975. private _maxAngle;
  103976. private _maxReach;
  103977. private _rightHandedSystem;
  103978. private _bendAxis;
  103979. private _slerping;
  103980. private _adjustRoll;
  103981. /**
  103982. * Gets or sets maximum allowed angle
  103983. */
  103984. maxAngle: number;
  103985. /**
  103986. * Creates a new BoneIKController
  103987. * @param mesh defines the mesh to control
  103988. * @param bone defines the bone to control
  103989. * @param options defines options to set up the controller
  103990. */
  103991. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  103992. targetMesh?: AbstractMesh;
  103993. poleTargetMesh?: AbstractMesh;
  103994. poleTargetBone?: Bone;
  103995. poleTargetLocalOffset?: Vector3;
  103996. poleAngle?: number;
  103997. bendAxis?: Vector3;
  103998. maxAngle?: number;
  103999. slerpAmount?: number;
  104000. });
  104001. private _setMaxAngle;
  104002. /**
  104003. * Force the controller to update the bones
  104004. */
  104005. update(): void;
  104006. }
  104007. }
  104008. declare module BABYLON {
  104009. /**
  104010. * Class used to make a bone look toward a point in space
  104011. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104012. */
  104013. export class BoneLookController {
  104014. private static _tmpVecs;
  104015. private static _tmpQuat;
  104016. private static _tmpMats;
  104017. /**
  104018. * The target Vector3 that the bone will look at
  104019. */
  104020. target: Vector3;
  104021. /**
  104022. * The mesh that the bone is attached to
  104023. */
  104024. mesh: AbstractMesh;
  104025. /**
  104026. * The bone that will be looking to the target
  104027. */
  104028. bone: Bone;
  104029. /**
  104030. * The up axis of the coordinate system that is used when the bone is rotated
  104031. */
  104032. upAxis: Vector3;
  104033. /**
  104034. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104035. */
  104036. upAxisSpace: Space;
  104037. /**
  104038. * Used to make an adjustment to the yaw of the bone
  104039. */
  104040. adjustYaw: number;
  104041. /**
  104042. * Used to make an adjustment to the pitch of the bone
  104043. */
  104044. adjustPitch: number;
  104045. /**
  104046. * Used to make an adjustment to the roll of the bone
  104047. */
  104048. adjustRoll: number;
  104049. /**
  104050. * 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)
  104051. */
  104052. slerpAmount: number;
  104053. private _minYaw;
  104054. private _maxYaw;
  104055. private _minPitch;
  104056. private _maxPitch;
  104057. private _minYawSin;
  104058. private _minYawCos;
  104059. private _maxYawSin;
  104060. private _maxYawCos;
  104061. private _midYawConstraint;
  104062. private _minPitchTan;
  104063. private _maxPitchTan;
  104064. private _boneQuat;
  104065. private _slerping;
  104066. private _transformYawPitch;
  104067. private _transformYawPitchInv;
  104068. private _firstFrameSkipped;
  104069. private _yawRange;
  104070. private _fowardAxis;
  104071. /**
  104072. * Gets or sets the minimum yaw angle that the bone can look to
  104073. */
  104074. minYaw: number;
  104075. /**
  104076. * Gets or sets the maximum yaw angle that the bone can look to
  104077. */
  104078. maxYaw: number;
  104079. /**
  104080. * Gets or sets the minimum pitch angle that the bone can look to
  104081. */
  104082. minPitch: number;
  104083. /**
  104084. * Gets or sets the maximum pitch angle that the bone can look to
  104085. */
  104086. maxPitch: number;
  104087. /**
  104088. * Create a BoneLookController
  104089. * @param mesh the mesh that the bone belongs to
  104090. * @param bone the bone that will be looking to the target
  104091. * @param target the target Vector3 to look at
  104092. * @param options optional settings:
  104093. * * maxYaw: the maximum angle the bone will yaw to
  104094. * * minYaw: the minimum angle the bone will yaw to
  104095. * * maxPitch: the maximum angle the bone will pitch to
  104096. * * minPitch: the minimum angle the bone will yaw to
  104097. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104098. * * upAxis: the up axis of the coordinate system
  104099. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104100. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104101. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104102. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104103. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104104. * * adjustRoll: used to make an adjustment to the roll of the bone
  104105. **/
  104106. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104107. maxYaw?: number;
  104108. minYaw?: number;
  104109. maxPitch?: number;
  104110. minPitch?: number;
  104111. slerpAmount?: number;
  104112. upAxis?: Vector3;
  104113. upAxisSpace?: Space;
  104114. yawAxis?: Vector3;
  104115. pitchAxis?: Vector3;
  104116. adjustYaw?: number;
  104117. adjustPitch?: number;
  104118. adjustRoll?: number;
  104119. });
  104120. /**
  104121. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104122. */
  104123. update(): void;
  104124. private _getAngleDiff;
  104125. private _getAngleBetween;
  104126. private _isAngleBetween;
  104127. }
  104128. }
  104129. declare module BABYLON {
  104130. /**
  104131. * Manage the gamepad inputs to control an arc rotate camera.
  104132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104133. */
  104134. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104135. /**
  104136. * Defines the camera the input is attached to.
  104137. */
  104138. camera: ArcRotateCamera;
  104139. /**
  104140. * Defines the gamepad the input is gathering event from.
  104141. */
  104142. gamepad: Nullable<Gamepad>;
  104143. /**
  104144. * Defines the gamepad rotation sensiblity.
  104145. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104146. */
  104147. gamepadRotationSensibility: number;
  104148. /**
  104149. * Defines the gamepad move sensiblity.
  104150. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104151. */
  104152. gamepadMoveSensibility: number;
  104153. private _yAxisScale;
  104154. /**
  104155. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104156. */
  104157. invertYAxis: boolean;
  104158. private _onGamepadConnectedObserver;
  104159. private _onGamepadDisconnectedObserver;
  104160. /**
  104161. * Attach the input controls to a specific dom element to get the input from.
  104162. * @param element Defines the element the controls should be listened from
  104163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104164. */
  104165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104166. /**
  104167. * Detach the current controls from the specified dom element.
  104168. * @param element Defines the element to stop listening the inputs from
  104169. */
  104170. detachControl(element: Nullable<HTMLElement>): void;
  104171. /**
  104172. * Update the current camera state depending on the inputs that have been used this frame.
  104173. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104174. */
  104175. checkInputs(): void;
  104176. /**
  104177. * Gets the class name of the current intput.
  104178. * @returns the class name
  104179. */
  104180. getClassName(): string;
  104181. /**
  104182. * Get the friendly name associated with the input class.
  104183. * @returns the input friendly name
  104184. */
  104185. getSimpleName(): string;
  104186. }
  104187. }
  104188. declare module BABYLON {
  104189. interface ArcRotateCameraInputsManager {
  104190. /**
  104191. * Add orientation input support to the input manager.
  104192. * @returns the current input manager
  104193. */
  104194. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104195. }
  104196. /**
  104197. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104198. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104199. */
  104200. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104201. /**
  104202. * Defines the camera the input is attached to.
  104203. */
  104204. camera: ArcRotateCamera;
  104205. /**
  104206. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104207. */
  104208. alphaCorrection: number;
  104209. /**
  104210. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104211. */
  104212. gammaCorrection: number;
  104213. private _alpha;
  104214. private _gamma;
  104215. private _dirty;
  104216. private _deviceOrientationHandler;
  104217. /**
  104218. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104219. */
  104220. constructor();
  104221. /**
  104222. * Attach the input controls to a specific dom element to get the input from.
  104223. * @param element Defines the element the controls should be listened from
  104224. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104225. */
  104226. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104227. /** @hidden */
  104228. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104229. /**
  104230. * Update the current camera state depending on the inputs that have been used this frame.
  104231. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104232. */
  104233. checkInputs(): void;
  104234. /**
  104235. * Detach the current controls from the specified dom element.
  104236. * @param element Defines the element to stop listening the inputs from
  104237. */
  104238. detachControl(element: Nullable<HTMLElement>): void;
  104239. /**
  104240. * Gets the class name of the current intput.
  104241. * @returns the class name
  104242. */
  104243. getClassName(): string;
  104244. /**
  104245. * Get the friendly name associated with the input class.
  104246. * @returns the input friendly name
  104247. */
  104248. getSimpleName(): string;
  104249. }
  104250. }
  104251. declare module BABYLON {
  104252. /**
  104253. * Listen to mouse events to control the camera.
  104254. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104255. */
  104256. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104257. /**
  104258. * Defines the camera the input is attached to.
  104259. */
  104260. camera: FlyCamera;
  104261. /**
  104262. * Defines if touch is enabled. (Default is true.)
  104263. */
  104264. touchEnabled: boolean;
  104265. /**
  104266. * Defines the buttons associated with the input to handle camera rotation.
  104267. */
  104268. buttons: number[];
  104269. /**
  104270. * Assign buttons for Yaw control.
  104271. */
  104272. buttonsYaw: number[];
  104273. /**
  104274. * Assign buttons for Pitch control.
  104275. */
  104276. buttonsPitch: number[];
  104277. /**
  104278. * Assign buttons for Roll control.
  104279. */
  104280. buttonsRoll: number[];
  104281. /**
  104282. * Detect if any button is being pressed while mouse is moved.
  104283. * -1 = Mouse locked.
  104284. * 0 = Left button.
  104285. * 1 = Middle Button.
  104286. * 2 = Right Button.
  104287. */
  104288. activeButton: number;
  104289. /**
  104290. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104291. * Higher values reduce its sensitivity.
  104292. */
  104293. angularSensibility: number;
  104294. private _mousemoveCallback;
  104295. private _observer;
  104296. private _rollObserver;
  104297. private previousPosition;
  104298. private noPreventDefault;
  104299. private element;
  104300. /**
  104301. * Listen to mouse events to control the camera.
  104302. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104303. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104304. */
  104305. constructor(touchEnabled?: boolean);
  104306. /**
  104307. * Attach the mouse control to the HTML DOM element.
  104308. * @param element Defines the element that listens to the input events.
  104309. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104310. */
  104311. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104312. /**
  104313. * Detach the current controls from the specified dom element.
  104314. * @param element Defines the element to stop listening the inputs from
  104315. */
  104316. detachControl(element: Nullable<HTMLElement>): void;
  104317. /**
  104318. * Gets the class name of the current input.
  104319. * @returns the class name.
  104320. */
  104321. getClassName(): string;
  104322. /**
  104323. * Get the friendly name associated with the input class.
  104324. * @returns the input's friendly name.
  104325. */
  104326. getSimpleName(): string;
  104327. private _pointerInput;
  104328. private _onMouseMove;
  104329. /**
  104330. * Rotate camera by mouse offset.
  104331. */
  104332. private rotateCamera;
  104333. }
  104334. }
  104335. declare module BABYLON {
  104336. /**
  104337. * Default Inputs manager for the FlyCamera.
  104338. * It groups all the default supported inputs for ease of use.
  104339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104340. */
  104341. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104342. /**
  104343. * Instantiates a new FlyCameraInputsManager.
  104344. * @param camera Defines the camera the inputs belong to.
  104345. */
  104346. constructor(camera: FlyCamera);
  104347. /**
  104348. * Add keyboard input support to the input manager.
  104349. * @returns the new FlyCameraKeyboardMoveInput().
  104350. */
  104351. addKeyboard(): FlyCameraInputsManager;
  104352. /**
  104353. * Add mouse input support to the input manager.
  104354. * @param touchEnabled Enable touch screen support.
  104355. * @returns the new FlyCameraMouseInput().
  104356. */
  104357. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104358. }
  104359. }
  104360. declare module BABYLON {
  104361. /**
  104362. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104363. * such as in a 3D Space Shooter or a Flight Simulator.
  104364. */
  104365. export class FlyCamera extends TargetCamera {
  104366. /**
  104367. * Define the collision ellipsoid of the camera.
  104368. * This is helpful for simulating a camera body, like a player's body.
  104369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104370. */
  104371. ellipsoid: Vector3;
  104372. /**
  104373. * Define an offset for the position of the ellipsoid around the camera.
  104374. * This can be helpful if the camera is attached away from the player's body center,
  104375. * such as at its head.
  104376. */
  104377. ellipsoidOffset: Vector3;
  104378. /**
  104379. * Enable or disable collisions of the camera with the rest of the scene objects.
  104380. */
  104381. checkCollisions: boolean;
  104382. /**
  104383. * Enable or disable gravity on the camera.
  104384. */
  104385. applyGravity: boolean;
  104386. /**
  104387. * Define the current direction the camera is moving to.
  104388. */
  104389. cameraDirection: Vector3;
  104390. /**
  104391. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104392. * This overrides and empties cameraRotation.
  104393. */
  104394. rotationQuaternion: Quaternion;
  104395. /**
  104396. * Track Roll to maintain the wanted Rolling when looking around.
  104397. */
  104398. _trackRoll: number;
  104399. /**
  104400. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104401. */
  104402. rollCorrect: number;
  104403. /**
  104404. * Mimic a banked turn, Rolling the camera when Yawing.
  104405. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104406. */
  104407. bankedTurn: boolean;
  104408. /**
  104409. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104410. */
  104411. bankedTurnLimit: number;
  104412. /**
  104413. * Value of 0 disables the banked Roll.
  104414. * Value of 1 is equal to the Yaw angle in radians.
  104415. */
  104416. bankedTurnMultiplier: number;
  104417. /**
  104418. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104419. */
  104420. inputs: FlyCameraInputsManager;
  104421. /**
  104422. * Gets the input sensibility for mouse input.
  104423. * Higher values reduce sensitivity.
  104424. */
  104425. /**
  104426. * Sets the input sensibility for a mouse input.
  104427. * Higher values reduce sensitivity.
  104428. */
  104429. angularSensibility: number;
  104430. /**
  104431. * Get the keys for camera movement forward.
  104432. */
  104433. /**
  104434. * Set the keys for camera movement forward.
  104435. */
  104436. keysForward: number[];
  104437. /**
  104438. * Get the keys for camera movement backward.
  104439. */
  104440. keysBackward: number[];
  104441. /**
  104442. * Get the keys for camera movement up.
  104443. */
  104444. /**
  104445. * Set the keys for camera movement up.
  104446. */
  104447. keysUp: number[];
  104448. /**
  104449. * Get the keys for camera movement down.
  104450. */
  104451. /**
  104452. * Set the keys for camera movement down.
  104453. */
  104454. keysDown: number[];
  104455. /**
  104456. * Get the keys for camera movement left.
  104457. */
  104458. /**
  104459. * Set the keys for camera movement left.
  104460. */
  104461. keysLeft: number[];
  104462. /**
  104463. * Set the keys for camera movement right.
  104464. */
  104465. /**
  104466. * Set the keys for camera movement right.
  104467. */
  104468. keysRight: number[];
  104469. /**
  104470. * Event raised when the camera collides with a mesh in the scene.
  104471. */
  104472. onCollide: (collidedMesh: AbstractMesh) => void;
  104473. private _collider;
  104474. private _needMoveForGravity;
  104475. private _oldPosition;
  104476. private _diffPosition;
  104477. private _newPosition;
  104478. /** @hidden */
  104479. _localDirection: Vector3;
  104480. /** @hidden */
  104481. _transformedDirection: Vector3;
  104482. /**
  104483. * Instantiates a FlyCamera.
  104484. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104485. * such as in a 3D Space Shooter or a Flight Simulator.
  104486. * @param name Define the name of the camera in the scene.
  104487. * @param position Define the starting position of the camera in the scene.
  104488. * @param scene Define the scene the camera belongs to.
  104489. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104490. */
  104491. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104492. /**
  104493. * Attach a control to the HTML DOM element.
  104494. * @param element Defines the element that listens to the input events.
  104495. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104496. */
  104497. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104498. /**
  104499. * Detach a control from the HTML DOM element.
  104500. * The camera will stop reacting to that input.
  104501. * @param element Defines the element that listens to the input events.
  104502. */
  104503. detachControl(element: HTMLElement): void;
  104504. private _collisionMask;
  104505. /**
  104506. * Get the mask that the camera ignores in collision events.
  104507. */
  104508. /**
  104509. * Set the mask that the camera ignores in collision events.
  104510. */
  104511. collisionMask: number;
  104512. /** @hidden */
  104513. _collideWithWorld(displacement: Vector3): void;
  104514. /** @hidden */
  104515. private _onCollisionPositionChange;
  104516. /** @hidden */
  104517. _checkInputs(): void;
  104518. /** @hidden */
  104519. _decideIfNeedsToMove(): boolean;
  104520. /** @hidden */
  104521. _updatePosition(): void;
  104522. /**
  104523. * Restore the Roll to its target value at the rate specified.
  104524. * @param rate - Higher means slower restoring.
  104525. * @hidden
  104526. */
  104527. restoreRoll(rate: number): void;
  104528. /**
  104529. * Destroy the camera and release the current resources held by it.
  104530. */
  104531. dispose(): void;
  104532. /**
  104533. * Get the current object class name.
  104534. * @returns the class name.
  104535. */
  104536. getClassName(): string;
  104537. }
  104538. }
  104539. declare module BABYLON {
  104540. /**
  104541. * Listen to keyboard events to control the camera.
  104542. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104543. */
  104544. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104545. /**
  104546. * Defines the camera the input is attached to.
  104547. */
  104548. camera: FlyCamera;
  104549. /**
  104550. * The list of keyboard keys used to control the forward move of the camera.
  104551. */
  104552. keysForward: number[];
  104553. /**
  104554. * The list of keyboard keys used to control the backward move of the camera.
  104555. */
  104556. keysBackward: number[];
  104557. /**
  104558. * The list of keyboard keys used to control the forward move of the camera.
  104559. */
  104560. keysUp: number[];
  104561. /**
  104562. * The list of keyboard keys used to control the backward move of the camera.
  104563. */
  104564. keysDown: number[];
  104565. /**
  104566. * The list of keyboard keys used to control the right strafe move of the camera.
  104567. */
  104568. keysRight: number[];
  104569. /**
  104570. * The list of keyboard keys used to control the left strafe move of the camera.
  104571. */
  104572. keysLeft: number[];
  104573. private _keys;
  104574. private _onCanvasBlurObserver;
  104575. private _onKeyboardObserver;
  104576. private _engine;
  104577. private _scene;
  104578. /**
  104579. * Attach the input controls to a specific dom element to get the input from.
  104580. * @param element Defines the element the controls should be listened from
  104581. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104582. */
  104583. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104584. /**
  104585. * Detach the current controls from the specified dom element.
  104586. * @param element Defines the element to stop listening the inputs from
  104587. */
  104588. detachControl(element: Nullable<HTMLElement>): void;
  104589. /**
  104590. * Gets the class name of the current intput.
  104591. * @returns the class name
  104592. */
  104593. getClassName(): string;
  104594. /** @hidden */
  104595. _onLostFocus(e: FocusEvent): void;
  104596. /**
  104597. * Get the friendly name associated with the input class.
  104598. * @returns the input friendly name
  104599. */
  104600. getSimpleName(): string;
  104601. /**
  104602. * Update the current camera state depending on the inputs that have been used this frame.
  104603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104604. */
  104605. checkInputs(): void;
  104606. }
  104607. }
  104608. declare module BABYLON {
  104609. /**
  104610. * Manage the mouse wheel inputs to control a follow camera.
  104611. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104612. */
  104613. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104614. /**
  104615. * Defines the camera the input is attached to.
  104616. */
  104617. camera: FollowCamera;
  104618. /**
  104619. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104620. */
  104621. axisControlRadius: boolean;
  104622. /**
  104623. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104624. */
  104625. axisControlHeight: boolean;
  104626. /**
  104627. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104628. */
  104629. axisControlRotation: boolean;
  104630. /**
  104631. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104632. * relation to mouseWheel events.
  104633. */
  104634. wheelPrecision: number;
  104635. /**
  104636. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104637. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104638. */
  104639. wheelDeltaPercentage: number;
  104640. private _wheel;
  104641. private _observer;
  104642. /**
  104643. * Attach the input controls to a specific dom element to get the input from.
  104644. * @param element Defines the element the controls should be listened from
  104645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104646. */
  104647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104648. /**
  104649. * Detach the current controls from the specified dom element.
  104650. * @param element Defines the element to stop listening the inputs from
  104651. */
  104652. detachControl(element: Nullable<HTMLElement>): void;
  104653. /**
  104654. * Gets the class name of the current intput.
  104655. * @returns the class name
  104656. */
  104657. getClassName(): string;
  104658. /**
  104659. * Get the friendly name associated with the input class.
  104660. * @returns the input friendly name
  104661. */
  104662. getSimpleName(): string;
  104663. }
  104664. }
  104665. declare module BABYLON {
  104666. /**
  104667. * Manage the pointers inputs to control an follow camera.
  104668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104669. */
  104670. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104671. /**
  104672. * Defines the camera the input is attached to.
  104673. */
  104674. camera: FollowCamera;
  104675. /**
  104676. * Gets the class name of the current input.
  104677. * @returns the class name
  104678. */
  104679. getClassName(): string;
  104680. /**
  104681. * Defines the pointer angular sensibility along the X axis or how fast is
  104682. * the camera rotating.
  104683. * A negative number will reverse the axis direction.
  104684. */
  104685. angularSensibilityX: number;
  104686. /**
  104687. * Defines the pointer angular sensibility along the Y axis or how fast is
  104688. * the camera rotating.
  104689. * A negative number will reverse the axis direction.
  104690. */
  104691. angularSensibilityY: number;
  104692. /**
  104693. * Defines the pointer pinch precision or how fast is the camera zooming.
  104694. * A negative number will reverse the axis direction.
  104695. */
  104696. pinchPrecision: number;
  104697. /**
  104698. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104699. * from 0.
  104700. * It defines the percentage of current camera.radius to use as delta when
  104701. * pinch zoom is used.
  104702. */
  104703. pinchDeltaPercentage: number;
  104704. /**
  104705. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104706. */
  104707. axisXControlRadius: boolean;
  104708. /**
  104709. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104710. */
  104711. axisXControlHeight: boolean;
  104712. /**
  104713. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104714. */
  104715. axisXControlRotation: boolean;
  104716. /**
  104717. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104718. */
  104719. axisYControlRadius: boolean;
  104720. /**
  104721. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104722. */
  104723. axisYControlHeight: boolean;
  104724. /**
  104725. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104726. */
  104727. axisYControlRotation: boolean;
  104728. /**
  104729. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104730. */
  104731. axisPinchControlRadius: boolean;
  104732. /**
  104733. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104734. */
  104735. axisPinchControlHeight: boolean;
  104736. /**
  104737. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104738. */
  104739. axisPinchControlRotation: boolean;
  104740. /**
  104741. * Log error messages if basic misconfiguration has occurred.
  104742. */
  104743. warningEnable: boolean;
  104744. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104745. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104746. private _warningCounter;
  104747. private _warning;
  104748. }
  104749. }
  104750. declare module BABYLON {
  104751. /**
  104752. * Default Inputs manager for the FollowCamera.
  104753. * It groups all the default supported inputs for ease of use.
  104754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104755. */
  104756. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104757. /**
  104758. * Instantiates a new FollowCameraInputsManager.
  104759. * @param camera Defines the camera the inputs belong to
  104760. */
  104761. constructor(camera: FollowCamera);
  104762. /**
  104763. * Add keyboard input support to the input manager.
  104764. * @returns the current input manager
  104765. */
  104766. addKeyboard(): FollowCameraInputsManager;
  104767. /**
  104768. * Add mouse wheel input support to the input manager.
  104769. * @returns the current input manager
  104770. */
  104771. addMouseWheel(): FollowCameraInputsManager;
  104772. /**
  104773. * Add pointers input support to the input manager.
  104774. * @returns the current input manager
  104775. */
  104776. addPointers(): FollowCameraInputsManager;
  104777. /**
  104778. * Add orientation input support to the input manager.
  104779. * @returns the current input manager
  104780. */
  104781. addVRDeviceOrientation(): FollowCameraInputsManager;
  104782. }
  104783. }
  104784. declare module BABYLON {
  104785. /**
  104786. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104787. * an arc rotate version arcFollowCamera are available.
  104788. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104789. */
  104790. export class FollowCamera extends TargetCamera {
  104791. /**
  104792. * Distance the follow camera should follow an object at
  104793. */
  104794. radius: number;
  104795. /**
  104796. * Minimum allowed distance of the camera to the axis of rotation
  104797. * (The camera can not get closer).
  104798. * This can help limiting how the Camera is able to move in the scene.
  104799. */
  104800. lowerRadiusLimit: Nullable<number>;
  104801. /**
  104802. * Maximum allowed distance of the camera to the axis of rotation
  104803. * (The camera can not get further).
  104804. * This can help limiting how the Camera is able to move in the scene.
  104805. */
  104806. upperRadiusLimit: Nullable<number>;
  104807. /**
  104808. * Define a rotation offset between the camera and the object it follows
  104809. */
  104810. rotationOffset: number;
  104811. /**
  104812. * Minimum allowed angle to camera position relative to target object.
  104813. * This can help limiting how the Camera is able to move in the scene.
  104814. */
  104815. lowerRotationOffsetLimit: Nullable<number>;
  104816. /**
  104817. * Maximum allowed angle to camera position relative to target object.
  104818. * This can help limiting how the Camera is able to move in the scene.
  104819. */
  104820. upperRotationOffsetLimit: Nullable<number>;
  104821. /**
  104822. * Define a height offset between the camera and the object it follows.
  104823. * It can help following an object from the top (like a car chaing a plane)
  104824. */
  104825. heightOffset: number;
  104826. /**
  104827. * Minimum allowed height of camera position relative to target object.
  104828. * This can help limiting how the Camera is able to move in the scene.
  104829. */
  104830. lowerHeightOffsetLimit: Nullable<number>;
  104831. /**
  104832. * Maximum allowed height of camera position relative to target object.
  104833. * This can help limiting how the Camera is able to move in the scene.
  104834. */
  104835. upperHeightOffsetLimit: Nullable<number>;
  104836. /**
  104837. * Define how fast the camera can accelerate to follow it s target.
  104838. */
  104839. cameraAcceleration: number;
  104840. /**
  104841. * Define the speed limit of the camera following an object.
  104842. */
  104843. maxCameraSpeed: number;
  104844. /**
  104845. * Define the target of the camera.
  104846. */
  104847. lockedTarget: Nullable<AbstractMesh>;
  104848. /**
  104849. * Defines the input associated with the camera.
  104850. */
  104851. inputs: FollowCameraInputsManager;
  104852. /**
  104853. * Instantiates the follow camera.
  104854. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104855. * @param name Define the name of the camera in the scene
  104856. * @param position Define the position of the camera
  104857. * @param scene Define the scene the camera belong to
  104858. * @param lockedTarget Define the target of the camera
  104859. */
  104860. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104861. private _follow;
  104862. /**
  104863. * Attached controls to the current camera.
  104864. * @param element Defines the element the controls should be listened from
  104865. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104866. */
  104867. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104868. /**
  104869. * Detach the current controls from the camera.
  104870. * The camera will stop reacting to inputs.
  104871. * @param element Defines the element to stop listening the inputs from
  104872. */
  104873. detachControl(element: HTMLElement): void;
  104874. /** @hidden */
  104875. _checkInputs(): void;
  104876. private _checkLimits;
  104877. /**
  104878. * Gets the camera class name.
  104879. * @returns the class name
  104880. */
  104881. getClassName(): string;
  104882. }
  104883. /**
  104884. * Arc Rotate version of the follow camera.
  104885. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104886. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104887. */
  104888. export class ArcFollowCamera extends TargetCamera {
  104889. /** The longitudinal angle of the camera */
  104890. alpha: number;
  104891. /** The latitudinal angle of the camera */
  104892. beta: number;
  104893. /** The radius of the camera from its target */
  104894. radius: number;
  104895. /** Define the camera target (the messh it should follow) */
  104896. target: Nullable<AbstractMesh>;
  104897. private _cartesianCoordinates;
  104898. /**
  104899. * Instantiates a new ArcFollowCamera
  104900. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104901. * @param name Define the name of the camera
  104902. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104903. * @param beta Define the rotation angle of the camera around the elevation axis
  104904. * @param radius Define the radius of the camera from its target point
  104905. * @param target Define the target of the camera
  104906. * @param scene Define the scene the camera belongs to
  104907. */
  104908. constructor(name: string,
  104909. /** The longitudinal angle of the camera */
  104910. alpha: number,
  104911. /** The latitudinal angle of the camera */
  104912. beta: number,
  104913. /** The radius of the camera from its target */
  104914. radius: number,
  104915. /** Define the camera target (the messh it should follow) */
  104916. target: Nullable<AbstractMesh>, scene: Scene);
  104917. private _follow;
  104918. /** @hidden */
  104919. _checkInputs(): void;
  104920. /**
  104921. * Returns the class name of the object.
  104922. * It is mostly used internally for serialization purposes.
  104923. */
  104924. getClassName(): string;
  104925. }
  104926. }
  104927. declare module BABYLON {
  104928. /**
  104929. * Manage the keyboard inputs to control the movement of a follow camera.
  104930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104931. */
  104932. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104933. /**
  104934. * Defines the camera the input is attached to.
  104935. */
  104936. camera: FollowCamera;
  104937. /**
  104938. * Defines the list of key codes associated with the up action (increase heightOffset)
  104939. */
  104940. keysHeightOffsetIncr: number[];
  104941. /**
  104942. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104943. */
  104944. keysHeightOffsetDecr: number[];
  104945. /**
  104946. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104947. */
  104948. keysHeightOffsetModifierAlt: boolean;
  104949. /**
  104950. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104951. */
  104952. keysHeightOffsetModifierCtrl: boolean;
  104953. /**
  104954. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104955. */
  104956. keysHeightOffsetModifierShift: boolean;
  104957. /**
  104958. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104959. */
  104960. keysRotationOffsetIncr: number[];
  104961. /**
  104962. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104963. */
  104964. keysRotationOffsetDecr: number[];
  104965. /**
  104966. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  104967. */
  104968. keysRotationOffsetModifierAlt: boolean;
  104969. /**
  104970. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  104971. */
  104972. keysRotationOffsetModifierCtrl: boolean;
  104973. /**
  104974. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  104975. */
  104976. keysRotationOffsetModifierShift: boolean;
  104977. /**
  104978. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  104979. */
  104980. keysRadiusIncr: number[];
  104981. /**
  104982. * Defines the list of key codes associated with the zoom-out action (increase radius)
  104983. */
  104984. keysRadiusDecr: number[];
  104985. /**
  104986. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  104987. */
  104988. keysRadiusModifierAlt: boolean;
  104989. /**
  104990. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  104991. */
  104992. keysRadiusModifierCtrl: boolean;
  104993. /**
  104994. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  104995. */
  104996. keysRadiusModifierShift: boolean;
  104997. /**
  104998. * Defines the rate of change of heightOffset.
  104999. */
  105000. heightSensibility: number;
  105001. /**
  105002. * Defines the rate of change of rotationOffset.
  105003. */
  105004. rotationSensibility: number;
  105005. /**
  105006. * Defines the rate of change of radius.
  105007. */
  105008. radiusSensibility: number;
  105009. private _keys;
  105010. private _ctrlPressed;
  105011. private _altPressed;
  105012. private _shiftPressed;
  105013. private _onCanvasBlurObserver;
  105014. private _onKeyboardObserver;
  105015. private _engine;
  105016. private _scene;
  105017. /**
  105018. * Attach the input controls to a specific dom element to get the input from.
  105019. * @param element Defines the element the controls should be listened from
  105020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105021. */
  105022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105023. /**
  105024. * Detach the current controls from the specified dom element.
  105025. * @param element Defines the element to stop listening the inputs from
  105026. */
  105027. detachControl(element: Nullable<HTMLElement>): void;
  105028. /**
  105029. * Update the current camera state depending on the inputs that have been used this frame.
  105030. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105031. */
  105032. checkInputs(): void;
  105033. /**
  105034. * Gets the class name of the current input.
  105035. * @returns the class name
  105036. */
  105037. getClassName(): string;
  105038. /**
  105039. * Get the friendly name associated with the input class.
  105040. * @returns the input friendly name
  105041. */
  105042. getSimpleName(): string;
  105043. /**
  105044. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105045. * allow modification of the heightOffset value.
  105046. */
  105047. private _modifierHeightOffset;
  105048. /**
  105049. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105050. * allow modification of the rotationOffset value.
  105051. */
  105052. private _modifierRotationOffset;
  105053. /**
  105054. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105055. * allow modification of the radius value.
  105056. */
  105057. private _modifierRadius;
  105058. }
  105059. }
  105060. declare module BABYLON {
  105061. interface FreeCameraInputsManager {
  105062. /**
  105063. * @hidden
  105064. */
  105065. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105066. /**
  105067. * Add orientation input support to the input manager.
  105068. * @returns the current input manager
  105069. */
  105070. addDeviceOrientation(): FreeCameraInputsManager;
  105071. }
  105072. /**
  105073. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105074. * Screen rotation is taken into account.
  105075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105076. */
  105077. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105078. private _camera;
  105079. private _screenOrientationAngle;
  105080. private _constantTranform;
  105081. private _screenQuaternion;
  105082. private _alpha;
  105083. private _beta;
  105084. private _gamma;
  105085. /**
  105086. * Can be used to detect if a device orientation sensor is availible on a device
  105087. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105088. * @returns a promise that will resolve on orientation change
  105089. */
  105090. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105091. /**
  105092. * @hidden
  105093. */
  105094. _onDeviceOrientationChangedObservable: Observable<void>;
  105095. /**
  105096. * Instantiates a new input
  105097. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105098. */
  105099. constructor();
  105100. /**
  105101. * Define the camera controlled by the input.
  105102. */
  105103. camera: FreeCamera;
  105104. /**
  105105. * Attach the input controls to a specific dom element to get the input from.
  105106. * @param element Defines the element the controls should be listened from
  105107. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105108. */
  105109. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105110. private _orientationChanged;
  105111. private _deviceOrientation;
  105112. /**
  105113. * Detach the current controls from the specified dom element.
  105114. * @param element Defines the element to stop listening the inputs from
  105115. */
  105116. detachControl(element: Nullable<HTMLElement>): void;
  105117. /**
  105118. * Update the current camera state depending on the inputs that have been used this frame.
  105119. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105120. */
  105121. checkInputs(): void;
  105122. /**
  105123. * Gets the class name of the current intput.
  105124. * @returns the class name
  105125. */
  105126. getClassName(): string;
  105127. /**
  105128. * Get the friendly name associated with the input class.
  105129. * @returns the input friendly name
  105130. */
  105131. getSimpleName(): string;
  105132. }
  105133. }
  105134. declare module BABYLON {
  105135. /**
  105136. * Manage the gamepad inputs to control a free camera.
  105137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105138. */
  105139. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105140. /**
  105141. * Define the camera the input is attached to.
  105142. */
  105143. camera: FreeCamera;
  105144. /**
  105145. * Define the Gamepad controlling the input
  105146. */
  105147. gamepad: Nullable<Gamepad>;
  105148. /**
  105149. * Defines the gamepad rotation sensiblity.
  105150. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105151. */
  105152. gamepadAngularSensibility: number;
  105153. /**
  105154. * Defines the gamepad move sensiblity.
  105155. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105156. */
  105157. gamepadMoveSensibility: number;
  105158. private _yAxisScale;
  105159. /**
  105160. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105161. */
  105162. invertYAxis: boolean;
  105163. private _onGamepadConnectedObserver;
  105164. private _onGamepadDisconnectedObserver;
  105165. private _cameraTransform;
  105166. private _deltaTransform;
  105167. private _vector3;
  105168. private _vector2;
  105169. /**
  105170. * Attach the input controls to a specific dom element to get the input from.
  105171. * @param element Defines the element the controls should be listened from
  105172. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105173. */
  105174. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105175. /**
  105176. * Detach the current controls from the specified dom element.
  105177. * @param element Defines the element to stop listening the inputs from
  105178. */
  105179. detachControl(element: Nullable<HTMLElement>): void;
  105180. /**
  105181. * Update the current camera state depending on the inputs that have been used this frame.
  105182. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105183. */
  105184. checkInputs(): void;
  105185. /**
  105186. * Gets the class name of the current intput.
  105187. * @returns the class name
  105188. */
  105189. getClassName(): string;
  105190. /**
  105191. * Get the friendly name associated with the input class.
  105192. * @returns the input friendly name
  105193. */
  105194. getSimpleName(): string;
  105195. }
  105196. }
  105197. declare module BABYLON {
  105198. /**
  105199. * Defines the potential axis of a Joystick
  105200. */
  105201. export enum JoystickAxis {
  105202. /** X axis */
  105203. X = 0,
  105204. /** Y axis */
  105205. Y = 1,
  105206. /** Z axis */
  105207. Z = 2
  105208. }
  105209. /**
  105210. * Class used to define virtual joystick (used in touch mode)
  105211. */
  105212. export class VirtualJoystick {
  105213. /**
  105214. * Gets or sets a boolean indicating that left and right values must be inverted
  105215. */
  105216. reverseLeftRight: boolean;
  105217. /**
  105218. * Gets or sets a boolean indicating that up and down values must be inverted
  105219. */
  105220. reverseUpDown: boolean;
  105221. /**
  105222. * Gets the offset value for the position (ie. the change of the position value)
  105223. */
  105224. deltaPosition: Vector3;
  105225. /**
  105226. * Gets a boolean indicating if the virtual joystick was pressed
  105227. */
  105228. pressed: boolean;
  105229. /**
  105230. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105231. */
  105232. static Canvas: Nullable<HTMLCanvasElement>;
  105233. private static _globalJoystickIndex;
  105234. private static vjCanvasContext;
  105235. private static vjCanvasWidth;
  105236. private static vjCanvasHeight;
  105237. private static halfWidth;
  105238. private _action;
  105239. private _axisTargetedByLeftAndRight;
  105240. private _axisTargetedByUpAndDown;
  105241. private _joystickSensibility;
  105242. private _inversedSensibility;
  105243. private _joystickPointerID;
  105244. private _joystickColor;
  105245. private _joystickPointerPos;
  105246. private _joystickPreviousPointerPos;
  105247. private _joystickPointerStartPos;
  105248. private _deltaJoystickVector;
  105249. private _leftJoystick;
  105250. private _touches;
  105251. private _onPointerDownHandlerRef;
  105252. private _onPointerMoveHandlerRef;
  105253. private _onPointerUpHandlerRef;
  105254. private _onResize;
  105255. /**
  105256. * Creates a new virtual joystick
  105257. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105258. */
  105259. constructor(leftJoystick?: boolean);
  105260. /**
  105261. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105262. * @param newJoystickSensibility defines the new sensibility
  105263. */
  105264. setJoystickSensibility(newJoystickSensibility: number): void;
  105265. private _onPointerDown;
  105266. private _onPointerMove;
  105267. private _onPointerUp;
  105268. /**
  105269. * Change the color of the virtual joystick
  105270. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105271. */
  105272. setJoystickColor(newColor: string): void;
  105273. /**
  105274. * Defines a callback to call when the joystick is touched
  105275. * @param action defines the callback
  105276. */
  105277. setActionOnTouch(action: () => any): void;
  105278. /**
  105279. * Defines which axis you'd like to control for left & right
  105280. * @param axis defines the axis to use
  105281. */
  105282. setAxisForLeftRight(axis: JoystickAxis): void;
  105283. /**
  105284. * Defines which axis you'd like to control for up & down
  105285. * @param axis defines the axis to use
  105286. */
  105287. setAxisForUpDown(axis: JoystickAxis): void;
  105288. private _drawVirtualJoystick;
  105289. /**
  105290. * Release internal HTML canvas
  105291. */
  105292. releaseCanvas(): void;
  105293. }
  105294. }
  105295. declare module BABYLON {
  105296. interface FreeCameraInputsManager {
  105297. /**
  105298. * Add virtual joystick input support to the input manager.
  105299. * @returns the current input manager
  105300. */
  105301. addVirtualJoystick(): FreeCameraInputsManager;
  105302. }
  105303. /**
  105304. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105305. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105306. */
  105307. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105308. /**
  105309. * Defines the camera the input is attached to.
  105310. */
  105311. camera: FreeCamera;
  105312. private _leftjoystick;
  105313. private _rightjoystick;
  105314. /**
  105315. * Gets the left stick of the virtual joystick.
  105316. * @returns The virtual Joystick
  105317. */
  105318. getLeftJoystick(): VirtualJoystick;
  105319. /**
  105320. * Gets the right stick of the virtual joystick.
  105321. * @returns The virtual Joystick
  105322. */
  105323. getRightJoystick(): VirtualJoystick;
  105324. /**
  105325. * Update the current camera state depending on the inputs that have been used this frame.
  105326. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105327. */
  105328. checkInputs(): void;
  105329. /**
  105330. * Attach the input controls to a specific dom element to get the input from.
  105331. * @param element Defines the element the controls should be listened from
  105332. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105333. */
  105334. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105335. /**
  105336. * Detach the current controls from the specified dom element.
  105337. * @param element Defines the element to stop listening the inputs from
  105338. */
  105339. detachControl(element: Nullable<HTMLElement>): void;
  105340. /**
  105341. * Gets the class name of the current intput.
  105342. * @returns the class name
  105343. */
  105344. getClassName(): string;
  105345. /**
  105346. * Get the friendly name associated with the input class.
  105347. * @returns the input friendly name
  105348. */
  105349. getSimpleName(): string;
  105350. }
  105351. }
  105352. declare module BABYLON {
  105353. /**
  105354. * This represents a FPS type of camera controlled by touch.
  105355. * This is like a universal camera minus the Gamepad controls.
  105356. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105357. */
  105358. export class TouchCamera extends FreeCamera {
  105359. /**
  105360. * Defines the touch sensibility for rotation.
  105361. * The higher the faster.
  105362. */
  105363. touchAngularSensibility: number;
  105364. /**
  105365. * Defines the touch sensibility for move.
  105366. * The higher the faster.
  105367. */
  105368. touchMoveSensibility: number;
  105369. /**
  105370. * Instantiates a new touch camera.
  105371. * This represents a FPS type of camera controlled by touch.
  105372. * This is like a universal camera minus the Gamepad controls.
  105373. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105374. * @param name Define the name of the camera in the scene
  105375. * @param position Define the start position of the camera in the scene
  105376. * @param scene Define the scene the camera belongs to
  105377. */
  105378. constructor(name: string, position: Vector3, scene: Scene);
  105379. /**
  105380. * Gets the current object class name.
  105381. * @return the class name
  105382. */
  105383. getClassName(): string;
  105384. /** @hidden */
  105385. _setupInputs(): void;
  105386. }
  105387. }
  105388. declare module BABYLON {
  105389. /**
  105390. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105391. * being tilted forward or back and left or right.
  105392. */
  105393. export class DeviceOrientationCamera extends FreeCamera {
  105394. private _initialQuaternion;
  105395. private _quaternionCache;
  105396. private _tmpDragQuaternion;
  105397. private _disablePointerInputWhenUsingDeviceOrientation;
  105398. /**
  105399. * Creates a new device orientation camera
  105400. * @param name The name of the camera
  105401. * @param position The start position camera
  105402. * @param scene The scene the camera belongs to
  105403. */
  105404. constructor(name: string, position: Vector3, scene: Scene);
  105405. /**
  105406. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105407. */
  105408. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105409. private _dragFactor;
  105410. /**
  105411. * Enabled turning on the y axis when the orientation sensor is active
  105412. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105413. */
  105414. enableHorizontalDragging(dragFactor?: number): void;
  105415. /**
  105416. * Gets the current instance class name ("DeviceOrientationCamera").
  105417. * This helps avoiding instanceof at run time.
  105418. * @returns the class name
  105419. */
  105420. getClassName(): string;
  105421. /**
  105422. * @hidden
  105423. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105424. */
  105425. _checkInputs(): void;
  105426. /**
  105427. * Reset the camera to its default orientation on the specified axis only.
  105428. * @param axis The axis to reset
  105429. */
  105430. resetToCurrentRotation(axis?: Axis): void;
  105431. }
  105432. }
  105433. declare module BABYLON {
  105434. /**
  105435. * Defines supported buttons for XBox360 compatible gamepads
  105436. */
  105437. export enum Xbox360Button {
  105438. /** A */
  105439. A = 0,
  105440. /** B */
  105441. B = 1,
  105442. /** X */
  105443. X = 2,
  105444. /** Y */
  105445. Y = 3,
  105446. /** Start */
  105447. Start = 4,
  105448. /** Back */
  105449. Back = 5,
  105450. /** Left button */
  105451. LB = 6,
  105452. /** Right button */
  105453. RB = 7,
  105454. /** Left stick */
  105455. LeftStick = 8,
  105456. /** Right stick */
  105457. RightStick = 9
  105458. }
  105459. /** Defines values for XBox360 DPad */
  105460. export enum Xbox360Dpad {
  105461. /** Up */
  105462. Up = 0,
  105463. /** Down */
  105464. Down = 1,
  105465. /** Left */
  105466. Left = 2,
  105467. /** Right */
  105468. Right = 3
  105469. }
  105470. /**
  105471. * Defines a XBox360 gamepad
  105472. */
  105473. export class Xbox360Pad extends Gamepad {
  105474. private _leftTrigger;
  105475. private _rightTrigger;
  105476. private _onlefttriggerchanged;
  105477. private _onrighttriggerchanged;
  105478. private _onbuttondown;
  105479. private _onbuttonup;
  105480. private _ondpaddown;
  105481. private _ondpadup;
  105482. /** Observable raised when a button is pressed */
  105483. onButtonDownObservable: Observable<Xbox360Button>;
  105484. /** Observable raised when a button is released */
  105485. onButtonUpObservable: Observable<Xbox360Button>;
  105486. /** Observable raised when a pad is pressed */
  105487. onPadDownObservable: Observable<Xbox360Dpad>;
  105488. /** Observable raised when a pad is released */
  105489. onPadUpObservable: Observable<Xbox360Dpad>;
  105490. private _buttonA;
  105491. private _buttonB;
  105492. private _buttonX;
  105493. private _buttonY;
  105494. private _buttonBack;
  105495. private _buttonStart;
  105496. private _buttonLB;
  105497. private _buttonRB;
  105498. private _buttonLeftStick;
  105499. private _buttonRightStick;
  105500. private _dPadUp;
  105501. private _dPadDown;
  105502. private _dPadLeft;
  105503. private _dPadRight;
  105504. private _isXboxOnePad;
  105505. /**
  105506. * Creates a new XBox360 gamepad object
  105507. * @param id defines the id of this gamepad
  105508. * @param index defines its index
  105509. * @param gamepad defines the internal HTML gamepad object
  105510. * @param xboxOne defines if it is a XBox One gamepad
  105511. */
  105512. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105513. /**
  105514. * Defines the callback to call when left trigger is pressed
  105515. * @param callback defines the callback to use
  105516. */
  105517. onlefttriggerchanged(callback: (value: number) => void): void;
  105518. /**
  105519. * Defines the callback to call when right trigger is pressed
  105520. * @param callback defines the callback to use
  105521. */
  105522. onrighttriggerchanged(callback: (value: number) => void): void;
  105523. /**
  105524. * Gets the left trigger value
  105525. */
  105526. /**
  105527. * Sets the left trigger value
  105528. */
  105529. leftTrigger: number;
  105530. /**
  105531. * Gets the right trigger value
  105532. */
  105533. /**
  105534. * Sets the right trigger value
  105535. */
  105536. rightTrigger: number;
  105537. /**
  105538. * Defines the callback to call when a button is pressed
  105539. * @param callback defines the callback to use
  105540. */
  105541. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105542. /**
  105543. * Defines the callback to call when a button is released
  105544. * @param callback defines the callback to use
  105545. */
  105546. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105547. /**
  105548. * Defines the callback to call when a pad is pressed
  105549. * @param callback defines the callback to use
  105550. */
  105551. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105552. /**
  105553. * Defines the callback to call when a pad is released
  105554. * @param callback defines the callback to use
  105555. */
  105556. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105557. private _setButtonValue;
  105558. private _setDPadValue;
  105559. /**
  105560. * Gets the value of the `A` button
  105561. */
  105562. /**
  105563. * Sets the value of the `A` button
  105564. */
  105565. buttonA: number;
  105566. /**
  105567. * Gets the value of the `B` button
  105568. */
  105569. /**
  105570. * Sets the value of the `B` button
  105571. */
  105572. buttonB: number;
  105573. /**
  105574. * Gets the value of the `X` button
  105575. */
  105576. /**
  105577. * Sets the value of the `X` button
  105578. */
  105579. buttonX: number;
  105580. /**
  105581. * Gets the value of the `Y` button
  105582. */
  105583. /**
  105584. * Sets the value of the `Y` button
  105585. */
  105586. buttonY: number;
  105587. /**
  105588. * Gets the value of the `Start` button
  105589. */
  105590. /**
  105591. * Sets the value of the `Start` button
  105592. */
  105593. buttonStart: number;
  105594. /**
  105595. * Gets the value of the `Back` button
  105596. */
  105597. /**
  105598. * Sets the value of the `Back` button
  105599. */
  105600. buttonBack: number;
  105601. /**
  105602. * Gets the value of the `Left` button
  105603. */
  105604. /**
  105605. * Sets the value of the `Left` button
  105606. */
  105607. buttonLB: number;
  105608. /**
  105609. * Gets the value of the `Right` button
  105610. */
  105611. /**
  105612. * Sets the value of the `Right` button
  105613. */
  105614. buttonRB: number;
  105615. /**
  105616. * Gets the value of the Left joystick
  105617. */
  105618. /**
  105619. * Sets the value of the Left joystick
  105620. */
  105621. buttonLeftStick: number;
  105622. /**
  105623. * Gets the value of the Right joystick
  105624. */
  105625. /**
  105626. * Sets the value of the Right joystick
  105627. */
  105628. buttonRightStick: number;
  105629. /**
  105630. * Gets the value of D-pad up
  105631. */
  105632. /**
  105633. * Sets the value of D-pad up
  105634. */
  105635. dPadUp: number;
  105636. /**
  105637. * Gets the value of D-pad down
  105638. */
  105639. /**
  105640. * Sets the value of D-pad down
  105641. */
  105642. dPadDown: number;
  105643. /**
  105644. * Gets the value of D-pad left
  105645. */
  105646. /**
  105647. * Sets the value of D-pad left
  105648. */
  105649. dPadLeft: number;
  105650. /**
  105651. * Gets the value of D-pad right
  105652. */
  105653. /**
  105654. * Sets the value of D-pad right
  105655. */
  105656. dPadRight: number;
  105657. /**
  105658. * Force the gamepad to synchronize with device values
  105659. */
  105660. update(): void;
  105661. /**
  105662. * Disposes the gamepad
  105663. */
  105664. dispose(): void;
  105665. }
  105666. }
  105667. declare module BABYLON {
  105668. /**
  105669. * Defines supported buttons for DualShock compatible gamepads
  105670. */
  105671. export enum DualShockButton {
  105672. /** Cross */
  105673. Cross = 0,
  105674. /** Circle */
  105675. Circle = 1,
  105676. /** Square */
  105677. Square = 2,
  105678. /** Triangle */
  105679. Triangle = 3,
  105680. /** Options */
  105681. Options = 4,
  105682. /** Share */
  105683. Share = 5,
  105684. /** L1 */
  105685. L1 = 6,
  105686. /** R1 */
  105687. R1 = 7,
  105688. /** Left stick */
  105689. LeftStick = 8,
  105690. /** Right stick */
  105691. RightStick = 9
  105692. }
  105693. /** Defines values for DualShock DPad */
  105694. export enum DualShockDpad {
  105695. /** Up */
  105696. Up = 0,
  105697. /** Down */
  105698. Down = 1,
  105699. /** Left */
  105700. Left = 2,
  105701. /** Right */
  105702. Right = 3
  105703. }
  105704. /**
  105705. * Defines a DualShock gamepad
  105706. */
  105707. export class DualShockPad extends Gamepad {
  105708. private _leftTrigger;
  105709. private _rightTrigger;
  105710. private _onlefttriggerchanged;
  105711. private _onrighttriggerchanged;
  105712. private _onbuttondown;
  105713. private _onbuttonup;
  105714. private _ondpaddown;
  105715. private _ondpadup;
  105716. /** Observable raised when a button is pressed */
  105717. onButtonDownObservable: Observable<DualShockButton>;
  105718. /** Observable raised when a button is released */
  105719. onButtonUpObservable: Observable<DualShockButton>;
  105720. /** Observable raised when a pad is pressed */
  105721. onPadDownObservable: Observable<DualShockDpad>;
  105722. /** Observable raised when a pad is released */
  105723. onPadUpObservable: Observable<DualShockDpad>;
  105724. private _buttonCross;
  105725. private _buttonCircle;
  105726. private _buttonSquare;
  105727. private _buttonTriangle;
  105728. private _buttonShare;
  105729. private _buttonOptions;
  105730. private _buttonL1;
  105731. private _buttonR1;
  105732. private _buttonLeftStick;
  105733. private _buttonRightStick;
  105734. private _dPadUp;
  105735. private _dPadDown;
  105736. private _dPadLeft;
  105737. private _dPadRight;
  105738. /**
  105739. * Creates a new DualShock gamepad object
  105740. * @param id defines the id of this gamepad
  105741. * @param index defines its index
  105742. * @param gamepad defines the internal HTML gamepad object
  105743. */
  105744. constructor(id: string, index: number, gamepad: any);
  105745. /**
  105746. * Defines the callback to call when left trigger is pressed
  105747. * @param callback defines the callback to use
  105748. */
  105749. onlefttriggerchanged(callback: (value: number) => void): void;
  105750. /**
  105751. * Defines the callback to call when right trigger is pressed
  105752. * @param callback defines the callback to use
  105753. */
  105754. onrighttriggerchanged(callback: (value: number) => void): void;
  105755. /**
  105756. * Gets the left trigger value
  105757. */
  105758. /**
  105759. * Sets the left trigger value
  105760. */
  105761. leftTrigger: number;
  105762. /**
  105763. * Gets the right trigger value
  105764. */
  105765. /**
  105766. * Sets the right trigger value
  105767. */
  105768. rightTrigger: number;
  105769. /**
  105770. * Defines the callback to call when a button is pressed
  105771. * @param callback defines the callback to use
  105772. */
  105773. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105774. /**
  105775. * Defines the callback to call when a button is released
  105776. * @param callback defines the callback to use
  105777. */
  105778. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105779. /**
  105780. * Defines the callback to call when a pad is pressed
  105781. * @param callback defines the callback to use
  105782. */
  105783. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105784. /**
  105785. * Defines the callback to call when a pad is released
  105786. * @param callback defines the callback to use
  105787. */
  105788. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105789. private _setButtonValue;
  105790. private _setDPadValue;
  105791. /**
  105792. * Gets the value of the `Cross` button
  105793. */
  105794. /**
  105795. * Sets the value of the `Cross` button
  105796. */
  105797. buttonCross: number;
  105798. /**
  105799. * Gets the value of the `Circle` button
  105800. */
  105801. /**
  105802. * Sets the value of the `Circle` button
  105803. */
  105804. buttonCircle: number;
  105805. /**
  105806. * Gets the value of the `Square` button
  105807. */
  105808. /**
  105809. * Sets the value of the `Square` button
  105810. */
  105811. buttonSquare: number;
  105812. /**
  105813. * Gets the value of the `Triangle` button
  105814. */
  105815. /**
  105816. * Sets the value of the `Triangle` button
  105817. */
  105818. buttonTriangle: number;
  105819. /**
  105820. * Gets the value of the `Options` button
  105821. */
  105822. /**
  105823. * Sets the value of the `Options` button
  105824. */
  105825. buttonOptions: number;
  105826. /**
  105827. * Gets the value of the `Share` button
  105828. */
  105829. /**
  105830. * Sets the value of the `Share` button
  105831. */
  105832. buttonShare: number;
  105833. /**
  105834. * Gets the value of the `L1` button
  105835. */
  105836. /**
  105837. * Sets the value of the `L1` button
  105838. */
  105839. buttonL1: number;
  105840. /**
  105841. * Gets the value of the `R1` button
  105842. */
  105843. /**
  105844. * Sets the value of the `R1` button
  105845. */
  105846. buttonR1: number;
  105847. /**
  105848. * Gets the value of the Left joystick
  105849. */
  105850. /**
  105851. * Sets the value of the Left joystick
  105852. */
  105853. buttonLeftStick: number;
  105854. /**
  105855. * Gets the value of the Right joystick
  105856. */
  105857. /**
  105858. * Sets the value of the Right joystick
  105859. */
  105860. buttonRightStick: number;
  105861. /**
  105862. * Gets the value of D-pad up
  105863. */
  105864. /**
  105865. * Sets the value of D-pad up
  105866. */
  105867. dPadUp: number;
  105868. /**
  105869. * Gets the value of D-pad down
  105870. */
  105871. /**
  105872. * Sets the value of D-pad down
  105873. */
  105874. dPadDown: number;
  105875. /**
  105876. * Gets the value of D-pad left
  105877. */
  105878. /**
  105879. * Sets the value of D-pad left
  105880. */
  105881. dPadLeft: number;
  105882. /**
  105883. * Gets the value of D-pad right
  105884. */
  105885. /**
  105886. * Sets the value of D-pad right
  105887. */
  105888. dPadRight: number;
  105889. /**
  105890. * Force the gamepad to synchronize with device values
  105891. */
  105892. update(): void;
  105893. /**
  105894. * Disposes the gamepad
  105895. */
  105896. dispose(): void;
  105897. }
  105898. }
  105899. declare module BABYLON {
  105900. /**
  105901. * Manager for handling gamepads
  105902. */
  105903. export class GamepadManager {
  105904. private _scene?;
  105905. private _babylonGamepads;
  105906. private _oneGamepadConnected;
  105907. /** @hidden */
  105908. _isMonitoring: boolean;
  105909. private _gamepadEventSupported;
  105910. private _gamepadSupport;
  105911. /**
  105912. * observable to be triggered when the gamepad controller has been connected
  105913. */
  105914. onGamepadConnectedObservable: Observable<Gamepad>;
  105915. /**
  105916. * observable to be triggered when the gamepad controller has been disconnected
  105917. */
  105918. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105919. private _onGamepadConnectedEvent;
  105920. private _onGamepadDisconnectedEvent;
  105921. /**
  105922. * Initializes the gamepad manager
  105923. * @param _scene BabylonJS scene
  105924. */
  105925. constructor(_scene?: Scene | undefined);
  105926. /**
  105927. * The gamepads in the game pad manager
  105928. */
  105929. readonly gamepads: Gamepad[];
  105930. /**
  105931. * Get the gamepad controllers based on type
  105932. * @param type The type of gamepad controller
  105933. * @returns Nullable gamepad
  105934. */
  105935. getGamepadByType(type?: number): Nullable<Gamepad>;
  105936. /**
  105937. * Disposes the gamepad manager
  105938. */
  105939. dispose(): void;
  105940. private _addNewGamepad;
  105941. private _startMonitoringGamepads;
  105942. private _stopMonitoringGamepads;
  105943. /** @hidden */
  105944. _checkGamepadsStatus(): void;
  105945. private _updateGamepadObjects;
  105946. }
  105947. }
  105948. declare module BABYLON {
  105949. interface Scene {
  105950. /** @hidden */
  105951. _gamepadManager: Nullable<GamepadManager>;
  105952. /**
  105953. * Gets the gamepad manager associated with the scene
  105954. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105955. */
  105956. gamepadManager: GamepadManager;
  105957. }
  105958. /**
  105959. * Interface representing a free camera inputs manager
  105960. */
  105961. interface FreeCameraInputsManager {
  105962. /**
  105963. * Adds gamepad input support to the FreeCameraInputsManager.
  105964. * @returns the FreeCameraInputsManager
  105965. */
  105966. addGamepad(): FreeCameraInputsManager;
  105967. }
  105968. /**
  105969. * Interface representing an arc rotate camera inputs manager
  105970. */
  105971. interface ArcRotateCameraInputsManager {
  105972. /**
  105973. * Adds gamepad input support to the ArcRotateCamera InputManager.
  105974. * @returns the camera inputs manager
  105975. */
  105976. addGamepad(): ArcRotateCameraInputsManager;
  105977. }
  105978. /**
  105979. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  105980. */
  105981. export class GamepadSystemSceneComponent implements ISceneComponent {
  105982. /**
  105983. * The component name helpfull to identify the component in the list of scene components.
  105984. */
  105985. readonly name: string;
  105986. /**
  105987. * The scene the component belongs to.
  105988. */
  105989. scene: Scene;
  105990. /**
  105991. * Creates a new instance of the component for the given scene
  105992. * @param scene Defines the scene to register the component in
  105993. */
  105994. constructor(scene: Scene);
  105995. /**
  105996. * Registers the component in a given scene
  105997. */
  105998. register(): void;
  105999. /**
  106000. * Rebuilds the elements related to this component in case of
  106001. * context lost for instance.
  106002. */
  106003. rebuild(): void;
  106004. /**
  106005. * Disposes the component and the associated ressources
  106006. */
  106007. dispose(): void;
  106008. private _beforeCameraUpdate;
  106009. }
  106010. }
  106011. declare module BABYLON {
  106012. /**
  106013. * 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,
  106014. * which still works and will still be found in many Playgrounds.
  106015. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106016. */
  106017. export class UniversalCamera extends TouchCamera {
  106018. /**
  106019. * Defines the gamepad rotation sensiblity.
  106020. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106021. */
  106022. gamepadAngularSensibility: number;
  106023. /**
  106024. * Defines the gamepad move sensiblity.
  106025. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106026. */
  106027. gamepadMoveSensibility: number;
  106028. /**
  106029. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  106030. * which still works and will still be found in many Playgrounds.
  106031. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106032. * @param name Define the name of the camera in the scene
  106033. * @param position Define the start position of the camera in the scene
  106034. * @param scene Define the scene the camera belongs to
  106035. */
  106036. constructor(name: string, position: Vector3, scene: Scene);
  106037. /**
  106038. * Gets the current object class name.
  106039. * @return the class name
  106040. */
  106041. getClassName(): string;
  106042. }
  106043. }
  106044. declare module BABYLON {
  106045. /**
  106046. * This represents a FPS type of camera. This is only here for back compat purpose.
  106047. * Please use the UniversalCamera instead as both are identical.
  106048. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106049. */
  106050. export class GamepadCamera extends UniversalCamera {
  106051. /**
  106052. * Instantiates a new Gamepad Camera
  106053. * This represents a FPS type of camera. This is only here for back compat purpose.
  106054. * Please use the UniversalCamera instead as both are identical.
  106055. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106056. * @param name Define the name of the camera in the scene
  106057. * @param position Define the start position of the camera in the scene
  106058. * @param scene Define the scene the camera belongs to
  106059. */
  106060. constructor(name: string, position: Vector3, scene: Scene);
  106061. /**
  106062. * Gets the current object class name.
  106063. * @return the class name
  106064. */
  106065. getClassName(): string;
  106066. }
  106067. }
  106068. declare module BABYLON {
  106069. /** @hidden */
  106070. export var passPixelShader: {
  106071. name: string;
  106072. shader: string;
  106073. };
  106074. }
  106075. declare module BABYLON {
  106076. /** @hidden */
  106077. export var passCubePixelShader: {
  106078. name: string;
  106079. shader: string;
  106080. };
  106081. }
  106082. declare module BABYLON {
  106083. /**
  106084. * PassPostProcess which produces an output the same as it's input
  106085. */
  106086. export class PassPostProcess extends PostProcess {
  106087. /**
  106088. * Creates the PassPostProcess
  106089. * @param name The name of the effect.
  106090. * @param options The required width/height ratio to downsize to before computing the render pass.
  106091. * @param camera The camera to apply the render pass to.
  106092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106093. * @param engine The engine which the post process will be applied. (default: current engine)
  106094. * @param reusable If the post process can be reused on the same frame. (default: false)
  106095. * @param textureType The type of texture to be used when performing the post processing.
  106096. * @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)
  106097. */
  106098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106099. }
  106100. /**
  106101. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106102. */
  106103. export class PassCubePostProcess extends PostProcess {
  106104. private _face;
  106105. /**
  106106. * Gets or sets the cube face to display.
  106107. * * 0 is +X
  106108. * * 1 is -X
  106109. * * 2 is +Y
  106110. * * 3 is -Y
  106111. * * 4 is +Z
  106112. * * 5 is -Z
  106113. */
  106114. face: number;
  106115. /**
  106116. * Creates the PassCubePostProcess
  106117. * @param name The name of the effect.
  106118. * @param options The required width/height ratio to downsize to before computing the render pass.
  106119. * @param camera The camera to apply the render pass to.
  106120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106121. * @param engine The engine which the post process will be applied. (default: current engine)
  106122. * @param reusable If the post process can be reused on the same frame. (default: false)
  106123. * @param textureType The type of texture to be used when performing the post processing.
  106124. * @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)
  106125. */
  106126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106127. }
  106128. }
  106129. declare module BABYLON {
  106130. /** @hidden */
  106131. export var anaglyphPixelShader: {
  106132. name: string;
  106133. shader: string;
  106134. };
  106135. }
  106136. declare module BABYLON {
  106137. /**
  106138. * Postprocess used to generate anaglyphic rendering
  106139. */
  106140. export class AnaglyphPostProcess extends PostProcess {
  106141. private _passedProcess;
  106142. /**
  106143. * Creates a new AnaglyphPostProcess
  106144. * @param name defines postprocess name
  106145. * @param options defines creation options or target ratio scale
  106146. * @param rigCameras defines cameras using this postprocess
  106147. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106148. * @param engine defines hosting engine
  106149. * @param reusable defines if the postprocess will be reused multiple times per frame
  106150. */
  106151. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106152. }
  106153. }
  106154. declare module BABYLON {
  106155. /**
  106156. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106157. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106158. */
  106159. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106160. /**
  106161. * Creates a new AnaglyphArcRotateCamera
  106162. * @param name defines camera name
  106163. * @param alpha defines alpha angle (in radians)
  106164. * @param beta defines beta angle (in radians)
  106165. * @param radius defines radius
  106166. * @param target defines camera target
  106167. * @param interaxialDistance defines distance between each color axis
  106168. * @param scene defines the hosting scene
  106169. */
  106170. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106171. /**
  106172. * Gets camera class name
  106173. * @returns AnaglyphArcRotateCamera
  106174. */
  106175. getClassName(): string;
  106176. }
  106177. }
  106178. declare module BABYLON {
  106179. /**
  106180. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106181. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106182. */
  106183. export class AnaglyphFreeCamera extends FreeCamera {
  106184. /**
  106185. * Creates a new AnaglyphFreeCamera
  106186. * @param name defines camera name
  106187. * @param position defines initial position
  106188. * @param interaxialDistance defines distance between each color axis
  106189. * @param scene defines the hosting scene
  106190. */
  106191. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106192. /**
  106193. * Gets camera class name
  106194. * @returns AnaglyphFreeCamera
  106195. */
  106196. getClassName(): string;
  106197. }
  106198. }
  106199. declare module BABYLON {
  106200. /**
  106201. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106202. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106203. */
  106204. export class AnaglyphGamepadCamera extends GamepadCamera {
  106205. /**
  106206. * Creates a new AnaglyphGamepadCamera
  106207. * @param name defines camera name
  106208. * @param position defines initial position
  106209. * @param interaxialDistance defines distance between each color axis
  106210. * @param scene defines the hosting scene
  106211. */
  106212. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106213. /**
  106214. * Gets camera class name
  106215. * @returns AnaglyphGamepadCamera
  106216. */
  106217. getClassName(): string;
  106218. }
  106219. }
  106220. declare module BABYLON {
  106221. /**
  106222. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106223. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106224. */
  106225. export class AnaglyphUniversalCamera extends UniversalCamera {
  106226. /**
  106227. * Creates a new AnaglyphUniversalCamera
  106228. * @param name defines camera name
  106229. * @param position defines initial position
  106230. * @param interaxialDistance defines distance between each color axis
  106231. * @param scene defines the hosting scene
  106232. */
  106233. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106234. /**
  106235. * Gets camera class name
  106236. * @returns AnaglyphUniversalCamera
  106237. */
  106238. getClassName(): string;
  106239. }
  106240. }
  106241. declare module BABYLON {
  106242. /** @hidden */
  106243. export var stereoscopicInterlacePixelShader: {
  106244. name: string;
  106245. shader: string;
  106246. };
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106251. */
  106252. export class StereoscopicInterlacePostProcess extends PostProcess {
  106253. private _stepSize;
  106254. private _passedProcess;
  106255. /**
  106256. * Initializes a StereoscopicInterlacePostProcess
  106257. * @param name The name of the effect.
  106258. * @param rigCameras The rig cameras to be appled to the post process
  106259. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106260. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106261. * @param engine The engine which the post process will be applied. (default: current engine)
  106262. * @param reusable If the post process can be reused on the same frame. (default: false)
  106263. */
  106264. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106265. }
  106266. }
  106267. declare module BABYLON {
  106268. /**
  106269. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106270. * @see http://doc.babylonjs.com/features/cameras
  106271. */
  106272. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106273. /**
  106274. * Creates a new StereoscopicArcRotateCamera
  106275. * @param name defines camera name
  106276. * @param alpha defines alpha angle (in radians)
  106277. * @param beta defines beta angle (in radians)
  106278. * @param radius defines radius
  106279. * @param target defines camera target
  106280. * @param interaxialDistance defines distance between each color axis
  106281. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106282. * @param scene defines the hosting scene
  106283. */
  106284. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106285. /**
  106286. * Gets camera class name
  106287. * @returns StereoscopicArcRotateCamera
  106288. */
  106289. getClassName(): string;
  106290. }
  106291. }
  106292. declare module BABYLON {
  106293. /**
  106294. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106295. * @see http://doc.babylonjs.com/features/cameras
  106296. */
  106297. export class StereoscopicFreeCamera extends FreeCamera {
  106298. /**
  106299. * Creates a new StereoscopicFreeCamera
  106300. * @param name defines camera name
  106301. * @param position defines initial position
  106302. * @param interaxialDistance defines distance between each color axis
  106303. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106304. * @param scene defines the hosting scene
  106305. */
  106306. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106307. /**
  106308. * Gets camera class name
  106309. * @returns StereoscopicFreeCamera
  106310. */
  106311. getClassName(): string;
  106312. }
  106313. }
  106314. declare module BABYLON {
  106315. /**
  106316. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106317. * @see http://doc.babylonjs.com/features/cameras
  106318. */
  106319. export class StereoscopicGamepadCamera extends GamepadCamera {
  106320. /**
  106321. * Creates a new StereoscopicGamepadCamera
  106322. * @param name defines camera name
  106323. * @param position defines initial position
  106324. * @param interaxialDistance defines distance between each color axis
  106325. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106326. * @param scene defines the hosting scene
  106327. */
  106328. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106329. /**
  106330. * Gets camera class name
  106331. * @returns StereoscopicGamepadCamera
  106332. */
  106333. getClassName(): string;
  106334. }
  106335. }
  106336. declare module BABYLON {
  106337. /**
  106338. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106339. * @see http://doc.babylonjs.com/features/cameras
  106340. */
  106341. export class StereoscopicUniversalCamera extends UniversalCamera {
  106342. /**
  106343. * Creates a new StereoscopicUniversalCamera
  106344. * @param name defines camera name
  106345. * @param position defines initial position
  106346. * @param interaxialDistance defines distance between each color axis
  106347. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106348. * @param scene defines the hosting scene
  106349. */
  106350. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106351. /**
  106352. * Gets camera class name
  106353. * @returns StereoscopicUniversalCamera
  106354. */
  106355. getClassName(): string;
  106356. }
  106357. }
  106358. declare module BABYLON {
  106359. /**
  106360. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106361. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106362. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106363. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106364. */
  106365. export class VirtualJoysticksCamera extends FreeCamera {
  106366. /**
  106367. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106368. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106369. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106370. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106371. * @param name Define the name of the camera in the scene
  106372. * @param position Define the start position of the camera in the scene
  106373. * @param scene Define the scene the camera belongs to
  106374. */
  106375. constructor(name: string, position: Vector3, scene: Scene);
  106376. /**
  106377. * Gets the current object class name.
  106378. * @return the class name
  106379. */
  106380. getClassName(): string;
  106381. }
  106382. }
  106383. declare module BABYLON {
  106384. /**
  106385. * This represents all the required metrics to create a VR camera.
  106386. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106387. */
  106388. export class VRCameraMetrics {
  106389. /**
  106390. * Define the horizontal resolution off the screen.
  106391. */
  106392. hResolution: number;
  106393. /**
  106394. * Define the vertical resolution off the screen.
  106395. */
  106396. vResolution: number;
  106397. /**
  106398. * Define the horizontal screen size.
  106399. */
  106400. hScreenSize: number;
  106401. /**
  106402. * Define the vertical screen size.
  106403. */
  106404. vScreenSize: number;
  106405. /**
  106406. * Define the vertical screen center position.
  106407. */
  106408. vScreenCenter: number;
  106409. /**
  106410. * Define the distance of the eyes to the screen.
  106411. */
  106412. eyeToScreenDistance: number;
  106413. /**
  106414. * Define the distance between both lenses
  106415. */
  106416. lensSeparationDistance: number;
  106417. /**
  106418. * Define the distance between both viewer's eyes.
  106419. */
  106420. interpupillaryDistance: number;
  106421. /**
  106422. * Define the distortion factor of the VR postprocess.
  106423. * Please, touch with care.
  106424. */
  106425. distortionK: number[];
  106426. /**
  106427. * Define the chromatic aberration correction factors for the VR post process.
  106428. */
  106429. chromaAbCorrection: number[];
  106430. /**
  106431. * Define the scale factor of the post process.
  106432. * The smaller the better but the slower.
  106433. */
  106434. postProcessScaleFactor: number;
  106435. /**
  106436. * Define an offset for the lens center.
  106437. */
  106438. lensCenterOffset: number;
  106439. /**
  106440. * Define if the current vr camera should compensate the distortion of the lense or not.
  106441. */
  106442. compensateDistortion: boolean;
  106443. /**
  106444. * Defines if multiview should be enabled when rendering (Default: false)
  106445. */
  106446. multiviewEnabled: boolean;
  106447. /**
  106448. * Gets the rendering aspect ratio based on the provided resolutions.
  106449. */
  106450. readonly aspectRatio: number;
  106451. /**
  106452. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106453. */
  106454. readonly aspectRatioFov: number;
  106455. /**
  106456. * @hidden
  106457. */
  106458. readonly leftHMatrix: Matrix;
  106459. /**
  106460. * @hidden
  106461. */
  106462. readonly rightHMatrix: Matrix;
  106463. /**
  106464. * @hidden
  106465. */
  106466. readonly leftPreViewMatrix: Matrix;
  106467. /**
  106468. * @hidden
  106469. */
  106470. readonly rightPreViewMatrix: Matrix;
  106471. /**
  106472. * Get the default VRMetrics based on the most generic setup.
  106473. * @returns the default vr metrics
  106474. */
  106475. static GetDefault(): VRCameraMetrics;
  106476. }
  106477. }
  106478. declare module BABYLON {
  106479. /** @hidden */
  106480. export var vrDistortionCorrectionPixelShader: {
  106481. name: string;
  106482. shader: string;
  106483. };
  106484. }
  106485. declare module BABYLON {
  106486. /**
  106487. * VRDistortionCorrectionPostProcess used for mobile VR
  106488. */
  106489. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106490. private _isRightEye;
  106491. private _distortionFactors;
  106492. private _postProcessScaleFactor;
  106493. private _lensCenterOffset;
  106494. private _scaleIn;
  106495. private _scaleFactor;
  106496. private _lensCenter;
  106497. /**
  106498. * Initializes the VRDistortionCorrectionPostProcess
  106499. * @param name The name of the effect.
  106500. * @param camera The camera to apply the render pass to.
  106501. * @param isRightEye If this is for the right eye distortion
  106502. * @param vrMetrics All the required metrics for the VR camera
  106503. */
  106504. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106505. }
  106506. }
  106507. declare module BABYLON {
  106508. /**
  106509. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106510. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106511. */
  106512. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106513. /**
  106514. * Creates a new VRDeviceOrientationArcRotateCamera
  106515. * @param name defines camera name
  106516. * @param alpha defines the camera rotation along the logitudinal axis
  106517. * @param beta defines the camera rotation along the latitudinal axis
  106518. * @param radius defines the camera distance from its target
  106519. * @param target defines the camera target
  106520. * @param scene defines the scene the camera belongs to
  106521. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106522. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106523. */
  106524. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106525. /**
  106526. * Gets camera class name
  106527. * @returns VRDeviceOrientationArcRotateCamera
  106528. */
  106529. getClassName(): string;
  106530. }
  106531. }
  106532. declare module BABYLON {
  106533. /**
  106534. * Camera used to simulate VR rendering (based on FreeCamera)
  106535. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106536. */
  106537. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106538. /**
  106539. * Creates a new VRDeviceOrientationFreeCamera
  106540. * @param name defines camera name
  106541. * @param position defines the start position of the camera
  106542. * @param scene defines the scene the camera belongs to
  106543. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106544. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106545. */
  106546. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106547. /**
  106548. * Gets camera class name
  106549. * @returns VRDeviceOrientationFreeCamera
  106550. */
  106551. getClassName(): string;
  106552. }
  106553. }
  106554. declare module BABYLON {
  106555. /**
  106556. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106557. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106558. */
  106559. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106560. /**
  106561. * Creates a new VRDeviceOrientationGamepadCamera
  106562. * @param name defines camera name
  106563. * @param position defines the start position of the camera
  106564. * @param scene defines the scene the camera belongs to
  106565. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106566. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106567. */
  106568. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106569. /**
  106570. * Gets camera class name
  106571. * @returns VRDeviceOrientationGamepadCamera
  106572. */
  106573. getClassName(): string;
  106574. }
  106575. }
  106576. declare module BABYLON {
  106577. /**
  106578. * Base class of materials working in push mode in babylon JS
  106579. * @hidden
  106580. */
  106581. export class PushMaterial extends Material {
  106582. protected _activeEffect: Effect;
  106583. protected _normalMatrix: Matrix;
  106584. /**
  106585. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106586. * This means that the material can keep using a previous shader while a new one is being compiled.
  106587. * This is mostly used when shader parallel compilation is supported (true by default)
  106588. */
  106589. allowShaderHotSwapping: boolean;
  106590. constructor(name: string, scene: Scene);
  106591. getEffect(): Effect;
  106592. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106593. /**
  106594. * Binds the given world matrix to the active effect
  106595. *
  106596. * @param world the matrix to bind
  106597. */
  106598. bindOnlyWorldMatrix(world: Matrix): void;
  106599. /**
  106600. * Binds the given normal matrix to the active effect
  106601. *
  106602. * @param normalMatrix the matrix to bind
  106603. */
  106604. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106605. bind(world: Matrix, mesh?: Mesh): void;
  106606. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106607. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106608. }
  106609. }
  106610. declare module BABYLON {
  106611. /**
  106612. * This groups all the flags used to control the materials channel.
  106613. */
  106614. export class MaterialFlags {
  106615. private static _DiffuseTextureEnabled;
  106616. /**
  106617. * Are diffuse textures enabled in the application.
  106618. */
  106619. static DiffuseTextureEnabled: boolean;
  106620. private static _AmbientTextureEnabled;
  106621. /**
  106622. * Are ambient textures enabled in the application.
  106623. */
  106624. static AmbientTextureEnabled: boolean;
  106625. private static _OpacityTextureEnabled;
  106626. /**
  106627. * Are opacity textures enabled in the application.
  106628. */
  106629. static OpacityTextureEnabled: boolean;
  106630. private static _ReflectionTextureEnabled;
  106631. /**
  106632. * Are reflection textures enabled in the application.
  106633. */
  106634. static ReflectionTextureEnabled: boolean;
  106635. private static _EmissiveTextureEnabled;
  106636. /**
  106637. * Are emissive textures enabled in the application.
  106638. */
  106639. static EmissiveTextureEnabled: boolean;
  106640. private static _SpecularTextureEnabled;
  106641. /**
  106642. * Are specular textures enabled in the application.
  106643. */
  106644. static SpecularTextureEnabled: boolean;
  106645. private static _BumpTextureEnabled;
  106646. /**
  106647. * Are bump textures enabled in the application.
  106648. */
  106649. static BumpTextureEnabled: boolean;
  106650. private static _LightmapTextureEnabled;
  106651. /**
  106652. * Are lightmap textures enabled in the application.
  106653. */
  106654. static LightmapTextureEnabled: boolean;
  106655. private static _RefractionTextureEnabled;
  106656. /**
  106657. * Are refraction textures enabled in the application.
  106658. */
  106659. static RefractionTextureEnabled: boolean;
  106660. private static _ColorGradingTextureEnabled;
  106661. /**
  106662. * Are color grading textures enabled in the application.
  106663. */
  106664. static ColorGradingTextureEnabled: boolean;
  106665. private static _FresnelEnabled;
  106666. /**
  106667. * Are fresnels enabled in the application.
  106668. */
  106669. static FresnelEnabled: boolean;
  106670. private static _ClearCoatTextureEnabled;
  106671. /**
  106672. * Are clear coat textures enabled in the application.
  106673. */
  106674. static ClearCoatTextureEnabled: boolean;
  106675. private static _ClearCoatBumpTextureEnabled;
  106676. /**
  106677. * Are clear coat bump textures enabled in the application.
  106678. */
  106679. static ClearCoatBumpTextureEnabled: boolean;
  106680. private static _ClearCoatTintTextureEnabled;
  106681. /**
  106682. * Are clear coat tint textures enabled in the application.
  106683. */
  106684. static ClearCoatTintTextureEnabled: boolean;
  106685. private static _SheenTextureEnabled;
  106686. /**
  106687. * Are sheen textures enabled in the application.
  106688. */
  106689. static SheenTextureEnabled: boolean;
  106690. private static _AnisotropicTextureEnabled;
  106691. /**
  106692. * Are anisotropic textures enabled in the application.
  106693. */
  106694. static AnisotropicTextureEnabled: boolean;
  106695. private static _ThicknessTextureEnabled;
  106696. /**
  106697. * Are thickness textures enabled in the application.
  106698. */
  106699. static ThicknessTextureEnabled: boolean;
  106700. }
  106701. }
  106702. declare module BABYLON {
  106703. /** @hidden */
  106704. export var defaultFragmentDeclaration: {
  106705. name: string;
  106706. shader: string;
  106707. };
  106708. }
  106709. declare module BABYLON {
  106710. /** @hidden */
  106711. export var defaultUboDeclaration: {
  106712. name: string;
  106713. shader: string;
  106714. };
  106715. }
  106716. declare module BABYLON {
  106717. /** @hidden */
  106718. export var lightFragmentDeclaration: {
  106719. name: string;
  106720. shader: string;
  106721. };
  106722. }
  106723. declare module BABYLON {
  106724. /** @hidden */
  106725. export var lightUboDeclaration: {
  106726. name: string;
  106727. shader: string;
  106728. };
  106729. }
  106730. declare module BABYLON {
  106731. /** @hidden */
  106732. export var lightsFragmentFunctions: {
  106733. name: string;
  106734. shader: string;
  106735. };
  106736. }
  106737. declare module BABYLON {
  106738. /** @hidden */
  106739. export var shadowsFragmentFunctions: {
  106740. name: string;
  106741. shader: string;
  106742. };
  106743. }
  106744. declare module BABYLON {
  106745. /** @hidden */
  106746. export var fresnelFunction: {
  106747. name: string;
  106748. shader: string;
  106749. };
  106750. }
  106751. declare module BABYLON {
  106752. /** @hidden */
  106753. export var reflectionFunction: {
  106754. name: string;
  106755. shader: string;
  106756. };
  106757. }
  106758. declare module BABYLON {
  106759. /** @hidden */
  106760. export var bumpFragmentFunctions: {
  106761. name: string;
  106762. shader: string;
  106763. };
  106764. }
  106765. declare module BABYLON {
  106766. /** @hidden */
  106767. export var logDepthDeclaration: {
  106768. name: string;
  106769. shader: string;
  106770. };
  106771. }
  106772. declare module BABYLON {
  106773. /** @hidden */
  106774. export var bumpFragment: {
  106775. name: string;
  106776. shader: string;
  106777. };
  106778. }
  106779. declare module BABYLON {
  106780. /** @hidden */
  106781. export var depthPrePass: {
  106782. name: string;
  106783. shader: string;
  106784. };
  106785. }
  106786. declare module BABYLON {
  106787. /** @hidden */
  106788. export var lightFragment: {
  106789. name: string;
  106790. shader: string;
  106791. };
  106792. }
  106793. declare module BABYLON {
  106794. /** @hidden */
  106795. export var logDepthFragment: {
  106796. name: string;
  106797. shader: string;
  106798. };
  106799. }
  106800. declare module BABYLON {
  106801. /** @hidden */
  106802. export var defaultPixelShader: {
  106803. name: string;
  106804. shader: string;
  106805. };
  106806. }
  106807. declare module BABYLON {
  106808. /** @hidden */
  106809. export var defaultVertexDeclaration: {
  106810. name: string;
  106811. shader: string;
  106812. };
  106813. }
  106814. declare module BABYLON {
  106815. /** @hidden */
  106816. export var bumpVertexDeclaration: {
  106817. name: string;
  106818. shader: string;
  106819. };
  106820. }
  106821. declare module BABYLON {
  106822. /** @hidden */
  106823. export var bumpVertex: {
  106824. name: string;
  106825. shader: string;
  106826. };
  106827. }
  106828. declare module BABYLON {
  106829. /** @hidden */
  106830. export var fogVertex: {
  106831. name: string;
  106832. shader: string;
  106833. };
  106834. }
  106835. declare module BABYLON {
  106836. /** @hidden */
  106837. export var shadowsVertex: {
  106838. name: string;
  106839. shader: string;
  106840. };
  106841. }
  106842. declare module BABYLON {
  106843. /** @hidden */
  106844. export var pointCloudVertex: {
  106845. name: string;
  106846. shader: string;
  106847. };
  106848. }
  106849. declare module BABYLON {
  106850. /** @hidden */
  106851. export var logDepthVertex: {
  106852. name: string;
  106853. shader: string;
  106854. };
  106855. }
  106856. declare module BABYLON {
  106857. /** @hidden */
  106858. export var defaultVertexShader: {
  106859. name: string;
  106860. shader: string;
  106861. };
  106862. }
  106863. declare module BABYLON {
  106864. /** @hidden */
  106865. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106866. MAINUV1: boolean;
  106867. MAINUV2: boolean;
  106868. DIFFUSE: boolean;
  106869. DIFFUSEDIRECTUV: number;
  106870. AMBIENT: boolean;
  106871. AMBIENTDIRECTUV: number;
  106872. OPACITY: boolean;
  106873. OPACITYDIRECTUV: number;
  106874. OPACITYRGB: boolean;
  106875. REFLECTION: boolean;
  106876. EMISSIVE: boolean;
  106877. EMISSIVEDIRECTUV: number;
  106878. SPECULAR: boolean;
  106879. SPECULARDIRECTUV: number;
  106880. BUMP: boolean;
  106881. BUMPDIRECTUV: number;
  106882. PARALLAX: boolean;
  106883. PARALLAXOCCLUSION: boolean;
  106884. SPECULAROVERALPHA: boolean;
  106885. CLIPPLANE: boolean;
  106886. CLIPPLANE2: boolean;
  106887. CLIPPLANE3: boolean;
  106888. CLIPPLANE4: boolean;
  106889. ALPHATEST: boolean;
  106890. DEPTHPREPASS: boolean;
  106891. ALPHAFROMDIFFUSE: boolean;
  106892. POINTSIZE: boolean;
  106893. FOG: boolean;
  106894. SPECULARTERM: boolean;
  106895. DIFFUSEFRESNEL: boolean;
  106896. OPACITYFRESNEL: boolean;
  106897. REFLECTIONFRESNEL: boolean;
  106898. REFRACTIONFRESNEL: boolean;
  106899. EMISSIVEFRESNEL: boolean;
  106900. FRESNEL: boolean;
  106901. NORMAL: boolean;
  106902. UV1: boolean;
  106903. UV2: boolean;
  106904. VERTEXCOLOR: boolean;
  106905. VERTEXALPHA: boolean;
  106906. NUM_BONE_INFLUENCERS: number;
  106907. BonesPerMesh: number;
  106908. BONETEXTURE: boolean;
  106909. INSTANCES: boolean;
  106910. GLOSSINESS: boolean;
  106911. ROUGHNESS: boolean;
  106912. EMISSIVEASILLUMINATION: boolean;
  106913. LINKEMISSIVEWITHDIFFUSE: boolean;
  106914. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106915. LIGHTMAP: boolean;
  106916. LIGHTMAPDIRECTUV: number;
  106917. OBJECTSPACE_NORMALMAP: boolean;
  106918. USELIGHTMAPASSHADOWMAP: boolean;
  106919. REFLECTIONMAP_3D: boolean;
  106920. REFLECTIONMAP_SPHERICAL: boolean;
  106921. REFLECTIONMAP_PLANAR: boolean;
  106922. REFLECTIONMAP_CUBIC: boolean;
  106923. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106924. REFLECTIONMAP_PROJECTION: boolean;
  106925. REFLECTIONMAP_SKYBOX: boolean;
  106926. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106927. REFLECTIONMAP_EXPLICIT: boolean;
  106928. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106929. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106930. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106931. INVERTCUBICMAP: boolean;
  106932. LOGARITHMICDEPTH: boolean;
  106933. REFRACTION: boolean;
  106934. REFRACTIONMAP_3D: boolean;
  106935. REFLECTIONOVERALPHA: boolean;
  106936. TWOSIDEDLIGHTING: boolean;
  106937. SHADOWFLOAT: boolean;
  106938. MORPHTARGETS: boolean;
  106939. MORPHTARGETS_NORMAL: boolean;
  106940. MORPHTARGETS_TANGENT: boolean;
  106941. MORPHTARGETS_UV: boolean;
  106942. NUM_MORPH_INFLUENCERS: number;
  106943. NONUNIFORMSCALING: boolean;
  106944. PREMULTIPLYALPHA: boolean;
  106945. IMAGEPROCESSING: boolean;
  106946. VIGNETTE: boolean;
  106947. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106948. VIGNETTEBLENDMODEOPAQUE: boolean;
  106949. TONEMAPPING: boolean;
  106950. TONEMAPPING_ACES: boolean;
  106951. CONTRAST: boolean;
  106952. COLORCURVES: boolean;
  106953. COLORGRADING: boolean;
  106954. COLORGRADING3D: boolean;
  106955. SAMPLER3DGREENDEPTH: boolean;
  106956. SAMPLER3DBGRMAP: boolean;
  106957. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106958. MULTIVIEW: boolean;
  106959. /**
  106960. * If the reflection texture on this material is in linear color space
  106961. * @hidden
  106962. */
  106963. IS_REFLECTION_LINEAR: boolean;
  106964. /**
  106965. * If the refraction texture on this material is in linear color space
  106966. * @hidden
  106967. */
  106968. IS_REFRACTION_LINEAR: boolean;
  106969. EXPOSURE: boolean;
  106970. constructor();
  106971. setReflectionMode(modeToEnable: string): void;
  106972. }
  106973. /**
  106974. * This is the default material used in Babylon. It is the best trade off between quality
  106975. * and performances.
  106976. * @see http://doc.babylonjs.com/babylon101/materials
  106977. */
  106978. export class StandardMaterial extends PushMaterial {
  106979. private _diffuseTexture;
  106980. /**
  106981. * The basic texture of the material as viewed under a light.
  106982. */
  106983. diffuseTexture: Nullable<BaseTexture>;
  106984. private _ambientTexture;
  106985. /**
  106986. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  106987. */
  106988. ambientTexture: Nullable<BaseTexture>;
  106989. private _opacityTexture;
  106990. /**
  106991. * Define the transparency of the material from a texture.
  106992. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  106993. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  106994. */
  106995. opacityTexture: Nullable<BaseTexture>;
  106996. private _reflectionTexture;
  106997. /**
  106998. * Define the texture used to display the reflection.
  106999. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107000. */
  107001. reflectionTexture: Nullable<BaseTexture>;
  107002. private _emissiveTexture;
  107003. /**
  107004. * Define texture of the material as if self lit.
  107005. * This will be mixed in the final result even in the absence of light.
  107006. */
  107007. emissiveTexture: Nullable<BaseTexture>;
  107008. private _specularTexture;
  107009. /**
  107010. * Define how the color and intensity of the highlight given by the light in the material.
  107011. */
  107012. specularTexture: Nullable<BaseTexture>;
  107013. private _bumpTexture;
  107014. /**
  107015. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107016. * 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.
  107017. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107018. */
  107019. bumpTexture: Nullable<BaseTexture>;
  107020. private _lightmapTexture;
  107021. /**
  107022. * Complex lighting can be computationally expensive to compute at runtime.
  107023. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107024. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107025. */
  107026. lightmapTexture: Nullable<BaseTexture>;
  107027. private _refractionTexture;
  107028. /**
  107029. * Define the texture used to display the refraction.
  107030. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107031. */
  107032. refractionTexture: Nullable<BaseTexture>;
  107033. /**
  107034. * The color of the material lit by the environmental background lighting.
  107035. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107036. */
  107037. ambientColor: Color3;
  107038. /**
  107039. * The basic color of the material as viewed under a light.
  107040. */
  107041. diffuseColor: Color3;
  107042. /**
  107043. * Define how the color and intensity of the highlight given by the light in the material.
  107044. */
  107045. specularColor: Color3;
  107046. /**
  107047. * Define the color of the material as if self lit.
  107048. * This will be mixed in the final result even in the absence of light.
  107049. */
  107050. emissiveColor: Color3;
  107051. /**
  107052. * Defines how sharp are the highlights in the material.
  107053. * The bigger the value the sharper giving a more glossy feeling to the result.
  107054. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107055. */
  107056. specularPower: number;
  107057. private _useAlphaFromDiffuseTexture;
  107058. /**
  107059. * Does the transparency come from the diffuse texture alpha channel.
  107060. */
  107061. useAlphaFromDiffuseTexture: boolean;
  107062. private _useEmissiveAsIllumination;
  107063. /**
  107064. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107065. */
  107066. useEmissiveAsIllumination: boolean;
  107067. private _linkEmissiveWithDiffuse;
  107068. /**
  107069. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107070. * the emissive level when the final color is close to one.
  107071. */
  107072. linkEmissiveWithDiffuse: boolean;
  107073. private _useSpecularOverAlpha;
  107074. /**
  107075. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107076. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107077. */
  107078. useSpecularOverAlpha: boolean;
  107079. private _useReflectionOverAlpha;
  107080. /**
  107081. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107082. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107083. */
  107084. useReflectionOverAlpha: boolean;
  107085. private _disableLighting;
  107086. /**
  107087. * Does lights from the scene impacts this material.
  107088. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107089. */
  107090. disableLighting: boolean;
  107091. private _useObjectSpaceNormalMap;
  107092. /**
  107093. * Allows using an object space normal map (instead of tangent space).
  107094. */
  107095. useObjectSpaceNormalMap: boolean;
  107096. private _useParallax;
  107097. /**
  107098. * Is parallax enabled or not.
  107099. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107100. */
  107101. useParallax: boolean;
  107102. private _useParallaxOcclusion;
  107103. /**
  107104. * Is parallax occlusion enabled or not.
  107105. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107106. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107107. */
  107108. useParallaxOcclusion: boolean;
  107109. /**
  107110. * 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.
  107111. */
  107112. parallaxScaleBias: number;
  107113. private _roughness;
  107114. /**
  107115. * Helps to define how blurry the reflections should appears in the material.
  107116. */
  107117. roughness: number;
  107118. /**
  107119. * In case of refraction, define the value of the index of refraction.
  107120. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107121. */
  107122. indexOfRefraction: number;
  107123. /**
  107124. * Invert the refraction texture alongside the y axis.
  107125. * It can be useful with procedural textures or probe for instance.
  107126. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107127. */
  107128. invertRefractionY: boolean;
  107129. /**
  107130. * Defines the alpha limits in alpha test mode.
  107131. */
  107132. alphaCutOff: number;
  107133. private _useLightmapAsShadowmap;
  107134. /**
  107135. * In case of light mapping, define whether the map contains light or shadow informations.
  107136. */
  107137. useLightmapAsShadowmap: boolean;
  107138. private _diffuseFresnelParameters;
  107139. /**
  107140. * Define the diffuse fresnel parameters of the material.
  107141. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107142. */
  107143. diffuseFresnelParameters: FresnelParameters;
  107144. private _opacityFresnelParameters;
  107145. /**
  107146. * Define the opacity fresnel parameters of the material.
  107147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107148. */
  107149. opacityFresnelParameters: FresnelParameters;
  107150. private _reflectionFresnelParameters;
  107151. /**
  107152. * Define the reflection fresnel parameters of the material.
  107153. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107154. */
  107155. reflectionFresnelParameters: FresnelParameters;
  107156. private _refractionFresnelParameters;
  107157. /**
  107158. * Define the refraction fresnel parameters of the material.
  107159. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107160. */
  107161. refractionFresnelParameters: FresnelParameters;
  107162. private _emissiveFresnelParameters;
  107163. /**
  107164. * Define the emissive fresnel parameters of the material.
  107165. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107166. */
  107167. emissiveFresnelParameters: FresnelParameters;
  107168. private _useReflectionFresnelFromSpecular;
  107169. /**
  107170. * If true automatically deducts the fresnels values from the material specularity.
  107171. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107172. */
  107173. useReflectionFresnelFromSpecular: boolean;
  107174. private _useGlossinessFromSpecularMapAlpha;
  107175. /**
  107176. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107177. */
  107178. useGlossinessFromSpecularMapAlpha: boolean;
  107179. private _maxSimultaneousLights;
  107180. /**
  107181. * Defines the maximum number of lights that can be used in the material
  107182. */
  107183. maxSimultaneousLights: number;
  107184. private _invertNormalMapX;
  107185. /**
  107186. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107187. */
  107188. invertNormalMapX: boolean;
  107189. private _invertNormalMapY;
  107190. /**
  107191. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107192. */
  107193. invertNormalMapY: boolean;
  107194. private _twoSidedLighting;
  107195. /**
  107196. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107197. */
  107198. twoSidedLighting: boolean;
  107199. /**
  107200. * Default configuration related to image processing available in the standard Material.
  107201. */
  107202. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107203. /**
  107204. * Gets the image processing configuration used either in this material.
  107205. */
  107206. /**
  107207. * Sets the Default image processing configuration used either in the this material.
  107208. *
  107209. * If sets to null, the scene one is in use.
  107210. */
  107211. imageProcessingConfiguration: ImageProcessingConfiguration;
  107212. /**
  107213. * Keep track of the image processing observer to allow dispose and replace.
  107214. */
  107215. private _imageProcessingObserver;
  107216. /**
  107217. * Attaches a new image processing configuration to the Standard Material.
  107218. * @param configuration
  107219. */
  107220. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107221. /**
  107222. * Gets wether the color curves effect is enabled.
  107223. */
  107224. /**
  107225. * Sets wether the color curves effect is enabled.
  107226. */
  107227. cameraColorCurvesEnabled: boolean;
  107228. /**
  107229. * Gets wether the color grading effect is enabled.
  107230. */
  107231. /**
  107232. * Gets wether the color grading effect is enabled.
  107233. */
  107234. cameraColorGradingEnabled: boolean;
  107235. /**
  107236. * Gets wether tonemapping is enabled or not.
  107237. */
  107238. /**
  107239. * Sets wether tonemapping is enabled or not
  107240. */
  107241. cameraToneMappingEnabled: boolean;
  107242. /**
  107243. * The camera exposure used on this material.
  107244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107245. * This corresponds to a photographic exposure.
  107246. */
  107247. /**
  107248. * The camera exposure used on this material.
  107249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107250. * This corresponds to a photographic exposure.
  107251. */
  107252. cameraExposure: number;
  107253. /**
  107254. * Gets The camera contrast used on this material.
  107255. */
  107256. /**
  107257. * Sets The camera contrast used on this material.
  107258. */
  107259. cameraContrast: number;
  107260. /**
  107261. * Gets the Color Grading 2D Lookup Texture.
  107262. */
  107263. /**
  107264. * Sets the Color Grading 2D Lookup Texture.
  107265. */
  107266. cameraColorGradingTexture: Nullable<BaseTexture>;
  107267. /**
  107268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107270. * 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;
  107271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107272. */
  107273. /**
  107274. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107275. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107276. * 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;
  107277. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107278. */
  107279. cameraColorCurves: Nullable<ColorCurves>;
  107280. /**
  107281. * Custom callback helping to override the default shader used in the material.
  107282. */
  107283. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107284. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107285. protected _worldViewProjectionMatrix: Matrix;
  107286. protected _globalAmbientColor: Color3;
  107287. protected _useLogarithmicDepth: boolean;
  107288. protected _rebuildInParallel: boolean;
  107289. /**
  107290. * Instantiates a new standard material.
  107291. * This is the default material used in Babylon. It is the best trade off between quality
  107292. * and performances.
  107293. * @see http://doc.babylonjs.com/babylon101/materials
  107294. * @param name Define the name of the material in the scene
  107295. * @param scene Define the scene the material belong to
  107296. */
  107297. constructor(name: string, scene: Scene);
  107298. /**
  107299. * Gets a boolean indicating that current material needs to register RTT
  107300. */
  107301. readonly hasRenderTargetTextures: boolean;
  107302. /**
  107303. * Gets the current class name of the material e.g. "StandardMaterial"
  107304. * Mainly use in serialization.
  107305. * @returns the class name
  107306. */
  107307. getClassName(): string;
  107308. /**
  107309. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107310. * You can try switching to logarithmic depth.
  107311. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107312. */
  107313. useLogarithmicDepth: boolean;
  107314. /**
  107315. * Specifies if the material will require alpha blending
  107316. * @returns a boolean specifying if alpha blending is needed
  107317. */
  107318. needAlphaBlending(): boolean;
  107319. /**
  107320. * Specifies if this material should be rendered in alpha test mode
  107321. * @returns a boolean specifying if an alpha test is needed.
  107322. */
  107323. needAlphaTesting(): boolean;
  107324. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107325. /**
  107326. * Get the texture used for alpha test purpose.
  107327. * @returns the diffuse texture in case of the standard material.
  107328. */
  107329. getAlphaTestTexture(): Nullable<BaseTexture>;
  107330. /**
  107331. * Get if the submesh is ready to be used and all its information available.
  107332. * Child classes can use it to update shaders
  107333. * @param mesh defines the mesh to check
  107334. * @param subMesh defines which submesh to check
  107335. * @param useInstances specifies that instances should be used
  107336. * @returns a boolean indicating that the submesh is ready or not
  107337. */
  107338. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107339. /**
  107340. * Builds the material UBO layouts.
  107341. * Used internally during the effect preparation.
  107342. */
  107343. buildUniformLayout(): void;
  107344. /**
  107345. * Unbinds the material from the mesh
  107346. */
  107347. unbind(): void;
  107348. /**
  107349. * Binds the submesh to this material by preparing the effect and shader to draw
  107350. * @param world defines the world transformation matrix
  107351. * @param mesh defines the mesh containing the submesh
  107352. * @param subMesh defines the submesh to bind the material to
  107353. */
  107354. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107355. /**
  107356. * Get the list of animatables in the material.
  107357. * @returns the list of animatables object used in the material
  107358. */
  107359. getAnimatables(): IAnimatable[];
  107360. /**
  107361. * Gets the active textures from the material
  107362. * @returns an array of textures
  107363. */
  107364. getActiveTextures(): BaseTexture[];
  107365. /**
  107366. * Specifies if the material uses a texture
  107367. * @param texture defines the texture to check against the material
  107368. * @returns a boolean specifying if the material uses the texture
  107369. */
  107370. hasTexture(texture: BaseTexture): boolean;
  107371. /**
  107372. * Disposes the material
  107373. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107374. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107375. */
  107376. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107377. /**
  107378. * Makes a duplicate of the material, and gives it a new name
  107379. * @param name defines the new name for the duplicated material
  107380. * @returns the cloned material
  107381. */
  107382. clone(name: string): StandardMaterial;
  107383. /**
  107384. * Serializes this material in a JSON representation
  107385. * @returns the serialized material object
  107386. */
  107387. serialize(): any;
  107388. /**
  107389. * Creates a standard material from parsed material data
  107390. * @param source defines the JSON representation of the material
  107391. * @param scene defines the hosting scene
  107392. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107393. * @returns a new standard material
  107394. */
  107395. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107396. /**
  107397. * Are diffuse textures enabled in the application.
  107398. */
  107399. static DiffuseTextureEnabled: boolean;
  107400. /**
  107401. * Are ambient textures enabled in the application.
  107402. */
  107403. static AmbientTextureEnabled: boolean;
  107404. /**
  107405. * Are opacity textures enabled in the application.
  107406. */
  107407. static OpacityTextureEnabled: boolean;
  107408. /**
  107409. * Are reflection textures enabled in the application.
  107410. */
  107411. static ReflectionTextureEnabled: boolean;
  107412. /**
  107413. * Are emissive textures enabled in the application.
  107414. */
  107415. static EmissiveTextureEnabled: boolean;
  107416. /**
  107417. * Are specular textures enabled in the application.
  107418. */
  107419. static SpecularTextureEnabled: boolean;
  107420. /**
  107421. * Are bump textures enabled in the application.
  107422. */
  107423. static BumpTextureEnabled: boolean;
  107424. /**
  107425. * Are lightmap textures enabled in the application.
  107426. */
  107427. static LightmapTextureEnabled: boolean;
  107428. /**
  107429. * Are refraction textures enabled in the application.
  107430. */
  107431. static RefractionTextureEnabled: boolean;
  107432. /**
  107433. * Are color grading textures enabled in the application.
  107434. */
  107435. static ColorGradingTextureEnabled: boolean;
  107436. /**
  107437. * Are fresnels enabled in the application.
  107438. */
  107439. static FresnelEnabled: boolean;
  107440. }
  107441. }
  107442. declare module BABYLON {
  107443. /** @hidden */
  107444. export var imageProcessingPixelShader: {
  107445. name: string;
  107446. shader: string;
  107447. };
  107448. }
  107449. declare module BABYLON {
  107450. /**
  107451. * ImageProcessingPostProcess
  107452. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107453. */
  107454. export class ImageProcessingPostProcess extends PostProcess {
  107455. /**
  107456. * Default configuration related to image processing available in the PBR Material.
  107457. */
  107458. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107459. /**
  107460. * Gets the image processing configuration used either in this material.
  107461. */
  107462. /**
  107463. * Sets the Default image processing configuration used either in the this material.
  107464. *
  107465. * If sets to null, the scene one is in use.
  107466. */
  107467. imageProcessingConfiguration: ImageProcessingConfiguration;
  107468. /**
  107469. * Keep track of the image processing observer to allow dispose and replace.
  107470. */
  107471. private _imageProcessingObserver;
  107472. /**
  107473. * Attaches a new image processing configuration to the PBR Material.
  107474. * @param configuration
  107475. */
  107476. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107477. /**
  107478. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107479. */
  107480. /**
  107481. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107482. */
  107483. colorCurves: Nullable<ColorCurves>;
  107484. /**
  107485. * Gets wether the color curves effect is enabled.
  107486. */
  107487. /**
  107488. * Sets wether the color curves effect is enabled.
  107489. */
  107490. colorCurvesEnabled: boolean;
  107491. /**
  107492. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107493. */
  107494. /**
  107495. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107496. */
  107497. colorGradingTexture: Nullable<BaseTexture>;
  107498. /**
  107499. * Gets wether the color grading effect is enabled.
  107500. */
  107501. /**
  107502. * Gets wether the color grading effect is enabled.
  107503. */
  107504. colorGradingEnabled: boolean;
  107505. /**
  107506. * Gets exposure used in the effect.
  107507. */
  107508. /**
  107509. * Sets exposure used in the effect.
  107510. */
  107511. exposure: number;
  107512. /**
  107513. * Gets wether tonemapping is enabled or not.
  107514. */
  107515. /**
  107516. * Sets wether tonemapping is enabled or not
  107517. */
  107518. toneMappingEnabled: boolean;
  107519. /**
  107520. * Gets the type of tone mapping effect.
  107521. */
  107522. /**
  107523. * Sets the type of tone mapping effect.
  107524. */
  107525. toneMappingType: number;
  107526. /**
  107527. * Gets contrast used in the effect.
  107528. */
  107529. /**
  107530. * Sets contrast used in the effect.
  107531. */
  107532. contrast: number;
  107533. /**
  107534. * Gets Vignette stretch size.
  107535. */
  107536. /**
  107537. * Sets Vignette stretch size.
  107538. */
  107539. vignetteStretch: number;
  107540. /**
  107541. * Gets Vignette centre X Offset.
  107542. */
  107543. /**
  107544. * Sets Vignette centre X Offset.
  107545. */
  107546. vignetteCentreX: number;
  107547. /**
  107548. * Gets Vignette centre Y Offset.
  107549. */
  107550. /**
  107551. * Sets Vignette centre Y Offset.
  107552. */
  107553. vignetteCentreY: number;
  107554. /**
  107555. * Gets Vignette weight or intensity of the vignette effect.
  107556. */
  107557. /**
  107558. * Sets Vignette weight or intensity of the vignette effect.
  107559. */
  107560. vignetteWeight: number;
  107561. /**
  107562. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107563. * if vignetteEnabled is set to true.
  107564. */
  107565. /**
  107566. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107567. * if vignetteEnabled is set to true.
  107568. */
  107569. vignetteColor: Color4;
  107570. /**
  107571. * Gets Camera field of view used by the Vignette effect.
  107572. */
  107573. /**
  107574. * Sets Camera field of view used by the Vignette effect.
  107575. */
  107576. vignetteCameraFov: number;
  107577. /**
  107578. * Gets the vignette blend mode allowing different kind of effect.
  107579. */
  107580. /**
  107581. * Sets the vignette blend mode allowing different kind of effect.
  107582. */
  107583. vignetteBlendMode: number;
  107584. /**
  107585. * Gets wether the vignette effect is enabled.
  107586. */
  107587. /**
  107588. * Sets wether the vignette effect is enabled.
  107589. */
  107590. vignetteEnabled: boolean;
  107591. private _fromLinearSpace;
  107592. /**
  107593. * Gets wether the input of the processing is in Gamma or Linear Space.
  107594. */
  107595. /**
  107596. * Sets wether the input of the processing is in Gamma or Linear Space.
  107597. */
  107598. fromLinearSpace: boolean;
  107599. /**
  107600. * Defines cache preventing GC.
  107601. */
  107602. private _defines;
  107603. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107604. /**
  107605. * "ImageProcessingPostProcess"
  107606. * @returns "ImageProcessingPostProcess"
  107607. */
  107608. getClassName(): string;
  107609. protected _updateParameters(): void;
  107610. dispose(camera?: Camera): void;
  107611. }
  107612. }
  107613. declare module BABYLON {
  107614. /**
  107615. * Class containing static functions to help procedurally build meshes
  107616. */
  107617. export class GroundBuilder {
  107618. /**
  107619. * Creates a ground mesh
  107620. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107621. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107622. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107623. * @param name defines the name of the mesh
  107624. * @param options defines the options used to create the mesh
  107625. * @param scene defines the hosting scene
  107626. * @returns the ground mesh
  107627. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107628. */
  107629. static CreateGround(name: string, options: {
  107630. width?: number;
  107631. height?: number;
  107632. subdivisions?: number;
  107633. subdivisionsX?: number;
  107634. subdivisionsY?: number;
  107635. updatable?: boolean;
  107636. }, scene: any): Mesh;
  107637. /**
  107638. * Creates a tiled ground mesh
  107639. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107640. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107641. * * 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
  107642. * * 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
  107643. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107644. * @param name defines the name of the mesh
  107645. * @param options defines the options used to create the mesh
  107646. * @param scene defines the hosting scene
  107647. * @returns the tiled ground mesh
  107648. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107649. */
  107650. static CreateTiledGround(name: string, options: {
  107651. xmin: number;
  107652. zmin: number;
  107653. xmax: number;
  107654. zmax: number;
  107655. subdivisions?: {
  107656. w: number;
  107657. h: number;
  107658. };
  107659. precision?: {
  107660. w: number;
  107661. h: number;
  107662. };
  107663. updatable?: boolean;
  107664. }, scene?: Nullable<Scene>): Mesh;
  107665. /**
  107666. * Creates a ground mesh from a height map
  107667. * * The parameter `url` sets the URL of the height map image resource.
  107668. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107669. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107670. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107671. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107672. * * 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.
  107673. * * 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).
  107674. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107676. * @param name defines the name of the mesh
  107677. * @param url defines the url to the height map
  107678. * @param options defines the options used to create the mesh
  107679. * @param scene defines the hosting scene
  107680. * @returns the ground mesh
  107681. * @see https://doc.babylonjs.com/babylon101/height_map
  107682. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107683. */
  107684. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107685. width?: number;
  107686. height?: number;
  107687. subdivisions?: number;
  107688. minHeight?: number;
  107689. maxHeight?: number;
  107690. colorFilter?: Color3;
  107691. alphaFilter?: number;
  107692. updatable?: boolean;
  107693. onReady?: (mesh: GroundMesh) => void;
  107694. }, scene?: Nullable<Scene>): GroundMesh;
  107695. }
  107696. }
  107697. declare module BABYLON {
  107698. /**
  107699. * Class containing static functions to help procedurally build meshes
  107700. */
  107701. export class TorusBuilder {
  107702. /**
  107703. * Creates a torus mesh
  107704. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107705. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107706. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107707. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107708. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107709. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107710. * @param name defines the name of the mesh
  107711. * @param options defines the options used to create the mesh
  107712. * @param scene defines the hosting scene
  107713. * @returns the torus mesh
  107714. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107715. */
  107716. static CreateTorus(name: string, options: {
  107717. diameter?: number;
  107718. thickness?: number;
  107719. tessellation?: number;
  107720. updatable?: boolean;
  107721. sideOrientation?: number;
  107722. frontUVs?: Vector4;
  107723. backUVs?: Vector4;
  107724. }, scene: any): Mesh;
  107725. }
  107726. }
  107727. declare module BABYLON {
  107728. /**
  107729. * Class containing static functions to help procedurally build meshes
  107730. */
  107731. export class CylinderBuilder {
  107732. /**
  107733. * Creates a cylinder or a cone mesh
  107734. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107735. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107736. * * 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.
  107737. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107738. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107739. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107740. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107741. * * 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).
  107742. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107743. * * 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).
  107744. * * 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
  107745. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107746. * * 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
  107747. * * 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.
  107748. * * If `enclose` is false, a ring surface is one element.
  107749. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107750. * * 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
  107751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107754. * @param name defines the name of the mesh
  107755. * @param options defines the options used to create the mesh
  107756. * @param scene defines the hosting scene
  107757. * @returns the cylinder mesh
  107758. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107759. */
  107760. static CreateCylinder(name: string, options: {
  107761. height?: number;
  107762. diameterTop?: number;
  107763. diameterBottom?: number;
  107764. diameter?: number;
  107765. tessellation?: number;
  107766. subdivisions?: number;
  107767. arc?: number;
  107768. faceColors?: Color4[];
  107769. faceUV?: Vector4[];
  107770. updatable?: boolean;
  107771. hasRings?: boolean;
  107772. enclose?: boolean;
  107773. cap?: number;
  107774. sideOrientation?: number;
  107775. frontUVs?: Vector4;
  107776. backUVs?: Vector4;
  107777. }, scene: any): Mesh;
  107778. }
  107779. }
  107780. declare module BABYLON {
  107781. /**
  107782. * Options to modify the vr teleportation behavior.
  107783. */
  107784. export interface VRTeleportationOptions {
  107785. /**
  107786. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107787. */
  107788. floorMeshName?: string;
  107789. /**
  107790. * A list of meshes to be used as the teleportation floor. (default: empty)
  107791. */
  107792. floorMeshes?: Mesh[];
  107793. }
  107794. /**
  107795. * Options to modify the vr experience helper's behavior.
  107796. */
  107797. export interface VRExperienceHelperOptions extends WebVROptions {
  107798. /**
  107799. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107800. */
  107801. createDeviceOrientationCamera?: boolean;
  107802. /**
  107803. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107804. */
  107805. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107806. /**
  107807. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107808. */
  107809. laserToggle?: boolean;
  107810. /**
  107811. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107812. */
  107813. floorMeshes?: Mesh[];
  107814. /**
  107815. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107816. */
  107817. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107818. }
  107819. /**
  107820. * Event containing information after VR has been entered
  107821. */
  107822. export class OnAfterEnteringVRObservableEvent {
  107823. /**
  107824. * If entering vr was successful
  107825. */
  107826. success: boolean;
  107827. }
  107828. /**
  107829. * Helps to quickly add VR support to an existing scene.
  107830. * See http://doc.babylonjs.com/how_to/webvr_helper
  107831. */
  107832. export class VRExperienceHelper {
  107833. /** Options to modify the vr experience helper's behavior. */
  107834. webVROptions: VRExperienceHelperOptions;
  107835. private _scene;
  107836. private _position;
  107837. private _btnVR;
  107838. private _btnVRDisplayed;
  107839. private _webVRsupported;
  107840. private _webVRready;
  107841. private _webVRrequesting;
  107842. private _webVRpresenting;
  107843. private _hasEnteredVR;
  107844. private _fullscreenVRpresenting;
  107845. private _canvas;
  107846. private _webVRCamera;
  107847. private _vrDeviceOrientationCamera;
  107848. private _deviceOrientationCamera;
  107849. private _existingCamera;
  107850. private _onKeyDown;
  107851. private _onVrDisplayPresentChange;
  107852. private _onVRDisplayChanged;
  107853. private _onVRRequestPresentStart;
  107854. private _onVRRequestPresentComplete;
  107855. /**
  107856. * 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)
  107857. */
  107858. enableGazeEvenWhenNoPointerLock: boolean;
  107859. /**
  107860. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107861. */
  107862. exitVROnDoubleTap: boolean;
  107863. /**
  107864. * Observable raised right before entering VR.
  107865. */
  107866. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107867. /**
  107868. * Observable raised when entering VR has completed.
  107869. */
  107870. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107871. /**
  107872. * Observable raised when exiting VR.
  107873. */
  107874. onExitingVRObservable: Observable<VRExperienceHelper>;
  107875. /**
  107876. * Observable raised when controller mesh is loaded.
  107877. */
  107878. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107879. /** Return this.onEnteringVRObservable
  107880. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107881. */
  107882. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107883. /** Return this.onExitingVRObservable
  107884. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107885. */
  107886. readonly onExitingVR: Observable<VRExperienceHelper>;
  107887. /** Return this.onControllerMeshLoadedObservable
  107888. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107889. */
  107890. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107891. private _rayLength;
  107892. private _useCustomVRButton;
  107893. private _teleportationRequested;
  107894. private _teleportActive;
  107895. private _floorMeshName;
  107896. private _floorMeshesCollection;
  107897. private _rotationAllowed;
  107898. private _teleportBackwardsVector;
  107899. private _teleportationTarget;
  107900. private _isDefaultTeleportationTarget;
  107901. private _postProcessMove;
  107902. private _teleportationFillColor;
  107903. private _teleportationBorderColor;
  107904. private _rotationAngle;
  107905. private _haloCenter;
  107906. private _cameraGazer;
  107907. private _padSensibilityUp;
  107908. private _padSensibilityDown;
  107909. private _leftController;
  107910. private _rightController;
  107911. /**
  107912. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107913. */
  107914. onNewMeshSelected: Observable<AbstractMesh>;
  107915. /**
  107916. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107917. * This observable will provide the mesh and the controller used to select the mesh
  107918. */
  107919. onMeshSelectedWithController: Observable<{
  107920. mesh: AbstractMesh;
  107921. controller: WebVRController;
  107922. }>;
  107923. /**
  107924. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107925. */
  107926. onNewMeshPicked: Observable<PickingInfo>;
  107927. private _circleEase;
  107928. /**
  107929. * Observable raised before camera teleportation
  107930. */
  107931. onBeforeCameraTeleport: Observable<Vector3>;
  107932. /**
  107933. * Observable raised after camera teleportation
  107934. */
  107935. onAfterCameraTeleport: Observable<Vector3>;
  107936. /**
  107937. * Observable raised when current selected mesh gets unselected
  107938. */
  107939. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107940. private _raySelectionPredicate;
  107941. /**
  107942. * To be optionaly changed by user to define custom ray selection
  107943. */
  107944. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107945. /**
  107946. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107947. */
  107948. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107949. /**
  107950. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107951. */
  107952. teleportationEnabled: boolean;
  107953. private _defaultHeight;
  107954. private _teleportationInitialized;
  107955. private _interactionsEnabled;
  107956. private _interactionsRequested;
  107957. private _displayGaze;
  107958. private _displayLaserPointer;
  107959. /**
  107960. * The mesh used to display where the user is going to teleport.
  107961. */
  107962. /**
  107963. * Sets the mesh to be used to display where the user is going to teleport.
  107964. */
  107965. teleportationTarget: Mesh;
  107966. /**
  107967. * 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
  107968. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  107969. * See http://doc.babylonjs.com/resources/baking_transformations
  107970. */
  107971. gazeTrackerMesh: Mesh;
  107972. /**
  107973. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  107974. */
  107975. updateGazeTrackerScale: boolean;
  107976. /**
  107977. * If the gaze trackers color should be updated when selecting meshes
  107978. */
  107979. updateGazeTrackerColor: boolean;
  107980. /**
  107981. * If the controller laser color should be updated when selecting meshes
  107982. */
  107983. updateControllerLaserColor: boolean;
  107984. /**
  107985. * The gaze tracking mesh corresponding to the left controller
  107986. */
  107987. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  107988. /**
  107989. * The gaze tracking mesh corresponding to the right controller
  107990. */
  107991. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  107992. /**
  107993. * If the ray of the gaze should be displayed.
  107994. */
  107995. /**
  107996. * Sets if the ray of the gaze should be displayed.
  107997. */
  107998. displayGaze: boolean;
  107999. /**
  108000. * If the ray of the LaserPointer should be displayed.
  108001. */
  108002. /**
  108003. * Sets if the ray of the LaserPointer should be displayed.
  108004. */
  108005. displayLaserPointer: boolean;
  108006. /**
  108007. * The deviceOrientationCamera used as the camera when not in VR.
  108008. */
  108009. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108010. /**
  108011. * Based on the current WebVR support, returns the current VR camera used.
  108012. */
  108013. readonly currentVRCamera: Nullable<Camera>;
  108014. /**
  108015. * The webVRCamera which is used when in VR.
  108016. */
  108017. readonly webVRCamera: WebVRFreeCamera;
  108018. /**
  108019. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108020. */
  108021. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108022. /**
  108023. * The html button that is used to trigger entering into VR.
  108024. */
  108025. readonly vrButton: Nullable<HTMLButtonElement>;
  108026. private readonly _teleportationRequestInitiated;
  108027. /**
  108028. * Defines wether or not Pointer lock should be requested when switching to
  108029. * full screen.
  108030. */
  108031. requestPointerLockOnFullScreen: boolean;
  108032. /**
  108033. * Instantiates a VRExperienceHelper.
  108034. * Helps to quickly add VR support to an existing scene.
  108035. * @param scene The scene the VRExperienceHelper belongs to.
  108036. * @param webVROptions Options to modify the vr experience helper's behavior.
  108037. */
  108038. constructor(scene: Scene,
  108039. /** Options to modify the vr experience helper's behavior. */
  108040. webVROptions?: VRExperienceHelperOptions);
  108041. private _onDefaultMeshLoaded;
  108042. private _onResize;
  108043. private _onFullscreenChange;
  108044. /**
  108045. * Gets a value indicating if we are currently in VR mode.
  108046. */
  108047. readonly isInVRMode: boolean;
  108048. private onVrDisplayPresentChange;
  108049. private onVRDisplayChanged;
  108050. private moveButtonToBottomRight;
  108051. private displayVRButton;
  108052. private updateButtonVisibility;
  108053. private _cachedAngularSensibility;
  108054. /**
  108055. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108056. * Otherwise, will use the fullscreen API.
  108057. */
  108058. enterVR(): void;
  108059. /**
  108060. * Attempt to exit VR, or fullscreen.
  108061. */
  108062. exitVR(): void;
  108063. /**
  108064. * The position of the vr experience helper.
  108065. */
  108066. /**
  108067. * Sets the position of the vr experience helper.
  108068. */
  108069. position: Vector3;
  108070. /**
  108071. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108072. */
  108073. enableInteractions(): void;
  108074. private readonly _noControllerIsActive;
  108075. private beforeRender;
  108076. private _isTeleportationFloor;
  108077. /**
  108078. * Adds a floor mesh to be used for teleportation.
  108079. * @param floorMesh the mesh to be used for teleportation.
  108080. */
  108081. addFloorMesh(floorMesh: Mesh): void;
  108082. /**
  108083. * Removes a floor mesh from being used for teleportation.
  108084. * @param floorMesh the mesh to be removed.
  108085. */
  108086. removeFloorMesh(floorMesh: Mesh): void;
  108087. /**
  108088. * Enables interactions and teleportation using the VR controllers and gaze.
  108089. * @param vrTeleportationOptions options to modify teleportation behavior.
  108090. */
  108091. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108092. private _onNewGamepadConnected;
  108093. private _tryEnableInteractionOnController;
  108094. private _onNewGamepadDisconnected;
  108095. private _enableInteractionOnController;
  108096. private _checkTeleportWithRay;
  108097. private _checkRotate;
  108098. private _checkTeleportBackwards;
  108099. private _enableTeleportationOnController;
  108100. private _createTeleportationCircles;
  108101. private _displayTeleportationTarget;
  108102. private _hideTeleportationTarget;
  108103. private _rotateCamera;
  108104. private _moveTeleportationSelectorTo;
  108105. private _workingVector;
  108106. private _workingQuaternion;
  108107. private _workingMatrix;
  108108. /**
  108109. * Teleports the users feet to the desired location
  108110. * @param location The location where the user's feet should be placed
  108111. */
  108112. teleportCamera(location: Vector3): void;
  108113. private _convertNormalToDirectionOfRay;
  108114. private _castRayAndSelectObject;
  108115. private _notifySelectedMeshUnselected;
  108116. /**
  108117. * Sets the color of the laser ray from the vr controllers.
  108118. * @param color new color for the ray.
  108119. */
  108120. changeLaserColor(color: Color3): void;
  108121. /**
  108122. * Sets the color of the ray from the vr headsets gaze.
  108123. * @param color new color for the ray.
  108124. */
  108125. changeGazeColor(color: Color3): void;
  108126. /**
  108127. * Exits VR and disposes of the vr experience helper
  108128. */
  108129. dispose(): void;
  108130. /**
  108131. * Gets the name of the VRExperienceHelper class
  108132. * @returns "VRExperienceHelper"
  108133. */
  108134. getClassName(): string;
  108135. }
  108136. }
  108137. declare module BABYLON {
  108138. /**
  108139. * Manages an XRSession to work with Babylon's engine
  108140. * @see https://doc.babylonjs.com/how_to/webxr
  108141. */
  108142. export class WebXRSessionManager implements IDisposable {
  108143. private scene;
  108144. /**
  108145. * Fires every time a new xrFrame arrives which can be used to update the camera
  108146. */
  108147. onXRFrameObservable: Observable<any>;
  108148. /**
  108149. * Fires when the xr session is ended either by the device or manually done
  108150. */
  108151. onXRSessionEnded: Observable<any>;
  108152. /**
  108153. * Underlying xr session
  108154. */
  108155. session: XRSession;
  108156. /**
  108157. * Type of reference space used when creating the session
  108158. */
  108159. referenceSpace: XRReferenceSpace;
  108160. /** @hidden */
  108161. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108162. /**
  108163. * Current XR frame
  108164. */
  108165. currentFrame: Nullable<XRFrame>;
  108166. private _xrNavigator;
  108167. private baseLayer;
  108168. /**
  108169. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108170. * @param scene The scene which the session should be created for
  108171. */
  108172. constructor(scene: Scene);
  108173. /**
  108174. * Initializes the manager
  108175. * After initialization enterXR can be called to start an XR session
  108176. * @returns Promise which resolves after it is initialized
  108177. */
  108178. initializeAsync(): Promise<void>;
  108179. /**
  108180. * Initializes an xr session
  108181. * @param xrSessionMode mode to initialize
  108182. * @returns a promise which will resolve once the session has been initialized
  108183. */
  108184. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108185. /**
  108186. * Sets the reference space on the xr session
  108187. * @param referenceSpace space to set
  108188. * @returns a promise that will resolve once the reference space has been set
  108189. */
  108190. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108191. /**
  108192. * Updates the render state of the session
  108193. * @param state state to set
  108194. * @returns a promise that resolves once the render state has been updated
  108195. */
  108196. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108197. /**
  108198. * Starts rendering to the xr layer
  108199. * @returns a promise that will resolve once rendering has started
  108200. */
  108201. startRenderingToXRAsync(): Promise<void>;
  108202. /**
  108203. * Stops the xrSession and restores the renderloop
  108204. * @returns Promise which resolves after it exits XR
  108205. */
  108206. exitXRAsync(): Promise<unknown>;
  108207. /**
  108208. * Checks if a session would be supported for the creation options specified
  108209. * @param sessionMode session mode to check if supported eg. immersive-vr
  108210. * @returns true if supported
  108211. */
  108212. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108213. /**
  108214. * @hidden
  108215. * Converts the render layer of xrSession to a render target
  108216. * @param session session to create render target for
  108217. * @param scene scene the new render target should be created for
  108218. */
  108219. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108220. /**
  108221. * Disposes of the session manager
  108222. */
  108223. dispose(): void;
  108224. }
  108225. }
  108226. declare module BABYLON {
  108227. /**
  108228. * WebXR Camera which holds the views for the xrSession
  108229. * @see https://doc.babylonjs.com/how_to/webxr
  108230. */
  108231. export class WebXRCamera extends FreeCamera {
  108232. private static _TmpMatrix;
  108233. /**
  108234. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108235. * @param name the name of the camera
  108236. * @param scene the scene to add the camera to
  108237. */
  108238. constructor(name: string, scene: Scene);
  108239. private _updateNumberOfRigCameras;
  108240. /** @hidden */
  108241. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108242. /**
  108243. * Updates the cameras position from the current pose information of the XR session
  108244. * @param xrSessionManager the session containing pose information
  108245. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108246. */
  108247. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108248. }
  108249. }
  108250. declare module BABYLON {
  108251. /**
  108252. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108253. */
  108254. export class WebXRManagedOutputCanvas implements IDisposable {
  108255. private helper;
  108256. private _canvas;
  108257. /**
  108258. * xrpresent context of the canvas which can be used to display/mirror xr content
  108259. */
  108260. canvasContext: WebGLRenderingContext;
  108261. /**
  108262. * xr layer for the canvas
  108263. */
  108264. xrLayer: Nullable<XRWebGLLayer>;
  108265. /**
  108266. * Initializes the xr layer for the session
  108267. * @param xrSession xr session
  108268. * @returns a promise that will resolve once the XR Layer has been created
  108269. */
  108270. initializeXRLayerAsync(xrSession: any): any;
  108271. /**
  108272. * Initializes the canvas to be added/removed upon entering/exiting xr
  108273. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108274. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108275. */
  108276. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108277. /**
  108278. * Disposes of the object
  108279. */
  108280. dispose(): void;
  108281. private _setManagedOutputCanvas;
  108282. private _addCanvas;
  108283. private _removeCanvas;
  108284. }
  108285. }
  108286. declare module BABYLON {
  108287. /**
  108288. * States of the webXR experience
  108289. */
  108290. export enum WebXRState {
  108291. /**
  108292. * Transitioning to being in XR mode
  108293. */
  108294. ENTERING_XR = 0,
  108295. /**
  108296. * Transitioning to non XR mode
  108297. */
  108298. EXITING_XR = 1,
  108299. /**
  108300. * In XR mode and presenting
  108301. */
  108302. IN_XR = 2,
  108303. /**
  108304. * Not entered XR mode
  108305. */
  108306. NOT_IN_XR = 3
  108307. }
  108308. /**
  108309. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108310. * @see https://doc.babylonjs.com/how_to/webxr
  108311. */
  108312. export class WebXRExperienceHelper implements IDisposable {
  108313. private scene;
  108314. /**
  108315. * 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
  108316. */
  108317. container: AbstractMesh;
  108318. /**
  108319. * Camera used to render xr content
  108320. */
  108321. camera: WebXRCamera;
  108322. /**
  108323. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108324. */
  108325. state: WebXRState;
  108326. private _setState;
  108327. private static _TmpVector;
  108328. /**
  108329. * Fires when the state of the experience helper has changed
  108330. */
  108331. onStateChangedObservable: Observable<WebXRState>;
  108332. /** Session manager used to keep track of xr session */
  108333. sessionManager: WebXRSessionManager;
  108334. private _nonVRCamera;
  108335. private _originalSceneAutoClear;
  108336. private _supported;
  108337. /**
  108338. * Creates the experience helper
  108339. * @param scene the scene to attach the experience helper to
  108340. * @returns a promise for the experience helper
  108341. */
  108342. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108343. /**
  108344. * Creates a WebXRExperienceHelper
  108345. * @param scene The scene the helper should be created in
  108346. */
  108347. private constructor();
  108348. /**
  108349. * Exits XR mode and returns the scene to its original state
  108350. * @returns promise that resolves after xr mode has exited
  108351. */
  108352. exitXRAsync(): Promise<unknown>;
  108353. /**
  108354. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108355. * @param sessionCreationOptions options for the XR session
  108356. * @param referenceSpaceType frame of reference of the XR session
  108357. * @param outputCanvas the output canvas that will be used to enter XR mode
  108358. * @returns promise that resolves after xr mode has entered
  108359. */
  108360. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108361. /**
  108362. * Updates the global position of the camera by moving the camera's container
  108363. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108364. * @param position The desired global position of the camera
  108365. */
  108366. setPositionOfCameraUsingContainer(position: Vector3): void;
  108367. /**
  108368. * Rotates the xr camera by rotating the camera's container around the camera's position
  108369. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108370. * @param rotation the desired quaternion rotation to apply to the camera
  108371. */
  108372. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108373. /**
  108374. * Disposes of the experience helper
  108375. */
  108376. dispose(): void;
  108377. }
  108378. }
  108379. declare module BABYLON {
  108380. /**
  108381. * Button which can be used to enter a different mode of XR
  108382. */
  108383. export class WebXREnterExitUIButton {
  108384. /** button element */
  108385. element: HTMLElement;
  108386. /** XR initialization options for the button */
  108387. sessionMode: XRSessionMode;
  108388. /** Reference space type */
  108389. referenceSpaceType: XRReferenceSpaceType;
  108390. /**
  108391. * Creates a WebXREnterExitUIButton
  108392. * @param element button element
  108393. * @param sessionMode XR initialization session mode
  108394. * @param referenceSpaceType the type of reference space to be used
  108395. */
  108396. constructor(
  108397. /** button element */
  108398. element: HTMLElement,
  108399. /** XR initialization options for the button */
  108400. sessionMode: XRSessionMode,
  108401. /** Reference space type */
  108402. referenceSpaceType: XRReferenceSpaceType);
  108403. /**
  108404. * Overwritable function which can be used to update the button's visuals when the state changes
  108405. * @param activeButton the current active button in the UI
  108406. */
  108407. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108408. }
  108409. /**
  108410. * Options to create the webXR UI
  108411. */
  108412. export class WebXREnterExitUIOptions {
  108413. /**
  108414. * Context to enter xr with
  108415. */
  108416. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108417. /**
  108418. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108419. */
  108420. customButtons?: Array<WebXREnterExitUIButton>;
  108421. }
  108422. /**
  108423. * UI to allow the user to enter/exit XR mode
  108424. */
  108425. export class WebXREnterExitUI implements IDisposable {
  108426. private scene;
  108427. private _overlay;
  108428. private _buttons;
  108429. private _activeButton;
  108430. /**
  108431. * Fired every time the active button is changed.
  108432. *
  108433. * When xr is entered via a button that launches xr that button will be the callback parameter
  108434. *
  108435. * When exiting xr the callback parameter will be null)
  108436. */
  108437. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108438. /**
  108439. * Creates UI to allow the user to enter/exit XR mode
  108440. * @param scene the scene to add the ui to
  108441. * @param helper the xr experience helper to enter/exit xr with
  108442. * @param options options to configure the UI
  108443. * @returns the created ui
  108444. */
  108445. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108446. private constructor();
  108447. private _updateButtons;
  108448. /**
  108449. * Disposes of the object
  108450. */
  108451. dispose(): void;
  108452. }
  108453. }
  108454. declare module BABYLON {
  108455. /**
  108456. * Represents an XR input
  108457. */
  108458. export class WebXRController {
  108459. private scene;
  108460. /** The underlying input source for the controller */
  108461. inputSource: XRInputSource;
  108462. private parentContainer;
  108463. /**
  108464. * 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
  108465. */
  108466. grip?: AbstractMesh;
  108467. /**
  108468. * Pointer which can be used to select objects or attach a visible laser to
  108469. */
  108470. pointer: AbstractMesh;
  108471. /**
  108472. * Event that fires when the controller is removed/disposed
  108473. */
  108474. onDisposeObservable: Observable<{}>;
  108475. private _tmpMatrix;
  108476. private _tmpQuaternion;
  108477. private _tmpVector;
  108478. /**
  108479. * Creates the controller
  108480. * @see https://doc.babylonjs.com/how_to/webxr
  108481. * @param scene the scene which the controller should be associated to
  108482. * @param inputSource the underlying input source for the controller
  108483. * @param parentContainer parent that the controller meshes should be children of
  108484. */
  108485. constructor(scene: Scene,
  108486. /** The underlying input source for the controller */
  108487. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108488. /**
  108489. * Updates the controller pose based on the given XRFrame
  108490. * @param xrFrame xr frame to update the pose with
  108491. * @param referenceSpace reference space to use
  108492. */
  108493. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108494. /**
  108495. * Gets a world space ray coming from the controller
  108496. * @param result the resulting ray
  108497. */
  108498. getWorldPointerRayToRef(result: Ray): void;
  108499. /**
  108500. * Disposes of the object
  108501. */
  108502. dispose(): void;
  108503. }
  108504. }
  108505. declare module BABYLON {
  108506. /**
  108507. * XR input used to track XR inputs such as controllers/rays
  108508. */
  108509. export class WebXRInput implements IDisposable {
  108510. /**
  108511. * Base experience the input listens to
  108512. */
  108513. baseExperience: WebXRExperienceHelper;
  108514. /**
  108515. * XR controllers being tracked
  108516. */
  108517. controllers: Array<WebXRController>;
  108518. private _frameObserver;
  108519. private _stateObserver;
  108520. /**
  108521. * Event when a controller has been connected/added
  108522. */
  108523. onControllerAddedObservable: Observable<WebXRController>;
  108524. /**
  108525. * Event when a controller has been removed/disconnected
  108526. */
  108527. onControllerRemovedObservable: Observable<WebXRController>;
  108528. /**
  108529. * Initializes the WebXRInput
  108530. * @param baseExperience experience helper which the input should be created for
  108531. */
  108532. constructor(
  108533. /**
  108534. * Base experience the input listens to
  108535. */
  108536. baseExperience: WebXRExperienceHelper);
  108537. private _onInputSourcesChange;
  108538. private _addAndRemoveControllers;
  108539. /**
  108540. * Disposes of the object
  108541. */
  108542. dispose(): void;
  108543. }
  108544. }
  108545. declare module BABYLON {
  108546. /**
  108547. * Enables teleportation
  108548. */
  108549. export class WebXRControllerTeleportation {
  108550. private _teleportationFillColor;
  108551. private _teleportationBorderColor;
  108552. private _tmpRay;
  108553. private _tmpVector;
  108554. /**
  108555. * Creates a WebXRControllerTeleportation
  108556. * @param input input manager to add teleportation to
  108557. * @param floorMeshes floormeshes which can be teleported to
  108558. */
  108559. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108560. }
  108561. }
  108562. declare module BABYLON {
  108563. /**
  108564. * Handles pointer input automatically for the pointer of XR controllers
  108565. */
  108566. export class WebXRControllerPointerSelection {
  108567. private static _idCounter;
  108568. private _tmpRay;
  108569. /**
  108570. * Creates a WebXRControllerPointerSelection
  108571. * @param input input manager to setup pointer selection
  108572. */
  108573. constructor(input: WebXRInput);
  108574. private _convertNormalToDirectionOfRay;
  108575. private _updatePointerDistance;
  108576. }
  108577. }
  108578. declare module BABYLON {
  108579. /**
  108580. * Class used to represent data loading progression
  108581. */
  108582. export class SceneLoaderProgressEvent {
  108583. /** defines if data length to load can be evaluated */
  108584. readonly lengthComputable: boolean;
  108585. /** defines the loaded data length */
  108586. readonly loaded: number;
  108587. /** defines the data length to load */
  108588. readonly total: number;
  108589. /**
  108590. * Create a new progress event
  108591. * @param lengthComputable defines if data length to load can be evaluated
  108592. * @param loaded defines the loaded data length
  108593. * @param total defines the data length to load
  108594. */
  108595. constructor(
  108596. /** defines if data length to load can be evaluated */
  108597. lengthComputable: boolean,
  108598. /** defines the loaded data length */
  108599. loaded: number,
  108600. /** defines the data length to load */
  108601. total: number);
  108602. /**
  108603. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108604. * @param event defines the source event
  108605. * @returns a new SceneLoaderProgressEvent
  108606. */
  108607. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108608. }
  108609. /**
  108610. * Interface used by SceneLoader plugins to define supported file extensions
  108611. */
  108612. export interface ISceneLoaderPluginExtensions {
  108613. /**
  108614. * Defines the list of supported extensions
  108615. */
  108616. [extension: string]: {
  108617. isBinary: boolean;
  108618. };
  108619. }
  108620. /**
  108621. * Interface used by SceneLoader plugin factory
  108622. */
  108623. export interface ISceneLoaderPluginFactory {
  108624. /**
  108625. * Defines the name of the factory
  108626. */
  108627. name: string;
  108628. /**
  108629. * Function called to create a new plugin
  108630. * @return the new plugin
  108631. */
  108632. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108633. /**
  108634. * Boolean indicating if the plugin can direct load specific data
  108635. */
  108636. canDirectLoad?: (data: string) => boolean;
  108637. }
  108638. /**
  108639. * Interface used to define a SceneLoader plugin
  108640. */
  108641. export interface ISceneLoaderPlugin {
  108642. /**
  108643. * The friendly name of this plugin.
  108644. */
  108645. name: string;
  108646. /**
  108647. * The file extensions supported by this plugin.
  108648. */
  108649. extensions: string | ISceneLoaderPluginExtensions;
  108650. /**
  108651. * Import meshes into a scene.
  108652. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108653. * @param scene The scene to import into
  108654. * @param data The data to import
  108655. * @param rootUrl The root url for scene and resources
  108656. * @param meshes The meshes array to import into
  108657. * @param particleSystems The particle systems array to import into
  108658. * @param skeletons The skeletons array to import into
  108659. * @param onError The callback when import fails
  108660. * @returns True if successful or false otherwise
  108661. */
  108662. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108663. /**
  108664. * Load into a scene.
  108665. * @param scene The scene to load into
  108666. * @param data The data to import
  108667. * @param rootUrl The root url for scene and resources
  108668. * @param onError The callback when import fails
  108669. * @returns true if successful or false otherwise
  108670. */
  108671. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108672. /**
  108673. * The callback that returns true if the data can be directly loaded.
  108674. */
  108675. canDirectLoad?: (data: string) => boolean;
  108676. /**
  108677. * The callback that allows custom handling of the root url based on the response url.
  108678. */
  108679. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108680. /**
  108681. * Load into an asset container.
  108682. * @param scene The scene to load into
  108683. * @param data The data to import
  108684. * @param rootUrl The root url for scene and resources
  108685. * @param onError The callback when import fails
  108686. * @returns The loaded asset container
  108687. */
  108688. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108689. }
  108690. /**
  108691. * Interface used to define an async SceneLoader plugin
  108692. */
  108693. export interface ISceneLoaderPluginAsync {
  108694. /**
  108695. * The friendly name of this plugin.
  108696. */
  108697. name: string;
  108698. /**
  108699. * The file extensions supported by this plugin.
  108700. */
  108701. extensions: string | ISceneLoaderPluginExtensions;
  108702. /**
  108703. * Import meshes into a scene.
  108704. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108705. * @param scene The scene to import into
  108706. * @param data The data to import
  108707. * @param rootUrl The root url for scene and resources
  108708. * @param onProgress The callback when the load progresses
  108709. * @param fileName Defines the name of the file to load
  108710. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108711. */
  108712. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108713. meshes: AbstractMesh[];
  108714. particleSystems: IParticleSystem[];
  108715. skeletons: Skeleton[];
  108716. animationGroups: AnimationGroup[];
  108717. }>;
  108718. /**
  108719. * Load into a scene.
  108720. * @param scene The scene to load into
  108721. * @param data The data to import
  108722. * @param rootUrl The root url for scene and resources
  108723. * @param onProgress The callback when the load progresses
  108724. * @param fileName Defines the name of the file to load
  108725. * @returns Nothing
  108726. */
  108727. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108728. /**
  108729. * The callback that returns true if the data can be directly loaded.
  108730. */
  108731. canDirectLoad?: (data: string) => boolean;
  108732. /**
  108733. * The callback that allows custom handling of the root url based on the response url.
  108734. */
  108735. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108736. /**
  108737. * Load into an asset container.
  108738. * @param scene The scene to load into
  108739. * @param data The data to import
  108740. * @param rootUrl The root url for scene and resources
  108741. * @param onProgress The callback when the load progresses
  108742. * @param fileName Defines the name of the file to load
  108743. * @returns The loaded asset container
  108744. */
  108745. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108746. }
  108747. /**
  108748. * Class used to load scene from various file formats using registered plugins
  108749. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108750. */
  108751. export class SceneLoader {
  108752. /**
  108753. * No logging while loading
  108754. */
  108755. static readonly NO_LOGGING: number;
  108756. /**
  108757. * Minimal logging while loading
  108758. */
  108759. static readonly MINIMAL_LOGGING: number;
  108760. /**
  108761. * Summary logging while loading
  108762. */
  108763. static readonly SUMMARY_LOGGING: number;
  108764. /**
  108765. * Detailled logging while loading
  108766. */
  108767. static readonly DETAILED_LOGGING: number;
  108768. /**
  108769. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108770. */
  108771. static ForceFullSceneLoadingForIncremental: boolean;
  108772. /**
  108773. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108774. */
  108775. static ShowLoadingScreen: boolean;
  108776. /**
  108777. * Defines the current logging level (while loading the scene)
  108778. * @ignorenaming
  108779. */
  108780. static loggingLevel: number;
  108781. /**
  108782. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108783. */
  108784. static CleanBoneMatrixWeights: boolean;
  108785. /**
  108786. * Event raised when a plugin is used to load a scene
  108787. */
  108788. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108789. private static _registeredPlugins;
  108790. private static _getDefaultPlugin;
  108791. private static _getPluginForExtension;
  108792. private static _getPluginForDirectLoad;
  108793. private static _getPluginForFilename;
  108794. private static _getDirectLoad;
  108795. private static _loadData;
  108796. private static _getFileInfo;
  108797. /**
  108798. * Gets a plugin that can load the given extension
  108799. * @param extension defines the extension to load
  108800. * @returns a plugin or null if none works
  108801. */
  108802. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108803. /**
  108804. * Gets a boolean indicating that the given extension can be loaded
  108805. * @param extension defines the extension to load
  108806. * @returns true if the extension is supported
  108807. */
  108808. static IsPluginForExtensionAvailable(extension: string): boolean;
  108809. /**
  108810. * Adds a new plugin to the list of registered plugins
  108811. * @param plugin defines the plugin to add
  108812. */
  108813. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108814. /**
  108815. * Import meshes into a scene
  108816. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108817. * @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)
  108818. * @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)
  108819. * @param scene the instance of BABYLON.Scene to append to
  108820. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108821. * @param onProgress a callback with a progress event for each file being loaded
  108822. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108823. * @param pluginExtension the extension used to determine the plugin
  108824. * @returns The loaded plugin
  108825. */
  108826. 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>;
  108827. /**
  108828. * Import meshes into a scene
  108829. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108830. * @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)
  108831. * @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)
  108832. * @param scene the instance of BABYLON.Scene to append to
  108833. * @param onProgress a callback with a progress event for each file being loaded
  108834. * @param pluginExtension the extension used to determine the plugin
  108835. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108836. */
  108837. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108838. meshes: AbstractMesh[];
  108839. particleSystems: IParticleSystem[];
  108840. skeletons: Skeleton[];
  108841. animationGroups: AnimationGroup[];
  108842. }>;
  108843. /**
  108844. * Load a scene
  108845. * @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)
  108846. * @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)
  108847. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108848. * @param onSuccess a callback with the scene when import succeeds
  108849. * @param onProgress a callback with a progress event for each file being loaded
  108850. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108851. * @param pluginExtension the extension used to determine the plugin
  108852. * @returns The loaded plugin
  108853. */
  108854. 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>;
  108855. /**
  108856. * Load a scene
  108857. * @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)
  108858. * @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)
  108859. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108860. * @param onProgress a callback with a progress event for each file being loaded
  108861. * @param pluginExtension the extension used to determine the plugin
  108862. * @returns The loaded scene
  108863. */
  108864. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108865. /**
  108866. * Append a scene
  108867. * @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)
  108868. * @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)
  108869. * @param scene is the instance of BABYLON.Scene to append to
  108870. * @param onSuccess a callback with the scene when import succeeds
  108871. * @param onProgress a callback with a progress event for each file being loaded
  108872. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108873. * @param pluginExtension the extension used to determine the plugin
  108874. * @returns The loaded plugin
  108875. */
  108876. 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>;
  108877. /**
  108878. * Append a scene
  108879. * @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)
  108880. * @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)
  108881. * @param scene is the instance of BABYLON.Scene to append to
  108882. * @param onProgress a callback with a progress event for each file being loaded
  108883. * @param pluginExtension the extension used to determine the plugin
  108884. * @returns The given scene
  108885. */
  108886. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108887. /**
  108888. * Load a scene into an asset container
  108889. * @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)
  108890. * @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)
  108891. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108892. * @param onSuccess a callback with the scene when import succeeds
  108893. * @param onProgress a callback with a progress event for each file being loaded
  108894. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108895. * @param pluginExtension the extension used to determine the plugin
  108896. * @returns The loaded plugin
  108897. */
  108898. 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>;
  108899. /**
  108900. * Load a scene into an asset container
  108901. * @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)
  108902. * @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)
  108903. * @param scene is the instance of Scene to append to
  108904. * @param onProgress a callback with a progress event for each file being loaded
  108905. * @param pluginExtension the extension used to determine the plugin
  108906. * @returns The loaded asset container
  108907. */
  108908. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108909. }
  108910. }
  108911. declare module BABYLON {
  108912. /**
  108913. * Generic Controller
  108914. */
  108915. export class GenericController extends WebVRController {
  108916. /**
  108917. * Base Url for the controller model.
  108918. */
  108919. static readonly MODEL_BASE_URL: string;
  108920. /**
  108921. * File name for the controller model.
  108922. */
  108923. static readonly MODEL_FILENAME: string;
  108924. /**
  108925. * Creates a new GenericController from a gamepad
  108926. * @param vrGamepad the gamepad that the controller should be created from
  108927. */
  108928. constructor(vrGamepad: any);
  108929. /**
  108930. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108931. * @param scene scene in which to add meshes
  108932. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108933. */
  108934. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108935. /**
  108936. * Called once for each button that changed state since the last frame
  108937. * @param buttonIdx Which button index changed
  108938. * @param state New state of the button
  108939. * @param changes Which properties on the state changed since last frame
  108940. */
  108941. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108942. }
  108943. }
  108944. declare module BABYLON {
  108945. /**
  108946. * Defines the WindowsMotionController object that the state of the windows motion controller
  108947. */
  108948. export class WindowsMotionController extends WebVRController {
  108949. /**
  108950. * The base url used to load the left and right controller models
  108951. */
  108952. static MODEL_BASE_URL: string;
  108953. /**
  108954. * The name of the left controller model file
  108955. */
  108956. static MODEL_LEFT_FILENAME: string;
  108957. /**
  108958. * The name of the right controller model file
  108959. */
  108960. static MODEL_RIGHT_FILENAME: string;
  108961. /**
  108962. * The controller name prefix for this controller type
  108963. */
  108964. static readonly GAMEPAD_ID_PREFIX: string;
  108965. /**
  108966. * The controller id pattern for this controller type
  108967. */
  108968. private static readonly GAMEPAD_ID_PATTERN;
  108969. private _loadedMeshInfo;
  108970. private readonly _mapping;
  108971. /**
  108972. * Fired when the trackpad on this controller is clicked
  108973. */
  108974. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  108975. /**
  108976. * Fired when the trackpad on this controller is modified
  108977. */
  108978. onTrackpadValuesChangedObservable: Observable<StickValues>;
  108979. /**
  108980. * The current x and y values of this controller's trackpad
  108981. */
  108982. trackpad: StickValues;
  108983. /**
  108984. * Creates a new WindowsMotionController from a gamepad
  108985. * @param vrGamepad the gamepad that the controller should be created from
  108986. */
  108987. constructor(vrGamepad: any);
  108988. /**
  108989. * Fired when the trigger on this controller is modified
  108990. */
  108991. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108992. /**
  108993. * Fired when the menu button on this controller is modified
  108994. */
  108995. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  108996. /**
  108997. * Fired when the grip button on this controller is modified
  108998. */
  108999. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109000. /**
  109001. * Fired when the thumbstick button on this controller is modified
  109002. */
  109003. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109004. /**
  109005. * Fired when the touchpad button on this controller is modified
  109006. */
  109007. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109008. /**
  109009. * Fired when the touchpad values on this controller are modified
  109010. */
  109011. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109012. private _updateTrackpad;
  109013. /**
  109014. * Called once per frame by the engine.
  109015. */
  109016. update(): void;
  109017. /**
  109018. * Called once for each button that changed state since the last frame
  109019. * @param buttonIdx Which button index changed
  109020. * @param state New state of the button
  109021. * @param changes Which properties on the state changed since last frame
  109022. */
  109023. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109024. /**
  109025. * Moves the buttons on the controller mesh based on their current state
  109026. * @param buttonName the name of the button to move
  109027. * @param buttonValue the value of the button which determines the buttons new position
  109028. */
  109029. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109030. /**
  109031. * Moves the axis on the controller mesh based on its current state
  109032. * @param axis the index of the axis
  109033. * @param axisValue the value of the axis which determines the meshes new position
  109034. * @hidden
  109035. */
  109036. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109037. /**
  109038. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109039. * @param scene scene in which to add meshes
  109040. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109041. */
  109042. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109043. /**
  109044. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109045. * can be transformed by button presses and axes values, based on this._mapping.
  109046. *
  109047. * @param scene scene in which the meshes exist
  109048. * @param meshes list of meshes that make up the controller model to process
  109049. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109050. */
  109051. private processModel;
  109052. private createMeshInfo;
  109053. /**
  109054. * Gets the ray of the controller in the direction the controller is pointing
  109055. * @param length the length the resulting ray should be
  109056. * @returns a ray in the direction the controller is pointing
  109057. */
  109058. getForwardRay(length?: number): Ray;
  109059. /**
  109060. * Disposes of the controller
  109061. */
  109062. dispose(): void;
  109063. }
  109064. }
  109065. declare module BABYLON {
  109066. /**
  109067. * Oculus Touch Controller
  109068. */
  109069. export class OculusTouchController extends WebVRController {
  109070. /**
  109071. * Base Url for the controller model.
  109072. */
  109073. static MODEL_BASE_URL: string;
  109074. /**
  109075. * File name for the left controller model.
  109076. */
  109077. static MODEL_LEFT_FILENAME: string;
  109078. /**
  109079. * File name for the right controller model.
  109080. */
  109081. static MODEL_RIGHT_FILENAME: string;
  109082. /**
  109083. * Base Url for the Quest controller model.
  109084. */
  109085. static QUEST_MODEL_BASE_URL: string;
  109086. /**
  109087. * @hidden
  109088. * If the controllers are running on a device that needs the updated Quest controller models
  109089. */
  109090. static _IsQuest: boolean;
  109091. /**
  109092. * Fired when the secondary trigger on this controller is modified
  109093. */
  109094. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109095. /**
  109096. * Fired when the thumb rest on this controller is modified
  109097. */
  109098. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109099. /**
  109100. * Creates a new OculusTouchController from a gamepad
  109101. * @param vrGamepad the gamepad that the controller should be created from
  109102. */
  109103. constructor(vrGamepad: any);
  109104. /**
  109105. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109106. * @param scene scene in which to add meshes
  109107. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109108. */
  109109. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109110. /**
  109111. * Fired when the A button on this controller is modified
  109112. */
  109113. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109114. /**
  109115. * Fired when the B button on this controller is modified
  109116. */
  109117. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109118. /**
  109119. * Fired when the X button on this controller is modified
  109120. */
  109121. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109122. /**
  109123. * Fired when the Y button on this controller is modified
  109124. */
  109125. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109126. /**
  109127. * Called once for each button that changed state since the last frame
  109128. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109129. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109130. * 2) secondary trigger (same)
  109131. * 3) A (right) X (left), touch, pressed = value
  109132. * 4) B / Y
  109133. * 5) thumb rest
  109134. * @param buttonIdx Which button index changed
  109135. * @param state New state of the button
  109136. * @param changes Which properties on the state changed since last frame
  109137. */
  109138. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109139. }
  109140. }
  109141. declare module BABYLON {
  109142. /**
  109143. * Vive Controller
  109144. */
  109145. export class ViveController extends WebVRController {
  109146. /**
  109147. * Base Url for the controller model.
  109148. */
  109149. static MODEL_BASE_URL: string;
  109150. /**
  109151. * File name for the controller model.
  109152. */
  109153. static MODEL_FILENAME: string;
  109154. /**
  109155. * Creates a new ViveController from a gamepad
  109156. * @param vrGamepad the gamepad that the controller should be created from
  109157. */
  109158. constructor(vrGamepad: any);
  109159. /**
  109160. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109161. * @param scene scene in which to add meshes
  109162. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109163. */
  109164. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109165. /**
  109166. * Fired when the left button on this controller is modified
  109167. */
  109168. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109169. /**
  109170. * Fired when the right button on this controller is modified
  109171. */
  109172. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109173. /**
  109174. * Fired when the menu button on this controller is modified
  109175. */
  109176. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109177. /**
  109178. * Called once for each button that changed state since the last frame
  109179. * Vive mapping:
  109180. * 0: touchpad
  109181. * 1: trigger
  109182. * 2: left AND right buttons
  109183. * 3: menu button
  109184. * @param buttonIdx Which button index changed
  109185. * @param state New state of the button
  109186. * @param changes Which properties on the state changed since last frame
  109187. */
  109188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109189. }
  109190. }
  109191. declare module BABYLON {
  109192. /**
  109193. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109194. */
  109195. export class WebXRControllerModelLoader {
  109196. /**
  109197. * Creates the WebXRControllerModelLoader
  109198. * @param input xr input that creates the controllers
  109199. */
  109200. constructor(input: WebXRInput);
  109201. }
  109202. }
  109203. declare module BABYLON {
  109204. /**
  109205. * Contains an array of blocks representing the octree
  109206. */
  109207. export interface IOctreeContainer<T> {
  109208. /**
  109209. * Blocks within the octree
  109210. */
  109211. blocks: Array<OctreeBlock<T>>;
  109212. }
  109213. /**
  109214. * Class used to store a cell in an octree
  109215. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109216. */
  109217. export class OctreeBlock<T> {
  109218. /**
  109219. * Gets the content of the current block
  109220. */
  109221. entries: T[];
  109222. /**
  109223. * Gets the list of block children
  109224. */
  109225. blocks: Array<OctreeBlock<T>>;
  109226. private _depth;
  109227. private _maxDepth;
  109228. private _capacity;
  109229. private _minPoint;
  109230. private _maxPoint;
  109231. private _boundingVectors;
  109232. private _creationFunc;
  109233. /**
  109234. * Creates a new block
  109235. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109236. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109237. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109238. * @param depth defines the current depth of this block in the octree
  109239. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109240. * @param creationFunc defines a callback to call when an element is added to the block
  109241. */
  109242. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109243. /**
  109244. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109245. */
  109246. readonly capacity: number;
  109247. /**
  109248. * Gets the minimum vector (in world space) of the block's bounding box
  109249. */
  109250. readonly minPoint: Vector3;
  109251. /**
  109252. * Gets the maximum vector (in world space) of the block's bounding box
  109253. */
  109254. readonly maxPoint: Vector3;
  109255. /**
  109256. * Add a new element to this block
  109257. * @param entry defines the element to add
  109258. */
  109259. addEntry(entry: T): void;
  109260. /**
  109261. * Remove an element from this block
  109262. * @param entry defines the element to remove
  109263. */
  109264. removeEntry(entry: T): void;
  109265. /**
  109266. * Add an array of elements to this block
  109267. * @param entries defines the array of elements to add
  109268. */
  109269. addEntries(entries: T[]): void;
  109270. /**
  109271. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109272. * @param frustumPlanes defines the frustum planes to test
  109273. * @param selection defines the array to store current content if selection is positive
  109274. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109275. */
  109276. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109277. /**
  109278. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109279. * @param sphereCenter defines the bounding sphere center
  109280. * @param sphereRadius defines the bounding sphere radius
  109281. * @param selection defines the array to store current content if selection is positive
  109282. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109283. */
  109284. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109285. /**
  109286. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109287. * @param ray defines the ray to test with
  109288. * @param selection defines the array to store current content if selection is positive
  109289. */
  109290. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109291. /**
  109292. * Subdivide the content into child blocks (this block will then be empty)
  109293. */
  109294. createInnerBlocks(): void;
  109295. /**
  109296. * @hidden
  109297. */
  109298. 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;
  109299. }
  109300. }
  109301. declare module BABYLON {
  109302. /**
  109303. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109304. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109305. */
  109306. export class Octree<T> {
  109307. /** 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.) */
  109308. maxDepth: number;
  109309. /**
  109310. * Blocks within the octree containing objects
  109311. */
  109312. blocks: Array<OctreeBlock<T>>;
  109313. /**
  109314. * Content stored in the octree
  109315. */
  109316. dynamicContent: T[];
  109317. private _maxBlockCapacity;
  109318. private _selectionContent;
  109319. private _creationFunc;
  109320. /**
  109321. * Creates a octree
  109322. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109323. * @param creationFunc function to be used to instatiate the octree
  109324. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109325. * @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.)
  109326. */
  109327. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109328. /** 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.) */
  109329. maxDepth?: number);
  109330. /**
  109331. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109332. * @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);
  109333. * @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);
  109334. * @param entries meshes to be added to the octree blocks
  109335. */
  109336. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109337. /**
  109338. * Adds a mesh to the octree
  109339. * @param entry Mesh to add to the octree
  109340. */
  109341. addMesh(entry: T): void;
  109342. /**
  109343. * Remove an element from the octree
  109344. * @param entry defines the element to remove
  109345. */
  109346. removeMesh(entry: T): void;
  109347. /**
  109348. * Selects an array of meshes within the frustum
  109349. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109350. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109351. * @returns array of meshes within the frustum
  109352. */
  109353. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109354. /**
  109355. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109356. * @param sphereCenter defines the bounding sphere center
  109357. * @param sphereRadius defines the bounding sphere radius
  109358. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109359. * @returns an array of objects that intersect the sphere
  109360. */
  109361. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109362. /**
  109363. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109364. * @param ray defines the ray to test with
  109365. * @returns array of intersected objects
  109366. */
  109367. intersectsRay(ray: Ray): SmartArray<T>;
  109368. /**
  109369. * Adds a mesh into the octree block if it intersects the block
  109370. */
  109371. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109372. /**
  109373. * Adds a submesh into the octree block if it intersects the block
  109374. */
  109375. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109376. }
  109377. }
  109378. declare module BABYLON {
  109379. interface Scene {
  109380. /**
  109381. * @hidden
  109382. * Backing Filed
  109383. */
  109384. _selectionOctree: Octree<AbstractMesh>;
  109385. /**
  109386. * Gets the octree used to boost mesh selection (picking)
  109387. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109388. */
  109389. selectionOctree: Octree<AbstractMesh>;
  109390. /**
  109391. * Creates or updates the octree used to boost selection (picking)
  109392. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109393. * @param maxCapacity defines the maximum capacity per leaf
  109394. * @param maxDepth defines the maximum depth of the octree
  109395. * @returns an octree of AbstractMesh
  109396. */
  109397. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109398. }
  109399. interface AbstractMesh {
  109400. /**
  109401. * @hidden
  109402. * Backing Field
  109403. */
  109404. _submeshesOctree: Octree<SubMesh>;
  109405. /**
  109406. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109407. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109408. * @param maxCapacity defines the maximum size of each block (64 by default)
  109409. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109410. * @returns the new octree
  109411. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109412. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109413. */
  109414. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109415. }
  109416. /**
  109417. * Defines the octree scene component responsible to manage any octrees
  109418. * in a given scene.
  109419. */
  109420. export class OctreeSceneComponent {
  109421. /**
  109422. * The component name help to identify the component in the list of scene components.
  109423. */
  109424. readonly name: string;
  109425. /**
  109426. * The scene the component belongs to.
  109427. */
  109428. scene: Scene;
  109429. /**
  109430. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109431. */
  109432. readonly checksIsEnabled: boolean;
  109433. /**
  109434. * Creates a new instance of the component for the given scene
  109435. * @param scene Defines the scene to register the component in
  109436. */
  109437. constructor(scene: Scene);
  109438. /**
  109439. * Registers the component in a given scene
  109440. */
  109441. register(): void;
  109442. /**
  109443. * Return the list of active meshes
  109444. * @returns the list of active meshes
  109445. */
  109446. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109447. /**
  109448. * Return the list of active sub meshes
  109449. * @param mesh The mesh to get the candidates sub meshes from
  109450. * @returns the list of active sub meshes
  109451. */
  109452. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109453. private _tempRay;
  109454. /**
  109455. * Return the list of sub meshes intersecting with a given local ray
  109456. * @param mesh defines the mesh to find the submesh for
  109457. * @param localRay defines the ray in local space
  109458. * @returns the list of intersecting sub meshes
  109459. */
  109460. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109461. /**
  109462. * Return the list of sub meshes colliding with a collider
  109463. * @param mesh defines the mesh to find the submesh for
  109464. * @param collider defines the collider to evaluate the collision against
  109465. * @returns the list of colliding sub meshes
  109466. */
  109467. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109468. /**
  109469. * Rebuilds the elements related to this component in case of
  109470. * context lost for instance.
  109471. */
  109472. rebuild(): void;
  109473. /**
  109474. * Disposes the component and the associated ressources.
  109475. */
  109476. dispose(): void;
  109477. }
  109478. }
  109479. declare module BABYLON {
  109480. /**
  109481. * Renders a layer on top of an existing scene
  109482. */
  109483. export class UtilityLayerRenderer implements IDisposable {
  109484. /** the original scene that will be rendered on top of */
  109485. originalScene: Scene;
  109486. private _pointerCaptures;
  109487. private _lastPointerEvents;
  109488. private static _DefaultUtilityLayer;
  109489. private static _DefaultKeepDepthUtilityLayer;
  109490. private _sharedGizmoLight;
  109491. private _renderCamera;
  109492. /**
  109493. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109494. * @returns the camera that is used when rendering the utility layer
  109495. */
  109496. getRenderCamera(): Nullable<Camera>;
  109497. /**
  109498. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109499. * @param cam the camera that should be used when rendering the utility layer
  109500. */
  109501. setRenderCamera(cam: Nullable<Camera>): void;
  109502. /**
  109503. * @hidden
  109504. * Light which used by gizmos to get light shading
  109505. */
  109506. _getSharedGizmoLight(): HemisphericLight;
  109507. /**
  109508. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109509. */
  109510. pickUtilitySceneFirst: boolean;
  109511. /**
  109512. * 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)
  109513. */
  109514. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109515. /**
  109516. * 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)
  109517. */
  109518. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109519. /**
  109520. * The scene that is rendered on top of the original scene
  109521. */
  109522. utilityLayerScene: Scene;
  109523. /**
  109524. * If the utility layer should automatically be rendered on top of existing scene
  109525. */
  109526. shouldRender: boolean;
  109527. /**
  109528. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109529. */
  109530. onlyCheckPointerDownEvents: boolean;
  109531. /**
  109532. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109533. */
  109534. processAllEvents: boolean;
  109535. /**
  109536. * Observable raised when the pointer move from the utility layer scene to the main scene
  109537. */
  109538. onPointerOutObservable: Observable<number>;
  109539. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109540. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109541. private _afterRenderObserver;
  109542. private _sceneDisposeObserver;
  109543. private _originalPointerObserver;
  109544. /**
  109545. * Instantiates a UtilityLayerRenderer
  109546. * @param originalScene the original scene that will be rendered on top of
  109547. * @param handleEvents boolean indicating if the utility layer should handle events
  109548. */
  109549. constructor(
  109550. /** the original scene that will be rendered on top of */
  109551. originalScene: Scene, handleEvents?: boolean);
  109552. private _notifyObservers;
  109553. /**
  109554. * Renders the utility layers scene on top of the original scene
  109555. */
  109556. render(): void;
  109557. /**
  109558. * Disposes of the renderer
  109559. */
  109560. dispose(): void;
  109561. private _updateCamera;
  109562. }
  109563. }
  109564. declare module BABYLON {
  109565. /**
  109566. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109567. */
  109568. export class Gizmo implements IDisposable {
  109569. /** The utility layer the gizmo will be added to */
  109570. gizmoLayer: UtilityLayerRenderer;
  109571. /**
  109572. * The root mesh of the gizmo
  109573. */
  109574. _rootMesh: Mesh;
  109575. private _attachedMesh;
  109576. /**
  109577. * Ratio for the scale of the gizmo (Default: 1)
  109578. */
  109579. scaleRatio: number;
  109580. /**
  109581. * If a custom mesh has been set (Default: false)
  109582. */
  109583. protected _customMeshSet: boolean;
  109584. /**
  109585. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109586. * * When set, interactions will be enabled
  109587. */
  109588. attachedMesh: Nullable<AbstractMesh>;
  109589. /**
  109590. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109591. * @param mesh The mesh to replace the default mesh of the gizmo
  109592. */
  109593. setCustomMesh(mesh: Mesh): void;
  109594. /**
  109595. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109596. */
  109597. updateGizmoRotationToMatchAttachedMesh: boolean;
  109598. /**
  109599. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109600. */
  109601. updateGizmoPositionToMatchAttachedMesh: boolean;
  109602. /**
  109603. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109604. */
  109605. updateScale: boolean;
  109606. protected _interactionsEnabled: boolean;
  109607. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109608. private _beforeRenderObserver;
  109609. private _tempVector;
  109610. /**
  109611. * Creates a gizmo
  109612. * @param gizmoLayer The utility layer the gizmo will be added to
  109613. */
  109614. constructor(
  109615. /** The utility layer the gizmo will be added to */
  109616. gizmoLayer?: UtilityLayerRenderer);
  109617. /**
  109618. * Updates the gizmo to match the attached mesh's position/rotation
  109619. */
  109620. protected _update(): void;
  109621. /**
  109622. * Disposes of the gizmo
  109623. */
  109624. dispose(): void;
  109625. }
  109626. }
  109627. declare module BABYLON {
  109628. /**
  109629. * Single plane drag gizmo
  109630. */
  109631. export class PlaneDragGizmo extends Gizmo {
  109632. /**
  109633. * Drag behavior responsible for the gizmos dragging interactions
  109634. */
  109635. dragBehavior: PointerDragBehavior;
  109636. private _pointerObserver;
  109637. /**
  109638. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109639. */
  109640. snapDistance: number;
  109641. /**
  109642. * Event that fires each time the gizmo snaps to a new location.
  109643. * * snapDistance is the the change in distance
  109644. */
  109645. onSnapObservable: Observable<{
  109646. snapDistance: number;
  109647. }>;
  109648. private _plane;
  109649. private _coloredMaterial;
  109650. private _hoverMaterial;
  109651. private _isEnabled;
  109652. private _parent;
  109653. /** @hidden */
  109654. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109655. /** @hidden */
  109656. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109657. /**
  109658. * Creates a PlaneDragGizmo
  109659. * @param gizmoLayer The utility layer the gizmo will be added to
  109660. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109661. * @param color The color of the gizmo
  109662. */
  109663. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109664. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109665. /**
  109666. * If the gizmo is enabled
  109667. */
  109668. isEnabled: boolean;
  109669. /**
  109670. * Disposes of the gizmo
  109671. */
  109672. dispose(): void;
  109673. }
  109674. }
  109675. declare module BABYLON {
  109676. /**
  109677. * Gizmo that enables dragging a mesh along 3 axis
  109678. */
  109679. export class PositionGizmo extends Gizmo {
  109680. /**
  109681. * Internal gizmo used for interactions on the x axis
  109682. */
  109683. xGizmo: AxisDragGizmo;
  109684. /**
  109685. * Internal gizmo used for interactions on the y axis
  109686. */
  109687. yGizmo: AxisDragGizmo;
  109688. /**
  109689. * Internal gizmo used for interactions on the z axis
  109690. */
  109691. zGizmo: AxisDragGizmo;
  109692. /**
  109693. * Internal gizmo used for interactions on the yz plane
  109694. */
  109695. xPlaneGizmo: PlaneDragGizmo;
  109696. /**
  109697. * Internal gizmo used for interactions on the xz plane
  109698. */
  109699. yPlaneGizmo: PlaneDragGizmo;
  109700. /**
  109701. * Internal gizmo used for interactions on the xy plane
  109702. */
  109703. zPlaneGizmo: PlaneDragGizmo;
  109704. /**
  109705. * private variables
  109706. */
  109707. private _meshAttached;
  109708. private _updateGizmoRotationToMatchAttachedMesh;
  109709. private _snapDistance;
  109710. private _scaleRatio;
  109711. /** Fires an event when any of it's sub gizmos are dragged */
  109712. onDragStartObservable: Observable<unknown>;
  109713. /** Fires an event when any of it's sub gizmos are released from dragging */
  109714. onDragEndObservable: Observable<unknown>;
  109715. /**
  109716. * If set to true, planar drag is enabled
  109717. */
  109718. private _planarGizmoEnabled;
  109719. attachedMesh: Nullable<AbstractMesh>;
  109720. /**
  109721. * Creates a PositionGizmo
  109722. * @param gizmoLayer The utility layer the gizmo will be added to
  109723. */
  109724. constructor(gizmoLayer?: UtilityLayerRenderer);
  109725. /**
  109726. * If the planar drag gizmo is enabled
  109727. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109728. */
  109729. planarGizmoEnabled: boolean;
  109730. updateGizmoRotationToMatchAttachedMesh: boolean;
  109731. /**
  109732. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109733. */
  109734. snapDistance: number;
  109735. /**
  109736. * Ratio for the scale of the gizmo (Default: 1)
  109737. */
  109738. scaleRatio: number;
  109739. /**
  109740. * Disposes of the gizmo
  109741. */
  109742. dispose(): void;
  109743. /**
  109744. * CustomMeshes are not supported by this gizmo
  109745. * @param mesh The mesh to replace the default mesh of the gizmo
  109746. */
  109747. setCustomMesh(mesh: Mesh): void;
  109748. }
  109749. }
  109750. declare module BABYLON {
  109751. /**
  109752. * Single axis drag gizmo
  109753. */
  109754. export class AxisDragGizmo extends Gizmo {
  109755. /**
  109756. * Drag behavior responsible for the gizmos dragging interactions
  109757. */
  109758. dragBehavior: PointerDragBehavior;
  109759. private _pointerObserver;
  109760. /**
  109761. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109762. */
  109763. snapDistance: number;
  109764. /**
  109765. * Event that fires each time the gizmo snaps to a new location.
  109766. * * snapDistance is the the change in distance
  109767. */
  109768. onSnapObservable: Observable<{
  109769. snapDistance: number;
  109770. }>;
  109771. private _isEnabled;
  109772. private _parent;
  109773. private _arrow;
  109774. private _coloredMaterial;
  109775. private _hoverMaterial;
  109776. /** @hidden */
  109777. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109778. /** @hidden */
  109779. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109780. /**
  109781. * Creates an AxisDragGizmo
  109782. * @param gizmoLayer The utility layer the gizmo will be added to
  109783. * @param dragAxis The axis which the gizmo will be able to drag on
  109784. * @param color The color of the gizmo
  109785. */
  109786. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109787. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109788. /**
  109789. * If the gizmo is enabled
  109790. */
  109791. isEnabled: boolean;
  109792. /**
  109793. * Disposes of the gizmo
  109794. */
  109795. dispose(): void;
  109796. }
  109797. }
  109798. declare module BABYLON.Debug {
  109799. /**
  109800. * The Axes viewer will show 3 axes in a specific point in space
  109801. */
  109802. export class AxesViewer {
  109803. private _xAxis;
  109804. private _yAxis;
  109805. private _zAxis;
  109806. private _scaleLinesFactor;
  109807. private _instanced;
  109808. /**
  109809. * Gets the hosting scene
  109810. */
  109811. scene: Scene;
  109812. /**
  109813. * Gets or sets a number used to scale line length
  109814. */
  109815. scaleLines: number;
  109816. /** Gets the node hierarchy used to render x-axis */
  109817. readonly xAxis: TransformNode;
  109818. /** Gets the node hierarchy used to render y-axis */
  109819. readonly yAxis: TransformNode;
  109820. /** Gets the node hierarchy used to render z-axis */
  109821. readonly zAxis: TransformNode;
  109822. /**
  109823. * Creates a new AxesViewer
  109824. * @param scene defines the hosting scene
  109825. * @param scaleLines defines a number used to scale line length (1 by default)
  109826. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109827. * @param xAxis defines the node hierarchy used to render the x-axis
  109828. * @param yAxis defines the node hierarchy used to render the y-axis
  109829. * @param zAxis defines the node hierarchy used to render the z-axis
  109830. */
  109831. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109832. /**
  109833. * Force the viewer to update
  109834. * @param position defines the position of the viewer
  109835. * @param xaxis defines the x axis of the viewer
  109836. * @param yaxis defines the y axis of the viewer
  109837. * @param zaxis defines the z axis of the viewer
  109838. */
  109839. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109840. /**
  109841. * Creates an instance of this axes viewer.
  109842. * @returns a new axes viewer with instanced meshes
  109843. */
  109844. createInstance(): AxesViewer;
  109845. /** Releases resources */
  109846. dispose(): void;
  109847. private static _SetRenderingGroupId;
  109848. }
  109849. }
  109850. declare module BABYLON.Debug {
  109851. /**
  109852. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109853. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109854. */
  109855. export class BoneAxesViewer extends AxesViewer {
  109856. /**
  109857. * Gets or sets the target mesh where to display the axes viewer
  109858. */
  109859. mesh: Nullable<Mesh>;
  109860. /**
  109861. * Gets or sets the target bone where to display the axes viewer
  109862. */
  109863. bone: Nullable<Bone>;
  109864. /** Gets current position */
  109865. pos: Vector3;
  109866. /** Gets direction of X axis */
  109867. xaxis: Vector3;
  109868. /** Gets direction of Y axis */
  109869. yaxis: Vector3;
  109870. /** Gets direction of Z axis */
  109871. zaxis: Vector3;
  109872. /**
  109873. * Creates a new BoneAxesViewer
  109874. * @param scene defines the hosting scene
  109875. * @param bone defines the target bone
  109876. * @param mesh defines the target mesh
  109877. * @param scaleLines defines a scaling factor for line length (1 by default)
  109878. */
  109879. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109880. /**
  109881. * Force the viewer to update
  109882. */
  109883. update(): void;
  109884. /** Releases resources */
  109885. dispose(): void;
  109886. }
  109887. }
  109888. declare module BABYLON {
  109889. /**
  109890. * Interface used to define scene explorer extensibility option
  109891. */
  109892. export interface IExplorerExtensibilityOption {
  109893. /**
  109894. * Define the option label
  109895. */
  109896. label: string;
  109897. /**
  109898. * Defines the action to execute on click
  109899. */
  109900. action: (entity: any) => void;
  109901. }
  109902. /**
  109903. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109904. */
  109905. export interface IExplorerExtensibilityGroup {
  109906. /**
  109907. * Defines a predicate to test if a given type mut be extended
  109908. */
  109909. predicate: (entity: any) => boolean;
  109910. /**
  109911. * Gets the list of options added to a type
  109912. */
  109913. entries: IExplorerExtensibilityOption[];
  109914. }
  109915. /**
  109916. * Interface used to define the options to use to create the Inspector
  109917. */
  109918. export interface IInspectorOptions {
  109919. /**
  109920. * Display in overlay mode (default: false)
  109921. */
  109922. overlay?: boolean;
  109923. /**
  109924. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109925. */
  109926. globalRoot?: HTMLElement;
  109927. /**
  109928. * Display the Scene explorer
  109929. */
  109930. showExplorer?: boolean;
  109931. /**
  109932. * Display the property inspector
  109933. */
  109934. showInspector?: boolean;
  109935. /**
  109936. * Display in embed mode (both panes on the right)
  109937. */
  109938. embedMode?: boolean;
  109939. /**
  109940. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109941. */
  109942. handleResize?: boolean;
  109943. /**
  109944. * Allow the panes to popup (default: true)
  109945. */
  109946. enablePopup?: boolean;
  109947. /**
  109948. * Allow the panes to be closed by users (default: true)
  109949. */
  109950. enableClose?: boolean;
  109951. /**
  109952. * Optional list of extensibility entries
  109953. */
  109954. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109955. /**
  109956. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109957. */
  109958. inspectorURL?: string;
  109959. }
  109960. interface Scene {
  109961. /**
  109962. * @hidden
  109963. * Backing field
  109964. */
  109965. _debugLayer: DebugLayer;
  109966. /**
  109967. * Gets the debug layer (aka Inspector) associated with the scene
  109968. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109969. */
  109970. debugLayer: DebugLayer;
  109971. }
  109972. /**
  109973. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109974. * what is happening in your scene
  109975. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109976. */
  109977. export class DebugLayer {
  109978. /**
  109979. * Define the url to get the inspector script from.
  109980. * By default it uses the babylonjs CDN.
  109981. * @ignoreNaming
  109982. */
  109983. static InspectorURL: string;
  109984. private _scene;
  109985. private BJSINSPECTOR;
  109986. private _onPropertyChangedObservable?;
  109987. /**
  109988. * Observable triggered when a property is changed through the inspector.
  109989. */
  109990. readonly onPropertyChangedObservable: any;
  109991. /**
  109992. * Instantiates a new debug layer.
  109993. * The debug layer (aka Inspector) is the go to tool in order to better understand
  109994. * what is happening in your scene
  109995. * @see http://doc.babylonjs.com/features/playground_debuglayer
  109996. * @param scene Defines the scene to inspect
  109997. */
  109998. constructor(scene: Scene);
  109999. /** Creates the inspector window. */
  110000. private _createInspector;
  110001. /**
  110002. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110003. * @param entity defines the entity to select
  110004. * @param lineContainerTitle defines the specific block to highlight
  110005. */
  110006. select(entity: any, lineContainerTitle?: string): void;
  110007. /** Get the inspector from bundle or global */
  110008. private _getGlobalInspector;
  110009. /**
  110010. * Get if the inspector is visible or not.
  110011. * @returns true if visible otherwise, false
  110012. */
  110013. isVisible(): boolean;
  110014. /**
  110015. * Hide the inspector and close its window.
  110016. */
  110017. hide(): void;
  110018. /**
  110019. * Launch the debugLayer.
  110020. * @param config Define the configuration of the inspector
  110021. * @return a promise fulfilled when the debug layer is visible
  110022. */
  110023. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110024. }
  110025. }
  110026. declare module BABYLON {
  110027. /**
  110028. * Class containing static functions to help procedurally build meshes
  110029. */
  110030. export class BoxBuilder {
  110031. /**
  110032. * Creates a box mesh
  110033. * * The parameter `size` sets the size (float) of each box side (default 1)
  110034. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110035. * * 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)
  110036. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110037. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110038. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110040. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110041. * @param name defines the name of the mesh
  110042. * @param options defines the options used to create the mesh
  110043. * @param scene defines the hosting scene
  110044. * @returns the box mesh
  110045. */
  110046. static CreateBox(name: string, options: {
  110047. size?: number;
  110048. width?: number;
  110049. height?: number;
  110050. depth?: number;
  110051. faceUV?: Vector4[];
  110052. faceColors?: Color4[];
  110053. sideOrientation?: number;
  110054. frontUVs?: Vector4;
  110055. backUVs?: Vector4;
  110056. wrap?: boolean;
  110057. topBaseAt?: number;
  110058. bottomBaseAt?: number;
  110059. updatable?: boolean;
  110060. }, scene?: Nullable<Scene>): Mesh;
  110061. }
  110062. }
  110063. declare module BABYLON {
  110064. /**
  110065. * Class containing static functions to help procedurally build meshes
  110066. */
  110067. export class SphereBuilder {
  110068. /**
  110069. * Creates a sphere mesh
  110070. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110071. * * 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`)
  110072. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110073. * * 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
  110074. * * 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)
  110075. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110076. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110077. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110078. * @param name defines the name of the mesh
  110079. * @param options defines the options used to create the mesh
  110080. * @param scene defines the hosting scene
  110081. * @returns the sphere mesh
  110082. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110083. */
  110084. static CreateSphere(name: string, options: {
  110085. segments?: number;
  110086. diameter?: number;
  110087. diameterX?: number;
  110088. diameterY?: number;
  110089. diameterZ?: number;
  110090. arc?: number;
  110091. slice?: number;
  110092. sideOrientation?: number;
  110093. frontUVs?: Vector4;
  110094. backUVs?: Vector4;
  110095. updatable?: boolean;
  110096. }, scene?: Nullable<Scene>): Mesh;
  110097. }
  110098. }
  110099. declare module BABYLON.Debug {
  110100. /**
  110101. * Used to show the physics impostor around the specific mesh
  110102. */
  110103. export class PhysicsViewer {
  110104. /** @hidden */
  110105. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110106. /** @hidden */
  110107. protected _meshes: Array<Nullable<AbstractMesh>>;
  110108. /** @hidden */
  110109. protected _scene: Nullable<Scene>;
  110110. /** @hidden */
  110111. protected _numMeshes: number;
  110112. /** @hidden */
  110113. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110114. private _renderFunction;
  110115. private _utilityLayer;
  110116. private _debugBoxMesh;
  110117. private _debugSphereMesh;
  110118. private _debugCylinderMesh;
  110119. private _debugMaterial;
  110120. private _debugMeshMeshes;
  110121. /**
  110122. * Creates a new PhysicsViewer
  110123. * @param scene defines the hosting scene
  110124. */
  110125. constructor(scene: Scene);
  110126. /** @hidden */
  110127. protected _updateDebugMeshes(): void;
  110128. /**
  110129. * Renders a specified physic impostor
  110130. * @param impostor defines the impostor to render
  110131. * @param targetMesh defines the mesh represented by the impostor
  110132. * @returns the new debug mesh used to render the impostor
  110133. */
  110134. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110135. /**
  110136. * Hides a specified physic impostor
  110137. * @param impostor defines the impostor to hide
  110138. */
  110139. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110140. private _getDebugMaterial;
  110141. private _getDebugBoxMesh;
  110142. private _getDebugSphereMesh;
  110143. private _getDebugCylinderMesh;
  110144. private _getDebugMeshMesh;
  110145. private _getDebugMesh;
  110146. /** Releases all resources */
  110147. dispose(): void;
  110148. }
  110149. }
  110150. declare module BABYLON {
  110151. /**
  110152. * Class containing static functions to help procedurally build meshes
  110153. */
  110154. export class LinesBuilder {
  110155. /**
  110156. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110157. * * 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
  110158. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110159. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110160. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110161. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110162. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110163. * * 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
  110164. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110165. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110166. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110167. * @param name defines the name of the new line system
  110168. * @param options defines the options used to create the line system
  110169. * @param scene defines the hosting scene
  110170. * @returns a new line system mesh
  110171. */
  110172. static CreateLineSystem(name: string, options: {
  110173. lines: Vector3[][];
  110174. updatable?: boolean;
  110175. instance?: Nullable<LinesMesh>;
  110176. colors?: Nullable<Color4[][]>;
  110177. useVertexAlpha?: boolean;
  110178. }, scene: Nullable<Scene>): LinesMesh;
  110179. /**
  110180. * Creates a line mesh
  110181. * 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
  110182. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110183. * * The parameter `points` is an array successive Vector3
  110184. * * 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
  110185. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110186. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110187. * * When updating an instance, remember that only point positions can change, not the number of points
  110188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110189. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110190. * @param name defines the name of the new line system
  110191. * @param options defines the options used to create the line system
  110192. * @param scene defines the hosting scene
  110193. * @returns a new line mesh
  110194. */
  110195. static CreateLines(name: string, options: {
  110196. points: Vector3[];
  110197. updatable?: boolean;
  110198. instance?: Nullable<LinesMesh>;
  110199. colors?: Color4[];
  110200. useVertexAlpha?: boolean;
  110201. }, scene?: Nullable<Scene>): LinesMesh;
  110202. /**
  110203. * Creates a dashed line mesh
  110204. * * 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
  110205. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110206. * * The parameter `points` is an array successive Vector3
  110207. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110208. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110209. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110210. * * 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
  110211. * * When updating an instance, remember that only point positions can change, not the number of points
  110212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110213. * @param name defines the name of the mesh
  110214. * @param options defines the options used to create the mesh
  110215. * @param scene defines the hosting scene
  110216. * @returns the dashed line mesh
  110217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110218. */
  110219. static CreateDashedLines(name: string, options: {
  110220. points: Vector3[];
  110221. dashSize?: number;
  110222. gapSize?: number;
  110223. dashNb?: number;
  110224. updatable?: boolean;
  110225. instance?: LinesMesh;
  110226. }, scene?: Nullable<Scene>): LinesMesh;
  110227. }
  110228. }
  110229. declare module BABYLON {
  110230. /**
  110231. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110232. * in order to better appreciate the issue one might have.
  110233. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110234. */
  110235. export class RayHelper {
  110236. /**
  110237. * Defines the ray we are currently tryin to visualize.
  110238. */
  110239. ray: Nullable<Ray>;
  110240. private _renderPoints;
  110241. private _renderLine;
  110242. private _renderFunction;
  110243. private _scene;
  110244. private _updateToMeshFunction;
  110245. private _attachedToMesh;
  110246. private _meshSpaceDirection;
  110247. private _meshSpaceOrigin;
  110248. /**
  110249. * Helper function to create a colored helper in a scene in one line.
  110250. * @param ray Defines the ray we are currently tryin to visualize
  110251. * @param scene Defines the scene the ray is used in
  110252. * @param color Defines the color we want to see the ray in
  110253. * @returns The newly created ray helper.
  110254. */
  110255. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110256. /**
  110257. * Instantiate a new ray helper.
  110258. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110259. * in order to better appreciate the issue one might have.
  110260. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110261. * @param ray Defines the ray we are currently tryin to visualize
  110262. */
  110263. constructor(ray: Ray);
  110264. /**
  110265. * Shows the ray we are willing to debug.
  110266. * @param scene Defines the scene the ray needs to be rendered in
  110267. * @param color Defines the color the ray needs to be rendered in
  110268. */
  110269. show(scene: Scene, color?: Color3): void;
  110270. /**
  110271. * Hides the ray we are debugging.
  110272. */
  110273. hide(): void;
  110274. private _render;
  110275. /**
  110276. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110277. * @param mesh Defines the mesh we want the helper attached to
  110278. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110279. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110280. * @param length Defines the length of the ray
  110281. */
  110282. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110283. /**
  110284. * Detach the ray helper from the mesh it has previously been attached to.
  110285. */
  110286. detachFromMesh(): void;
  110287. private _updateToMesh;
  110288. /**
  110289. * Dispose the helper and release its associated resources.
  110290. */
  110291. dispose(): void;
  110292. }
  110293. }
  110294. declare module BABYLON.Debug {
  110295. /**
  110296. * Class used to render a debug view of a given skeleton
  110297. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110298. */
  110299. export class SkeletonViewer {
  110300. /** defines the skeleton to render */
  110301. skeleton: Skeleton;
  110302. /** defines the mesh attached to the skeleton */
  110303. mesh: AbstractMesh;
  110304. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110305. autoUpdateBonesMatrices: boolean;
  110306. /** defines the rendering group id to use with the viewer */
  110307. renderingGroupId: number;
  110308. /** Gets or sets the color used to render the skeleton */
  110309. color: Color3;
  110310. private _scene;
  110311. private _debugLines;
  110312. private _debugMesh;
  110313. private _isEnabled;
  110314. private _renderFunction;
  110315. private _utilityLayer;
  110316. /**
  110317. * Returns the mesh used to render the bones
  110318. */
  110319. readonly debugMesh: Nullable<LinesMesh>;
  110320. /**
  110321. * Creates a new SkeletonViewer
  110322. * @param skeleton defines the skeleton to render
  110323. * @param mesh defines the mesh attached to the skeleton
  110324. * @param scene defines the hosting scene
  110325. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110326. * @param renderingGroupId defines the rendering group id to use with the viewer
  110327. */
  110328. constructor(
  110329. /** defines the skeleton to render */
  110330. skeleton: Skeleton,
  110331. /** defines the mesh attached to the skeleton */
  110332. mesh: AbstractMesh, scene: Scene,
  110333. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110334. autoUpdateBonesMatrices?: boolean,
  110335. /** defines the rendering group id to use with the viewer */
  110336. renderingGroupId?: number);
  110337. /** Gets or sets a boolean indicating if the viewer is enabled */
  110338. isEnabled: boolean;
  110339. private _getBonePosition;
  110340. private _getLinesForBonesWithLength;
  110341. private _getLinesForBonesNoLength;
  110342. /** Update the viewer to sync with current skeleton state */
  110343. update(): void;
  110344. /** Release associated resources */
  110345. dispose(): void;
  110346. }
  110347. }
  110348. declare module BABYLON {
  110349. /**
  110350. * Options to create the null engine
  110351. */
  110352. export class NullEngineOptions {
  110353. /**
  110354. * Render width (Default: 512)
  110355. */
  110356. renderWidth: number;
  110357. /**
  110358. * Render height (Default: 256)
  110359. */
  110360. renderHeight: number;
  110361. /**
  110362. * Texture size (Default: 512)
  110363. */
  110364. textureSize: number;
  110365. /**
  110366. * If delta time between frames should be constant
  110367. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110368. */
  110369. deterministicLockstep: boolean;
  110370. /**
  110371. * Maximum about of steps between frames (Default: 4)
  110372. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110373. */
  110374. lockstepMaxSteps: number;
  110375. }
  110376. /**
  110377. * The null engine class provides support for headless version of babylon.js.
  110378. * This can be used in server side scenario or for testing purposes
  110379. */
  110380. export class NullEngine extends Engine {
  110381. private _options;
  110382. /**
  110383. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110384. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110385. * @returns true if engine is in deterministic lock step mode
  110386. */
  110387. isDeterministicLockStep(): boolean;
  110388. /**
  110389. * Gets the max steps when engine is running in deterministic lock step
  110390. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110391. * @returns the max steps
  110392. */
  110393. getLockstepMaxSteps(): number;
  110394. /**
  110395. * Gets the current hardware scaling level.
  110396. * By default the hardware scaling level is computed from the window device ratio.
  110397. * 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.
  110398. * @returns a number indicating the current hardware scaling level
  110399. */
  110400. getHardwareScalingLevel(): number;
  110401. constructor(options?: NullEngineOptions);
  110402. /**
  110403. * Creates a vertex buffer
  110404. * @param vertices the data for the vertex buffer
  110405. * @returns the new WebGL static buffer
  110406. */
  110407. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110408. /**
  110409. * Creates a new index buffer
  110410. * @param indices defines the content of the index buffer
  110411. * @param updatable defines if the index buffer must be updatable
  110412. * @returns a new webGL buffer
  110413. */
  110414. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110415. /**
  110416. * Clear the current render buffer or the current render target (if any is set up)
  110417. * @param color defines the color to use
  110418. * @param backBuffer defines if the back buffer must be cleared
  110419. * @param depth defines if the depth buffer must be cleared
  110420. * @param stencil defines if the stencil buffer must be cleared
  110421. */
  110422. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110423. /**
  110424. * Gets the current render width
  110425. * @param useScreen defines if screen size must be used (or the current render target if any)
  110426. * @returns a number defining the current render width
  110427. */
  110428. getRenderWidth(useScreen?: boolean): number;
  110429. /**
  110430. * Gets the current render height
  110431. * @param useScreen defines if screen size must be used (or the current render target if any)
  110432. * @returns a number defining the current render height
  110433. */
  110434. getRenderHeight(useScreen?: boolean): number;
  110435. /**
  110436. * Set the WebGL's viewport
  110437. * @param viewport defines the viewport element to be used
  110438. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110439. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110440. */
  110441. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110442. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110443. /**
  110444. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110445. * @param pipelineContext defines the pipeline context to use
  110446. * @param uniformsNames defines the list of uniform names
  110447. * @returns an array of webGL uniform locations
  110448. */
  110449. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110450. /**
  110451. * Gets the lsit of active attributes for a given webGL program
  110452. * @param pipelineContext defines the pipeline context to use
  110453. * @param attributesNames defines the list of attribute names to get
  110454. * @returns an array of indices indicating the offset of each attribute
  110455. */
  110456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110457. /**
  110458. * Binds an effect to the webGL context
  110459. * @param effect defines the effect to bind
  110460. */
  110461. bindSamplers(effect: Effect): void;
  110462. /**
  110463. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110464. * @param effect defines the effect to activate
  110465. */
  110466. enableEffect(effect: Effect): void;
  110467. /**
  110468. * Set various states to the webGL context
  110469. * @param culling defines backface culling state
  110470. * @param zOffset defines the value to apply to zOffset (0 by default)
  110471. * @param force defines if states must be applied even if cache is up to date
  110472. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110473. */
  110474. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110475. /**
  110476. * Set the value of an uniform to an array of int32
  110477. * @param uniform defines the webGL uniform location where to store the value
  110478. * @param array defines the array of int32 to store
  110479. */
  110480. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110481. /**
  110482. * Set the value of an uniform to an array of int32 (stored as vec2)
  110483. * @param uniform defines the webGL uniform location where to store the value
  110484. * @param array defines the array of int32 to store
  110485. */
  110486. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110487. /**
  110488. * Set the value of an uniform to an array of int32 (stored as vec3)
  110489. * @param uniform defines the webGL uniform location where to store the value
  110490. * @param array defines the array of int32 to store
  110491. */
  110492. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110493. /**
  110494. * Set the value of an uniform to an array of int32 (stored as vec4)
  110495. * @param uniform defines the webGL uniform location where to store the value
  110496. * @param array defines the array of int32 to store
  110497. */
  110498. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110499. /**
  110500. * Set the value of an uniform to an array of float32
  110501. * @param uniform defines the webGL uniform location where to store the value
  110502. * @param array defines the array of float32 to store
  110503. */
  110504. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110505. /**
  110506. * Set the value of an uniform to an array of float32 (stored as vec2)
  110507. * @param uniform defines the webGL uniform location where to store the value
  110508. * @param array defines the array of float32 to store
  110509. */
  110510. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110511. /**
  110512. * Set the value of an uniform to an array of float32 (stored as vec3)
  110513. * @param uniform defines the webGL uniform location where to store the value
  110514. * @param array defines the array of float32 to store
  110515. */
  110516. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110517. /**
  110518. * Set the value of an uniform to an array of float32 (stored as vec4)
  110519. * @param uniform defines the webGL uniform location where to store the value
  110520. * @param array defines the array of float32 to store
  110521. */
  110522. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110523. /**
  110524. * Set the value of an uniform to an array of number
  110525. * @param uniform defines the webGL uniform location where to store the value
  110526. * @param array defines the array of number to store
  110527. */
  110528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110529. /**
  110530. * Set the value of an uniform to an array of number (stored as vec2)
  110531. * @param uniform defines the webGL uniform location where to store the value
  110532. * @param array defines the array of number to store
  110533. */
  110534. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110535. /**
  110536. * Set the value of an uniform to an array of number (stored as vec3)
  110537. * @param uniform defines the webGL uniform location where to store the value
  110538. * @param array defines the array of number to store
  110539. */
  110540. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110541. /**
  110542. * Set the value of an uniform to an array of number (stored as vec4)
  110543. * @param uniform defines the webGL uniform location where to store the value
  110544. * @param array defines the array of number to store
  110545. */
  110546. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110547. /**
  110548. * Set the value of an uniform to an array of float32 (stored as matrices)
  110549. * @param uniform defines the webGL uniform location where to store the value
  110550. * @param matrices defines the array of float32 to store
  110551. */
  110552. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110553. /**
  110554. * Set the value of an uniform to a matrix (3x3)
  110555. * @param uniform defines the webGL uniform location where to store the value
  110556. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110557. */
  110558. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110559. /**
  110560. * Set the value of an uniform to a matrix (2x2)
  110561. * @param uniform defines the webGL uniform location where to store the value
  110562. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110563. */
  110564. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110565. /**
  110566. * Set the value of an uniform to a number (float)
  110567. * @param uniform defines the webGL uniform location where to store the value
  110568. * @param value defines the float number to store
  110569. */
  110570. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110571. /**
  110572. * Set the value of an uniform to a vec2
  110573. * @param uniform defines the webGL uniform location where to store the value
  110574. * @param x defines the 1st component of the value
  110575. * @param y defines the 2nd component of the value
  110576. */
  110577. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110578. /**
  110579. * Set the value of an uniform to a vec3
  110580. * @param uniform defines the webGL uniform location where to store the value
  110581. * @param x defines the 1st component of the value
  110582. * @param y defines the 2nd component of the value
  110583. * @param z defines the 3rd component of the value
  110584. */
  110585. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110586. /**
  110587. * Set the value of an uniform to a boolean
  110588. * @param uniform defines the webGL uniform location where to store the value
  110589. * @param bool defines the boolean to store
  110590. */
  110591. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110592. /**
  110593. * Set the value of an uniform to a vec4
  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. * @param w defines the 4th component of the value
  110599. */
  110600. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110601. /**
  110602. * Sets the current alpha mode
  110603. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110604. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110605. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110606. */
  110607. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110608. /**
  110609. * Bind webGl buffers directly to the webGL context
  110610. * @param vertexBuffers defines the vertex buffer to bind
  110611. * @param indexBuffer defines the index buffer to bind
  110612. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110613. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110614. * @param effect defines the effect associated with the vertex buffer
  110615. */
  110616. bindBuffers(vertexBuffers: {
  110617. [key: string]: VertexBuffer;
  110618. }, indexBuffer: DataBuffer, effect: Effect): void;
  110619. /**
  110620. * Force the entire cache to be cleared
  110621. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110622. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110623. */
  110624. wipeCaches(bruteForce?: boolean): void;
  110625. /**
  110626. * Send a draw order
  110627. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110628. * @param indexStart defines the starting index
  110629. * @param indexCount defines the number of index to draw
  110630. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110631. */
  110632. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110633. /**
  110634. * Draw a list of indexed primitives
  110635. * @param fillMode defines the primitive to use
  110636. * @param indexStart defines the starting index
  110637. * @param indexCount defines the number of index to draw
  110638. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110639. */
  110640. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110641. /**
  110642. * Draw a list of unindexed primitives
  110643. * @param fillMode defines the primitive to use
  110644. * @param verticesStart defines the index of first vertex to draw
  110645. * @param verticesCount defines the count of vertices to draw
  110646. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110647. */
  110648. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110649. /** @hidden */
  110650. _createTexture(): WebGLTexture;
  110651. /** @hidden */
  110652. _releaseTexture(texture: InternalTexture): void;
  110653. /**
  110654. * Usually called from Texture.ts.
  110655. * Passed information to create a WebGLTexture
  110656. * @param urlArg defines a value which contains one of the following:
  110657. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110658. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110659. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110660. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110661. * @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)
  110662. * @param scene needed for loading to the correct scene
  110663. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110664. * @param onLoad optional callback to be called upon successful completion
  110665. * @param onError optional callback to be called upon failure
  110666. * @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
  110667. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110668. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110669. * @param forcedExtension defines the extension to use to pick the right loader
  110670. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110671. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110672. */
  110673. 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;
  110674. /**
  110675. * Creates a new render target texture
  110676. * @param size defines the size of the texture
  110677. * @param options defines the options used to create the texture
  110678. * @returns a new render target texture stored in an InternalTexture
  110679. */
  110680. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110681. /**
  110682. * Update the sampling mode of a given texture
  110683. * @param samplingMode defines the required sampling mode
  110684. * @param texture defines the texture to update
  110685. */
  110686. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110687. /**
  110688. * Binds the frame buffer to the specified texture.
  110689. * @param texture The texture to render to or null for the default canvas
  110690. * @param faceIndex The face of the texture to render to in case of cube texture
  110691. * @param requiredWidth The width of the target to render to
  110692. * @param requiredHeight The height of the target to render to
  110693. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110694. * @param depthStencilTexture The depth stencil texture to use to render
  110695. * @param lodLevel defines le lod level to bind to the frame buffer
  110696. */
  110697. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110698. /**
  110699. * Unbind the current render target texture from the webGL context
  110700. * @param texture defines the render target texture to unbind
  110701. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110702. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110703. */
  110704. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110705. /**
  110706. * Creates a dynamic vertex buffer
  110707. * @param vertices the data for the dynamic vertex buffer
  110708. * @returns the new WebGL dynamic buffer
  110709. */
  110710. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110711. /**
  110712. * Update the content of a dynamic texture
  110713. * @param texture defines the texture to update
  110714. * @param canvas defines the canvas containing the source
  110715. * @param invertY defines if data must be stored with Y axis inverted
  110716. * @param premulAlpha defines if alpha is stored as premultiplied
  110717. * @param format defines the format of the data
  110718. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110719. */
  110720. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110721. /**
  110722. * Gets a boolean indicating if all created effects are ready
  110723. * @returns true if all effects are ready
  110724. */
  110725. areAllEffectsReady(): boolean;
  110726. /**
  110727. * @hidden
  110728. * Get the current error code of the webGL context
  110729. * @returns the error code
  110730. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110731. */
  110732. getError(): number;
  110733. /** @hidden */
  110734. _getUnpackAlignement(): number;
  110735. /** @hidden */
  110736. _unpackFlipY(value: boolean): void;
  110737. /**
  110738. * Update a dynamic index buffer
  110739. * @param indexBuffer defines the target index buffer
  110740. * @param indices defines the data to update
  110741. * @param offset defines the offset in the target index buffer where update should start
  110742. */
  110743. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110744. /**
  110745. * Updates a dynamic vertex buffer.
  110746. * @param vertexBuffer the vertex buffer to update
  110747. * @param vertices the data used to update the vertex buffer
  110748. * @param byteOffset the byte offset of the data (optional)
  110749. * @param byteLength the byte length of the data (optional)
  110750. */
  110751. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110752. /** @hidden */
  110753. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110754. /** @hidden */
  110755. _bindTexture(channel: number, texture: InternalTexture): void;
  110756. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110757. /**
  110758. * 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
  110759. */
  110760. releaseEffects(): void;
  110761. displayLoadingUI(): void;
  110762. hideLoadingUI(): void;
  110763. /** @hidden */
  110764. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110765. /** @hidden */
  110766. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110767. /** @hidden */
  110768. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110769. /** @hidden */
  110770. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110771. }
  110772. }
  110773. declare module BABYLON {
  110774. /** @hidden */
  110775. export class _OcclusionDataStorage {
  110776. /** @hidden */
  110777. occlusionInternalRetryCounter: number;
  110778. /** @hidden */
  110779. isOcclusionQueryInProgress: boolean;
  110780. /** @hidden */
  110781. isOccluded: boolean;
  110782. /** @hidden */
  110783. occlusionRetryCount: number;
  110784. /** @hidden */
  110785. occlusionType: number;
  110786. /** @hidden */
  110787. occlusionQueryAlgorithmType: number;
  110788. }
  110789. interface Engine {
  110790. /**
  110791. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110792. * @return the new query
  110793. */
  110794. createQuery(): WebGLQuery;
  110795. /**
  110796. * Delete and release a webGL query
  110797. * @param query defines the query to delete
  110798. * @return the current engine
  110799. */
  110800. deleteQuery(query: WebGLQuery): Engine;
  110801. /**
  110802. * Check if a given query has resolved and got its value
  110803. * @param query defines the query to check
  110804. * @returns true if the query got its value
  110805. */
  110806. isQueryResultAvailable(query: WebGLQuery): boolean;
  110807. /**
  110808. * Gets the value of a given query
  110809. * @param query defines the query to check
  110810. * @returns the value of the query
  110811. */
  110812. getQueryResult(query: WebGLQuery): number;
  110813. /**
  110814. * Initiates an occlusion query
  110815. * @param algorithmType defines the algorithm to use
  110816. * @param query defines the query to use
  110817. * @returns the current engine
  110818. * @see http://doc.babylonjs.com/features/occlusionquery
  110819. */
  110820. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110821. /**
  110822. * Ends an occlusion query
  110823. * @see http://doc.babylonjs.com/features/occlusionquery
  110824. * @param algorithmType defines the algorithm to use
  110825. * @returns the current engine
  110826. */
  110827. endOcclusionQuery(algorithmType: number): Engine;
  110828. /**
  110829. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110830. * Please note that only one query can be issued at a time
  110831. * @returns a time token used to track the time span
  110832. */
  110833. startTimeQuery(): Nullable<_TimeToken>;
  110834. /**
  110835. * Ends a time query
  110836. * @param token defines the token used to measure the time span
  110837. * @returns the time spent (in ns)
  110838. */
  110839. endTimeQuery(token: _TimeToken): int;
  110840. /** @hidden */
  110841. _currentNonTimestampToken: Nullable<_TimeToken>;
  110842. /** @hidden */
  110843. _createTimeQuery(): WebGLQuery;
  110844. /** @hidden */
  110845. _deleteTimeQuery(query: WebGLQuery): void;
  110846. /** @hidden */
  110847. _getGlAlgorithmType(algorithmType: number): number;
  110848. /** @hidden */
  110849. _getTimeQueryResult(query: WebGLQuery): any;
  110850. /** @hidden */
  110851. _getTimeQueryAvailability(query: WebGLQuery): any;
  110852. }
  110853. interface AbstractMesh {
  110854. /**
  110855. * Backing filed
  110856. * @hidden
  110857. */
  110858. __occlusionDataStorage: _OcclusionDataStorage;
  110859. /**
  110860. * Access property
  110861. * @hidden
  110862. */
  110863. _occlusionDataStorage: _OcclusionDataStorage;
  110864. /**
  110865. * 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.
  110866. * The default value is -1 which means don't break the query and wait till the result
  110867. * @see http://doc.babylonjs.com/features/occlusionquery
  110868. */
  110869. occlusionRetryCount: number;
  110870. /**
  110871. * 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:
  110872. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110873. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110874. * * 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.
  110875. * @see http://doc.babylonjs.com/features/occlusionquery
  110876. */
  110877. occlusionType: number;
  110878. /**
  110879. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110880. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110881. * * 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.
  110882. * @see http://doc.babylonjs.com/features/occlusionquery
  110883. */
  110884. occlusionQueryAlgorithmType: number;
  110885. /**
  110886. * 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
  110887. * @see http://doc.babylonjs.com/features/occlusionquery
  110888. */
  110889. isOccluded: boolean;
  110890. /**
  110891. * Flag to check the progress status of the query
  110892. * @see http://doc.babylonjs.com/features/occlusionquery
  110893. */
  110894. isOcclusionQueryInProgress: boolean;
  110895. }
  110896. }
  110897. declare module BABYLON {
  110898. /** @hidden */
  110899. export var _forceTransformFeedbackToBundle: boolean;
  110900. interface Engine {
  110901. /**
  110902. * Creates a webGL transform feedback object
  110903. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110904. * @returns the webGL transform feedback object
  110905. */
  110906. createTransformFeedback(): WebGLTransformFeedback;
  110907. /**
  110908. * Delete a webGL transform feedback object
  110909. * @param value defines the webGL transform feedback object to delete
  110910. */
  110911. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110912. /**
  110913. * Bind a webGL transform feedback object to the webgl context
  110914. * @param value defines the webGL transform feedback object to bind
  110915. */
  110916. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110917. /**
  110918. * Begins a transform feedback operation
  110919. * @param usePoints defines if points or triangles must be used
  110920. */
  110921. beginTransformFeedback(usePoints: boolean): void;
  110922. /**
  110923. * Ends a transform feedback operation
  110924. */
  110925. endTransformFeedback(): void;
  110926. /**
  110927. * Specify the varyings to use with transform feedback
  110928. * @param program defines the associated webGL program
  110929. * @param value defines the list of strings representing the varying names
  110930. */
  110931. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110932. /**
  110933. * Bind a webGL buffer for a transform feedback operation
  110934. * @param value defines the webGL buffer to bind
  110935. */
  110936. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110937. }
  110938. }
  110939. declare module BABYLON {
  110940. /**
  110941. * Creation options of the multi render target texture.
  110942. */
  110943. export interface IMultiRenderTargetOptions {
  110944. /**
  110945. * Define if the texture needs to create mip maps after render.
  110946. */
  110947. generateMipMaps?: boolean;
  110948. /**
  110949. * Define the types of all the draw buffers we want to create
  110950. */
  110951. types?: number[];
  110952. /**
  110953. * Define the sampling modes of all the draw buffers we want to create
  110954. */
  110955. samplingModes?: number[];
  110956. /**
  110957. * Define if a depth buffer is required
  110958. */
  110959. generateDepthBuffer?: boolean;
  110960. /**
  110961. * Define if a stencil buffer is required
  110962. */
  110963. generateStencilBuffer?: boolean;
  110964. /**
  110965. * Define if a depth texture is required instead of a depth buffer
  110966. */
  110967. generateDepthTexture?: boolean;
  110968. /**
  110969. * Define the number of desired draw buffers
  110970. */
  110971. textureCount?: number;
  110972. /**
  110973. * Define if aspect ratio should be adapted to the texture or stay the scene one
  110974. */
  110975. doNotChangeAspectRatio?: boolean;
  110976. /**
  110977. * Define the default type of the buffers we are creating
  110978. */
  110979. defaultType?: number;
  110980. }
  110981. /**
  110982. * A multi render target, like a render target provides the ability to render to a texture.
  110983. * Unlike the render target, it can render to several draw buffers in one draw.
  110984. * This is specially interesting in deferred rendering or for any effects requiring more than
  110985. * just one color from a single pass.
  110986. */
  110987. export class MultiRenderTarget extends RenderTargetTexture {
  110988. private _internalTextures;
  110989. private _textures;
  110990. private _multiRenderTargetOptions;
  110991. /**
  110992. * Get if draw buffers are currently supported by the used hardware and browser.
  110993. */
  110994. readonly isSupported: boolean;
  110995. /**
  110996. * Get the list of textures generated by the multi render target.
  110997. */
  110998. readonly textures: Texture[];
  110999. /**
  111000. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111001. */
  111002. readonly depthTexture: Texture;
  111003. /**
  111004. * Set the wrapping mode on U of all the textures we are rendering to.
  111005. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111006. */
  111007. wrapU: number;
  111008. /**
  111009. * Set the wrapping mode on V of all the textures we are rendering to.
  111010. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111011. */
  111012. wrapV: number;
  111013. /**
  111014. * Instantiate a new multi render target texture.
  111015. * A multi render target, like a render target provides the ability to render to a texture.
  111016. * Unlike the render target, it can render to several draw buffers in one draw.
  111017. * This is specially interesting in deferred rendering or for any effects requiring more than
  111018. * just one color from a single pass.
  111019. * @param name Define the name of the texture
  111020. * @param size Define the size of the buffers to render to
  111021. * @param count Define the number of target we are rendering into
  111022. * @param scene Define the scene the texture belongs to
  111023. * @param options Define the options used to create the multi render target
  111024. */
  111025. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111026. /** @hidden */
  111027. _rebuild(): void;
  111028. private _createInternalTextures;
  111029. private _createTextures;
  111030. /**
  111031. * Define the number of samples used if MSAA is enabled.
  111032. */
  111033. samples: number;
  111034. /**
  111035. * Resize all the textures in the multi render target.
  111036. * Be carrefull as it will recreate all the data in the new texture.
  111037. * @param size Define the new size
  111038. */
  111039. resize(size: any): void;
  111040. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111041. /**
  111042. * Dispose the render targets and their associated resources
  111043. */
  111044. dispose(): void;
  111045. /**
  111046. * Release all the underlying texture used as draw buffers.
  111047. */
  111048. releaseInternalTextures(): void;
  111049. }
  111050. }
  111051. declare module BABYLON {
  111052. interface ThinEngine {
  111053. /**
  111054. * Unbind a list of render target textures from the webGL context
  111055. * This is used only when drawBuffer extension or webGL2 are active
  111056. * @param textures defines the render target textures to unbind
  111057. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111058. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111059. */
  111060. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111061. /**
  111062. * Create a multi render target texture
  111063. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111064. * @param size defines the size of the texture
  111065. * @param options defines the creation options
  111066. * @returns the cube texture as an InternalTexture
  111067. */
  111068. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111069. /**
  111070. * Update the sample count for a given multiple render target texture
  111071. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111072. * @param textures defines the textures to update
  111073. * @param samples defines the sample count to set
  111074. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111075. */
  111076. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111077. }
  111078. }
  111079. declare module BABYLON {
  111080. /**
  111081. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111082. */
  111083. export interface CubeMapInfo {
  111084. /**
  111085. * The pixel array for the front face.
  111086. * This is stored in format, left to right, up to down format.
  111087. */
  111088. front: Nullable<ArrayBufferView>;
  111089. /**
  111090. * The pixel array for the back face.
  111091. * This is stored in format, left to right, up to down format.
  111092. */
  111093. back: Nullable<ArrayBufferView>;
  111094. /**
  111095. * The pixel array for the left face.
  111096. * This is stored in format, left to right, up to down format.
  111097. */
  111098. left: Nullable<ArrayBufferView>;
  111099. /**
  111100. * The pixel array for the right face.
  111101. * This is stored in format, left to right, up to down format.
  111102. */
  111103. right: Nullable<ArrayBufferView>;
  111104. /**
  111105. * The pixel array for the up face.
  111106. * This is stored in format, left to right, up to down format.
  111107. */
  111108. up: Nullable<ArrayBufferView>;
  111109. /**
  111110. * The pixel array for the down face.
  111111. * This is stored in format, left to right, up to down format.
  111112. */
  111113. down: Nullable<ArrayBufferView>;
  111114. /**
  111115. * The size of the cubemap stored.
  111116. *
  111117. * Each faces will be size * size pixels.
  111118. */
  111119. size: number;
  111120. /**
  111121. * The format of the texture.
  111122. *
  111123. * RGBA, RGB.
  111124. */
  111125. format: number;
  111126. /**
  111127. * The type of the texture data.
  111128. *
  111129. * UNSIGNED_INT, FLOAT.
  111130. */
  111131. type: number;
  111132. /**
  111133. * Specifies whether the texture is in gamma space.
  111134. */
  111135. gammaSpace: boolean;
  111136. }
  111137. /**
  111138. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111139. */
  111140. export class PanoramaToCubeMapTools {
  111141. private static FACE_FRONT;
  111142. private static FACE_BACK;
  111143. private static FACE_RIGHT;
  111144. private static FACE_LEFT;
  111145. private static FACE_DOWN;
  111146. private static FACE_UP;
  111147. /**
  111148. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111149. *
  111150. * @param float32Array The source data.
  111151. * @param inputWidth The width of the input panorama.
  111152. * @param inputHeight The height of the input panorama.
  111153. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111154. * @return The cubemap data
  111155. */
  111156. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111157. private static CreateCubemapTexture;
  111158. private static CalcProjectionSpherical;
  111159. }
  111160. }
  111161. declare module BABYLON {
  111162. /**
  111163. * Helper class dealing with the extraction of spherical polynomial dataArray
  111164. * from a cube map.
  111165. */
  111166. export class CubeMapToSphericalPolynomialTools {
  111167. private static FileFaces;
  111168. /**
  111169. * Converts a texture to the according Spherical Polynomial data.
  111170. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111171. *
  111172. * @param texture The texture to extract the information from.
  111173. * @return The Spherical Polynomial data.
  111174. */
  111175. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111176. /**
  111177. * Converts a cubemap to the according Spherical Polynomial data.
  111178. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111179. *
  111180. * @param cubeInfo The Cube map to extract the information from.
  111181. * @return The Spherical Polynomial data.
  111182. */
  111183. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111184. }
  111185. }
  111186. declare module BABYLON {
  111187. interface BaseTexture {
  111188. /**
  111189. * Get the polynomial representation of the texture data.
  111190. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111191. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111192. */
  111193. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111194. }
  111195. }
  111196. declare module BABYLON {
  111197. /** @hidden */
  111198. export var rgbdEncodePixelShader: {
  111199. name: string;
  111200. shader: string;
  111201. };
  111202. }
  111203. declare module BABYLON {
  111204. /** @hidden */
  111205. export var rgbdDecodePixelShader: {
  111206. name: string;
  111207. shader: string;
  111208. };
  111209. }
  111210. declare module BABYLON {
  111211. /**
  111212. * Raw texture data and descriptor sufficient for WebGL texture upload
  111213. */
  111214. export interface EnvironmentTextureInfo {
  111215. /**
  111216. * Version of the environment map
  111217. */
  111218. version: number;
  111219. /**
  111220. * Width of image
  111221. */
  111222. width: number;
  111223. /**
  111224. * Irradiance information stored in the file.
  111225. */
  111226. irradiance: any;
  111227. /**
  111228. * Specular information stored in the file.
  111229. */
  111230. specular: any;
  111231. }
  111232. /**
  111233. * Defines One Image in the file. It requires only the position in the file
  111234. * as well as the length.
  111235. */
  111236. interface BufferImageData {
  111237. /**
  111238. * Length of the image data.
  111239. */
  111240. length: number;
  111241. /**
  111242. * Position of the data from the null terminator delimiting the end of the JSON.
  111243. */
  111244. position: number;
  111245. }
  111246. /**
  111247. * Defines the specular data enclosed in the file.
  111248. * This corresponds to the version 1 of the data.
  111249. */
  111250. export interface EnvironmentTextureSpecularInfoV1 {
  111251. /**
  111252. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111253. */
  111254. specularDataPosition?: number;
  111255. /**
  111256. * This contains all the images data needed to reconstruct the cubemap.
  111257. */
  111258. mipmaps: Array<BufferImageData>;
  111259. /**
  111260. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111261. */
  111262. lodGenerationScale: number;
  111263. }
  111264. /**
  111265. * Sets of helpers addressing the serialization and deserialization of environment texture
  111266. * stored in a BabylonJS env file.
  111267. * Those files are usually stored as .env files.
  111268. */
  111269. export class EnvironmentTextureTools {
  111270. /**
  111271. * Magic number identifying the env file.
  111272. */
  111273. private static _MagicBytes;
  111274. /**
  111275. * Gets the environment info from an env file.
  111276. * @param data The array buffer containing the .env bytes.
  111277. * @returns the environment file info (the json header) if successfully parsed.
  111278. */
  111279. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111280. /**
  111281. * Creates an environment texture from a loaded cube texture.
  111282. * @param texture defines the cube texture to convert in env file
  111283. * @return a promise containing the environment data if succesfull.
  111284. */
  111285. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111286. /**
  111287. * Creates a JSON representation of the spherical data.
  111288. * @param texture defines the texture containing the polynomials
  111289. * @return the JSON representation of the spherical info
  111290. */
  111291. private static _CreateEnvTextureIrradiance;
  111292. /**
  111293. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111294. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111295. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111296. * @return the views described by info providing access to the underlying buffer
  111297. */
  111298. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111299. /**
  111300. * Uploads the texture info contained in the env file to the GPU.
  111301. * @param texture defines the internal texture to upload to
  111302. * @param arrayBuffer defines the buffer cotaining the data to load
  111303. * @param info defines the texture info retrieved through the GetEnvInfo method
  111304. * @returns a promise
  111305. */
  111306. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111307. /**
  111308. * Uploads the levels of image data to the GPU.
  111309. * @param texture defines the internal texture to upload to
  111310. * @param imageData defines the array buffer views of image data [mipmap][face]
  111311. * @returns a promise
  111312. */
  111313. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111314. /**
  111315. * Uploads spherical polynomials information to the texture.
  111316. * @param texture defines the texture we are trying to upload the information to
  111317. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111318. */
  111319. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111320. /** @hidden */
  111321. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111322. }
  111323. }
  111324. declare module BABYLON {
  111325. /**
  111326. * Contains position and normal vectors for a vertex
  111327. */
  111328. export class PositionNormalVertex {
  111329. /** the position of the vertex (defaut: 0,0,0) */
  111330. position: Vector3;
  111331. /** the normal of the vertex (defaut: 0,1,0) */
  111332. normal: Vector3;
  111333. /**
  111334. * Creates a PositionNormalVertex
  111335. * @param position the position of the vertex (defaut: 0,0,0)
  111336. * @param normal the normal of the vertex (defaut: 0,1,0)
  111337. */
  111338. constructor(
  111339. /** the position of the vertex (defaut: 0,0,0) */
  111340. position?: Vector3,
  111341. /** the normal of the vertex (defaut: 0,1,0) */
  111342. normal?: Vector3);
  111343. /**
  111344. * Clones the PositionNormalVertex
  111345. * @returns the cloned PositionNormalVertex
  111346. */
  111347. clone(): PositionNormalVertex;
  111348. }
  111349. /**
  111350. * Contains position, normal and uv vectors for a vertex
  111351. */
  111352. export class PositionNormalTextureVertex {
  111353. /** the position of the vertex (defaut: 0,0,0) */
  111354. position: Vector3;
  111355. /** the normal of the vertex (defaut: 0,1,0) */
  111356. normal: Vector3;
  111357. /** the uv of the vertex (default: 0,0) */
  111358. uv: Vector2;
  111359. /**
  111360. * Creates a PositionNormalTextureVertex
  111361. * @param position the position of the vertex (defaut: 0,0,0)
  111362. * @param normal the normal of the vertex (defaut: 0,1,0)
  111363. * @param uv the uv of the vertex (default: 0,0)
  111364. */
  111365. constructor(
  111366. /** the position of the vertex (defaut: 0,0,0) */
  111367. position?: Vector3,
  111368. /** the normal of the vertex (defaut: 0,1,0) */
  111369. normal?: Vector3,
  111370. /** the uv of the vertex (default: 0,0) */
  111371. uv?: Vector2);
  111372. /**
  111373. * Clones the PositionNormalTextureVertex
  111374. * @returns the cloned PositionNormalTextureVertex
  111375. */
  111376. clone(): PositionNormalTextureVertex;
  111377. }
  111378. }
  111379. declare module BABYLON {
  111380. /** @hidden */
  111381. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111382. private _genericAttributeLocation;
  111383. private _varyingLocationCount;
  111384. private _varyingLocationMap;
  111385. private _replacements;
  111386. private _textureCount;
  111387. private _uniforms;
  111388. lineProcessor(line: string): string;
  111389. attributeProcessor(attribute: string): string;
  111390. varyingProcessor(varying: string, isFragment: boolean): string;
  111391. uniformProcessor(uniform: string): string;
  111392. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111393. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111394. }
  111395. }
  111396. declare module BABYLON {
  111397. /**
  111398. * Container for accessors for natively-stored mesh data buffers.
  111399. */
  111400. class NativeDataBuffer extends DataBuffer {
  111401. /**
  111402. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111403. */
  111404. nativeIndexBuffer?: any;
  111405. /**
  111406. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111407. */
  111408. nativeVertexBuffer?: any;
  111409. }
  111410. /** @hidden */
  111411. export class NativeEngine extends Engine {
  111412. private readonly _native;
  111413. getHardwareScalingLevel(): number;
  111414. constructor();
  111415. /**
  111416. * Can be used to override the current requestAnimationFrame requester.
  111417. * @hidden
  111418. */
  111419. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111420. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111421. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111422. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111423. recordVertexArrayObject(vertexBuffers: {
  111424. [key: string]: VertexBuffer;
  111425. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111426. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111427. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111428. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111429. /**
  111430. * Draw a list of indexed primitives
  111431. * @param fillMode defines the primitive to use
  111432. * @param indexStart defines the starting index
  111433. * @param indexCount defines the number of index to draw
  111434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111435. */
  111436. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111437. /**
  111438. * Draw a list of unindexed primitives
  111439. * @param fillMode defines the primitive to use
  111440. * @param verticesStart defines the index of first vertex to draw
  111441. * @param verticesCount defines the count of vertices to draw
  111442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111443. */
  111444. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111445. createPipelineContext(): IPipelineContext;
  111446. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111447. /** @hidden */
  111448. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111449. /** @hidden */
  111450. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111451. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111452. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111453. protected _setProgram(program: WebGLProgram): void;
  111454. _releaseEffect(effect: Effect): void;
  111455. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111456. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111457. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111458. bindSamplers(effect: Effect): void;
  111459. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111460. getRenderWidth(useScreen?: boolean): number;
  111461. getRenderHeight(useScreen?: boolean): number;
  111462. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111463. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111464. /**
  111465. * Set the z offset to apply to current rendering
  111466. * @param value defines the offset to apply
  111467. */
  111468. setZOffset(value: number): void;
  111469. /**
  111470. * Gets the current value of the zOffset
  111471. * @returns the current zOffset state
  111472. */
  111473. getZOffset(): number;
  111474. /**
  111475. * Enable or disable depth buffering
  111476. * @param enable defines the state to set
  111477. */
  111478. setDepthBuffer(enable: boolean): void;
  111479. /**
  111480. * Gets a boolean indicating if depth writing is enabled
  111481. * @returns the current depth writing state
  111482. */
  111483. getDepthWrite(): boolean;
  111484. /**
  111485. * Enable or disable depth writing
  111486. * @param enable defines the state to set
  111487. */
  111488. setDepthWrite(enable: boolean): void;
  111489. /**
  111490. * Enable or disable color writing
  111491. * @param enable defines the state to set
  111492. */
  111493. setColorWrite(enable: boolean): void;
  111494. /**
  111495. * Gets a boolean indicating if color writing is enabled
  111496. * @returns the current color writing state
  111497. */
  111498. getColorWrite(): boolean;
  111499. /**
  111500. * Sets alpha constants used by some alpha blending modes
  111501. * @param r defines the red component
  111502. * @param g defines the green component
  111503. * @param b defines the blue component
  111504. * @param a defines the alpha component
  111505. */
  111506. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111507. /**
  111508. * Sets the current alpha mode
  111509. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111510. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111511. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111512. */
  111513. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111514. /**
  111515. * Gets the current alpha mode
  111516. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111517. * @returns the current alpha mode
  111518. */
  111519. getAlphaMode(): number;
  111520. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111521. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111522. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111523. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111524. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111525. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111526. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111527. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111528. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111529. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111530. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111531. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111532. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111533. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111534. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111535. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111536. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111537. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111538. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111539. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111540. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111541. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111542. wipeCaches(bruteForce?: boolean): void;
  111543. _createTexture(): WebGLTexture;
  111544. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111545. /**
  111546. * Usually called from BABYLON.Texture.ts.
  111547. * Passed information to create a WebGLTexture
  111548. * @param urlArg defines a value which contains one of the following:
  111549. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111550. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111551. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111552. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111553. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111554. * @param scene needed for loading to the correct scene
  111555. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111556. * @param onLoad optional callback to be called upon successful completion
  111557. * @param onError optional callback to be called upon failure
  111558. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111559. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111560. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111561. * @param forcedExtension defines the extension to use to pick the right loader
  111562. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111563. */
  111564. 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;
  111565. /**
  111566. * Creates a cube texture
  111567. * @param rootUrl defines the url where the files to load is located
  111568. * @param scene defines the current scene
  111569. * @param files defines the list of files to load (1 per face)
  111570. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111571. * @param onLoad defines an optional callback raised when the texture is loaded
  111572. * @param onError defines an optional callback raised if there is an issue to load the texture
  111573. * @param format defines the format of the data
  111574. * @param forcedExtension defines the extension to use to pick the right loader
  111575. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111576. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111577. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111578. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111579. * @returns the cube texture as an InternalTexture
  111580. */
  111581. 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;
  111582. private _getSamplingFilter;
  111583. private static _GetNativeTextureFormat;
  111584. createRenderTargetTexture(size: number | {
  111585. width: number;
  111586. height: number;
  111587. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111588. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111589. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111590. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111591. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111592. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111593. /**
  111594. * Updates a dynamic vertex buffer.
  111595. * @param vertexBuffer the vertex buffer to update
  111596. * @param data the data used to update the vertex buffer
  111597. * @param byteOffset the byte offset of the data (optional)
  111598. * @param byteLength the byte length of the data (optional)
  111599. */
  111600. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111601. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111602. private _updateAnisotropicLevel;
  111603. private _getAddressMode;
  111604. /** @hidden */
  111605. _bindTexture(channel: number, texture: InternalTexture): void;
  111606. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111607. releaseEffects(): void;
  111608. /** @hidden */
  111609. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111610. /** @hidden */
  111611. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111612. /** @hidden */
  111613. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111614. /** @hidden */
  111615. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111616. }
  111617. }
  111618. declare module BABYLON {
  111619. /**
  111620. * Gather the list of clipboard event types as constants.
  111621. */
  111622. export class ClipboardEventTypes {
  111623. /**
  111624. * The clipboard event is fired when a copy command is active (pressed).
  111625. */
  111626. static readonly COPY: number;
  111627. /**
  111628. * The clipboard event is fired when a cut command is active (pressed).
  111629. */
  111630. static readonly CUT: number;
  111631. /**
  111632. * The clipboard event is fired when a paste command is active (pressed).
  111633. */
  111634. static readonly PASTE: number;
  111635. }
  111636. /**
  111637. * This class is used to store clipboard related info for the onClipboardObservable event.
  111638. */
  111639. export class ClipboardInfo {
  111640. /**
  111641. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111642. */
  111643. type: number;
  111644. /**
  111645. * Defines the related dom event
  111646. */
  111647. event: ClipboardEvent;
  111648. /**
  111649. *Creates an instance of ClipboardInfo.
  111650. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111651. * @param event Defines the related dom event
  111652. */
  111653. constructor(
  111654. /**
  111655. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111656. */
  111657. type: number,
  111658. /**
  111659. * Defines the related dom event
  111660. */
  111661. event: ClipboardEvent);
  111662. /**
  111663. * Get the clipboard event's type from the keycode.
  111664. * @param keyCode Defines the keyCode for the current keyboard event.
  111665. * @return {number}
  111666. */
  111667. static GetTypeFromCharacter(keyCode: number): number;
  111668. }
  111669. }
  111670. declare module BABYLON {
  111671. /**
  111672. * Google Daydream controller
  111673. */
  111674. export class DaydreamController extends WebVRController {
  111675. /**
  111676. * Base Url for the controller model.
  111677. */
  111678. static MODEL_BASE_URL: string;
  111679. /**
  111680. * File name for the controller model.
  111681. */
  111682. static MODEL_FILENAME: string;
  111683. /**
  111684. * Gamepad Id prefix used to identify Daydream Controller.
  111685. */
  111686. static readonly GAMEPAD_ID_PREFIX: string;
  111687. /**
  111688. * Creates a new DaydreamController from a gamepad
  111689. * @param vrGamepad the gamepad that the controller should be created from
  111690. */
  111691. constructor(vrGamepad: any);
  111692. /**
  111693. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111694. * @param scene scene in which to add meshes
  111695. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111696. */
  111697. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111698. /**
  111699. * Called once for each button that changed state since the last frame
  111700. * @param buttonIdx Which button index changed
  111701. * @param state New state of the button
  111702. * @param changes Which properties on the state changed since last frame
  111703. */
  111704. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111705. }
  111706. }
  111707. declare module BABYLON {
  111708. /**
  111709. * Gear VR Controller
  111710. */
  111711. export class GearVRController extends WebVRController {
  111712. /**
  111713. * Base Url for the controller model.
  111714. */
  111715. static MODEL_BASE_URL: string;
  111716. /**
  111717. * File name for the controller model.
  111718. */
  111719. static MODEL_FILENAME: string;
  111720. /**
  111721. * Gamepad Id prefix used to identify this controller.
  111722. */
  111723. static readonly GAMEPAD_ID_PREFIX: string;
  111724. private readonly _buttonIndexToObservableNameMap;
  111725. /**
  111726. * Creates a new GearVRController from a gamepad
  111727. * @param vrGamepad the gamepad that the controller should be created from
  111728. */
  111729. constructor(vrGamepad: any);
  111730. /**
  111731. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111732. * @param scene scene in which to add meshes
  111733. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111734. */
  111735. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111736. /**
  111737. * Called once for each button that changed state since the last frame
  111738. * @param buttonIdx Which button index changed
  111739. * @param state New state of the button
  111740. * @param changes Which properties on the state changed since last frame
  111741. */
  111742. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111743. }
  111744. }
  111745. declare module BABYLON {
  111746. /**
  111747. * Class containing static functions to help procedurally build meshes
  111748. */
  111749. export class PolyhedronBuilder {
  111750. /**
  111751. * Creates a polyhedron mesh
  111752. * * 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
  111753. * * The parameter `size` (positive float, default 1) sets the polygon size
  111754. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111755. * * 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`
  111756. * * 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
  111757. * * 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)`)
  111758. * * 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
  111759. * * 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
  111760. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111761. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111762. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111763. * @param name defines the name of the mesh
  111764. * @param options defines the options used to create the mesh
  111765. * @param scene defines the hosting scene
  111766. * @returns the polyhedron mesh
  111767. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111768. */
  111769. static CreatePolyhedron(name: string, options: {
  111770. type?: number;
  111771. size?: number;
  111772. sizeX?: number;
  111773. sizeY?: number;
  111774. sizeZ?: number;
  111775. custom?: any;
  111776. faceUV?: Vector4[];
  111777. faceColors?: Color4[];
  111778. flat?: boolean;
  111779. updatable?: boolean;
  111780. sideOrientation?: number;
  111781. frontUVs?: Vector4;
  111782. backUVs?: Vector4;
  111783. }, scene?: Nullable<Scene>): Mesh;
  111784. }
  111785. }
  111786. declare module BABYLON {
  111787. /**
  111788. * Gizmo that enables scaling a mesh along 3 axis
  111789. */
  111790. export class ScaleGizmo extends Gizmo {
  111791. /**
  111792. * Internal gizmo used for interactions on the x axis
  111793. */
  111794. xGizmo: AxisScaleGizmo;
  111795. /**
  111796. * Internal gizmo used for interactions on the y axis
  111797. */
  111798. yGizmo: AxisScaleGizmo;
  111799. /**
  111800. * Internal gizmo used for interactions on the z axis
  111801. */
  111802. zGizmo: AxisScaleGizmo;
  111803. /**
  111804. * Internal gizmo used to scale all axis equally
  111805. */
  111806. uniformScaleGizmo: AxisScaleGizmo;
  111807. private _meshAttached;
  111808. private _updateGizmoRotationToMatchAttachedMesh;
  111809. private _snapDistance;
  111810. private _scaleRatio;
  111811. private _uniformScalingMesh;
  111812. private _octahedron;
  111813. /** Fires an event when any of it's sub gizmos are dragged */
  111814. onDragStartObservable: Observable<unknown>;
  111815. /** Fires an event when any of it's sub gizmos are released from dragging */
  111816. onDragEndObservable: Observable<unknown>;
  111817. attachedMesh: Nullable<AbstractMesh>;
  111818. /**
  111819. * Creates a ScaleGizmo
  111820. * @param gizmoLayer The utility layer the gizmo will be added to
  111821. */
  111822. constructor(gizmoLayer?: UtilityLayerRenderer);
  111823. updateGizmoRotationToMatchAttachedMesh: boolean;
  111824. /**
  111825. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111826. */
  111827. snapDistance: number;
  111828. /**
  111829. * Ratio for the scale of the gizmo (Default: 1)
  111830. */
  111831. scaleRatio: number;
  111832. /**
  111833. * Disposes of the gizmo
  111834. */
  111835. dispose(): void;
  111836. }
  111837. }
  111838. declare module BABYLON {
  111839. /**
  111840. * Single axis scale gizmo
  111841. */
  111842. export class AxisScaleGizmo extends Gizmo {
  111843. /**
  111844. * Drag behavior responsible for the gizmos dragging interactions
  111845. */
  111846. dragBehavior: PointerDragBehavior;
  111847. private _pointerObserver;
  111848. /**
  111849. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111850. */
  111851. snapDistance: number;
  111852. /**
  111853. * Event that fires each time the gizmo snaps to a new location.
  111854. * * snapDistance is the the change in distance
  111855. */
  111856. onSnapObservable: Observable<{
  111857. snapDistance: number;
  111858. }>;
  111859. /**
  111860. * If the scaling operation should be done on all axis (default: false)
  111861. */
  111862. uniformScaling: boolean;
  111863. private _isEnabled;
  111864. private _parent;
  111865. private _arrow;
  111866. private _coloredMaterial;
  111867. private _hoverMaterial;
  111868. /**
  111869. * Creates an AxisScaleGizmo
  111870. * @param gizmoLayer The utility layer the gizmo will be added to
  111871. * @param dragAxis The axis which the gizmo will be able to scale on
  111872. * @param color The color of the gizmo
  111873. */
  111874. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111875. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111876. /**
  111877. * If the gizmo is enabled
  111878. */
  111879. isEnabled: boolean;
  111880. /**
  111881. * Disposes of the gizmo
  111882. */
  111883. dispose(): void;
  111884. /**
  111885. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111886. * @param mesh The mesh to replace the default mesh of the gizmo
  111887. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111888. */
  111889. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111890. }
  111891. }
  111892. declare module BABYLON {
  111893. /**
  111894. * Bounding box gizmo
  111895. */
  111896. export class BoundingBoxGizmo extends Gizmo {
  111897. private _lineBoundingBox;
  111898. private _rotateSpheresParent;
  111899. private _scaleBoxesParent;
  111900. private _boundingDimensions;
  111901. private _renderObserver;
  111902. private _pointerObserver;
  111903. private _scaleDragSpeed;
  111904. private _tmpQuaternion;
  111905. private _tmpVector;
  111906. private _tmpRotationMatrix;
  111907. /**
  111908. * 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)
  111909. */
  111910. ignoreChildren: boolean;
  111911. /**
  111912. * 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)
  111913. */
  111914. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111915. /**
  111916. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111917. */
  111918. rotationSphereSize: number;
  111919. /**
  111920. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111921. */
  111922. scaleBoxSize: number;
  111923. /**
  111924. * 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)
  111925. */
  111926. fixedDragMeshScreenSize: boolean;
  111927. /**
  111928. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111929. */
  111930. fixedDragMeshScreenSizeDistanceFactor: number;
  111931. /**
  111932. * Fired when a rotation sphere or scale box is dragged
  111933. */
  111934. onDragStartObservable: Observable<{}>;
  111935. /**
  111936. * Fired when a scale box is dragged
  111937. */
  111938. onScaleBoxDragObservable: Observable<{}>;
  111939. /**
  111940. * Fired when a scale box drag is ended
  111941. */
  111942. onScaleBoxDragEndObservable: Observable<{}>;
  111943. /**
  111944. * Fired when a rotation sphere is dragged
  111945. */
  111946. onRotationSphereDragObservable: Observable<{}>;
  111947. /**
  111948. * Fired when a rotation sphere drag is ended
  111949. */
  111950. onRotationSphereDragEndObservable: Observable<{}>;
  111951. /**
  111952. * 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)
  111953. */
  111954. scalePivot: Nullable<Vector3>;
  111955. /**
  111956. * Mesh used as a pivot to rotate the attached mesh
  111957. */
  111958. private _anchorMesh;
  111959. private _existingMeshScale;
  111960. private _dragMesh;
  111961. private pointerDragBehavior;
  111962. private coloredMaterial;
  111963. private hoverColoredMaterial;
  111964. /**
  111965. * Sets the color of the bounding box gizmo
  111966. * @param color the color to set
  111967. */
  111968. setColor(color: Color3): void;
  111969. /**
  111970. * Creates an BoundingBoxGizmo
  111971. * @param gizmoLayer The utility layer the gizmo will be added to
  111972. * @param color The color of the gizmo
  111973. */
  111974. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111975. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111976. private _selectNode;
  111977. /**
  111978. * Updates the bounding box information for the Gizmo
  111979. */
  111980. updateBoundingBox(): void;
  111981. private _updateRotationSpheres;
  111982. private _updateScaleBoxes;
  111983. /**
  111984. * Enables rotation on the specified axis and disables rotation on the others
  111985. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111986. */
  111987. setEnabledRotationAxis(axis: string): void;
  111988. /**
  111989. * Enables/disables scaling
  111990. * @param enable if scaling should be enabled
  111991. */
  111992. setEnabledScaling(enable: boolean): void;
  111993. private _updateDummy;
  111994. /**
  111995. * Enables a pointer drag behavior on the bounding box of the gizmo
  111996. */
  111997. enableDragBehavior(): void;
  111998. /**
  111999. * Disposes of the gizmo
  112000. */
  112001. dispose(): void;
  112002. /**
  112003. * 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)
  112004. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112005. * @returns the bounding box mesh with the passed in mesh as a child
  112006. */
  112007. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112008. /**
  112009. * CustomMeshes are not supported by this gizmo
  112010. * @param mesh The mesh to replace the default mesh of the gizmo
  112011. */
  112012. setCustomMesh(mesh: Mesh): void;
  112013. }
  112014. }
  112015. declare module BABYLON {
  112016. /**
  112017. * Single plane rotation gizmo
  112018. */
  112019. export class PlaneRotationGizmo extends Gizmo {
  112020. /**
  112021. * Drag behavior responsible for the gizmos dragging interactions
  112022. */
  112023. dragBehavior: PointerDragBehavior;
  112024. private _pointerObserver;
  112025. /**
  112026. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112027. */
  112028. snapDistance: number;
  112029. /**
  112030. * Event that fires each time the gizmo snaps to a new location.
  112031. * * snapDistance is the the change in distance
  112032. */
  112033. onSnapObservable: Observable<{
  112034. snapDistance: number;
  112035. }>;
  112036. private _isEnabled;
  112037. private _parent;
  112038. /**
  112039. * Creates a PlaneRotationGizmo
  112040. * @param gizmoLayer The utility layer the gizmo will be added to
  112041. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112042. * @param color The color of the gizmo
  112043. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112044. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112045. */
  112046. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112047. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112048. /**
  112049. * If the gizmo is enabled
  112050. */
  112051. isEnabled: boolean;
  112052. /**
  112053. * Disposes of the gizmo
  112054. */
  112055. dispose(): void;
  112056. }
  112057. }
  112058. declare module BABYLON {
  112059. /**
  112060. * Gizmo that enables rotating a mesh along 3 axis
  112061. */
  112062. export class RotationGizmo extends Gizmo {
  112063. /**
  112064. * Internal gizmo used for interactions on the x axis
  112065. */
  112066. xGizmo: PlaneRotationGizmo;
  112067. /**
  112068. * Internal gizmo used for interactions on the y axis
  112069. */
  112070. yGizmo: PlaneRotationGizmo;
  112071. /**
  112072. * Internal gizmo used for interactions on the z axis
  112073. */
  112074. zGizmo: PlaneRotationGizmo;
  112075. /** Fires an event when any of it's sub gizmos are dragged */
  112076. onDragStartObservable: Observable<unknown>;
  112077. /** Fires an event when any of it's sub gizmos are released from dragging */
  112078. onDragEndObservable: Observable<unknown>;
  112079. private _meshAttached;
  112080. attachedMesh: Nullable<AbstractMesh>;
  112081. /**
  112082. * Creates a RotationGizmo
  112083. * @param gizmoLayer The utility layer the gizmo will be added to
  112084. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112085. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112086. */
  112087. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112088. updateGizmoRotationToMatchAttachedMesh: boolean;
  112089. /**
  112090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112091. */
  112092. snapDistance: number;
  112093. /**
  112094. * Ratio for the scale of the gizmo (Default: 1)
  112095. */
  112096. scaleRatio: number;
  112097. /**
  112098. * Disposes of the gizmo
  112099. */
  112100. dispose(): void;
  112101. /**
  112102. * CustomMeshes are not supported by this gizmo
  112103. * @param mesh The mesh to replace the default mesh of the gizmo
  112104. */
  112105. setCustomMesh(mesh: Mesh): void;
  112106. }
  112107. }
  112108. declare module BABYLON {
  112109. /**
  112110. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112111. */
  112112. export class GizmoManager implements IDisposable {
  112113. private scene;
  112114. /**
  112115. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112116. */
  112117. gizmos: {
  112118. positionGizmo: Nullable<PositionGizmo>;
  112119. rotationGizmo: Nullable<RotationGizmo>;
  112120. scaleGizmo: Nullable<ScaleGizmo>;
  112121. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112122. };
  112123. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112124. clearGizmoOnEmptyPointerEvent: boolean;
  112125. /** Fires an event when the manager is attached to a mesh */
  112126. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112127. private _gizmosEnabled;
  112128. private _pointerObserver;
  112129. private _attachedMesh;
  112130. private _boundingBoxColor;
  112131. private _defaultUtilityLayer;
  112132. private _defaultKeepDepthUtilityLayer;
  112133. /**
  112134. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112135. */
  112136. boundingBoxDragBehavior: SixDofDragBehavior;
  112137. /**
  112138. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112139. */
  112140. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112141. /**
  112142. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112143. */
  112144. usePointerToAttachGizmos: boolean;
  112145. /**
  112146. * Utility layer that the bounding box gizmo belongs to
  112147. */
  112148. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112149. /**
  112150. * Utility layer that all gizmos besides bounding box belong to
  112151. */
  112152. readonly utilityLayer: UtilityLayerRenderer;
  112153. /**
  112154. * Instatiates a gizmo manager
  112155. * @param scene the scene to overlay the gizmos on top of
  112156. */
  112157. constructor(scene: Scene);
  112158. /**
  112159. * Attaches a set of gizmos to the specified mesh
  112160. * @param mesh The mesh the gizmo's should be attached to
  112161. */
  112162. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112163. /**
  112164. * If the position gizmo is enabled
  112165. */
  112166. positionGizmoEnabled: boolean;
  112167. /**
  112168. * If the rotation gizmo is enabled
  112169. */
  112170. rotationGizmoEnabled: boolean;
  112171. /**
  112172. * If the scale gizmo is enabled
  112173. */
  112174. scaleGizmoEnabled: boolean;
  112175. /**
  112176. * If the boundingBox gizmo is enabled
  112177. */
  112178. boundingBoxGizmoEnabled: boolean;
  112179. /**
  112180. * Disposes of the gizmo manager
  112181. */
  112182. dispose(): void;
  112183. }
  112184. }
  112185. declare module BABYLON {
  112186. /**
  112187. * A directional light is defined by a direction (what a surprise!).
  112188. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112189. * 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.
  112190. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112191. */
  112192. export class DirectionalLight extends ShadowLight {
  112193. private _shadowFrustumSize;
  112194. /**
  112195. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112196. */
  112197. /**
  112198. * Specifies a fix frustum size for the shadow generation.
  112199. */
  112200. shadowFrustumSize: number;
  112201. private _shadowOrthoScale;
  112202. /**
  112203. * Gets the shadow projection scale against the optimal computed one.
  112204. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112205. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112206. */
  112207. /**
  112208. * Sets the shadow projection scale against the optimal computed one.
  112209. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112210. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112211. */
  112212. shadowOrthoScale: number;
  112213. /**
  112214. * Automatically compute the projection matrix to best fit (including all the casters)
  112215. * on each frame.
  112216. */
  112217. autoUpdateExtends: boolean;
  112218. private _orthoLeft;
  112219. private _orthoRight;
  112220. private _orthoTop;
  112221. private _orthoBottom;
  112222. /**
  112223. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112224. * The directional light is emitted from everywhere in the given direction.
  112225. * It can cast shadows.
  112226. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112227. * @param name The friendly name of the light
  112228. * @param direction The direction of the light
  112229. * @param scene The scene the light belongs to
  112230. */
  112231. constructor(name: string, direction: Vector3, scene: Scene);
  112232. /**
  112233. * Returns the string "DirectionalLight".
  112234. * @return The class name
  112235. */
  112236. getClassName(): string;
  112237. /**
  112238. * Returns the integer 1.
  112239. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112240. */
  112241. getTypeID(): number;
  112242. /**
  112243. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112244. * Returns the DirectionalLight Shadow projection matrix.
  112245. */
  112246. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112247. /**
  112248. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112249. * Returns the DirectionalLight Shadow projection matrix.
  112250. */
  112251. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112252. /**
  112253. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112254. * Returns the DirectionalLight Shadow projection matrix.
  112255. */
  112256. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112257. protected _buildUniformLayout(): void;
  112258. /**
  112259. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112260. * @param effect The effect to update
  112261. * @param lightIndex The index of the light in the effect to update
  112262. * @returns The directional light
  112263. */
  112264. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112265. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112266. /**
  112267. * Gets the minZ used for shadow according to both the scene and the light.
  112268. *
  112269. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112270. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112271. * @param activeCamera The camera we are returning the min for
  112272. * @returns the depth min z
  112273. */
  112274. getDepthMinZ(activeCamera: Camera): number;
  112275. /**
  112276. * Gets the maxZ used for shadow according to both the scene and the light.
  112277. *
  112278. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112279. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112280. * @param activeCamera The camera we are returning the max for
  112281. * @returns the depth max z
  112282. */
  112283. getDepthMaxZ(activeCamera: Camera): number;
  112284. /**
  112285. * Prepares the list of defines specific to the light type.
  112286. * @param defines the list of defines
  112287. * @param lightIndex defines the index of the light for the effect
  112288. */
  112289. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112290. }
  112291. }
  112292. declare module BABYLON {
  112293. /**
  112294. * Class containing static functions to help procedurally build meshes
  112295. */
  112296. export class HemisphereBuilder {
  112297. /**
  112298. * Creates a hemisphere mesh
  112299. * @param name defines the name of the mesh
  112300. * @param options defines the options used to create the mesh
  112301. * @param scene defines the hosting scene
  112302. * @returns the hemisphere mesh
  112303. */
  112304. static CreateHemisphere(name: string, options: {
  112305. segments?: number;
  112306. diameter?: number;
  112307. sideOrientation?: number;
  112308. }, scene: any): Mesh;
  112309. }
  112310. }
  112311. declare module BABYLON {
  112312. /**
  112313. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112314. * These values define a cone of light starting from the position, emitting toward the direction.
  112315. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112316. * and the exponent defines the speed of the decay of the light with distance (reach).
  112317. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112318. */
  112319. export class SpotLight extends ShadowLight {
  112320. private _angle;
  112321. private _innerAngle;
  112322. private _cosHalfAngle;
  112323. private _lightAngleScale;
  112324. private _lightAngleOffset;
  112325. /**
  112326. * Gets the cone angle of the spot light in Radians.
  112327. */
  112328. /**
  112329. * Sets the cone angle of the spot light in Radians.
  112330. */
  112331. angle: number;
  112332. /**
  112333. * Only used in gltf falloff mode, this defines the angle where
  112334. * the directional falloff will start before cutting at angle which could be seen
  112335. * as outer angle.
  112336. */
  112337. /**
  112338. * Only used in gltf falloff mode, this defines the angle where
  112339. * the directional falloff will start before cutting at angle which could be seen
  112340. * as outer angle.
  112341. */
  112342. innerAngle: number;
  112343. private _shadowAngleScale;
  112344. /**
  112345. * Allows scaling the angle of the light for shadow generation only.
  112346. */
  112347. /**
  112348. * Allows scaling the angle of the light for shadow generation only.
  112349. */
  112350. shadowAngleScale: number;
  112351. /**
  112352. * The light decay speed with the distance from the emission spot.
  112353. */
  112354. exponent: number;
  112355. private _projectionTextureMatrix;
  112356. /**
  112357. * Allows reading the projecton texture
  112358. */
  112359. readonly projectionTextureMatrix: Matrix;
  112360. protected _projectionTextureLightNear: number;
  112361. /**
  112362. * Gets the near clip of the Spotlight for texture projection.
  112363. */
  112364. /**
  112365. * Sets the near clip of the Spotlight for texture projection.
  112366. */
  112367. projectionTextureLightNear: number;
  112368. protected _projectionTextureLightFar: number;
  112369. /**
  112370. * Gets the far clip of the Spotlight for texture projection.
  112371. */
  112372. /**
  112373. * Sets the far clip of the Spotlight for texture projection.
  112374. */
  112375. projectionTextureLightFar: number;
  112376. protected _projectionTextureUpDirection: Vector3;
  112377. /**
  112378. * Gets the Up vector of the Spotlight for texture projection.
  112379. */
  112380. /**
  112381. * Sets the Up vector of the Spotlight for texture projection.
  112382. */
  112383. projectionTextureUpDirection: Vector3;
  112384. private _projectionTexture;
  112385. /**
  112386. * Gets the projection texture of the light.
  112387. */
  112388. /**
  112389. * Sets the projection texture of the light.
  112390. */
  112391. projectionTexture: Nullable<BaseTexture>;
  112392. private _projectionTextureViewLightDirty;
  112393. private _projectionTextureProjectionLightDirty;
  112394. private _projectionTextureDirty;
  112395. private _projectionTextureViewTargetVector;
  112396. private _projectionTextureViewLightMatrix;
  112397. private _projectionTextureProjectionLightMatrix;
  112398. private _projectionTextureScalingMatrix;
  112399. /**
  112400. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112401. * It can cast shadows.
  112402. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112403. * @param name The light friendly name
  112404. * @param position The position of the spot light in the scene
  112405. * @param direction The direction of the light in the scene
  112406. * @param angle The cone angle of the light in Radians
  112407. * @param exponent The light decay speed with the distance from the emission spot
  112408. * @param scene The scene the lights belongs to
  112409. */
  112410. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112411. /**
  112412. * Returns the string "SpotLight".
  112413. * @returns the class name
  112414. */
  112415. getClassName(): string;
  112416. /**
  112417. * Returns the integer 2.
  112418. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112419. */
  112420. getTypeID(): number;
  112421. /**
  112422. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112423. */
  112424. protected _setDirection(value: Vector3): void;
  112425. /**
  112426. * Overrides the position setter to recompute the projection texture view light Matrix.
  112427. */
  112428. protected _setPosition(value: Vector3): void;
  112429. /**
  112430. * 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.
  112431. * Returns the SpotLight.
  112432. */
  112433. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112434. protected _computeProjectionTextureViewLightMatrix(): void;
  112435. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112436. /**
  112437. * Main function for light texture projection matrix computing.
  112438. */
  112439. protected _computeProjectionTextureMatrix(): void;
  112440. protected _buildUniformLayout(): void;
  112441. private _computeAngleValues;
  112442. /**
  112443. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112444. * @param effect The effect to update
  112445. * @param lightIndex The index of the light in the effect to update
  112446. * @returns The spot light
  112447. */
  112448. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112449. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112450. /**
  112451. * Disposes the light and the associated resources.
  112452. */
  112453. dispose(): void;
  112454. /**
  112455. * Prepares the list of defines specific to the light type.
  112456. * @param defines the list of defines
  112457. * @param lightIndex defines the index of the light for the effect
  112458. */
  112459. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112460. }
  112461. }
  112462. declare module BABYLON {
  112463. /**
  112464. * Gizmo that enables viewing a light
  112465. */
  112466. export class LightGizmo extends Gizmo {
  112467. private _lightMesh;
  112468. private _material;
  112469. private cachedPosition;
  112470. private cachedForward;
  112471. /**
  112472. * Creates a LightGizmo
  112473. * @param gizmoLayer The utility layer the gizmo will be added to
  112474. */
  112475. constructor(gizmoLayer?: UtilityLayerRenderer);
  112476. private _light;
  112477. /**
  112478. * The light that the gizmo is attached to
  112479. */
  112480. light: Nullable<Light>;
  112481. /**
  112482. * Gets the material used to render the light gizmo
  112483. */
  112484. readonly material: StandardMaterial;
  112485. /**
  112486. * @hidden
  112487. * Updates the gizmo to match the attached mesh's position/rotation
  112488. */
  112489. protected _update(): void;
  112490. private static _Scale;
  112491. /**
  112492. * Creates the lines for a light mesh
  112493. */
  112494. private static _createLightLines;
  112495. /**
  112496. * Disposes of the light gizmo
  112497. */
  112498. dispose(): void;
  112499. private static _CreateHemisphericLightMesh;
  112500. private static _CreatePointLightMesh;
  112501. private static _CreateSpotLightMesh;
  112502. private static _CreateDirectionalLightMesh;
  112503. }
  112504. }
  112505. declare module BABYLON {
  112506. /** @hidden */
  112507. export var backgroundFragmentDeclaration: {
  112508. name: string;
  112509. shader: string;
  112510. };
  112511. }
  112512. declare module BABYLON {
  112513. /** @hidden */
  112514. export var backgroundUboDeclaration: {
  112515. name: string;
  112516. shader: string;
  112517. };
  112518. }
  112519. declare module BABYLON {
  112520. /** @hidden */
  112521. export var backgroundPixelShader: {
  112522. name: string;
  112523. shader: string;
  112524. };
  112525. }
  112526. declare module BABYLON {
  112527. /** @hidden */
  112528. export var backgroundVertexDeclaration: {
  112529. name: string;
  112530. shader: string;
  112531. };
  112532. }
  112533. declare module BABYLON {
  112534. /** @hidden */
  112535. export var backgroundVertexShader: {
  112536. name: string;
  112537. shader: string;
  112538. };
  112539. }
  112540. declare module BABYLON {
  112541. /**
  112542. * Background material used to create an efficient environement around your scene.
  112543. */
  112544. export class BackgroundMaterial extends PushMaterial {
  112545. /**
  112546. * Standard reflectance value at parallel view angle.
  112547. */
  112548. static StandardReflectance0: number;
  112549. /**
  112550. * Standard reflectance value at grazing angle.
  112551. */
  112552. static StandardReflectance90: number;
  112553. protected _primaryColor: Color3;
  112554. /**
  112555. * Key light Color (multiply against the environement texture)
  112556. */
  112557. primaryColor: Color3;
  112558. protected __perceptualColor: Nullable<Color3>;
  112559. /**
  112560. * Experimental Internal Use Only.
  112561. *
  112562. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112563. * This acts as a helper to set the primary color to a more "human friendly" value.
  112564. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112565. * output color as close as possible from the chosen value.
  112566. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112567. * part of lighting setup.)
  112568. */
  112569. _perceptualColor: Nullable<Color3>;
  112570. protected _primaryColorShadowLevel: float;
  112571. /**
  112572. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112573. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112574. */
  112575. primaryColorShadowLevel: float;
  112576. protected _primaryColorHighlightLevel: float;
  112577. /**
  112578. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112579. * The primary color is used at the level chosen to define what the white area would look.
  112580. */
  112581. primaryColorHighlightLevel: float;
  112582. protected _reflectionTexture: Nullable<BaseTexture>;
  112583. /**
  112584. * Reflection Texture used in the material.
  112585. * Should be author in a specific way for the best result (refer to the documentation).
  112586. */
  112587. reflectionTexture: Nullable<BaseTexture>;
  112588. protected _reflectionBlur: float;
  112589. /**
  112590. * Reflection Texture level of blur.
  112591. *
  112592. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112593. * texture twice.
  112594. */
  112595. reflectionBlur: float;
  112596. protected _diffuseTexture: Nullable<BaseTexture>;
  112597. /**
  112598. * Diffuse Texture used in the material.
  112599. * Should be author in a specific way for the best result (refer to the documentation).
  112600. */
  112601. diffuseTexture: Nullable<BaseTexture>;
  112602. protected _shadowLights: Nullable<IShadowLight[]>;
  112603. /**
  112604. * Specify the list of lights casting shadow on the material.
  112605. * All scene shadow lights will be included if null.
  112606. */
  112607. shadowLights: Nullable<IShadowLight[]>;
  112608. protected _shadowLevel: float;
  112609. /**
  112610. * Helps adjusting the shadow to a softer level if required.
  112611. * 0 means black shadows and 1 means no shadows.
  112612. */
  112613. shadowLevel: float;
  112614. protected _sceneCenter: Vector3;
  112615. /**
  112616. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112617. * It is usually zero but might be interesting to modify according to your setup.
  112618. */
  112619. sceneCenter: Vector3;
  112620. protected _opacityFresnel: boolean;
  112621. /**
  112622. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112623. * This helps ensuring a nice transition when the camera goes under the ground.
  112624. */
  112625. opacityFresnel: boolean;
  112626. protected _reflectionFresnel: boolean;
  112627. /**
  112628. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112629. * This helps adding a mirror texture on the ground.
  112630. */
  112631. reflectionFresnel: boolean;
  112632. protected _reflectionFalloffDistance: number;
  112633. /**
  112634. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112635. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112636. */
  112637. reflectionFalloffDistance: number;
  112638. protected _reflectionAmount: number;
  112639. /**
  112640. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112641. */
  112642. reflectionAmount: number;
  112643. protected _reflectionReflectance0: number;
  112644. /**
  112645. * This specifies the weight of the reflection at grazing angle.
  112646. */
  112647. reflectionReflectance0: number;
  112648. protected _reflectionReflectance90: number;
  112649. /**
  112650. * This specifies the weight of the reflection at a perpendicular point of view.
  112651. */
  112652. reflectionReflectance90: number;
  112653. /**
  112654. * Sets the reflection reflectance fresnel values according to the default standard
  112655. * empirically know to work well :-)
  112656. */
  112657. reflectionStandardFresnelWeight: number;
  112658. protected _useRGBColor: boolean;
  112659. /**
  112660. * Helps to directly use the maps channels instead of their level.
  112661. */
  112662. useRGBColor: boolean;
  112663. protected _enableNoise: boolean;
  112664. /**
  112665. * This helps reducing the banding effect that could occur on the background.
  112666. */
  112667. enableNoise: boolean;
  112668. /**
  112669. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112670. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112671. * Recommended to be keep at 1.0 except for special cases.
  112672. */
  112673. fovMultiplier: number;
  112674. private _fovMultiplier;
  112675. /**
  112676. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112677. */
  112678. useEquirectangularFOV: boolean;
  112679. private _maxSimultaneousLights;
  112680. /**
  112681. * Number of Simultaneous lights allowed on the material.
  112682. */
  112683. maxSimultaneousLights: int;
  112684. /**
  112685. * Default configuration related to image processing available in the Background Material.
  112686. */
  112687. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112688. /**
  112689. * Keep track of the image processing observer to allow dispose and replace.
  112690. */
  112691. private _imageProcessingObserver;
  112692. /**
  112693. * Attaches a new image processing configuration to the PBR Material.
  112694. * @param configuration (if null the scene configuration will be use)
  112695. */
  112696. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112697. /**
  112698. * Gets the image processing configuration used either in this material.
  112699. */
  112700. /**
  112701. * Sets the Default image processing configuration used either in the this material.
  112702. *
  112703. * If sets to null, the scene one is in use.
  112704. */
  112705. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112706. /**
  112707. * Gets wether the color curves effect is enabled.
  112708. */
  112709. /**
  112710. * Sets wether the color curves effect is enabled.
  112711. */
  112712. cameraColorCurvesEnabled: boolean;
  112713. /**
  112714. * Gets wether the color grading effect is enabled.
  112715. */
  112716. /**
  112717. * Gets wether the color grading effect is enabled.
  112718. */
  112719. cameraColorGradingEnabled: boolean;
  112720. /**
  112721. * Gets wether tonemapping is enabled or not.
  112722. */
  112723. /**
  112724. * Sets wether tonemapping is enabled or not
  112725. */
  112726. cameraToneMappingEnabled: boolean;
  112727. /**
  112728. * The camera exposure used on this material.
  112729. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112730. * This corresponds to a photographic exposure.
  112731. */
  112732. /**
  112733. * The camera exposure used on this material.
  112734. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112735. * This corresponds to a photographic exposure.
  112736. */
  112737. cameraExposure: float;
  112738. /**
  112739. * Gets The camera contrast used on this material.
  112740. */
  112741. /**
  112742. * Sets The camera contrast used on this material.
  112743. */
  112744. cameraContrast: float;
  112745. /**
  112746. * Gets the Color Grading 2D Lookup Texture.
  112747. */
  112748. /**
  112749. * Sets the Color Grading 2D Lookup Texture.
  112750. */
  112751. cameraColorGradingTexture: Nullable<BaseTexture>;
  112752. /**
  112753. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112754. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112755. * 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;
  112756. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112757. */
  112758. /**
  112759. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112760. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112761. * 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;
  112762. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112763. */
  112764. cameraColorCurves: Nullable<ColorCurves>;
  112765. /**
  112766. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112767. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112768. */
  112769. switchToBGR: boolean;
  112770. private _renderTargets;
  112771. private _reflectionControls;
  112772. private _white;
  112773. private _primaryShadowColor;
  112774. private _primaryHighlightColor;
  112775. /**
  112776. * Instantiates a Background Material in the given scene
  112777. * @param name The friendly name of the material
  112778. * @param scene The scene to add the material to
  112779. */
  112780. constructor(name: string, scene: Scene);
  112781. /**
  112782. * Gets a boolean indicating that current material needs to register RTT
  112783. */
  112784. readonly hasRenderTargetTextures: boolean;
  112785. /**
  112786. * The entire material has been created in order to prevent overdraw.
  112787. * @returns false
  112788. */
  112789. needAlphaTesting(): boolean;
  112790. /**
  112791. * The entire material has been created in order to prevent overdraw.
  112792. * @returns true if blending is enable
  112793. */
  112794. needAlphaBlending(): boolean;
  112795. /**
  112796. * Checks wether the material is ready to be rendered for a given mesh.
  112797. * @param mesh The mesh to render
  112798. * @param subMesh The submesh to check against
  112799. * @param useInstances Specify wether or not the material is used with instances
  112800. * @returns true if all the dependencies are ready (Textures, Effects...)
  112801. */
  112802. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112803. /**
  112804. * Compute the primary color according to the chosen perceptual color.
  112805. */
  112806. private _computePrimaryColorFromPerceptualColor;
  112807. /**
  112808. * Compute the highlights and shadow colors according to their chosen levels.
  112809. */
  112810. private _computePrimaryColors;
  112811. /**
  112812. * Build the uniform buffer used in the material.
  112813. */
  112814. buildUniformLayout(): void;
  112815. /**
  112816. * Unbind the material.
  112817. */
  112818. unbind(): void;
  112819. /**
  112820. * Bind only the world matrix to the material.
  112821. * @param world The world matrix to bind.
  112822. */
  112823. bindOnlyWorldMatrix(world: Matrix): void;
  112824. /**
  112825. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112826. * @param world The world matrix to bind.
  112827. * @param subMesh The submesh to bind for.
  112828. */
  112829. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112830. /**
  112831. * Checks to see if a texture is used in the material.
  112832. * @param texture - Base texture to use.
  112833. * @returns - Boolean specifying if a texture is used in the material.
  112834. */
  112835. hasTexture(texture: BaseTexture): boolean;
  112836. /**
  112837. * Dispose the material.
  112838. * @param forceDisposeEffect Force disposal of the associated effect.
  112839. * @param forceDisposeTextures Force disposal of the associated textures.
  112840. */
  112841. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112842. /**
  112843. * Clones the material.
  112844. * @param name The cloned name.
  112845. * @returns The cloned material.
  112846. */
  112847. clone(name: string): BackgroundMaterial;
  112848. /**
  112849. * Serializes the current material to its JSON representation.
  112850. * @returns The JSON representation.
  112851. */
  112852. serialize(): any;
  112853. /**
  112854. * Gets the class name of the material
  112855. * @returns "BackgroundMaterial"
  112856. */
  112857. getClassName(): string;
  112858. /**
  112859. * Parse a JSON input to create back a background material.
  112860. * @param source The JSON data to parse
  112861. * @param scene The scene to create the parsed material in
  112862. * @param rootUrl The root url of the assets the material depends upon
  112863. * @returns the instantiated BackgroundMaterial.
  112864. */
  112865. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112866. }
  112867. }
  112868. declare module BABYLON {
  112869. /**
  112870. * Represents the different options available during the creation of
  112871. * a Environment helper.
  112872. *
  112873. * This can control the default ground, skybox and image processing setup of your scene.
  112874. */
  112875. export interface IEnvironmentHelperOptions {
  112876. /**
  112877. * Specifies wether or not to create a ground.
  112878. * True by default.
  112879. */
  112880. createGround: boolean;
  112881. /**
  112882. * Specifies the ground size.
  112883. * 15 by default.
  112884. */
  112885. groundSize: number;
  112886. /**
  112887. * The texture used on the ground for the main color.
  112888. * Comes from the BabylonJS CDN by default.
  112889. *
  112890. * Remarks: Can be either a texture or a url.
  112891. */
  112892. groundTexture: string | BaseTexture;
  112893. /**
  112894. * The color mixed in the ground texture by default.
  112895. * BabylonJS clearColor by default.
  112896. */
  112897. groundColor: Color3;
  112898. /**
  112899. * Specifies the ground opacity.
  112900. * 1 by default.
  112901. */
  112902. groundOpacity: number;
  112903. /**
  112904. * Enables the ground to receive shadows.
  112905. * True by default.
  112906. */
  112907. enableGroundShadow: boolean;
  112908. /**
  112909. * Helps preventing the shadow to be fully black on the ground.
  112910. * 0.5 by default.
  112911. */
  112912. groundShadowLevel: number;
  112913. /**
  112914. * Creates a mirror texture attach to the ground.
  112915. * false by default.
  112916. */
  112917. enableGroundMirror: boolean;
  112918. /**
  112919. * Specifies the ground mirror size ratio.
  112920. * 0.3 by default as the default kernel is 64.
  112921. */
  112922. groundMirrorSizeRatio: number;
  112923. /**
  112924. * Specifies the ground mirror blur kernel size.
  112925. * 64 by default.
  112926. */
  112927. groundMirrorBlurKernel: number;
  112928. /**
  112929. * Specifies the ground mirror visibility amount.
  112930. * 1 by default
  112931. */
  112932. groundMirrorAmount: number;
  112933. /**
  112934. * Specifies the ground mirror reflectance weight.
  112935. * This uses the standard weight of the background material to setup the fresnel effect
  112936. * of the mirror.
  112937. * 1 by default.
  112938. */
  112939. groundMirrorFresnelWeight: number;
  112940. /**
  112941. * Specifies the ground mirror Falloff distance.
  112942. * This can helps reducing the size of the reflection.
  112943. * 0 by Default.
  112944. */
  112945. groundMirrorFallOffDistance: number;
  112946. /**
  112947. * Specifies the ground mirror texture type.
  112948. * Unsigned Int by Default.
  112949. */
  112950. groundMirrorTextureType: number;
  112951. /**
  112952. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112953. * the shown objects.
  112954. */
  112955. groundYBias: number;
  112956. /**
  112957. * Specifies wether or not to create a skybox.
  112958. * True by default.
  112959. */
  112960. createSkybox: boolean;
  112961. /**
  112962. * Specifies the skybox size.
  112963. * 20 by default.
  112964. */
  112965. skyboxSize: number;
  112966. /**
  112967. * The texture used on the skybox for the main color.
  112968. * Comes from the BabylonJS CDN by default.
  112969. *
  112970. * Remarks: Can be either a texture or a url.
  112971. */
  112972. skyboxTexture: string | BaseTexture;
  112973. /**
  112974. * The color mixed in the skybox texture by default.
  112975. * BabylonJS clearColor by default.
  112976. */
  112977. skyboxColor: Color3;
  112978. /**
  112979. * The background rotation around the Y axis of the scene.
  112980. * This helps aligning the key lights of your scene with the background.
  112981. * 0 by default.
  112982. */
  112983. backgroundYRotation: number;
  112984. /**
  112985. * Compute automatically the size of the elements to best fit with the scene.
  112986. */
  112987. sizeAuto: boolean;
  112988. /**
  112989. * Default position of the rootMesh if autoSize is not true.
  112990. */
  112991. rootPosition: Vector3;
  112992. /**
  112993. * Sets up the image processing in the scene.
  112994. * true by default.
  112995. */
  112996. setupImageProcessing: boolean;
  112997. /**
  112998. * The texture used as your environment texture in the scene.
  112999. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113000. *
  113001. * Remarks: Can be either a texture or a url.
  113002. */
  113003. environmentTexture: string | BaseTexture;
  113004. /**
  113005. * The value of the exposure to apply to the scene.
  113006. * 0.6 by default if setupImageProcessing is true.
  113007. */
  113008. cameraExposure: number;
  113009. /**
  113010. * The value of the contrast to apply to the scene.
  113011. * 1.6 by default if setupImageProcessing is true.
  113012. */
  113013. cameraContrast: number;
  113014. /**
  113015. * Specifies wether or not tonemapping should be enabled in the scene.
  113016. * true by default if setupImageProcessing is true.
  113017. */
  113018. toneMappingEnabled: boolean;
  113019. }
  113020. /**
  113021. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113022. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113023. * It also helps with the default setup of your imageProcessing configuration.
  113024. */
  113025. export class EnvironmentHelper {
  113026. /**
  113027. * Default ground texture URL.
  113028. */
  113029. private static _groundTextureCDNUrl;
  113030. /**
  113031. * Default skybox texture URL.
  113032. */
  113033. private static _skyboxTextureCDNUrl;
  113034. /**
  113035. * Default environment texture URL.
  113036. */
  113037. private static _environmentTextureCDNUrl;
  113038. /**
  113039. * Creates the default options for the helper.
  113040. */
  113041. private static _getDefaultOptions;
  113042. private _rootMesh;
  113043. /**
  113044. * Gets the root mesh created by the helper.
  113045. */
  113046. readonly rootMesh: Mesh;
  113047. private _skybox;
  113048. /**
  113049. * Gets the skybox created by the helper.
  113050. */
  113051. readonly skybox: Nullable<Mesh>;
  113052. private _skyboxTexture;
  113053. /**
  113054. * Gets the skybox texture created by the helper.
  113055. */
  113056. readonly skyboxTexture: Nullable<BaseTexture>;
  113057. private _skyboxMaterial;
  113058. /**
  113059. * Gets the skybox material created by the helper.
  113060. */
  113061. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113062. private _ground;
  113063. /**
  113064. * Gets the ground mesh created by the helper.
  113065. */
  113066. readonly ground: Nullable<Mesh>;
  113067. private _groundTexture;
  113068. /**
  113069. * Gets the ground texture created by the helper.
  113070. */
  113071. readonly groundTexture: Nullable<BaseTexture>;
  113072. private _groundMirror;
  113073. /**
  113074. * Gets the ground mirror created by the helper.
  113075. */
  113076. readonly groundMirror: Nullable<MirrorTexture>;
  113077. /**
  113078. * Gets the ground mirror render list to helps pushing the meshes
  113079. * you wish in the ground reflection.
  113080. */
  113081. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113082. private _groundMaterial;
  113083. /**
  113084. * Gets the ground material created by the helper.
  113085. */
  113086. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113087. /**
  113088. * Stores the creation options.
  113089. */
  113090. private readonly _scene;
  113091. private _options;
  113092. /**
  113093. * This observable will be notified with any error during the creation of the environment,
  113094. * mainly texture creation errors.
  113095. */
  113096. onErrorObservable: Observable<{
  113097. message?: string;
  113098. exception?: any;
  113099. }>;
  113100. /**
  113101. * constructor
  113102. * @param options Defines the options we want to customize the helper
  113103. * @param scene The scene to add the material to
  113104. */
  113105. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113106. /**
  113107. * Updates the background according to the new options
  113108. * @param options
  113109. */
  113110. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113111. /**
  113112. * Sets the primary color of all the available elements.
  113113. * @param color the main color to affect to the ground and the background
  113114. */
  113115. setMainColor(color: Color3): void;
  113116. /**
  113117. * Setup the image processing according to the specified options.
  113118. */
  113119. private _setupImageProcessing;
  113120. /**
  113121. * Setup the environment texture according to the specified options.
  113122. */
  113123. private _setupEnvironmentTexture;
  113124. /**
  113125. * Setup the background according to the specified options.
  113126. */
  113127. private _setupBackground;
  113128. /**
  113129. * Get the scene sizes according to the setup.
  113130. */
  113131. private _getSceneSize;
  113132. /**
  113133. * Setup the ground according to the specified options.
  113134. */
  113135. private _setupGround;
  113136. /**
  113137. * Setup the ground material according to the specified options.
  113138. */
  113139. private _setupGroundMaterial;
  113140. /**
  113141. * Setup the ground diffuse texture according to the specified options.
  113142. */
  113143. private _setupGroundDiffuseTexture;
  113144. /**
  113145. * Setup the ground mirror texture according to the specified options.
  113146. */
  113147. private _setupGroundMirrorTexture;
  113148. /**
  113149. * Setup the ground to receive the mirror texture.
  113150. */
  113151. private _setupMirrorInGroundMaterial;
  113152. /**
  113153. * Setup the skybox according to the specified options.
  113154. */
  113155. private _setupSkybox;
  113156. /**
  113157. * Setup the skybox material according to the specified options.
  113158. */
  113159. private _setupSkyboxMaterial;
  113160. /**
  113161. * Setup the skybox reflection texture according to the specified options.
  113162. */
  113163. private _setupSkyboxReflectionTexture;
  113164. private _errorHandler;
  113165. /**
  113166. * Dispose all the elements created by the Helper.
  113167. */
  113168. dispose(): void;
  113169. }
  113170. }
  113171. declare module BABYLON {
  113172. /**
  113173. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113174. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113175. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113176. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113177. */
  113178. export class PhotoDome extends TransformNode {
  113179. /**
  113180. * Define the image as a Monoscopic panoramic 360 image.
  113181. */
  113182. static readonly MODE_MONOSCOPIC: number;
  113183. /**
  113184. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113185. */
  113186. static readonly MODE_TOPBOTTOM: number;
  113187. /**
  113188. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113189. */
  113190. static readonly MODE_SIDEBYSIDE: number;
  113191. private _useDirectMapping;
  113192. /**
  113193. * The texture being displayed on the sphere
  113194. */
  113195. protected _photoTexture: Texture;
  113196. /**
  113197. * Gets or sets the texture being displayed on the sphere
  113198. */
  113199. photoTexture: Texture;
  113200. /**
  113201. * Observable raised when an error occured while loading the 360 image
  113202. */
  113203. onLoadErrorObservable: Observable<string>;
  113204. /**
  113205. * The skybox material
  113206. */
  113207. protected _material: BackgroundMaterial;
  113208. /**
  113209. * The surface used for the skybox
  113210. */
  113211. protected _mesh: Mesh;
  113212. /**
  113213. * Gets the mesh used for the skybox.
  113214. */
  113215. readonly mesh: Mesh;
  113216. /**
  113217. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113218. * Also see the options.resolution property.
  113219. */
  113220. fovMultiplier: number;
  113221. private _imageMode;
  113222. /**
  113223. * Gets or set the current video mode for the video. It can be:
  113224. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113225. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113226. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113227. */
  113228. imageMode: number;
  113229. /**
  113230. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113231. * @param name Element's name, child elements will append suffixes for their own names.
  113232. * @param urlsOfPhoto defines the url of the photo to display
  113233. * @param options defines an object containing optional or exposed sub element properties
  113234. * @param onError defines a callback called when an error occured while loading the texture
  113235. */
  113236. constructor(name: string, urlOfPhoto: string, options: {
  113237. resolution?: number;
  113238. size?: number;
  113239. useDirectMapping?: boolean;
  113240. faceForward?: boolean;
  113241. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113242. private _onBeforeCameraRenderObserver;
  113243. private _changeImageMode;
  113244. /**
  113245. * Releases resources associated with this node.
  113246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113248. */
  113249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113250. }
  113251. }
  113252. declare module BABYLON {
  113253. /**
  113254. * Class used to host RGBD texture specific utilities
  113255. */
  113256. export class RGBDTextureTools {
  113257. /**
  113258. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113259. * @param texture the texture to expand.
  113260. */
  113261. static ExpandRGBDTexture(texture: Texture): void;
  113262. }
  113263. }
  113264. declare module BABYLON {
  113265. /**
  113266. * Class used to host texture specific utilities
  113267. */
  113268. export class BRDFTextureTools {
  113269. /**
  113270. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113271. * @param scene defines the hosting scene
  113272. * @returns the environment BRDF texture
  113273. */
  113274. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113275. private static _environmentBRDFBase64Texture;
  113276. }
  113277. }
  113278. declare module BABYLON {
  113279. /**
  113280. * @hidden
  113281. */
  113282. export interface IMaterialClearCoatDefines {
  113283. CLEARCOAT: boolean;
  113284. CLEARCOAT_DEFAULTIOR: boolean;
  113285. CLEARCOAT_TEXTURE: boolean;
  113286. CLEARCOAT_TEXTUREDIRECTUV: number;
  113287. CLEARCOAT_BUMP: boolean;
  113288. CLEARCOAT_BUMPDIRECTUV: number;
  113289. CLEARCOAT_TINT: boolean;
  113290. CLEARCOAT_TINT_TEXTURE: boolean;
  113291. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113292. /** @hidden */
  113293. _areTexturesDirty: boolean;
  113294. }
  113295. /**
  113296. * Define the code related to the clear coat parameters of the pbr material.
  113297. */
  113298. export class PBRClearCoatConfiguration {
  113299. /**
  113300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113301. * The default fits with a polyurethane material.
  113302. */
  113303. private static readonly _DefaultIndexOfRefraction;
  113304. private _isEnabled;
  113305. /**
  113306. * Defines if the clear coat is enabled in the material.
  113307. */
  113308. isEnabled: boolean;
  113309. /**
  113310. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113311. */
  113312. intensity: number;
  113313. /**
  113314. * Defines the clear coat layer roughness.
  113315. */
  113316. roughness: number;
  113317. private _indexOfRefraction;
  113318. /**
  113319. * Defines the index of refraction of the clear coat.
  113320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113321. * The default fits with a polyurethane material.
  113322. * Changing the default value is more performance intensive.
  113323. */
  113324. indexOfRefraction: number;
  113325. private _texture;
  113326. /**
  113327. * Stores the clear coat values in a texture.
  113328. */
  113329. texture: Nullable<BaseTexture>;
  113330. private _bumpTexture;
  113331. /**
  113332. * Define the clear coat specific bump texture.
  113333. */
  113334. bumpTexture: Nullable<BaseTexture>;
  113335. private _isTintEnabled;
  113336. /**
  113337. * Defines if the clear coat tint is enabled in the material.
  113338. */
  113339. isTintEnabled: boolean;
  113340. /**
  113341. * Defines the clear coat tint of the material.
  113342. * This is only use if tint is enabled
  113343. */
  113344. tintColor: Color3;
  113345. /**
  113346. * Defines the distance at which the tint color should be found in the
  113347. * clear coat media.
  113348. * This is only use if tint is enabled
  113349. */
  113350. tintColorAtDistance: number;
  113351. /**
  113352. * Defines the clear coat layer thickness.
  113353. * This is only use if tint is enabled
  113354. */
  113355. tintThickness: number;
  113356. private _tintTexture;
  113357. /**
  113358. * Stores the clear tint values in a texture.
  113359. * rgb is tint
  113360. * a is a thickness factor
  113361. */
  113362. tintTexture: Nullable<BaseTexture>;
  113363. /** @hidden */
  113364. private _internalMarkAllSubMeshesAsTexturesDirty;
  113365. /** @hidden */
  113366. _markAllSubMeshesAsTexturesDirty(): void;
  113367. /**
  113368. * Instantiate a new istance of clear coat configuration.
  113369. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113370. */
  113371. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113372. /**
  113373. * Gets wehter the submesh is ready to be used or not.
  113374. * @param defines the list of "defines" to update.
  113375. * @param scene defines the scene the material belongs to.
  113376. * @param engine defines the engine the material belongs to.
  113377. * @param disableBumpMap defines wether the material disables bump or not.
  113378. * @returns - boolean indicating that the submesh is ready or not.
  113379. */
  113380. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113381. /**
  113382. * Checks to see if a texture is used in the material.
  113383. * @param defines the list of "defines" to update.
  113384. * @param scene defines the scene to the material belongs to.
  113385. */
  113386. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113387. /**
  113388. * Binds the material data.
  113389. * @param uniformBuffer defines the Uniform buffer to fill in.
  113390. * @param scene defines the scene the material belongs to.
  113391. * @param engine defines the engine the material belongs to.
  113392. * @param disableBumpMap defines wether the material disables bump or not.
  113393. * @param isFrozen defines wether the material is frozen or not.
  113394. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113395. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113396. */
  113397. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113398. /**
  113399. * Checks to see if a texture is used in the material.
  113400. * @param texture - Base texture to use.
  113401. * @returns - Boolean specifying if a texture is used in the material.
  113402. */
  113403. hasTexture(texture: BaseTexture): boolean;
  113404. /**
  113405. * Returns an array of the actively used textures.
  113406. * @param activeTextures Array of BaseTextures
  113407. */
  113408. getActiveTextures(activeTextures: BaseTexture[]): void;
  113409. /**
  113410. * Returns the animatable textures.
  113411. * @param animatables Array of animatable textures.
  113412. */
  113413. getAnimatables(animatables: IAnimatable[]): void;
  113414. /**
  113415. * Disposes the resources of the material.
  113416. * @param forceDisposeTextures - Forces the disposal of all textures.
  113417. */
  113418. dispose(forceDisposeTextures?: boolean): void;
  113419. /**
  113420. * Get the current class name of the texture useful for serialization or dynamic coding.
  113421. * @returns "PBRClearCoatConfiguration"
  113422. */
  113423. getClassName(): string;
  113424. /**
  113425. * Add fallbacks to the effect fallbacks list.
  113426. * @param defines defines the Base texture to use.
  113427. * @param fallbacks defines the current fallback list.
  113428. * @param currentRank defines the current fallback rank.
  113429. * @returns the new fallback rank.
  113430. */
  113431. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113432. /**
  113433. * Add the required uniforms to the current list.
  113434. * @param uniforms defines the current uniform list.
  113435. */
  113436. static AddUniforms(uniforms: string[]): void;
  113437. /**
  113438. * Add the required samplers to the current list.
  113439. * @param samplers defines the current sampler list.
  113440. */
  113441. static AddSamplers(samplers: string[]): void;
  113442. /**
  113443. * Add the required uniforms to the current buffer.
  113444. * @param uniformBuffer defines the current uniform buffer.
  113445. */
  113446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113447. /**
  113448. * Makes a duplicate of the current configuration into another one.
  113449. * @param clearCoatConfiguration define the config where to copy the info
  113450. */
  113451. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113452. /**
  113453. * Serializes this clear coat configuration.
  113454. * @returns - An object with the serialized config.
  113455. */
  113456. serialize(): any;
  113457. /**
  113458. * Parses a anisotropy Configuration from a serialized object.
  113459. * @param source - Serialized object.
  113460. * @param scene Defines the scene we are parsing for
  113461. * @param rootUrl Defines the rootUrl to load from
  113462. */
  113463. parse(source: any, scene: Scene, rootUrl: string): void;
  113464. }
  113465. }
  113466. declare module BABYLON {
  113467. /**
  113468. * @hidden
  113469. */
  113470. export interface IMaterialAnisotropicDefines {
  113471. ANISOTROPIC: boolean;
  113472. ANISOTROPIC_TEXTURE: boolean;
  113473. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113474. MAINUV1: boolean;
  113475. _areTexturesDirty: boolean;
  113476. _needUVs: boolean;
  113477. }
  113478. /**
  113479. * Define the code related to the anisotropic parameters of the pbr material.
  113480. */
  113481. export class PBRAnisotropicConfiguration {
  113482. private _isEnabled;
  113483. /**
  113484. * Defines if the anisotropy is enabled in the material.
  113485. */
  113486. isEnabled: boolean;
  113487. /**
  113488. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113489. */
  113490. intensity: number;
  113491. /**
  113492. * Defines if the effect is along the tangents, bitangents or in between.
  113493. * By default, the effect is "strectching" the highlights along the tangents.
  113494. */
  113495. direction: Vector2;
  113496. private _texture;
  113497. /**
  113498. * Stores the anisotropy values in a texture.
  113499. * rg is direction (like normal from -1 to 1)
  113500. * b is a intensity
  113501. */
  113502. texture: Nullable<BaseTexture>;
  113503. /** @hidden */
  113504. private _internalMarkAllSubMeshesAsTexturesDirty;
  113505. /** @hidden */
  113506. _markAllSubMeshesAsTexturesDirty(): void;
  113507. /**
  113508. * Instantiate a new istance of anisotropy configuration.
  113509. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113510. */
  113511. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113512. /**
  113513. * Specifies that the submesh is ready to be used.
  113514. * @param defines the list of "defines" to update.
  113515. * @param scene defines the scene the material belongs to.
  113516. * @returns - boolean indicating that the submesh is ready or not.
  113517. */
  113518. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113519. /**
  113520. * Checks to see if a texture is used in the material.
  113521. * @param defines the list of "defines" to update.
  113522. * @param mesh the mesh we are preparing the defines for.
  113523. * @param scene defines the scene the material belongs to.
  113524. */
  113525. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113526. /**
  113527. * Binds the material data.
  113528. * @param uniformBuffer defines the Uniform buffer to fill in.
  113529. * @param scene defines the scene the material belongs to.
  113530. * @param isFrozen defines wether the material is frozen or not.
  113531. */
  113532. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113533. /**
  113534. * Checks to see if a texture is used in the material.
  113535. * @param texture - Base texture to use.
  113536. * @returns - Boolean specifying if a texture is used in the material.
  113537. */
  113538. hasTexture(texture: BaseTexture): boolean;
  113539. /**
  113540. * Returns an array of the actively used textures.
  113541. * @param activeTextures Array of BaseTextures
  113542. */
  113543. getActiveTextures(activeTextures: BaseTexture[]): void;
  113544. /**
  113545. * Returns the animatable textures.
  113546. * @param animatables Array of animatable textures.
  113547. */
  113548. getAnimatables(animatables: IAnimatable[]): void;
  113549. /**
  113550. * Disposes the resources of the material.
  113551. * @param forceDisposeTextures - Forces the disposal of all textures.
  113552. */
  113553. dispose(forceDisposeTextures?: boolean): void;
  113554. /**
  113555. * Get the current class name of the texture useful for serialization or dynamic coding.
  113556. * @returns "PBRAnisotropicConfiguration"
  113557. */
  113558. getClassName(): string;
  113559. /**
  113560. * Add fallbacks to the effect fallbacks list.
  113561. * @param defines defines the Base texture to use.
  113562. * @param fallbacks defines the current fallback list.
  113563. * @param currentRank defines the current fallback rank.
  113564. * @returns the new fallback rank.
  113565. */
  113566. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113567. /**
  113568. * Add the required uniforms to the current list.
  113569. * @param uniforms defines the current uniform list.
  113570. */
  113571. static AddUniforms(uniforms: string[]): void;
  113572. /**
  113573. * Add the required uniforms to the current buffer.
  113574. * @param uniformBuffer defines the current uniform buffer.
  113575. */
  113576. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113577. /**
  113578. * Add the required samplers to the current list.
  113579. * @param samplers defines the current sampler list.
  113580. */
  113581. static AddSamplers(samplers: string[]): void;
  113582. /**
  113583. * Makes a duplicate of the current configuration into another one.
  113584. * @param anisotropicConfiguration define the config where to copy the info
  113585. */
  113586. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113587. /**
  113588. * Serializes this anisotropy configuration.
  113589. * @returns - An object with the serialized config.
  113590. */
  113591. serialize(): any;
  113592. /**
  113593. * Parses a anisotropy Configuration from a serialized object.
  113594. * @param source - Serialized object.
  113595. * @param scene Defines the scene we are parsing for
  113596. * @param rootUrl Defines the rootUrl to load from
  113597. */
  113598. parse(source: any, scene: Scene, rootUrl: string): void;
  113599. }
  113600. }
  113601. declare module BABYLON {
  113602. /**
  113603. * @hidden
  113604. */
  113605. export interface IMaterialBRDFDefines {
  113606. BRDF_V_HEIGHT_CORRELATED: boolean;
  113607. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113608. SPHERICAL_HARMONICS: boolean;
  113609. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113610. /** @hidden */
  113611. _areMiscDirty: boolean;
  113612. }
  113613. /**
  113614. * Define the code related to the BRDF parameters of the pbr material.
  113615. */
  113616. export class PBRBRDFConfiguration {
  113617. /**
  113618. * Default value used for the energy conservation.
  113619. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113620. */
  113621. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113622. /**
  113623. * Default value used for the Smith Visibility Height Correlated mode.
  113624. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113625. */
  113626. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113627. /**
  113628. * Default value used for the IBL diffuse part.
  113629. * This can help switching back to the polynomials mode globally which is a tiny bit
  113630. * less GPU intensive at the drawback of a lower quality.
  113631. */
  113632. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113633. /**
  113634. * Default value used for activating energy conservation for the specular workflow.
  113635. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113636. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113637. */
  113638. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113639. private _useEnergyConservation;
  113640. /**
  113641. * Defines if the material uses energy conservation.
  113642. */
  113643. useEnergyConservation: boolean;
  113644. private _useSmithVisibilityHeightCorrelated;
  113645. /**
  113646. * LEGACY Mode set to false
  113647. * Defines if the material uses height smith correlated visibility term.
  113648. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113649. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113650. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113651. * Not relying on height correlated will also disable energy conservation.
  113652. */
  113653. useSmithVisibilityHeightCorrelated: boolean;
  113654. private _useSphericalHarmonics;
  113655. /**
  113656. * LEGACY Mode set to false
  113657. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113658. * diffuse part of the IBL.
  113659. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113660. * to the ground truth.
  113661. */
  113662. useSphericalHarmonics: boolean;
  113663. private _useSpecularGlossinessInputEnergyConservation;
  113664. /**
  113665. * Defines if the material uses energy conservation, when the specular workflow is active.
  113666. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113667. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113668. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113669. */
  113670. useSpecularGlossinessInputEnergyConservation: boolean;
  113671. /** @hidden */
  113672. private _internalMarkAllSubMeshesAsMiscDirty;
  113673. /** @hidden */
  113674. _markAllSubMeshesAsMiscDirty(): void;
  113675. /**
  113676. * Instantiate a new istance of clear coat configuration.
  113677. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113678. */
  113679. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113680. /**
  113681. * Checks to see if a texture is used in the material.
  113682. * @param defines the list of "defines" to update.
  113683. */
  113684. prepareDefines(defines: IMaterialBRDFDefines): void;
  113685. /**
  113686. * Get the current class name of the texture useful for serialization or dynamic coding.
  113687. * @returns "PBRClearCoatConfiguration"
  113688. */
  113689. getClassName(): string;
  113690. /**
  113691. * Makes a duplicate of the current configuration into another one.
  113692. * @param brdfConfiguration define the config where to copy the info
  113693. */
  113694. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113695. /**
  113696. * Serializes this BRDF configuration.
  113697. * @returns - An object with the serialized config.
  113698. */
  113699. serialize(): any;
  113700. /**
  113701. * Parses a anisotropy Configuration from a serialized object.
  113702. * @param source - Serialized object.
  113703. * @param scene Defines the scene we are parsing for
  113704. * @param rootUrl Defines the rootUrl to load from
  113705. */
  113706. parse(source: any, scene: Scene, rootUrl: string): void;
  113707. }
  113708. }
  113709. declare module BABYLON {
  113710. /**
  113711. * @hidden
  113712. */
  113713. export interface IMaterialSheenDefines {
  113714. SHEEN: boolean;
  113715. SHEEN_TEXTURE: boolean;
  113716. SHEEN_TEXTUREDIRECTUV: number;
  113717. SHEEN_LINKWITHALBEDO: boolean;
  113718. /** @hidden */
  113719. _areTexturesDirty: boolean;
  113720. }
  113721. /**
  113722. * Define the code related to the Sheen parameters of the pbr material.
  113723. */
  113724. export class PBRSheenConfiguration {
  113725. private _isEnabled;
  113726. /**
  113727. * Defines if the material uses sheen.
  113728. */
  113729. isEnabled: boolean;
  113730. private _linkSheenWithAlbedo;
  113731. /**
  113732. * Defines if the sheen is linked to the sheen color.
  113733. */
  113734. linkSheenWithAlbedo: boolean;
  113735. /**
  113736. * Defines the sheen intensity.
  113737. */
  113738. intensity: number;
  113739. /**
  113740. * Defines the sheen color.
  113741. */
  113742. color: Color3;
  113743. private _texture;
  113744. /**
  113745. * Stores the sheen tint values in a texture.
  113746. * rgb is tint
  113747. * a is a intensity
  113748. */
  113749. texture: Nullable<BaseTexture>;
  113750. /** @hidden */
  113751. private _internalMarkAllSubMeshesAsTexturesDirty;
  113752. /** @hidden */
  113753. _markAllSubMeshesAsTexturesDirty(): void;
  113754. /**
  113755. * Instantiate a new istance of clear coat configuration.
  113756. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113757. */
  113758. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113759. /**
  113760. * Specifies that the submesh is ready to be used.
  113761. * @param defines the list of "defines" to update.
  113762. * @param scene defines the scene the material belongs to.
  113763. * @returns - boolean indicating that the submesh is ready or not.
  113764. */
  113765. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113766. /**
  113767. * Checks to see if a texture is used in the material.
  113768. * @param defines the list of "defines" to update.
  113769. * @param scene defines the scene the material belongs to.
  113770. */
  113771. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113772. /**
  113773. * Binds the material data.
  113774. * @param uniformBuffer defines the Uniform buffer to fill in.
  113775. * @param scene defines the scene the material belongs to.
  113776. * @param isFrozen defines wether the material is frozen or not.
  113777. */
  113778. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113779. /**
  113780. * Checks to see if a texture is used in the material.
  113781. * @param texture - Base texture to use.
  113782. * @returns - Boolean specifying if a texture is used in the material.
  113783. */
  113784. hasTexture(texture: BaseTexture): boolean;
  113785. /**
  113786. * Returns an array of the actively used textures.
  113787. * @param activeTextures Array of BaseTextures
  113788. */
  113789. getActiveTextures(activeTextures: BaseTexture[]): void;
  113790. /**
  113791. * Returns the animatable textures.
  113792. * @param animatables Array of animatable textures.
  113793. */
  113794. getAnimatables(animatables: IAnimatable[]): void;
  113795. /**
  113796. * Disposes the resources of the material.
  113797. * @param forceDisposeTextures - Forces the disposal of all textures.
  113798. */
  113799. dispose(forceDisposeTextures?: boolean): void;
  113800. /**
  113801. * Get the current class name of the texture useful for serialization or dynamic coding.
  113802. * @returns "PBRSheenConfiguration"
  113803. */
  113804. getClassName(): string;
  113805. /**
  113806. * Add fallbacks to the effect fallbacks list.
  113807. * @param defines defines the Base texture to use.
  113808. * @param fallbacks defines the current fallback list.
  113809. * @param currentRank defines the current fallback rank.
  113810. * @returns the new fallback rank.
  113811. */
  113812. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113813. /**
  113814. * Add the required uniforms to the current list.
  113815. * @param uniforms defines the current uniform list.
  113816. */
  113817. static AddUniforms(uniforms: string[]): void;
  113818. /**
  113819. * Add the required uniforms to the current buffer.
  113820. * @param uniformBuffer defines the current uniform buffer.
  113821. */
  113822. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113823. /**
  113824. * Add the required samplers to the current list.
  113825. * @param samplers defines the current sampler list.
  113826. */
  113827. static AddSamplers(samplers: string[]): void;
  113828. /**
  113829. * Makes a duplicate of the current configuration into another one.
  113830. * @param sheenConfiguration define the config where to copy the info
  113831. */
  113832. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113833. /**
  113834. * Serializes this BRDF configuration.
  113835. * @returns - An object with the serialized config.
  113836. */
  113837. serialize(): any;
  113838. /**
  113839. * Parses a anisotropy Configuration from a serialized object.
  113840. * @param source - Serialized object.
  113841. * @param scene Defines the scene we are parsing for
  113842. * @param rootUrl Defines the rootUrl to load from
  113843. */
  113844. parse(source: any, scene: Scene, rootUrl: string): void;
  113845. }
  113846. }
  113847. declare module BABYLON {
  113848. /**
  113849. * @hidden
  113850. */
  113851. export interface IMaterialSubSurfaceDefines {
  113852. SUBSURFACE: boolean;
  113853. SS_REFRACTION: boolean;
  113854. SS_TRANSLUCENCY: boolean;
  113855. SS_SCATERRING: boolean;
  113856. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113857. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113858. SS_REFRACTIONMAP_3D: boolean;
  113859. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113860. SS_LODINREFRACTIONALPHA: boolean;
  113861. SS_GAMMAREFRACTION: boolean;
  113862. SS_RGBDREFRACTION: boolean;
  113863. SS_LINEARSPECULARREFRACTION: boolean;
  113864. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113865. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113866. /** @hidden */
  113867. _areTexturesDirty: boolean;
  113868. }
  113869. /**
  113870. * Define the code related to the sub surface parameters of the pbr material.
  113871. */
  113872. export class PBRSubSurfaceConfiguration {
  113873. private _isRefractionEnabled;
  113874. /**
  113875. * Defines if the refraction is enabled in the material.
  113876. */
  113877. isRefractionEnabled: boolean;
  113878. private _isTranslucencyEnabled;
  113879. /**
  113880. * Defines if the translucency is enabled in the material.
  113881. */
  113882. isTranslucencyEnabled: boolean;
  113883. private _isScatteringEnabled;
  113884. /**
  113885. * Defines the refraction intensity of the material.
  113886. * The refraction when enabled replaces the Diffuse part of the material.
  113887. * The intensity helps transitionning between diffuse and refraction.
  113888. */
  113889. refractionIntensity: number;
  113890. /**
  113891. * Defines the translucency intensity of the material.
  113892. * When translucency has been enabled, this defines how much of the "translucency"
  113893. * is addded to the diffuse part of the material.
  113894. */
  113895. translucencyIntensity: number;
  113896. /**
  113897. * Defines the scattering intensity of the material.
  113898. * When scattering has been enabled, this defines how much of the "scattered light"
  113899. * is addded to the diffuse part of the material.
  113900. */
  113901. scatteringIntensity: number;
  113902. private _thicknessTexture;
  113903. /**
  113904. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113905. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113906. * 0 would mean minimumThickness
  113907. * 1 would mean maximumThickness
  113908. * The other channels might be use as a mask to vary the different effects intensity.
  113909. */
  113910. thicknessTexture: Nullable<BaseTexture>;
  113911. private _refractionTexture;
  113912. /**
  113913. * Defines the texture to use for refraction.
  113914. */
  113915. refractionTexture: Nullable<BaseTexture>;
  113916. private _indexOfRefraction;
  113917. /**
  113918. * Defines the index of refraction used in the material.
  113919. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113920. */
  113921. indexOfRefraction: number;
  113922. private _invertRefractionY;
  113923. /**
  113924. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113925. */
  113926. invertRefractionY: boolean;
  113927. private _linkRefractionWithTransparency;
  113928. /**
  113929. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113930. * Materials half opaque for instance using refraction could benefit from this control.
  113931. */
  113932. linkRefractionWithTransparency: boolean;
  113933. /**
  113934. * Defines the minimum thickness stored in the thickness map.
  113935. * If no thickness map is defined, this value will be used to simulate thickness.
  113936. */
  113937. minimumThickness: number;
  113938. /**
  113939. * Defines the maximum thickness stored in the thickness map.
  113940. */
  113941. maximumThickness: number;
  113942. /**
  113943. * Defines the volume tint of the material.
  113944. * This is used for both translucency and scattering.
  113945. */
  113946. tintColor: Color3;
  113947. /**
  113948. * Defines the distance at which the tint color should be found in the media.
  113949. * This is used for refraction only.
  113950. */
  113951. tintColorAtDistance: number;
  113952. /**
  113953. * Defines how far each channel transmit through the media.
  113954. * It is defined as a color to simplify it selection.
  113955. */
  113956. diffusionDistance: Color3;
  113957. private _useMaskFromThicknessTexture;
  113958. /**
  113959. * Stores the intensity of the different subsurface effects in the thickness texture.
  113960. * * the green channel is the translucency intensity.
  113961. * * the blue channel is the scattering intensity.
  113962. * * the alpha channel is the refraction intensity.
  113963. */
  113964. useMaskFromThicknessTexture: boolean;
  113965. /** @hidden */
  113966. private _internalMarkAllSubMeshesAsTexturesDirty;
  113967. /** @hidden */
  113968. _markAllSubMeshesAsTexturesDirty(): void;
  113969. /**
  113970. * Instantiate a new istance of sub surface configuration.
  113971. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113972. */
  113973. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113974. /**
  113975. * Gets wehter the submesh is ready to be used or not.
  113976. * @param defines the list of "defines" to update.
  113977. * @param scene defines the scene the material belongs to.
  113978. * @returns - boolean indicating that the submesh is ready or not.
  113979. */
  113980. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113981. /**
  113982. * Checks to see if a texture is used in the material.
  113983. * @param defines the list of "defines" to update.
  113984. * @param scene defines the scene to the material belongs to.
  113985. */
  113986. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113987. /**
  113988. * Binds the material data.
  113989. * @param uniformBuffer defines the Uniform buffer to fill in.
  113990. * @param scene defines the scene the material belongs to.
  113991. * @param engine defines the engine the material belongs to.
  113992. * @param isFrozen defines wether the material is frozen or not.
  113993. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113994. */
  113995. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113996. /**
  113997. * Unbinds the material from the mesh.
  113998. * @param activeEffect defines the effect that should be unbound from.
  113999. * @returns true if unbound, otherwise false
  114000. */
  114001. unbind(activeEffect: Effect): boolean;
  114002. /**
  114003. * Returns the texture used for refraction or null if none is used.
  114004. * @param scene defines the scene the material belongs to.
  114005. * @returns - Refraction texture if present. If no refraction texture and refraction
  114006. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114007. */
  114008. private _getRefractionTexture;
  114009. /**
  114010. * Returns true if alpha blending should be disabled.
  114011. */
  114012. readonly disableAlphaBlending: boolean;
  114013. /**
  114014. * Fills the list of render target textures.
  114015. * @param renderTargets the list of render targets to update
  114016. */
  114017. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114018. /**
  114019. * Checks to see if a texture is used in the material.
  114020. * @param texture - Base texture to use.
  114021. * @returns - Boolean specifying if a texture is used in the material.
  114022. */
  114023. hasTexture(texture: BaseTexture): boolean;
  114024. /**
  114025. * Gets a boolean indicating that current material needs to register RTT
  114026. * @returns true if this uses a render target otherwise false.
  114027. */
  114028. hasRenderTargetTextures(): boolean;
  114029. /**
  114030. * Returns an array of the actively used textures.
  114031. * @param activeTextures Array of BaseTextures
  114032. */
  114033. getActiveTextures(activeTextures: BaseTexture[]): void;
  114034. /**
  114035. * Returns the animatable textures.
  114036. * @param animatables Array of animatable textures.
  114037. */
  114038. getAnimatables(animatables: IAnimatable[]): void;
  114039. /**
  114040. * Disposes the resources of the material.
  114041. * @param forceDisposeTextures - Forces the disposal of all textures.
  114042. */
  114043. dispose(forceDisposeTextures?: boolean): void;
  114044. /**
  114045. * Get the current class name of the texture useful for serialization or dynamic coding.
  114046. * @returns "PBRSubSurfaceConfiguration"
  114047. */
  114048. getClassName(): string;
  114049. /**
  114050. * Add fallbacks to the effect fallbacks list.
  114051. * @param defines defines the Base texture to use.
  114052. * @param fallbacks defines the current fallback list.
  114053. * @param currentRank defines the current fallback rank.
  114054. * @returns the new fallback rank.
  114055. */
  114056. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114057. /**
  114058. * Add the required uniforms to the current list.
  114059. * @param uniforms defines the current uniform list.
  114060. */
  114061. static AddUniforms(uniforms: string[]): void;
  114062. /**
  114063. * Add the required samplers to the current list.
  114064. * @param samplers defines the current sampler list.
  114065. */
  114066. static AddSamplers(samplers: string[]): void;
  114067. /**
  114068. * Add the required uniforms to the current buffer.
  114069. * @param uniformBuffer defines the current uniform buffer.
  114070. */
  114071. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114072. /**
  114073. * Makes a duplicate of the current configuration into another one.
  114074. * @param configuration define the config where to copy the info
  114075. */
  114076. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114077. /**
  114078. * Serializes this Sub Surface configuration.
  114079. * @returns - An object with the serialized config.
  114080. */
  114081. serialize(): any;
  114082. /**
  114083. * Parses a anisotropy Configuration from a serialized object.
  114084. * @param source - Serialized object.
  114085. * @param scene Defines the scene we are parsing for
  114086. * @param rootUrl Defines the rootUrl to load from
  114087. */
  114088. parse(source: any, scene: Scene, rootUrl: string): void;
  114089. }
  114090. }
  114091. declare module BABYLON {
  114092. /** @hidden */
  114093. export var pbrFragmentDeclaration: {
  114094. name: string;
  114095. shader: string;
  114096. };
  114097. }
  114098. declare module BABYLON {
  114099. /** @hidden */
  114100. export var pbrUboDeclaration: {
  114101. name: string;
  114102. shader: string;
  114103. };
  114104. }
  114105. declare module BABYLON {
  114106. /** @hidden */
  114107. export var pbrFragmentExtraDeclaration: {
  114108. name: string;
  114109. shader: string;
  114110. };
  114111. }
  114112. declare module BABYLON {
  114113. /** @hidden */
  114114. export var pbrFragmentSamplersDeclaration: {
  114115. name: string;
  114116. shader: string;
  114117. };
  114118. }
  114119. declare module BABYLON {
  114120. /** @hidden */
  114121. export var pbrHelperFunctions: {
  114122. name: string;
  114123. shader: string;
  114124. };
  114125. }
  114126. declare module BABYLON {
  114127. /** @hidden */
  114128. export var harmonicsFunctions: {
  114129. name: string;
  114130. shader: string;
  114131. };
  114132. }
  114133. declare module BABYLON {
  114134. /** @hidden */
  114135. export var pbrDirectLightingSetupFunctions: {
  114136. name: string;
  114137. shader: string;
  114138. };
  114139. }
  114140. declare module BABYLON {
  114141. /** @hidden */
  114142. export var pbrDirectLightingFalloffFunctions: {
  114143. name: string;
  114144. shader: string;
  114145. };
  114146. }
  114147. declare module BABYLON {
  114148. /** @hidden */
  114149. export var pbrBRDFFunctions: {
  114150. name: string;
  114151. shader: string;
  114152. };
  114153. }
  114154. declare module BABYLON {
  114155. /** @hidden */
  114156. export var pbrDirectLightingFunctions: {
  114157. name: string;
  114158. shader: string;
  114159. };
  114160. }
  114161. declare module BABYLON {
  114162. /** @hidden */
  114163. export var pbrIBLFunctions: {
  114164. name: string;
  114165. shader: string;
  114166. };
  114167. }
  114168. declare module BABYLON {
  114169. /** @hidden */
  114170. export var pbrDebug: {
  114171. name: string;
  114172. shader: string;
  114173. };
  114174. }
  114175. declare module BABYLON {
  114176. /** @hidden */
  114177. export var pbrPixelShader: {
  114178. name: string;
  114179. shader: string;
  114180. };
  114181. }
  114182. declare module BABYLON {
  114183. /** @hidden */
  114184. export var pbrVertexDeclaration: {
  114185. name: string;
  114186. shader: string;
  114187. };
  114188. }
  114189. declare module BABYLON {
  114190. /** @hidden */
  114191. export var pbrVertexShader: {
  114192. name: string;
  114193. shader: string;
  114194. };
  114195. }
  114196. declare module BABYLON {
  114197. /**
  114198. * Manages the defines for the PBR Material.
  114199. * @hidden
  114200. */
  114201. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114202. PBR: boolean;
  114203. MAINUV1: boolean;
  114204. MAINUV2: boolean;
  114205. UV1: boolean;
  114206. UV2: boolean;
  114207. ALBEDO: boolean;
  114208. ALBEDODIRECTUV: number;
  114209. VERTEXCOLOR: boolean;
  114210. AMBIENT: boolean;
  114211. AMBIENTDIRECTUV: number;
  114212. AMBIENTINGRAYSCALE: boolean;
  114213. OPACITY: boolean;
  114214. VERTEXALPHA: boolean;
  114215. OPACITYDIRECTUV: number;
  114216. OPACITYRGB: boolean;
  114217. ALPHATEST: boolean;
  114218. DEPTHPREPASS: boolean;
  114219. ALPHABLEND: boolean;
  114220. ALPHAFROMALBEDO: boolean;
  114221. ALPHATESTVALUE: string;
  114222. SPECULAROVERALPHA: boolean;
  114223. RADIANCEOVERALPHA: boolean;
  114224. ALPHAFRESNEL: boolean;
  114225. LINEARALPHAFRESNEL: boolean;
  114226. PREMULTIPLYALPHA: boolean;
  114227. EMISSIVE: boolean;
  114228. EMISSIVEDIRECTUV: number;
  114229. REFLECTIVITY: boolean;
  114230. REFLECTIVITYDIRECTUV: number;
  114231. SPECULARTERM: boolean;
  114232. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114233. MICROSURFACEAUTOMATIC: boolean;
  114234. LODBASEDMICROSFURACE: boolean;
  114235. MICROSURFACEMAP: boolean;
  114236. MICROSURFACEMAPDIRECTUV: number;
  114237. METALLICWORKFLOW: boolean;
  114238. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114239. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114240. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114241. AOSTOREINMETALMAPRED: boolean;
  114242. ENVIRONMENTBRDF: boolean;
  114243. ENVIRONMENTBRDF_RGBD: boolean;
  114244. NORMAL: boolean;
  114245. TANGENT: boolean;
  114246. BUMP: boolean;
  114247. BUMPDIRECTUV: number;
  114248. OBJECTSPACE_NORMALMAP: boolean;
  114249. PARALLAX: boolean;
  114250. PARALLAXOCCLUSION: boolean;
  114251. NORMALXYSCALE: boolean;
  114252. LIGHTMAP: boolean;
  114253. LIGHTMAPDIRECTUV: number;
  114254. USELIGHTMAPASSHADOWMAP: boolean;
  114255. GAMMALIGHTMAP: boolean;
  114256. RGBDLIGHTMAP: boolean;
  114257. REFLECTION: boolean;
  114258. REFLECTIONMAP_3D: boolean;
  114259. REFLECTIONMAP_SPHERICAL: boolean;
  114260. REFLECTIONMAP_PLANAR: boolean;
  114261. REFLECTIONMAP_CUBIC: boolean;
  114262. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114263. REFLECTIONMAP_PROJECTION: boolean;
  114264. REFLECTIONMAP_SKYBOX: boolean;
  114265. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114266. REFLECTIONMAP_EXPLICIT: boolean;
  114267. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114268. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114269. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114270. INVERTCUBICMAP: boolean;
  114271. USESPHERICALFROMREFLECTIONMAP: boolean;
  114272. USEIRRADIANCEMAP: boolean;
  114273. SPHERICAL_HARMONICS: boolean;
  114274. USESPHERICALINVERTEX: boolean;
  114275. REFLECTIONMAP_OPPOSITEZ: boolean;
  114276. LODINREFLECTIONALPHA: boolean;
  114277. GAMMAREFLECTION: boolean;
  114278. RGBDREFLECTION: boolean;
  114279. LINEARSPECULARREFLECTION: boolean;
  114280. RADIANCEOCCLUSION: boolean;
  114281. HORIZONOCCLUSION: boolean;
  114282. INSTANCES: boolean;
  114283. NUM_BONE_INFLUENCERS: number;
  114284. BonesPerMesh: number;
  114285. BONETEXTURE: boolean;
  114286. NONUNIFORMSCALING: boolean;
  114287. MORPHTARGETS: boolean;
  114288. MORPHTARGETS_NORMAL: boolean;
  114289. MORPHTARGETS_TANGENT: boolean;
  114290. MORPHTARGETS_UV: boolean;
  114291. NUM_MORPH_INFLUENCERS: number;
  114292. IMAGEPROCESSING: boolean;
  114293. VIGNETTE: boolean;
  114294. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114295. VIGNETTEBLENDMODEOPAQUE: boolean;
  114296. TONEMAPPING: boolean;
  114297. TONEMAPPING_ACES: boolean;
  114298. CONTRAST: boolean;
  114299. COLORCURVES: boolean;
  114300. COLORGRADING: boolean;
  114301. COLORGRADING3D: boolean;
  114302. SAMPLER3DGREENDEPTH: boolean;
  114303. SAMPLER3DBGRMAP: boolean;
  114304. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114305. EXPOSURE: boolean;
  114306. MULTIVIEW: boolean;
  114307. USEPHYSICALLIGHTFALLOFF: boolean;
  114308. USEGLTFLIGHTFALLOFF: boolean;
  114309. TWOSIDEDLIGHTING: boolean;
  114310. SHADOWFLOAT: boolean;
  114311. CLIPPLANE: boolean;
  114312. CLIPPLANE2: boolean;
  114313. CLIPPLANE3: boolean;
  114314. CLIPPLANE4: boolean;
  114315. POINTSIZE: boolean;
  114316. FOG: boolean;
  114317. LOGARITHMICDEPTH: boolean;
  114318. FORCENORMALFORWARD: boolean;
  114319. SPECULARAA: boolean;
  114320. CLEARCOAT: boolean;
  114321. CLEARCOAT_DEFAULTIOR: boolean;
  114322. CLEARCOAT_TEXTURE: boolean;
  114323. CLEARCOAT_TEXTUREDIRECTUV: number;
  114324. CLEARCOAT_BUMP: boolean;
  114325. CLEARCOAT_BUMPDIRECTUV: number;
  114326. CLEARCOAT_TINT: boolean;
  114327. CLEARCOAT_TINT_TEXTURE: boolean;
  114328. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114329. ANISOTROPIC: boolean;
  114330. ANISOTROPIC_TEXTURE: boolean;
  114331. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114332. BRDF_V_HEIGHT_CORRELATED: boolean;
  114333. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114334. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114335. SHEEN: boolean;
  114336. SHEEN_TEXTURE: boolean;
  114337. SHEEN_TEXTUREDIRECTUV: number;
  114338. SHEEN_LINKWITHALBEDO: boolean;
  114339. SUBSURFACE: boolean;
  114340. SS_REFRACTION: boolean;
  114341. SS_TRANSLUCENCY: boolean;
  114342. SS_SCATERRING: boolean;
  114343. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114344. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114345. SS_REFRACTIONMAP_3D: boolean;
  114346. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114347. SS_LODINREFRACTIONALPHA: boolean;
  114348. SS_GAMMAREFRACTION: boolean;
  114349. SS_RGBDREFRACTION: boolean;
  114350. SS_LINEARSPECULARREFRACTION: boolean;
  114351. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114352. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114353. UNLIT: boolean;
  114354. DEBUGMODE: number;
  114355. /**
  114356. * Initializes the PBR Material defines.
  114357. */
  114358. constructor();
  114359. /**
  114360. * Resets the PBR Material defines.
  114361. */
  114362. reset(): void;
  114363. }
  114364. /**
  114365. * The Physically based material base class of BJS.
  114366. *
  114367. * This offers the main features of a standard PBR material.
  114368. * For more information, please refer to the documentation :
  114369. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114370. */
  114371. export abstract class PBRBaseMaterial extends PushMaterial {
  114372. /**
  114373. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114374. */
  114375. static readonly PBRMATERIAL_OPAQUE: number;
  114376. /**
  114377. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114378. */
  114379. static readonly PBRMATERIAL_ALPHATEST: number;
  114380. /**
  114381. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114382. */
  114383. static readonly PBRMATERIAL_ALPHABLEND: number;
  114384. /**
  114385. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114386. * They are also discarded below the alpha cutoff threshold to improve performances.
  114387. */
  114388. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114389. /**
  114390. * Defines the default value of how much AO map is occluding the analytical lights
  114391. * (point spot...).
  114392. */
  114393. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114394. /**
  114395. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114396. */
  114397. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114398. /**
  114399. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114400. * to enhance interoperability with other engines.
  114401. */
  114402. static readonly LIGHTFALLOFF_GLTF: number;
  114403. /**
  114404. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114405. * to enhance interoperability with other materials.
  114406. */
  114407. static readonly LIGHTFALLOFF_STANDARD: number;
  114408. /**
  114409. * Intensity of the direct lights e.g. the four lights available in your scene.
  114410. * This impacts both the direct diffuse and specular highlights.
  114411. */
  114412. protected _directIntensity: number;
  114413. /**
  114414. * Intensity of the emissive part of the material.
  114415. * This helps controlling the emissive effect without modifying the emissive color.
  114416. */
  114417. protected _emissiveIntensity: number;
  114418. /**
  114419. * Intensity of the environment e.g. how much the environment will light the object
  114420. * either through harmonics for rough material or through the refelction for shiny ones.
  114421. */
  114422. protected _environmentIntensity: number;
  114423. /**
  114424. * This is a special control allowing the reduction of the specular highlights coming from the
  114425. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114426. */
  114427. protected _specularIntensity: number;
  114428. /**
  114429. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114430. */
  114431. private _lightingInfos;
  114432. /**
  114433. * Debug Control allowing disabling the bump map on this material.
  114434. */
  114435. protected _disableBumpMap: boolean;
  114436. /**
  114437. * AKA Diffuse Texture in standard nomenclature.
  114438. */
  114439. protected _albedoTexture: Nullable<BaseTexture>;
  114440. /**
  114441. * AKA Occlusion Texture in other nomenclature.
  114442. */
  114443. protected _ambientTexture: Nullable<BaseTexture>;
  114444. /**
  114445. * AKA Occlusion Texture Intensity in other nomenclature.
  114446. */
  114447. protected _ambientTextureStrength: number;
  114448. /**
  114449. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114450. * 1 means it completely occludes it
  114451. * 0 mean it has no impact
  114452. */
  114453. protected _ambientTextureImpactOnAnalyticalLights: number;
  114454. /**
  114455. * Stores the alpha values in a texture.
  114456. */
  114457. protected _opacityTexture: Nullable<BaseTexture>;
  114458. /**
  114459. * Stores the reflection values in a texture.
  114460. */
  114461. protected _reflectionTexture: Nullable<BaseTexture>;
  114462. /**
  114463. * Stores the emissive values in a texture.
  114464. */
  114465. protected _emissiveTexture: Nullable<BaseTexture>;
  114466. /**
  114467. * AKA Specular texture in other nomenclature.
  114468. */
  114469. protected _reflectivityTexture: Nullable<BaseTexture>;
  114470. /**
  114471. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114472. */
  114473. protected _metallicTexture: Nullable<BaseTexture>;
  114474. /**
  114475. * Specifies the metallic scalar of the metallic/roughness workflow.
  114476. * Can also be used to scale the metalness values of the metallic texture.
  114477. */
  114478. protected _metallic: Nullable<number>;
  114479. /**
  114480. * Specifies the roughness scalar of the metallic/roughness workflow.
  114481. * Can also be used to scale the roughness values of the metallic texture.
  114482. */
  114483. protected _roughness: Nullable<number>;
  114484. /**
  114485. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114486. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114487. */
  114488. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114489. /**
  114490. * Stores surface normal data used to displace a mesh in a texture.
  114491. */
  114492. protected _bumpTexture: Nullable<BaseTexture>;
  114493. /**
  114494. * Stores the pre-calculated light information of a mesh in a texture.
  114495. */
  114496. protected _lightmapTexture: Nullable<BaseTexture>;
  114497. /**
  114498. * The color of a material in ambient lighting.
  114499. */
  114500. protected _ambientColor: Color3;
  114501. /**
  114502. * AKA Diffuse Color in other nomenclature.
  114503. */
  114504. protected _albedoColor: Color3;
  114505. /**
  114506. * AKA Specular Color in other nomenclature.
  114507. */
  114508. protected _reflectivityColor: Color3;
  114509. /**
  114510. * The color applied when light is reflected from a material.
  114511. */
  114512. protected _reflectionColor: Color3;
  114513. /**
  114514. * The color applied when light is emitted from a material.
  114515. */
  114516. protected _emissiveColor: Color3;
  114517. /**
  114518. * AKA Glossiness in other nomenclature.
  114519. */
  114520. protected _microSurface: number;
  114521. /**
  114522. * Specifies that the material will use the light map as a show map.
  114523. */
  114524. protected _useLightmapAsShadowmap: boolean;
  114525. /**
  114526. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114527. * makes the reflect vector face the model (under horizon).
  114528. */
  114529. protected _useHorizonOcclusion: boolean;
  114530. /**
  114531. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114532. * too much the area relying on ambient texture to define their ambient occlusion.
  114533. */
  114534. protected _useRadianceOcclusion: boolean;
  114535. /**
  114536. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114537. */
  114538. protected _useAlphaFromAlbedoTexture: boolean;
  114539. /**
  114540. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114541. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114542. */
  114543. protected _useSpecularOverAlpha: boolean;
  114544. /**
  114545. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114546. */
  114547. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114548. /**
  114549. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114550. */
  114551. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114552. /**
  114553. * Specifies if the metallic texture contains the roughness information in its green channel.
  114554. */
  114555. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114556. /**
  114557. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114558. */
  114559. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114560. /**
  114561. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114562. */
  114563. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114564. /**
  114565. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114566. */
  114567. protected _useAmbientInGrayScale: boolean;
  114568. /**
  114569. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114570. * The material will try to infer what glossiness each pixel should be.
  114571. */
  114572. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114573. /**
  114574. * Defines the falloff type used in this material.
  114575. * It by default is Physical.
  114576. */
  114577. protected _lightFalloff: number;
  114578. /**
  114579. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114580. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114581. */
  114582. protected _useRadianceOverAlpha: boolean;
  114583. /**
  114584. * Allows using an object space normal map (instead of tangent space).
  114585. */
  114586. protected _useObjectSpaceNormalMap: boolean;
  114587. /**
  114588. * Allows using the bump map in parallax mode.
  114589. */
  114590. protected _useParallax: boolean;
  114591. /**
  114592. * Allows using the bump map in parallax occlusion mode.
  114593. */
  114594. protected _useParallaxOcclusion: boolean;
  114595. /**
  114596. * Controls the scale bias of the parallax mode.
  114597. */
  114598. protected _parallaxScaleBias: number;
  114599. /**
  114600. * If sets to true, disables all the lights affecting the material.
  114601. */
  114602. protected _disableLighting: boolean;
  114603. /**
  114604. * Number of Simultaneous lights allowed on the material.
  114605. */
  114606. protected _maxSimultaneousLights: number;
  114607. /**
  114608. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114609. */
  114610. protected _invertNormalMapX: boolean;
  114611. /**
  114612. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114613. */
  114614. protected _invertNormalMapY: boolean;
  114615. /**
  114616. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114617. */
  114618. protected _twoSidedLighting: boolean;
  114619. /**
  114620. * Defines the alpha limits in alpha test mode.
  114621. */
  114622. protected _alphaCutOff: number;
  114623. /**
  114624. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114625. */
  114626. protected _forceAlphaTest: boolean;
  114627. /**
  114628. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114629. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114630. */
  114631. protected _useAlphaFresnel: boolean;
  114632. /**
  114633. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114634. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114635. */
  114636. protected _useLinearAlphaFresnel: boolean;
  114637. /**
  114638. * The transparency mode of the material.
  114639. */
  114640. protected _transparencyMode: Nullable<number>;
  114641. /**
  114642. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114643. * from cos thetav and roughness:
  114644. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114645. */
  114646. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114647. /**
  114648. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114649. */
  114650. protected _forceIrradianceInFragment: boolean;
  114651. /**
  114652. * Force normal to face away from face.
  114653. */
  114654. protected _forceNormalForward: boolean;
  114655. /**
  114656. * Enables specular anti aliasing in the PBR shader.
  114657. * It will both interacts on the Geometry for analytical and IBL lighting.
  114658. * It also prefilter the roughness map based on the bump values.
  114659. */
  114660. protected _enableSpecularAntiAliasing: boolean;
  114661. /**
  114662. * Default configuration related to image processing available in the PBR Material.
  114663. */
  114664. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114665. /**
  114666. * Keep track of the image processing observer to allow dispose and replace.
  114667. */
  114668. private _imageProcessingObserver;
  114669. /**
  114670. * Attaches a new image processing configuration to the PBR Material.
  114671. * @param configuration
  114672. */
  114673. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114674. /**
  114675. * Stores the available render targets.
  114676. */
  114677. private _renderTargets;
  114678. /**
  114679. * Sets the global ambient color for the material used in lighting calculations.
  114680. */
  114681. private _globalAmbientColor;
  114682. /**
  114683. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114684. */
  114685. private _useLogarithmicDepth;
  114686. /**
  114687. * If set to true, no lighting calculations will be applied.
  114688. */
  114689. private _unlit;
  114690. private _debugMode;
  114691. /**
  114692. * @hidden
  114693. * This is reserved for the inspector.
  114694. * Defines the material debug mode.
  114695. * It helps seeing only some components of the material while troubleshooting.
  114696. */
  114697. debugMode: number;
  114698. /**
  114699. * @hidden
  114700. * This is reserved for the inspector.
  114701. * Specify from where on screen the debug mode should start.
  114702. * The value goes from -1 (full screen) to 1 (not visible)
  114703. * It helps with side by side comparison against the final render
  114704. * This defaults to -1
  114705. */
  114706. private debugLimit;
  114707. /**
  114708. * @hidden
  114709. * This is reserved for the inspector.
  114710. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114711. * You can use the factor to better multiply the final value.
  114712. */
  114713. private debugFactor;
  114714. /**
  114715. * Defines the clear coat layer parameters for the material.
  114716. */
  114717. readonly clearCoat: PBRClearCoatConfiguration;
  114718. /**
  114719. * Defines the anisotropic parameters for the material.
  114720. */
  114721. readonly anisotropy: PBRAnisotropicConfiguration;
  114722. /**
  114723. * Defines the BRDF parameters for the material.
  114724. */
  114725. readonly brdf: PBRBRDFConfiguration;
  114726. /**
  114727. * Defines the Sheen parameters for the material.
  114728. */
  114729. readonly sheen: PBRSheenConfiguration;
  114730. /**
  114731. * Defines the SubSurface parameters for the material.
  114732. */
  114733. readonly subSurface: PBRSubSurfaceConfiguration;
  114734. /**
  114735. * Custom callback helping to override the default shader used in the material.
  114736. */
  114737. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114738. protected _rebuildInParallel: boolean;
  114739. /**
  114740. * Instantiates a new PBRMaterial instance.
  114741. *
  114742. * @param name The material name
  114743. * @param scene The scene the material will be use in.
  114744. */
  114745. constructor(name: string, scene: Scene);
  114746. /**
  114747. * Gets a boolean indicating that current material needs to register RTT
  114748. */
  114749. readonly hasRenderTargetTextures: boolean;
  114750. /**
  114751. * Gets the name of the material class.
  114752. */
  114753. getClassName(): string;
  114754. /**
  114755. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114756. */
  114757. /**
  114758. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114759. */
  114760. useLogarithmicDepth: boolean;
  114761. /**
  114762. * Gets the current transparency mode.
  114763. */
  114764. /**
  114765. * Sets the transparency mode of the material.
  114766. *
  114767. * | Value | Type | Description |
  114768. * | ----- | ----------------------------------- | ----------- |
  114769. * | 0 | OPAQUE | |
  114770. * | 1 | ALPHATEST | |
  114771. * | 2 | ALPHABLEND | |
  114772. * | 3 | ALPHATESTANDBLEND | |
  114773. *
  114774. */
  114775. transparencyMode: Nullable<number>;
  114776. /**
  114777. * Returns true if alpha blending should be disabled.
  114778. */
  114779. private readonly _disableAlphaBlending;
  114780. /**
  114781. * Specifies whether or not this material should be rendered in alpha blend mode.
  114782. */
  114783. needAlphaBlending(): boolean;
  114784. /**
  114785. * Specifies if the mesh will require alpha blending.
  114786. * @param mesh - BJS mesh.
  114787. */
  114788. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114789. /**
  114790. * Specifies whether or not this material should be rendered in alpha test mode.
  114791. */
  114792. needAlphaTesting(): boolean;
  114793. /**
  114794. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114795. */
  114796. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114797. /**
  114798. * Gets the texture used for the alpha test.
  114799. */
  114800. getAlphaTestTexture(): Nullable<BaseTexture>;
  114801. /**
  114802. * Specifies that the submesh is ready to be used.
  114803. * @param mesh - BJS mesh.
  114804. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114805. * @param useInstances - Specifies that instances should be used.
  114806. * @returns - boolean indicating that the submesh is ready or not.
  114807. */
  114808. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114809. /**
  114810. * Specifies if the material uses metallic roughness workflow.
  114811. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114812. */
  114813. isMetallicWorkflow(): boolean;
  114814. private _prepareEffect;
  114815. private _prepareDefines;
  114816. /**
  114817. * Force shader compilation
  114818. */
  114819. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114820. clipPlane: boolean;
  114821. }>): void;
  114822. /**
  114823. * Initializes the uniform buffer layout for the shader.
  114824. */
  114825. buildUniformLayout(): void;
  114826. /**
  114827. * Unbinds the material from the mesh
  114828. */
  114829. unbind(): void;
  114830. /**
  114831. * Binds the submesh data.
  114832. * @param world - The world matrix.
  114833. * @param mesh - The BJS mesh.
  114834. * @param subMesh - A submesh of the BJS mesh.
  114835. */
  114836. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114837. /**
  114838. * Returns the animatable textures.
  114839. * @returns - Array of animatable textures.
  114840. */
  114841. getAnimatables(): IAnimatable[];
  114842. /**
  114843. * Returns the texture used for reflections.
  114844. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114845. */
  114846. private _getReflectionTexture;
  114847. /**
  114848. * Returns an array of the actively used textures.
  114849. * @returns - Array of BaseTextures
  114850. */
  114851. getActiveTextures(): BaseTexture[];
  114852. /**
  114853. * Checks to see if a texture is used in the material.
  114854. * @param texture - Base texture to use.
  114855. * @returns - Boolean specifying if a texture is used in the material.
  114856. */
  114857. hasTexture(texture: BaseTexture): boolean;
  114858. /**
  114859. * Disposes the resources of the material.
  114860. * @param forceDisposeEffect - Forces the disposal of effects.
  114861. * @param forceDisposeTextures - Forces the disposal of all textures.
  114862. */
  114863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114864. }
  114865. }
  114866. declare module BABYLON {
  114867. /**
  114868. * The Physically based material of BJS.
  114869. *
  114870. * This offers the main features of a standard PBR material.
  114871. * For more information, please refer to the documentation :
  114872. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114873. */
  114874. export class PBRMaterial extends PBRBaseMaterial {
  114875. /**
  114876. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114877. */
  114878. static readonly PBRMATERIAL_OPAQUE: number;
  114879. /**
  114880. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114881. */
  114882. static readonly PBRMATERIAL_ALPHATEST: number;
  114883. /**
  114884. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114885. */
  114886. static readonly PBRMATERIAL_ALPHABLEND: number;
  114887. /**
  114888. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114889. * They are also discarded below the alpha cutoff threshold to improve performances.
  114890. */
  114891. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114892. /**
  114893. * Defines the default value of how much AO map is occluding the analytical lights
  114894. * (point spot...).
  114895. */
  114896. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114897. /**
  114898. * Intensity of the direct lights e.g. the four lights available in your scene.
  114899. * This impacts both the direct diffuse and specular highlights.
  114900. */
  114901. directIntensity: number;
  114902. /**
  114903. * Intensity of the emissive part of the material.
  114904. * This helps controlling the emissive effect without modifying the emissive color.
  114905. */
  114906. emissiveIntensity: number;
  114907. /**
  114908. * Intensity of the environment e.g. how much the environment will light the object
  114909. * either through harmonics for rough material or through the refelction for shiny ones.
  114910. */
  114911. environmentIntensity: number;
  114912. /**
  114913. * This is a special control allowing the reduction of the specular highlights coming from the
  114914. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114915. */
  114916. specularIntensity: number;
  114917. /**
  114918. * Debug Control allowing disabling the bump map on this material.
  114919. */
  114920. disableBumpMap: boolean;
  114921. /**
  114922. * AKA Diffuse Texture in standard nomenclature.
  114923. */
  114924. albedoTexture: BaseTexture;
  114925. /**
  114926. * AKA Occlusion Texture in other nomenclature.
  114927. */
  114928. ambientTexture: BaseTexture;
  114929. /**
  114930. * AKA Occlusion Texture Intensity in other nomenclature.
  114931. */
  114932. ambientTextureStrength: number;
  114933. /**
  114934. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114935. * 1 means it completely occludes it
  114936. * 0 mean it has no impact
  114937. */
  114938. ambientTextureImpactOnAnalyticalLights: number;
  114939. /**
  114940. * Stores the alpha values in a texture.
  114941. */
  114942. opacityTexture: BaseTexture;
  114943. /**
  114944. * Stores the reflection values in a texture.
  114945. */
  114946. reflectionTexture: Nullable<BaseTexture>;
  114947. /**
  114948. * Stores the emissive values in a texture.
  114949. */
  114950. emissiveTexture: BaseTexture;
  114951. /**
  114952. * AKA Specular texture in other nomenclature.
  114953. */
  114954. reflectivityTexture: BaseTexture;
  114955. /**
  114956. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114957. */
  114958. metallicTexture: BaseTexture;
  114959. /**
  114960. * Specifies the metallic scalar of the metallic/roughness workflow.
  114961. * Can also be used to scale the metalness values of the metallic texture.
  114962. */
  114963. metallic: Nullable<number>;
  114964. /**
  114965. * Specifies the roughness scalar of the metallic/roughness workflow.
  114966. * Can also be used to scale the roughness values of the metallic texture.
  114967. */
  114968. roughness: Nullable<number>;
  114969. /**
  114970. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114971. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114972. */
  114973. microSurfaceTexture: BaseTexture;
  114974. /**
  114975. * Stores surface normal data used to displace a mesh in a texture.
  114976. */
  114977. bumpTexture: BaseTexture;
  114978. /**
  114979. * Stores the pre-calculated light information of a mesh in a texture.
  114980. */
  114981. lightmapTexture: BaseTexture;
  114982. /**
  114983. * Stores the refracted light information in a texture.
  114984. */
  114985. refractionTexture: Nullable<BaseTexture>;
  114986. /**
  114987. * The color of a material in ambient lighting.
  114988. */
  114989. ambientColor: Color3;
  114990. /**
  114991. * AKA Diffuse Color in other nomenclature.
  114992. */
  114993. albedoColor: Color3;
  114994. /**
  114995. * AKA Specular Color in other nomenclature.
  114996. */
  114997. reflectivityColor: Color3;
  114998. /**
  114999. * The color reflected from the material.
  115000. */
  115001. reflectionColor: Color3;
  115002. /**
  115003. * The color emitted from the material.
  115004. */
  115005. emissiveColor: Color3;
  115006. /**
  115007. * AKA Glossiness in other nomenclature.
  115008. */
  115009. microSurface: number;
  115010. /**
  115011. * source material index of refraction (IOR)' / 'destination material IOR.
  115012. */
  115013. indexOfRefraction: number;
  115014. /**
  115015. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115016. */
  115017. invertRefractionY: boolean;
  115018. /**
  115019. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115020. * Materials half opaque for instance using refraction could benefit from this control.
  115021. */
  115022. linkRefractionWithTransparency: boolean;
  115023. /**
  115024. * If true, the light map contains occlusion information instead of lighting info.
  115025. */
  115026. useLightmapAsShadowmap: boolean;
  115027. /**
  115028. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115029. */
  115030. useAlphaFromAlbedoTexture: boolean;
  115031. /**
  115032. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115033. */
  115034. forceAlphaTest: boolean;
  115035. /**
  115036. * Defines the alpha limits in alpha test mode.
  115037. */
  115038. alphaCutOff: number;
  115039. /**
  115040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115042. */
  115043. useSpecularOverAlpha: boolean;
  115044. /**
  115045. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115046. */
  115047. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115048. /**
  115049. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115050. */
  115051. useRoughnessFromMetallicTextureAlpha: boolean;
  115052. /**
  115053. * Specifies if the metallic texture contains the roughness information in its green channel.
  115054. */
  115055. useRoughnessFromMetallicTextureGreen: boolean;
  115056. /**
  115057. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115058. */
  115059. useMetallnessFromMetallicTextureBlue: boolean;
  115060. /**
  115061. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115062. */
  115063. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115064. /**
  115065. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115066. */
  115067. useAmbientInGrayScale: boolean;
  115068. /**
  115069. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115070. * The material will try to infer what glossiness each pixel should be.
  115071. */
  115072. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115073. /**
  115074. * BJS is using an harcoded light falloff based on a manually sets up range.
  115075. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115076. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115077. */
  115078. /**
  115079. * BJS is using an harcoded light falloff based on a manually sets up range.
  115080. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115081. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115082. */
  115083. usePhysicalLightFalloff: boolean;
  115084. /**
  115085. * In order to support the falloff compatibility with gltf, a special mode has been added
  115086. * to reproduce the gltf light falloff.
  115087. */
  115088. /**
  115089. * In order to support the falloff compatibility with gltf, a special mode has been added
  115090. * to reproduce the gltf light falloff.
  115091. */
  115092. useGLTFLightFalloff: boolean;
  115093. /**
  115094. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115095. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115096. */
  115097. useRadianceOverAlpha: boolean;
  115098. /**
  115099. * Allows using an object space normal map (instead of tangent space).
  115100. */
  115101. useObjectSpaceNormalMap: boolean;
  115102. /**
  115103. * Allows using the bump map in parallax mode.
  115104. */
  115105. useParallax: boolean;
  115106. /**
  115107. * Allows using the bump map in parallax occlusion mode.
  115108. */
  115109. useParallaxOcclusion: boolean;
  115110. /**
  115111. * Controls the scale bias of the parallax mode.
  115112. */
  115113. parallaxScaleBias: number;
  115114. /**
  115115. * If sets to true, disables all the lights affecting the material.
  115116. */
  115117. disableLighting: boolean;
  115118. /**
  115119. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115120. */
  115121. forceIrradianceInFragment: boolean;
  115122. /**
  115123. * Number of Simultaneous lights allowed on the material.
  115124. */
  115125. maxSimultaneousLights: number;
  115126. /**
  115127. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115128. */
  115129. invertNormalMapX: boolean;
  115130. /**
  115131. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115132. */
  115133. invertNormalMapY: boolean;
  115134. /**
  115135. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115136. */
  115137. twoSidedLighting: boolean;
  115138. /**
  115139. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115140. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115141. */
  115142. useAlphaFresnel: boolean;
  115143. /**
  115144. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115145. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115146. */
  115147. useLinearAlphaFresnel: boolean;
  115148. /**
  115149. * Let user defines the brdf lookup texture used for IBL.
  115150. * A default 8bit version is embedded but you could point at :
  115151. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115152. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115153. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115154. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115155. */
  115156. environmentBRDFTexture: Nullable<BaseTexture>;
  115157. /**
  115158. * Force normal to face away from face.
  115159. */
  115160. forceNormalForward: boolean;
  115161. /**
  115162. * Enables specular anti aliasing in the PBR shader.
  115163. * It will both interacts on the Geometry for analytical and IBL lighting.
  115164. * It also prefilter the roughness map based on the bump values.
  115165. */
  115166. enableSpecularAntiAliasing: boolean;
  115167. /**
  115168. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115169. * makes the reflect vector face the model (under horizon).
  115170. */
  115171. useHorizonOcclusion: boolean;
  115172. /**
  115173. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115174. * too much the area relying on ambient texture to define their ambient occlusion.
  115175. */
  115176. useRadianceOcclusion: boolean;
  115177. /**
  115178. * If set to true, no lighting calculations will be applied.
  115179. */
  115180. unlit: boolean;
  115181. /**
  115182. * Gets the image processing configuration used either in this material.
  115183. */
  115184. /**
  115185. * Sets the Default image processing configuration used either in the this material.
  115186. *
  115187. * If sets to null, the scene one is in use.
  115188. */
  115189. imageProcessingConfiguration: ImageProcessingConfiguration;
  115190. /**
  115191. * Gets wether the color curves effect is enabled.
  115192. */
  115193. /**
  115194. * Sets wether the color curves effect is enabled.
  115195. */
  115196. cameraColorCurvesEnabled: boolean;
  115197. /**
  115198. * Gets wether the color grading effect is enabled.
  115199. */
  115200. /**
  115201. * Gets wether the color grading effect is enabled.
  115202. */
  115203. cameraColorGradingEnabled: boolean;
  115204. /**
  115205. * Gets wether tonemapping is enabled or not.
  115206. */
  115207. /**
  115208. * Sets wether tonemapping is enabled or not
  115209. */
  115210. cameraToneMappingEnabled: boolean;
  115211. /**
  115212. * The camera exposure used on this material.
  115213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115214. * This corresponds to a photographic exposure.
  115215. */
  115216. /**
  115217. * The camera exposure used on this material.
  115218. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115219. * This corresponds to a photographic exposure.
  115220. */
  115221. cameraExposure: number;
  115222. /**
  115223. * Gets The camera contrast used on this material.
  115224. */
  115225. /**
  115226. * Sets The camera contrast used on this material.
  115227. */
  115228. cameraContrast: number;
  115229. /**
  115230. * Gets the Color Grading 2D Lookup Texture.
  115231. */
  115232. /**
  115233. * Sets the Color Grading 2D Lookup Texture.
  115234. */
  115235. cameraColorGradingTexture: Nullable<BaseTexture>;
  115236. /**
  115237. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115238. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115239. * 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;
  115240. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115241. */
  115242. /**
  115243. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115244. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115245. * 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;
  115246. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115247. */
  115248. cameraColorCurves: Nullable<ColorCurves>;
  115249. /**
  115250. * Instantiates a new PBRMaterial instance.
  115251. *
  115252. * @param name The material name
  115253. * @param scene The scene the material will be use in.
  115254. */
  115255. constructor(name: string, scene: Scene);
  115256. /**
  115257. * Returns the name of this material class.
  115258. */
  115259. getClassName(): string;
  115260. /**
  115261. * Makes a duplicate of the current material.
  115262. * @param name - name to use for the new material.
  115263. */
  115264. clone(name: string): PBRMaterial;
  115265. /**
  115266. * Serializes this PBR Material.
  115267. * @returns - An object with the serialized material.
  115268. */
  115269. serialize(): any;
  115270. /**
  115271. * Parses a PBR Material from a serialized object.
  115272. * @param source - Serialized object.
  115273. * @param scene - BJS scene instance.
  115274. * @param rootUrl - url for the scene object
  115275. * @returns - PBRMaterial
  115276. */
  115277. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115278. }
  115279. }
  115280. declare module BABYLON {
  115281. /**
  115282. * Direct draw surface info
  115283. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115284. */
  115285. export interface DDSInfo {
  115286. /**
  115287. * Width of the texture
  115288. */
  115289. width: number;
  115290. /**
  115291. * Width of the texture
  115292. */
  115293. height: number;
  115294. /**
  115295. * Number of Mipmaps for the texture
  115296. * @see https://en.wikipedia.org/wiki/Mipmap
  115297. */
  115298. mipmapCount: number;
  115299. /**
  115300. * If the textures format is a known fourCC format
  115301. * @see https://www.fourcc.org/
  115302. */
  115303. isFourCC: boolean;
  115304. /**
  115305. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115306. */
  115307. isRGB: boolean;
  115308. /**
  115309. * If the texture is a lumincance format
  115310. */
  115311. isLuminance: boolean;
  115312. /**
  115313. * If this is a cube texture
  115314. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115315. */
  115316. isCube: boolean;
  115317. /**
  115318. * If the texture is a compressed format eg. FOURCC_DXT1
  115319. */
  115320. isCompressed: boolean;
  115321. /**
  115322. * The dxgiFormat of the texture
  115323. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115324. */
  115325. dxgiFormat: number;
  115326. /**
  115327. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115328. */
  115329. textureType: number;
  115330. /**
  115331. * Sphericle polynomial created for the dds texture
  115332. */
  115333. sphericalPolynomial?: SphericalPolynomial;
  115334. }
  115335. /**
  115336. * Class used to provide DDS decompression tools
  115337. */
  115338. export class DDSTools {
  115339. /**
  115340. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115341. */
  115342. static StoreLODInAlphaChannel: boolean;
  115343. /**
  115344. * Gets DDS information from an array buffer
  115345. * @param arrayBuffer defines the array buffer to read data from
  115346. * @returns the DDS information
  115347. */
  115348. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115349. private static _FloatView;
  115350. private static _Int32View;
  115351. private static _ToHalfFloat;
  115352. private static _FromHalfFloat;
  115353. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115354. private static _GetHalfFloatRGBAArrayBuffer;
  115355. private static _GetFloatRGBAArrayBuffer;
  115356. private static _GetFloatAsUIntRGBAArrayBuffer;
  115357. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115358. private static _GetRGBAArrayBuffer;
  115359. private static _ExtractLongWordOrder;
  115360. private static _GetRGBArrayBuffer;
  115361. private static _GetLuminanceArrayBuffer;
  115362. /**
  115363. * Uploads DDS Levels to a Babylon Texture
  115364. * @hidden
  115365. */
  115366. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115367. }
  115368. interface ThinEngine {
  115369. /**
  115370. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115371. * @param rootUrl defines the url where the file to load is located
  115372. * @param scene defines the current scene
  115373. * @param lodScale defines scale to apply to the mip map selection
  115374. * @param lodOffset defines offset to apply to the mip map selection
  115375. * @param onLoad defines an optional callback raised when the texture is loaded
  115376. * @param onError defines an optional callback raised if there is an issue to load the texture
  115377. * @param format defines the format of the data
  115378. * @param forcedExtension defines the extension to use to pick the right loader
  115379. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115380. * @returns the cube texture as an InternalTexture
  115381. */
  115382. 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;
  115383. }
  115384. }
  115385. declare module BABYLON {
  115386. /**
  115387. * Implementation of the DDS Texture Loader.
  115388. * @hidden
  115389. */
  115390. export class _DDSTextureLoader implements IInternalTextureLoader {
  115391. /**
  115392. * Defines wether the loader supports cascade loading the different faces.
  115393. */
  115394. readonly supportCascades: boolean;
  115395. /**
  115396. * This returns if the loader support the current file information.
  115397. * @param extension defines the file extension of the file being loaded
  115398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115399. * @param fallback defines the fallback internal texture if any
  115400. * @param isBase64 defines whether the texture is encoded as a base64
  115401. * @param isBuffer defines whether the texture data are stored as a buffer
  115402. * @returns true if the loader can load the specified file
  115403. */
  115404. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115405. /**
  115406. * Transform the url before loading if required.
  115407. * @param rootUrl the url of the texture
  115408. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115409. * @returns the transformed texture
  115410. */
  115411. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115412. /**
  115413. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115414. * @param rootUrl the url of the texture
  115415. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115416. * @returns the fallback texture
  115417. */
  115418. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115419. /**
  115420. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115421. * @param data contains the texture data
  115422. * @param texture defines the BabylonJS internal texture
  115423. * @param createPolynomials will be true if polynomials have been requested
  115424. * @param onLoad defines the callback to trigger once the texture is ready
  115425. * @param onError defines the callback to trigger in case of error
  115426. */
  115427. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115428. /**
  115429. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115430. * @param data contains the texture data
  115431. * @param texture defines the BabylonJS internal texture
  115432. * @param callback defines the method to call once ready to upload
  115433. */
  115434. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115435. }
  115436. }
  115437. declare module BABYLON {
  115438. /**
  115439. * Implementation of the ENV Texture Loader.
  115440. * @hidden
  115441. */
  115442. export class _ENVTextureLoader implements IInternalTextureLoader {
  115443. /**
  115444. * Defines wether the loader supports cascade loading the different faces.
  115445. */
  115446. readonly supportCascades: boolean;
  115447. /**
  115448. * This returns if the loader support the current file information.
  115449. * @param extension defines the file extension of the file being loaded
  115450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115451. * @param fallback defines the fallback internal texture if any
  115452. * @param isBase64 defines whether the texture is encoded as a base64
  115453. * @param isBuffer defines whether the texture data are stored as a buffer
  115454. * @returns true if the loader can load the specified file
  115455. */
  115456. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115457. /**
  115458. * Transform the url before loading if required.
  115459. * @param rootUrl the url of the texture
  115460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115461. * @returns the transformed texture
  115462. */
  115463. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115464. /**
  115465. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115466. * @param rootUrl the url of the texture
  115467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115468. * @returns the fallback texture
  115469. */
  115470. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115471. /**
  115472. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115473. * @param data contains the texture data
  115474. * @param texture defines the BabylonJS internal texture
  115475. * @param createPolynomials will be true if polynomials have been requested
  115476. * @param onLoad defines the callback to trigger once the texture is ready
  115477. * @param onError defines the callback to trigger in case of error
  115478. */
  115479. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115480. /**
  115481. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115482. * @param data contains the texture data
  115483. * @param texture defines the BabylonJS internal texture
  115484. * @param callback defines the method to call once ready to upload
  115485. */
  115486. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115487. }
  115488. }
  115489. declare module BABYLON {
  115490. /**
  115491. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115492. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115493. */
  115494. export class KhronosTextureContainer {
  115495. /** contents of the KTX container file */
  115496. arrayBuffer: any;
  115497. private static HEADER_LEN;
  115498. private static COMPRESSED_2D;
  115499. private static COMPRESSED_3D;
  115500. private static TEX_2D;
  115501. private static TEX_3D;
  115502. /**
  115503. * Gets the openGL type
  115504. */
  115505. glType: number;
  115506. /**
  115507. * Gets the openGL type size
  115508. */
  115509. glTypeSize: number;
  115510. /**
  115511. * Gets the openGL format
  115512. */
  115513. glFormat: number;
  115514. /**
  115515. * Gets the openGL internal format
  115516. */
  115517. glInternalFormat: number;
  115518. /**
  115519. * Gets the base internal format
  115520. */
  115521. glBaseInternalFormat: number;
  115522. /**
  115523. * Gets image width in pixel
  115524. */
  115525. pixelWidth: number;
  115526. /**
  115527. * Gets image height in pixel
  115528. */
  115529. pixelHeight: number;
  115530. /**
  115531. * Gets image depth in pixels
  115532. */
  115533. pixelDepth: number;
  115534. /**
  115535. * Gets the number of array elements
  115536. */
  115537. numberOfArrayElements: number;
  115538. /**
  115539. * Gets the number of faces
  115540. */
  115541. numberOfFaces: number;
  115542. /**
  115543. * Gets the number of mipmap levels
  115544. */
  115545. numberOfMipmapLevels: number;
  115546. /**
  115547. * Gets the bytes of key value data
  115548. */
  115549. bytesOfKeyValueData: number;
  115550. /**
  115551. * Gets the load type
  115552. */
  115553. loadType: number;
  115554. /**
  115555. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115556. */
  115557. isInvalid: boolean;
  115558. /**
  115559. * Creates a new KhronosTextureContainer
  115560. * @param arrayBuffer contents of the KTX container file
  115561. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115562. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115563. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115564. */
  115565. constructor(
  115566. /** contents of the KTX container file */
  115567. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115568. /**
  115569. * Uploads KTX content to a Babylon Texture.
  115570. * It is assumed that the texture has already been created & is currently bound
  115571. * @hidden
  115572. */
  115573. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115574. private _upload2DCompressedLevels;
  115575. }
  115576. }
  115577. declare module BABYLON {
  115578. /**
  115579. * Implementation of the KTX Texture Loader.
  115580. * @hidden
  115581. */
  115582. export class _KTXTextureLoader implements IInternalTextureLoader {
  115583. /**
  115584. * Defines wether the loader supports cascade loading the different faces.
  115585. */
  115586. readonly supportCascades: boolean;
  115587. /**
  115588. * This returns if the loader support the current file information.
  115589. * @param extension defines the file extension of the file being loaded
  115590. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115591. * @param fallback defines the fallback internal texture if any
  115592. * @param isBase64 defines whether the texture is encoded as a base64
  115593. * @param isBuffer defines whether the texture data are stored as a buffer
  115594. * @returns true if the loader can load the specified file
  115595. */
  115596. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115597. /**
  115598. * Transform the url before loading if required.
  115599. * @param rootUrl the url of the texture
  115600. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115601. * @returns the transformed texture
  115602. */
  115603. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115604. /**
  115605. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115606. * @param rootUrl the url of the texture
  115607. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115608. * @returns the fallback texture
  115609. */
  115610. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115611. /**
  115612. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115613. * @param data contains the texture data
  115614. * @param texture defines the BabylonJS internal texture
  115615. * @param createPolynomials will be true if polynomials have been requested
  115616. * @param onLoad defines the callback to trigger once the texture is ready
  115617. * @param onError defines the callback to trigger in case of error
  115618. */
  115619. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115620. /**
  115621. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115622. * @param data contains the texture data
  115623. * @param texture defines the BabylonJS internal texture
  115624. * @param callback defines the method to call once ready to upload
  115625. */
  115626. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115627. }
  115628. }
  115629. declare module BABYLON {
  115630. /**
  115631. * Options for the default xr helper
  115632. */
  115633. export class WebXRDefaultExperienceOptions {
  115634. /**
  115635. * Floor meshes that should be used for teleporting
  115636. */
  115637. floorMeshes: Array<AbstractMesh>;
  115638. }
  115639. /**
  115640. * Default experience which provides a similar setup to the previous webVRExperience
  115641. */
  115642. export class WebXRDefaultExperience {
  115643. /**
  115644. * Base experience
  115645. */
  115646. baseExperience: WebXRExperienceHelper;
  115647. /**
  115648. * Input experience extension
  115649. */
  115650. input: WebXRInput;
  115651. /**
  115652. * Loads the controller models
  115653. */
  115654. controllerModelLoader: WebXRControllerModelLoader;
  115655. /**
  115656. * Enables laser pointer and selection
  115657. */
  115658. pointerSelection: WebXRControllerPointerSelection;
  115659. /**
  115660. * Enables teleportation
  115661. */
  115662. teleportation: WebXRControllerTeleportation;
  115663. /**
  115664. * Enables ui for enetering/exiting xr
  115665. */
  115666. enterExitUI: WebXREnterExitUI;
  115667. /**
  115668. * Default output canvas xr should render to
  115669. */
  115670. outputCanvas: WebXRManagedOutputCanvas;
  115671. /**
  115672. * Creates the default xr experience
  115673. * @param scene scene
  115674. * @param options options for basic configuration
  115675. * @returns resulting WebXRDefaultExperience
  115676. */
  115677. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115678. private constructor();
  115679. /**
  115680. * DIsposes of the experience helper
  115681. */
  115682. dispose(): void;
  115683. }
  115684. }
  115685. declare module BABYLON {
  115686. /** @hidden */
  115687. export var _forceSceneHelpersToBundle: boolean;
  115688. interface Scene {
  115689. /**
  115690. * Creates a default light for the scene.
  115691. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115692. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115693. */
  115694. createDefaultLight(replace?: boolean): void;
  115695. /**
  115696. * Creates a default camera for the scene.
  115697. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115698. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115699. * @param replace has default false, when true replaces the active camera in the scene
  115700. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115701. */
  115702. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115703. /**
  115704. * Creates a default camera and a default light.
  115705. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115706. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115707. * @param replace has the default false, when true replaces the active camera/light in the scene
  115708. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115709. */
  115710. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115711. /**
  115712. * Creates a new sky box
  115713. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115714. * @param environmentTexture defines the texture to use as environment texture
  115715. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115716. * @param scale defines the overall scale of the skybox
  115717. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115718. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115719. * @returns a new mesh holding the sky box
  115720. */
  115721. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115722. /**
  115723. * Creates a new environment
  115724. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115725. * @param options defines the options you can use to configure the environment
  115726. * @returns the new EnvironmentHelper
  115727. */
  115728. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115729. /**
  115730. * Creates a new VREXperienceHelper
  115731. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115732. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115733. * @returns a new VREXperienceHelper
  115734. */
  115735. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115736. /**
  115737. * Creates a new WebXRDefaultExperience
  115738. * @see http://doc.babylonjs.com/how_to/webxr
  115739. * @param options experience options
  115740. * @returns a promise for a new WebXRDefaultExperience
  115741. */
  115742. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115743. }
  115744. }
  115745. declare module BABYLON {
  115746. /**
  115747. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115748. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115749. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115750. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115751. */
  115752. export class VideoDome extends TransformNode {
  115753. /**
  115754. * Define the video source as a Monoscopic panoramic 360 video.
  115755. */
  115756. static readonly MODE_MONOSCOPIC: number;
  115757. /**
  115758. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115759. */
  115760. static readonly MODE_TOPBOTTOM: number;
  115761. /**
  115762. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115763. */
  115764. static readonly MODE_SIDEBYSIDE: number;
  115765. private _halfDome;
  115766. private _useDirectMapping;
  115767. /**
  115768. * The video texture being displayed on the sphere
  115769. */
  115770. protected _videoTexture: VideoTexture;
  115771. /**
  115772. * Gets the video texture being displayed on the sphere
  115773. */
  115774. readonly videoTexture: VideoTexture;
  115775. /**
  115776. * The skybox material
  115777. */
  115778. protected _material: BackgroundMaterial;
  115779. /**
  115780. * The surface used for the skybox
  115781. */
  115782. protected _mesh: Mesh;
  115783. /**
  115784. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115785. */
  115786. private _halfDomeMask;
  115787. /**
  115788. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115789. * Also see the options.resolution property.
  115790. */
  115791. fovMultiplier: number;
  115792. private _videoMode;
  115793. /**
  115794. * Gets or set the current video mode for the video. It can be:
  115795. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115796. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115797. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115798. */
  115799. videoMode: number;
  115800. /**
  115801. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115802. *
  115803. */
  115804. /**
  115805. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115806. */
  115807. halfDome: boolean;
  115808. /**
  115809. * Oberserver used in Stereoscopic VR Mode.
  115810. */
  115811. private _onBeforeCameraRenderObserver;
  115812. /**
  115813. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115814. * @param name Element's name, child elements will append suffixes for their own names.
  115815. * @param urlsOrVideo defines the url(s) or the video element to use
  115816. * @param options An object containing optional or exposed sub element properties
  115817. */
  115818. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115819. resolution?: number;
  115820. clickToPlay?: boolean;
  115821. autoPlay?: boolean;
  115822. loop?: boolean;
  115823. size?: number;
  115824. poster?: string;
  115825. faceForward?: boolean;
  115826. useDirectMapping?: boolean;
  115827. halfDomeMode?: boolean;
  115828. }, scene: Scene);
  115829. private _changeVideoMode;
  115830. /**
  115831. * Releases resources associated with this node.
  115832. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115833. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115834. */
  115835. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115836. }
  115837. }
  115838. declare module BABYLON {
  115839. /**
  115840. * This class can be used to get instrumentation data from a Babylon engine
  115841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115842. */
  115843. export class EngineInstrumentation implements IDisposable {
  115844. /**
  115845. * Define the instrumented engine.
  115846. */
  115847. engine: Engine;
  115848. private _captureGPUFrameTime;
  115849. private _gpuFrameTimeToken;
  115850. private _gpuFrameTime;
  115851. private _captureShaderCompilationTime;
  115852. private _shaderCompilationTime;
  115853. private _onBeginFrameObserver;
  115854. private _onEndFrameObserver;
  115855. private _onBeforeShaderCompilationObserver;
  115856. private _onAfterShaderCompilationObserver;
  115857. /**
  115858. * Gets the perf counter used for GPU frame time
  115859. */
  115860. readonly gpuFrameTimeCounter: PerfCounter;
  115861. /**
  115862. * Gets the GPU frame time capture status
  115863. */
  115864. /**
  115865. * Enable or disable the GPU frame time capture
  115866. */
  115867. captureGPUFrameTime: boolean;
  115868. /**
  115869. * Gets the perf counter used for shader compilation time
  115870. */
  115871. readonly shaderCompilationTimeCounter: PerfCounter;
  115872. /**
  115873. * Gets the shader compilation time capture status
  115874. */
  115875. /**
  115876. * Enable or disable the shader compilation time capture
  115877. */
  115878. captureShaderCompilationTime: boolean;
  115879. /**
  115880. * Instantiates a new engine instrumentation.
  115881. * This class can be used to get instrumentation data from a Babylon engine
  115882. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115883. * @param engine Defines the engine to instrument
  115884. */
  115885. constructor(
  115886. /**
  115887. * Define the instrumented engine.
  115888. */
  115889. engine: Engine);
  115890. /**
  115891. * Dispose and release associated resources.
  115892. */
  115893. dispose(): void;
  115894. }
  115895. }
  115896. declare module BABYLON {
  115897. /**
  115898. * This class can be used to get instrumentation data from a Babylon engine
  115899. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115900. */
  115901. export class SceneInstrumentation implements IDisposable {
  115902. /**
  115903. * Defines the scene to instrument
  115904. */
  115905. scene: Scene;
  115906. private _captureActiveMeshesEvaluationTime;
  115907. private _activeMeshesEvaluationTime;
  115908. private _captureRenderTargetsRenderTime;
  115909. private _renderTargetsRenderTime;
  115910. private _captureFrameTime;
  115911. private _frameTime;
  115912. private _captureRenderTime;
  115913. private _renderTime;
  115914. private _captureInterFrameTime;
  115915. private _interFrameTime;
  115916. private _captureParticlesRenderTime;
  115917. private _particlesRenderTime;
  115918. private _captureSpritesRenderTime;
  115919. private _spritesRenderTime;
  115920. private _capturePhysicsTime;
  115921. private _physicsTime;
  115922. private _captureAnimationsTime;
  115923. private _animationsTime;
  115924. private _captureCameraRenderTime;
  115925. private _cameraRenderTime;
  115926. private _onBeforeActiveMeshesEvaluationObserver;
  115927. private _onAfterActiveMeshesEvaluationObserver;
  115928. private _onBeforeRenderTargetsRenderObserver;
  115929. private _onAfterRenderTargetsRenderObserver;
  115930. private _onAfterRenderObserver;
  115931. private _onBeforeDrawPhaseObserver;
  115932. private _onAfterDrawPhaseObserver;
  115933. private _onBeforeAnimationsObserver;
  115934. private _onBeforeParticlesRenderingObserver;
  115935. private _onAfterParticlesRenderingObserver;
  115936. private _onBeforeSpritesRenderingObserver;
  115937. private _onAfterSpritesRenderingObserver;
  115938. private _onBeforePhysicsObserver;
  115939. private _onAfterPhysicsObserver;
  115940. private _onAfterAnimationsObserver;
  115941. private _onBeforeCameraRenderObserver;
  115942. private _onAfterCameraRenderObserver;
  115943. /**
  115944. * Gets the perf counter used for active meshes evaluation time
  115945. */
  115946. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115947. /**
  115948. * Gets the active meshes evaluation time capture status
  115949. */
  115950. /**
  115951. * Enable or disable the active meshes evaluation time capture
  115952. */
  115953. captureActiveMeshesEvaluationTime: boolean;
  115954. /**
  115955. * Gets the perf counter used for render targets render time
  115956. */
  115957. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115958. /**
  115959. * Gets the render targets render time capture status
  115960. */
  115961. /**
  115962. * Enable or disable the render targets render time capture
  115963. */
  115964. captureRenderTargetsRenderTime: boolean;
  115965. /**
  115966. * Gets the perf counter used for particles render time
  115967. */
  115968. readonly particlesRenderTimeCounter: PerfCounter;
  115969. /**
  115970. * Gets the particles render time capture status
  115971. */
  115972. /**
  115973. * Enable or disable the particles render time capture
  115974. */
  115975. captureParticlesRenderTime: boolean;
  115976. /**
  115977. * Gets the perf counter used for sprites render time
  115978. */
  115979. readonly spritesRenderTimeCounter: PerfCounter;
  115980. /**
  115981. * Gets the sprites render time capture status
  115982. */
  115983. /**
  115984. * Enable or disable the sprites render time capture
  115985. */
  115986. captureSpritesRenderTime: boolean;
  115987. /**
  115988. * Gets the perf counter used for physics time
  115989. */
  115990. readonly physicsTimeCounter: PerfCounter;
  115991. /**
  115992. * Gets the physics time capture status
  115993. */
  115994. /**
  115995. * Enable or disable the physics time capture
  115996. */
  115997. capturePhysicsTime: boolean;
  115998. /**
  115999. * Gets the perf counter used for animations time
  116000. */
  116001. readonly animationsTimeCounter: PerfCounter;
  116002. /**
  116003. * Gets the animations time capture status
  116004. */
  116005. /**
  116006. * Enable or disable the animations time capture
  116007. */
  116008. captureAnimationsTime: boolean;
  116009. /**
  116010. * Gets the perf counter used for frame time capture
  116011. */
  116012. readonly frameTimeCounter: PerfCounter;
  116013. /**
  116014. * Gets the frame time capture status
  116015. */
  116016. /**
  116017. * Enable or disable the frame time capture
  116018. */
  116019. captureFrameTime: boolean;
  116020. /**
  116021. * Gets the perf counter used for inter-frames time capture
  116022. */
  116023. readonly interFrameTimeCounter: PerfCounter;
  116024. /**
  116025. * Gets the inter-frames time capture status
  116026. */
  116027. /**
  116028. * Enable or disable the inter-frames time capture
  116029. */
  116030. captureInterFrameTime: boolean;
  116031. /**
  116032. * Gets the perf counter used for render time capture
  116033. */
  116034. readonly renderTimeCounter: PerfCounter;
  116035. /**
  116036. * Gets the render time capture status
  116037. */
  116038. /**
  116039. * Enable or disable the render time capture
  116040. */
  116041. captureRenderTime: boolean;
  116042. /**
  116043. * Gets the perf counter used for camera render time capture
  116044. */
  116045. readonly cameraRenderTimeCounter: PerfCounter;
  116046. /**
  116047. * Gets the camera render time capture status
  116048. */
  116049. /**
  116050. * Enable or disable the camera render time capture
  116051. */
  116052. captureCameraRenderTime: boolean;
  116053. /**
  116054. * Gets the perf counter used for draw calls
  116055. */
  116056. readonly drawCallsCounter: PerfCounter;
  116057. /**
  116058. * Instantiates a new scene instrumentation.
  116059. * This class can be used to get instrumentation data from a Babylon engine
  116060. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116061. * @param scene Defines the scene to instrument
  116062. */
  116063. constructor(
  116064. /**
  116065. * Defines the scene to instrument
  116066. */
  116067. scene: Scene);
  116068. /**
  116069. * Dispose and release associated resources.
  116070. */
  116071. dispose(): void;
  116072. }
  116073. }
  116074. declare module BABYLON {
  116075. /** @hidden */
  116076. export var glowMapGenerationPixelShader: {
  116077. name: string;
  116078. shader: string;
  116079. };
  116080. }
  116081. declare module BABYLON {
  116082. /** @hidden */
  116083. export var glowMapGenerationVertexShader: {
  116084. name: string;
  116085. shader: string;
  116086. };
  116087. }
  116088. declare module BABYLON {
  116089. /**
  116090. * Effect layer options. This helps customizing the behaviour
  116091. * of the effect layer.
  116092. */
  116093. export interface IEffectLayerOptions {
  116094. /**
  116095. * Multiplication factor apply to the canvas size to compute the render target size
  116096. * used to generated the objects (the smaller the faster).
  116097. */
  116098. mainTextureRatio: number;
  116099. /**
  116100. * Enforces a fixed size texture to ensure effect stability across devices.
  116101. */
  116102. mainTextureFixedSize?: number;
  116103. /**
  116104. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116105. */
  116106. alphaBlendingMode: number;
  116107. /**
  116108. * The camera attached to the layer.
  116109. */
  116110. camera: Nullable<Camera>;
  116111. /**
  116112. * The rendering group to draw the layer in.
  116113. */
  116114. renderingGroupId: number;
  116115. }
  116116. /**
  116117. * The effect layer Helps adding post process effect blended with the main pass.
  116118. *
  116119. * This can be for instance use to generate glow or higlight effects on the scene.
  116120. *
  116121. * The effect layer class can not be used directly and is intented to inherited from to be
  116122. * customized per effects.
  116123. */
  116124. export abstract class EffectLayer {
  116125. private _vertexBuffers;
  116126. private _indexBuffer;
  116127. private _cachedDefines;
  116128. private _effectLayerMapGenerationEffect;
  116129. private _effectLayerOptions;
  116130. private _mergeEffect;
  116131. protected _scene: Scene;
  116132. protected _engine: Engine;
  116133. protected _maxSize: number;
  116134. protected _mainTextureDesiredSize: ISize;
  116135. protected _mainTexture: RenderTargetTexture;
  116136. protected _shouldRender: boolean;
  116137. protected _postProcesses: PostProcess[];
  116138. protected _textures: BaseTexture[];
  116139. protected _emissiveTextureAndColor: {
  116140. texture: Nullable<BaseTexture>;
  116141. color: Color4;
  116142. };
  116143. /**
  116144. * The name of the layer
  116145. */
  116146. name: string;
  116147. /**
  116148. * The clear color of the texture used to generate the glow map.
  116149. */
  116150. neutralColor: Color4;
  116151. /**
  116152. * Specifies wether the highlight layer is enabled or not.
  116153. */
  116154. isEnabled: boolean;
  116155. /**
  116156. * Gets the camera attached to the layer.
  116157. */
  116158. readonly camera: Nullable<Camera>;
  116159. /**
  116160. * Gets the rendering group id the layer should render in.
  116161. */
  116162. renderingGroupId: number;
  116163. /**
  116164. * An event triggered when the effect layer has been disposed.
  116165. */
  116166. onDisposeObservable: Observable<EffectLayer>;
  116167. /**
  116168. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116169. */
  116170. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116171. /**
  116172. * An event triggered when the generated texture is being merged in the scene.
  116173. */
  116174. onBeforeComposeObservable: Observable<EffectLayer>;
  116175. /**
  116176. * An event triggered when the generated texture has been merged in the scene.
  116177. */
  116178. onAfterComposeObservable: Observable<EffectLayer>;
  116179. /**
  116180. * An event triggered when the efffect layer changes its size.
  116181. */
  116182. onSizeChangedObservable: Observable<EffectLayer>;
  116183. /** @hidden */
  116184. static _SceneComponentInitialization: (scene: Scene) => void;
  116185. /**
  116186. * Instantiates a new effect Layer and references it in the scene.
  116187. * @param name The name of the layer
  116188. * @param scene The scene to use the layer in
  116189. */
  116190. constructor(
  116191. /** The Friendly of the effect in the scene */
  116192. name: string, scene: Scene);
  116193. /**
  116194. * Get the effect name of the layer.
  116195. * @return The effect name
  116196. */
  116197. abstract getEffectName(): string;
  116198. /**
  116199. * Checks for the readiness of the element composing the layer.
  116200. * @param subMesh the mesh to check for
  116201. * @param useInstances specify wether or not to use instances to render the mesh
  116202. * @return true if ready otherwise, false
  116203. */
  116204. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116205. /**
  116206. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116207. * @returns true if the effect requires stencil during the main canvas render pass.
  116208. */
  116209. abstract needStencil(): boolean;
  116210. /**
  116211. * Create the merge effect. This is the shader use to blit the information back
  116212. * to the main canvas at the end of the scene rendering.
  116213. * @returns The effect containing the shader used to merge the effect on the main canvas
  116214. */
  116215. protected abstract _createMergeEffect(): Effect;
  116216. /**
  116217. * Creates the render target textures and post processes used in the effect layer.
  116218. */
  116219. protected abstract _createTextureAndPostProcesses(): void;
  116220. /**
  116221. * Implementation specific of rendering the generating effect on the main canvas.
  116222. * @param effect The effect used to render through
  116223. */
  116224. protected abstract _internalRender(effect: Effect): void;
  116225. /**
  116226. * Sets the required values for both the emissive texture and and the main color.
  116227. */
  116228. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116229. /**
  116230. * Free any resources and references associated to a mesh.
  116231. * Internal use
  116232. * @param mesh The mesh to free.
  116233. */
  116234. abstract _disposeMesh(mesh: Mesh): void;
  116235. /**
  116236. * Serializes this layer (Glow or Highlight for example)
  116237. * @returns a serialized layer object
  116238. */
  116239. abstract serialize?(): any;
  116240. /**
  116241. * Initializes the effect layer with the required options.
  116242. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116243. */
  116244. protected _init(options: Partial<IEffectLayerOptions>): void;
  116245. /**
  116246. * Generates the index buffer of the full screen quad blending to the main canvas.
  116247. */
  116248. private _generateIndexBuffer;
  116249. /**
  116250. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116251. */
  116252. private _generateVertexBuffer;
  116253. /**
  116254. * Sets the main texture desired size which is the closest power of two
  116255. * of the engine canvas size.
  116256. */
  116257. private _setMainTextureSize;
  116258. /**
  116259. * Creates the main texture for the effect layer.
  116260. */
  116261. protected _createMainTexture(): void;
  116262. /**
  116263. * Adds specific effects defines.
  116264. * @param defines The defines to add specifics to.
  116265. */
  116266. protected _addCustomEffectDefines(defines: string[]): void;
  116267. /**
  116268. * Checks for the readiness of the element composing the layer.
  116269. * @param subMesh the mesh to check for
  116270. * @param useInstances specify wether or not to use instances to render the mesh
  116271. * @param emissiveTexture the associated emissive texture used to generate the glow
  116272. * @return true if ready otherwise, false
  116273. */
  116274. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116275. /**
  116276. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116277. */
  116278. render(): void;
  116279. /**
  116280. * Determine if a given mesh will be used in the current effect.
  116281. * @param mesh mesh to test
  116282. * @returns true if the mesh will be used
  116283. */
  116284. hasMesh(mesh: AbstractMesh): boolean;
  116285. /**
  116286. * Returns true if the layer contains information to display, otherwise false.
  116287. * @returns true if the glow layer should be rendered
  116288. */
  116289. shouldRender(): boolean;
  116290. /**
  116291. * Returns true if the mesh should render, otherwise false.
  116292. * @param mesh The mesh to render
  116293. * @returns true if it should render otherwise false
  116294. */
  116295. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116296. /**
  116297. * Returns true if the mesh can be rendered, otherwise false.
  116298. * @param mesh The mesh to render
  116299. * @param material The material used on the mesh
  116300. * @returns true if it can be rendered otherwise false
  116301. */
  116302. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116303. /**
  116304. * Returns true if the mesh should render, otherwise false.
  116305. * @param mesh The mesh to render
  116306. * @returns true if it should render otherwise false
  116307. */
  116308. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116309. /**
  116310. * Renders the submesh passed in parameter to the generation map.
  116311. */
  116312. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116313. /**
  116314. * Rebuild the required buffers.
  116315. * @hidden Internal use only.
  116316. */
  116317. _rebuild(): void;
  116318. /**
  116319. * Dispose only the render target textures and post process.
  116320. */
  116321. private _disposeTextureAndPostProcesses;
  116322. /**
  116323. * Dispose the highlight layer and free resources.
  116324. */
  116325. dispose(): void;
  116326. /**
  116327. * Gets the class name of the effect layer
  116328. * @returns the string with the class name of the effect layer
  116329. */
  116330. getClassName(): string;
  116331. /**
  116332. * Creates an effect layer from parsed effect layer data
  116333. * @param parsedEffectLayer defines effect layer data
  116334. * @param scene defines the current scene
  116335. * @param rootUrl defines the root URL containing the effect layer information
  116336. * @returns a parsed effect Layer
  116337. */
  116338. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116339. }
  116340. }
  116341. declare module BABYLON {
  116342. interface AbstractScene {
  116343. /**
  116344. * The list of effect layers (highlights/glow) added to the scene
  116345. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116346. * @see http://doc.babylonjs.com/how_to/glow_layer
  116347. */
  116348. effectLayers: Array<EffectLayer>;
  116349. /**
  116350. * Removes the given effect layer from this scene.
  116351. * @param toRemove defines the effect layer to remove
  116352. * @returns the index of the removed effect layer
  116353. */
  116354. removeEffectLayer(toRemove: EffectLayer): number;
  116355. /**
  116356. * Adds the given effect layer to this scene
  116357. * @param newEffectLayer defines the effect layer to add
  116358. */
  116359. addEffectLayer(newEffectLayer: EffectLayer): void;
  116360. }
  116361. /**
  116362. * Defines the layer scene component responsible to manage any effect layers
  116363. * in a given scene.
  116364. */
  116365. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116366. /**
  116367. * The component name helpfull to identify the component in the list of scene components.
  116368. */
  116369. readonly name: string;
  116370. /**
  116371. * The scene the component belongs to.
  116372. */
  116373. scene: Scene;
  116374. private _engine;
  116375. private _renderEffects;
  116376. private _needStencil;
  116377. private _previousStencilState;
  116378. /**
  116379. * Creates a new instance of the component for the given scene
  116380. * @param scene Defines the scene to register the component in
  116381. */
  116382. constructor(scene: Scene);
  116383. /**
  116384. * Registers the component in a given scene
  116385. */
  116386. register(): void;
  116387. /**
  116388. * Rebuilds the elements related to this component in case of
  116389. * context lost for instance.
  116390. */
  116391. rebuild(): void;
  116392. /**
  116393. * Serializes the component data to the specified json object
  116394. * @param serializationObject The object to serialize to
  116395. */
  116396. serialize(serializationObject: any): void;
  116397. /**
  116398. * Adds all the elements from the container to the scene
  116399. * @param container the container holding the elements
  116400. */
  116401. addFromContainer(container: AbstractScene): void;
  116402. /**
  116403. * Removes all the elements in the container from the scene
  116404. * @param container contains the elements to remove
  116405. * @param dispose if the removed element should be disposed (default: false)
  116406. */
  116407. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116408. /**
  116409. * Disposes the component and the associated ressources.
  116410. */
  116411. dispose(): void;
  116412. private _isReadyForMesh;
  116413. private _renderMainTexture;
  116414. private _setStencil;
  116415. private _setStencilBack;
  116416. private _draw;
  116417. private _drawCamera;
  116418. private _drawRenderingGroup;
  116419. }
  116420. }
  116421. declare module BABYLON {
  116422. /** @hidden */
  116423. export var glowMapMergePixelShader: {
  116424. name: string;
  116425. shader: string;
  116426. };
  116427. }
  116428. declare module BABYLON {
  116429. /** @hidden */
  116430. export var glowMapMergeVertexShader: {
  116431. name: string;
  116432. shader: string;
  116433. };
  116434. }
  116435. declare module BABYLON {
  116436. interface AbstractScene {
  116437. /**
  116438. * Return a the first highlight layer of the scene with a given name.
  116439. * @param name The name of the highlight layer to look for.
  116440. * @return The highlight layer if found otherwise null.
  116441. */
  116442. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116443. }
  116444. /**
  116445. * Glow layer options. This helps customizing the behaviour
  116446. * of the glow layer.
  116447. */
  116448. export interface IGlowLayerOptions {
  116449. /**
  116450. * Multiplication factor apply to the canvas size to compute the render target size
  116451. * used to generated the glowing objects (the smaller the faster).
  116452. */
  116453. mainTextureRatio: number;
  116454. /**
  116455. * Enforces a fixed size texture to ensure resize independant blur.
  116456. */
  116457. mainTextureFixedSize?: number;
  116458. /**
  116459. * How big is the kernel of the blur texture.
  116460. */
  116461. blurKernelSize: number;
  116462. /**
  116463. * The camera attached to the layer.
  116464. */
  116465. camera: Nullable<Camera>;
  116466. /**
  116467. * Enable MSAA by chosing the number of samples.
  116468. */
  116469. mainTextureSamples?: number;
  116470. /**
  116471. * The rendering group to draw the layer in.
  116472. */
  116473. renderingGroupId: number;
  116474. }
  116475. /**
  116476. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116477. *
  116478. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116479. * glowy meshes to your scene.
  116480. *
  116481. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116482. */
  116483. export class GlowLayer extends EffectLayer {
  116484. /**
  116485. * Effect Name of the layer.
  116486. */
  116487. static readonly EffectName: string;
  116488. /**
  116489. * The default blur kernel size used for the glow.
  116490. */
  116491. static DefaultBlurKernelSize: number;
  116492. /**
  116493. * The default texture size ratio used for the glow.
  116494. */
  116495. static DefaultTextureRatio: number;
  116496. /**
  116497. * Sets the kernel size of the blur.
  116498. */
  116499. /**
  116500. * Gets the kernel size of the blur.
  116501. */
  116502. blurKernelSize: number;
  116503. /**
  116504. * Sets the glow intensity.
  116505. */
  116506. /**
  116507. * Gets the glow intensity.
  116508. */
  116509. intensity: number;
  116510. private _options;
  116511. private _intensity;
  116512. private _horizontalBlurPostprocess1;
  116513. private _verticalBlurPostprocess1;
  116514. private _horizontalBlurPostprocess2;
  116515. private _verticalBlurPostprocess2;
  116516. private _blurTexture1;
  116517. private _blurTexture2;
  116518. private _postProcesses1;
  116519. private _postProcesses2;
  116520. private _includedOnlyMeshes;
  116521. private _excludedMeshes;
  116522. /**
  116523. * Callback used to let the user override the color selection on a per mesh basis
  116524. */
  116525. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116526. /**
  116527. * Callback used to let the user override the texture selection on a per mesh basis
  116528. */
  116529. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116530. /**
  116531. * Instantiates a new glow Layer and references it to the scene.
  116532. * @param name The name of the layer
  116533. * @param scene The scene to use the layer in
  116534. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116535. */
  116536. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116537. /**
  116538. * Get the effect name of the layer.
  116539. * @return The effect name
  116540. */
  116541. getEffectName(): string;
  116542. /**
  116543. * Create the merge effect. This is the shader use to blit the information back
  116544. * to the main canvas at the end of the scene rendering.
  116545. */
  116546. protected _createMergeEffect(): Effect;
  116547. /**
  116548. * Creates the render target textures and post processes used in the glow layer.
  116549. */
  116550. protected _createTextureAndPostProcesses(): void;
  116551. /**
  116552. * Checks for the readiness of the element composing the layer.
  116553. * @param subMesh the mesh to check for
  116554. * @param useInstances specify wether or not to use instances to render the mesh
  116555. * @param emissiveTexture the associated emissive texture used to generate the glow
  116556. * @return true if ready otherwise, false
  116557. */
  116558. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116559. /**
  116560. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116561. */
  116562. needStencil(): boolean;
  116563. /**
  116564. * Returns true if the mesh can be rendered, otherwise false.
  116565. * @param mesh The mesh to render
  116566. * @param material The material used on the mesh
  116567. * @returns true if it can be rendered otherwise false
  116568. */
  116569. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116570. /**
  116571. * Implementation specific of rendering the generating effect on the main canvas.
  116572. * @param effect The effect used to render through
  116573. */
  116574. protected _internalRender(effect: Effect): void;
  116575. /**
  116576. * Sets the required values for both the emissive texture and and the main color.
  116577. */
  116578. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116579. /**
  116580. * Returns true if the mesh should render, otherwise false.
  116581. * @param mesh The mesh to render
  116582. * @returns true if it should render otherwise false
  116583. */
  116584. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116585. /**
  116586. * Adds specific effects defines.
  116587. * @param defines The defines to add specifics to.
  116588. */
  116589. protected _addCustomEffectDefines(defines: string[]): void;
  116590. /**
  116591. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116592. * @param mesh The mesh to exclude from the glow layer
  116593. */
  116594. addExcludedMesh(mesh: Mesh): void;
  116595. /**
  116596. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116597. * @param mesh The mesh to remove
  116598. */
  116599. removeExcludedMesh(mesh: Mesh): void;
  116600. /**
  116601. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116602. * @param mesh The mesh to include in the glow layer
  116603. */
  116604. addIncludedOnlyMesh(mesh: Mesh): void;
  116605. /**
  116606. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116607. * @param mesh The mesh to remove
  116608. */
  116609. removeIncludedOnlyMesh(mesh: Mesh): void;
  116610. /**
  116611. * Determine if a given mesh will be used in the glow layer
  116612. * @param mesh The mesh to test
  116613. * @returns true if the mesh will be highlighted by the current glow layer
  116614. */
  116615. hasMesh(mesh: AbstractMesh): boolean;
  116616. /**
  116617. * Free any resources and references associated to a mesh.
  116618. * Internal use
  116619. * @param mesh The mesh to free.
  116620. * @hidden
  116621. */
  116622. _disposeMesh(mesh: Mesh): void;
  116623. /**
  116624. * Gets the class name of the effect layer
  116625. * @returns the string with the class name of the effect layer
  116626. */
  116627. getClassName(): string;
  116628. /**
  116629. * Serializes this glow layer
  116630. * @returns a serialized glow layer object
  116631. */
  116632. serialize(): any;
  116633. /**
  116634. * Creates a Glow Layer from parsed glow layer data
  116635. * @param parsedGlowLayer defines glow layer data
  116636. * @param scene defines the current scene
  116637. * @param rootUrl defines the root URL containing the glow layer information
  116638. * @returns a parsed Glow Layer
  116639. */
  116640. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116641. }
  116642. }
  116643. declare module BABYLON {
  116644. /** @hidden */
  116645. export var glowBlurPostProcessPixelShader: {
  116646. name: string;
  116647. shader: string;
  116648. };
  116649. }
  116650. declare module BABYLON {
  116651. interface AbstractScene {
  116652. /**
  116653. * Return a the first highlight layer of the scene with a given name.
  116654. * @param name The name of the highlight layer to look for.
  116655. * @return The highlight layer if found otherwise null.
  116656. */
  116657. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116658. }
  116659. /**
  116660. * Highlight layer options. This helps customizing the behaviour
  116661. * of the highlight layer.
  116662. */
  116663. export interface IHighlightLayerOptions {
  116664. /**
  116665. * Multiplication factor apply to the canvas size to compute the render target size
  116666. * used to generated the glowing objects (the smaller the faster).
  116667. */
  116668. mainTextureRatio: number;
  116669. /**
  116670. * Enforces a fixed size texture to ensure resize independant blur.
  116671. */
  116672. mainTextureFixedSize?: number;
  116673. /**
  116674. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116675. * of the picture to blur (the smaller the faster).
  116676. */
  116677. blurTextureSizeRatio: number;
  116678. /**
  116679. * How big in texel of the blur texture is the vertical blur.
  116680. */
  116681. blurVerticalSize: number;
  116682. /**
  116683. * How big in texel of the blur texture is the horizontal blur.
  116684. */
  116685. blurHorizontalSize: number;
  116686. /**
  116687. * Alpha blending mode used to apply the blur. Default is combine.
  116688. */
  116689. alphaBlendingMode: number;
  116690. /**
  116691. * The camera attached to the layer.
  116692. */
  116693. camera: Nullable<Camera>;
  116694. /**
  116695. * Should we display highlight as a solid stroke?
  116696. */
  116697. isStroke?: boolean;
  116698. /**
  116699. * The rendering group to draw the layer in.
  116700. */
  116701. renderingGroupId: number;
  116702. }
  116703. /**
  116704. * The highlight layer Helps adding a glow effect around a mesh.
  116705. *
  116706. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116707. * glowy meshes to your scene.
  116708. *
  116709. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116710. */
  116711. export class HighlightLayer extends EffectLayer {
  116712. name: string;
  116713. /**
  116714. * Effect Name of the highlight layer.
  116715. */
  116716. static readonly EffectName: string;
  116717. /**
  116718. * The neutral color used during the preparation of the glow effect.
  116719. * This is black by default as the blend operation is a blend operation.
  116720. */
  116721. static NeutralColor: Color4;
  116722. /**
  116723. * Stencil value used for glowing meshes.
  116724. */
  116725. static GlowingMeshStencilReference: number;
  116726. /**
  116727. * Stencil value used for the other meshes in the scene.
  116728. */
  116729. static NormalMeshStencilReference: number;
  116730. /**
  116731. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116732. */
  116733. innerGlow: boolean;
  116734. /**
  116735. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116736. */
  116737. outerGlow: boolean;
  116738. /**
  116739. * Specifies the horizontal size of the blur.
  116740. */
  116741. /**
  116742. * Gets the horizontal size of the blur.
  116743. */
  116744. blurHorizontalSize: number;
  116745. /**
  116746. * Specifies the vertical size of the blur.
  116747. */
  116748. /**
  116749. * Gets the vertical size of the blur.
  116750. */
  116751. blurVerticalSize: number;
  116752. /**
  116753. * An event triggered when the highlight layer is being blurred.
  116754. */
  116755. onBeforeBlurObservable: Observable<HighlightLayer>;
  116756. /**
  116757. * An event triggered when the highlight layer has been blurred.
  116758. */
  116759. onAfterBlurObservable: Observable<HighlightLayer>;
  116760. private _instanceGlowingMeshStencilReference;
  116761. private _options;
  116762. private _downSamplePostprocess;
  116763. private _horizontalBlurPostprocess;
  116764. private _verticalBlurPostprocess;
  116765. private _blurTexture;
  116766. private _meshes;
  116767. private _excludedMeshes;
  116768. /**
  116769. * Instantiates a new highlight Layer and references it to the scene..
  116770. * @param name The name of the layer
  116771. * @param scene The scene to use the layer in
  116772. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116773. */
  116774. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116775. /**
  116776. * Get the effect name of the layer.
  116777. * @return The effect name
  116778. */
  116779. getEffectName(): string;
  116780. /**
  116781. * Create the merge effect. This is the shader use to blit the information back
  116782. * to the main canvas at the end of the scene rendering.
  116783. */
  116784. protected _createMergeEffect(): Effect;
  116785. /**
  116786. * Creates the render target textures and post processes used in the highlight layer.
  116787. */
  116788. protected _createTextureAndPostProcesses(): void;
  116789. /**
  116790. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116791. */
  116792. needStencil(): boolean;
  116793. /**
  116794. * Checks for the readiness of the element composing the layer.
  116795. * @param subMesh the mesh to check for
  116796. * @param useInstances specify wether or not to use instances to render the mesh
  116797. * @param emissiveTexture the associated emissive texture used to generate the glow
  116798. * @return true if ready otherwise, false
  116799. */
  116800. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116801. /**
  116802. * Implementation specific of rendering the generating effect on the main canvas.
  116803. * @param effect The effect used to render through
  116804. */
  116805. protected _internalRender(effect: Effect): void;
  116806. /**
  116807. * Returns true if the layer contains information to display, otherwise false.
  116808. */
  116809. shouldRender(): boolean;
  116810. /**
  116811. * Returns true if the mesh should render, otherwise false.
  116812. * @param mesh The mesh to render
  116813. * @returns true if it should render otherwise false
  116814. */
  116815. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116816. /**
  116817. * Sets the required values for both the emissive texture and and the main color.
  116818. */
  116819. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116820. /**
  116821. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116822. * @param mesh The mesh to exclude from the highlight layer
  116823. */
  116824. addExcludedMesh(mesh: Mesh): void;
  116825. /**
  116826. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116827. * @param mesh The mesh to highlight
  116828. */
  116829. removeExcludedMesh(mesh: Mesh): void;
  116830. /**
  116831. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116832. * @param mesh mesh to test
  116833. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116834. */
  116835. hasMesh(mesh: AbstractMesh): boolean;
  116836. /**
  116837. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116838. * @param mesh The mesh to highlight
  116839. * @param color The color of the highlight
  116840. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116841. */
  116842. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116843. /**
  116844. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116845. * @param mesh The mesh to highlight
  116846. */
  116847. removeMesh(mesh: Mesh): void;
  116848. /**
  116849. * Force the stencil to the normal expected value for none glowing parts
  116850. */
  116851. private _defaultStencilReference;
  116852. /**
  116853. * Free any resources and references associated to a mesh.
  116854. * Internal use
  116855. * @param mesh The mesh to free.
  116856. * @hidden
  116857. */
  116858. _disposeMesh(mesh: Mesh): void;
  116859. /**
  116860. * Dispose the highlight layer and free resources.
  116861. */
  116862. dispose(): void;
  116863. /**
  116864. * Gets the class name of the effect layer
  116865. * @returns the string with the class name of the effect layer
  116866. */
  116867. getClassName(): string;
  116868. /**
  116869. * Serializes this Highlight layer
  116870. * @returns a serialized Highlight layer object
  116871. */
  116872. serialize(): any;
  116873. /**
  116874. * Creates a Highlight layer from parsed Highlight layer data
  116875. * @param parsedHightlightLayer defines the Highlight layer data
  116876. * @param scene defines the current scene
  116877. * @param rootUrl defines the root URL containing the Highlight layer information
  116878. * @returns a parsed Highlight layer
  116879. */
  116880. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116881. }
  116882. }
  116883. declare module BABYLON {
  116884. interface AbstractScene {
  116885. /**
  116886. * The list of layers (background and foreground) of the scene
  116887. */
  116888. layers: Array<Layer>;
  116889. }
  116890. /**
  116891. * Defines the layer scene component responsible to manage any layers
  116892. * in a given scene.
  116893. */
  116894. export class LayerSceneComponent implements ISceneComponent {
  116895. /**
  116896. * The component name helpfull to identify the component in the list of scene components.
  116897. */
  116898. readonly name: string;
  116899. /**
  116900. * The scene the component belongs to.
  116901. */
  116902. scene: Scene;
  116903. private _engine;
  116904. /**
  116905. * Creates a new instance of the component for the given scene
  116906. * @param scene Defines the scene to register the component in
  116907. */
  116908. constructor(scene: Scene);
  116909. /**
  116910. * Registers the component in a given scene
  116911. */
  116912. register(): void;
  116913. /**
  116914. * Rebuilds the elements related to this component in case of
  116915. * context lost for instance.
  116916. */
  116917. rebuild(): void;
  116918. /**
  116919. * Disposes the component and the associated ressources.
  116920. */
  116921. dispose(): void;
  116922. private _draw;
  116923. private _drawCameraPredicate;
  116924. private _drawCameraBackground;
  116925. private _drawCameraForeground;
  116926. private _drawRenderTargetPredicate;
  116927. private _drawRenderTargetBackground;
  116928. private _drawRenderTargetForeground;
  116929. /**
  116930. * Adds all the elements from the container to the scene
  116931. * @param container the container holding the elements
  116932. */
  116933. addFromContainer(container: AbstractScene): void;
  116934. /**
  116935. * Removes all the elements in the container from the scene
  116936. * @param container contains the elements to remove
  116937. * @param dispose if the removed element should be disposed (default: false)
  116938. */
  116939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116940. }
  116941. }
  116942. declare module BABYLON {
  116943. /** @hidden */
  116944. export var layerPixelShader: {
  116945. name: string;
  116946. shader: string;
  116947. };
  116948. }
  116949. declare module BABYLON {
  116950. /** @hidden */
  116951. export var layerVertexShader: {
  116952. name: string;
  116953. shader: string;
  116954. };
  116955. }
  116956. declare module BABYLON {
  116957. /**
  116958. * This represents a full screen 2d layer.
  116959. * This can be useful to display a picture in the background of your scene for instance.
  116960. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116961. */
  116962. export class Layer {
  116963. /**
  116964. * Define the name of the layer.
  116965. */
  116966. name: string;
  116967. /**
  116968. * Define the texture the layer should display.
  116969. */
  116970. texture: Nullable<Texture>;
  116971. /**
  116972. * Is the layer in background or foreground.
  116973. */
  116974. isBackground: boolean;
  116975. /**
  116976. * Define the color of the layer (instead of texture).
  116977. */
  116978. color: Color4;
  116979. /**
  116980. * Define the scale of the layer in order to zoom in out of the texture.
  116981. */
  116982. scale: Vector2;
  116983. /**
  116984. * Define an offset for the layer in order to shift the texture.
  116985. */
  116986. offset: Vector2;
  116987. /**
  116988. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116989. */
  116990. alphaBlendingMode: number;
  116991. /**
  116992. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116993. * Alpha test will not mix with the background color in case of transparency.
  116994. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116995. */
  116996. alphaTest: boolean;
  116997. /**
  116998. * Define a mask to restrict the layer to only some of the scene cameras.
  116999. */
  117000. layerMask: number;
  117001. /**
  117002. * Define the list of render target the layer is visible into.
  117003. */
  117004. renderTargetTextures: RenderTargetTexture[];
  117005. /**
  117006. * Define if the layer is only used in renderTarget or if it also
  117007. * renders in the main frame buffer of the canvas.
  117008. */
  117009. renderOnlyInRenderTargetTextures: boolean;
  117010. private _scene;
  117011. private _vertexBuffers;
  117012. private _indexBuffer;
  117013. private _effect;
  117014. private _alphaTestEffect;
  117015. /**
  117016. * An event triggered when the layer is disposed.
  117017. */
  117018. onDisposeObservable: Observable<Layer>;
  117019. private _onDisposeObserver;
  117020. /**
  117021. * Back compatibility with callback before the onDisposeObservable existed.
  117022. * The set callback will be triggered when the layer has been disposed.
  117023. */
  117024. onDispose: () => void;
  117025. /**
  117026. * An event triggered before rendering the scene
  117027. */
  117028. onBeforeRenderObservable: Observable<Layer>;
  117029. private _onBeforeRenderObserver;
  117030. /**
  117031. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117032. * The set callback will be triggered just before rendering the layer.
  117033. */
  117034. onBeforeRender: () => void;
  117035. /**
  117036. * An event triggered after rendering the scene
  117037. */
  117038. onAfterRenderObservable: Observable<Layer>;
  117039. private _onAfterRenderObserver;
  117040. /**
  117041. * Back compatibility with callback before the onAfterRenderObservable existed.
  117042. * The set callback will be triggered just after rendering the layer.
  117043. */
  117044. onAfterRender: () => void;
  117045. /**
  117046. * Instantiates a new layer.
  117047. * This represents a full screen 2d layer.
  117048. * This can be useful to display a picture in the background of your scene for instance.
  117049. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117050. * @param name Define the name of the layer in the scene
  117051. * @param imgUrl Define the url of the texture to display in the layer
  117052. * @param scene Define the scene the layer belongs to
  117053. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117054. * @param color Defines a color for the layer
  117055. */
  117056. constructor(
  117057. /**
  117058. * Define the name of the layer.
  117059. */
  117060. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117061. private _createIndexBuffer;
  117062. /** @hidden */
  117063. _rebuild(): void;
  117064. /**
  117065. * Renders the layer in the scene.
  117066. */
  117067. render(): void;
  117068. /**
  117069. * Disposes and releases the associated ressources.
  117070. */
  117071. dispose(): void;
  117072. }
  117073. }
  117074. declare module BABYLON {
  117075. /** @hidden */
  117076. export var lensFlarePixelShader: {
  117077. name: string;
  117078. shader: string;
  117079. };
  117080. }
  117081. declare module BABYLON {
  117082. /** @hidden */
  117083. export var lensFlareVertexShader: {
  117084. name: string;
  117085. shader: string;
  117086. };
  117087. }
  117088. declare module BABYLON {
  117089. /**
  117090. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117091. * It is usually composed of several `lensFlare`.
  117092. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117093. */
  117094. export class LensFlareSystem {
  117095. /**
  117096. * Define the name of the lens flare system
  117097. */
  117098. name: string;
  117099. /**
  117100. * List of lens flares used in this system.
  117101. */
  117102. lensFlares: LensFlare[];
  117103. /**
  117104. * Define a limit from the border the lens flare can be visible.
  117105. */
  117106. borderLimit: number;
  117107. /**
  117108. * Define a viewport border we do not want to see the lens flare in.
  117109. */
  117110. viewportBorder: number;
  117111. /**
  117112. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117113. */
  117114. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117115. /**
  117116. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117117. */
  117118. layerMask: number;
  117119. /**
  117120. * Define the id of the lens flare system in the scene.
  117121. * (equal to name by default)
  117122. */
  117123. id: string;
  117124. private _scene;
  117125. private _emitter;
  117126. private _vertexBuffers;
  117127. private _indexBuffer;
  117128. private _effect;
  117129. private _positionX;
  117130. private _positionY;
  117131. private _isEnabled;
  117132. /** @hidden */
  117133. static _SceneComponentInitialization: (scene: Scene) => void;
  117134. /**
  117135. * Instantiates a lens flare system.
  117136. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117137. * It is usually composed of several `lensFlare`.
  117138. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117139. * @param name Define the name of the lens flare system in the scene
  117140. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117141. * @param scene Define the scene the lens flare system belongs to
  117142. */
  117143. constructor(
  117144. /**
  117145. * Define the name of the lens flare system
  117146. */
  117147. name: string, emitter: any, scene: Scene);
  117148. /**
  117149. * Define if the lens flare system is enabled.
  117150. */
  117151. isEnabled: boolean;
  117152. /**
  117153. * Get the scene the effects belongs to.
  117154. * @returns the scene holding the lens flare system
  117155. */
  117156. getScene(): Scene;
  117157. /**
  117158. * Get the emitter of the lens flare system.
  117159. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117160. * @returns the emitter of the lens flare system
  117161. */
  117162. getEmitter(): any;
  117163. /**
  117164. * Set the emitter of the lens flare system.
  117165. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117166. * @param newEmitter Define the new emitter of the system
  117167. */
  117168. setEmitter(newEmitter: any): void;
  117169. /**
  117170. * Get the lens flare system emitter position.
  117171. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117172. * @returns the position
  117173. */
  117174. getEmitterPosition(): Vector3;
  117175. /**
  117176. * @hidden
  117177. */
  117178. computeEffectivePosition(globalViewport: Viewport): boolean;
  117179. /** @hidden */
  117180. _isVisible(): boolean;
  117181. /**
  117182. * @hidden
  117183. */
  117184. render(): boolean;
  117185. /**
  117186. * Dispose and release the lens flare with its associated resources.
  117187. */
  117188. dispose(): void;
  117189. /**
  117190. * Parse a lens flare system from a JSON repressentation
  117191. * @param parsedLensFlareSystem Define the JSON to parse
  117192. * @param scene Define the scene the parsed system should be instantiated in
  117193. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117194. * @returns the parsed system
  117195. */
  117196. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117197. /**
  117198. * Serialize the current Lens Flare System into a JSON representation.
  117199. * @returns the serialized JSON
  117200. */
  117201. serialize(): any;
  117202. }
  117203. }
  117204. declare module BABYLON {
  117205. /**
  117206. * This represents one of the lens effect in a `lensFlareSystem`.
  117207. * It controls one of the indiviual texture used in the effect.
  117208. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117209. */
  117210. export class LensFlare {
  117211. /**
  117212. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117213. */
  117214. size: number;
  117215. /**
  117216. * 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.
  117217. */
  117218. position: number;
  117219. /**
  117220. * Define the lens color.
  117221. */
  117222. color: Color3;
  117223. /**
  117224. * Define the lens texture.
  117225. */
  117226. texture: Nullable<Texture>;
  117227. /**
  117228. * Define the alpha mode to render this particular lens.
  117229. */
  117230. alphaMode: number;
  117231. private _system;
  117232. /**
  117233. * Creates a new Lens Flare.
  117234. * This represents one of the lens effect in a `lensFlareSystem`.
  117235. * It controls one of the indiviual texture used in the effect.
  117236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117237. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117238. * @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.
  117239. * @param color Define the lens color
  117240. * @param imgUrl Define the lens texture url
  117241. * @param system Define the `lensFlareSystem` this flare is part of
  117242. * @returns The newly created Lens Flare
  117243. */
  117244. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117245. /**
  117246. * Instantiates a new Lens Flare.
  117247. * This represents one of the lens effect in a `lensFlareSystem`.
  117248. * It controls one of the indiviual texture used in the effect.
  117249. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117250. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117251. * @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.
  117252. * @param color Define the lens color
  117253. * @param imgUrl Define the lens texture url
  117254. * @param system Define the `lensFlareSystem` this flare is part of
  117255. */
  117256. constructor(
  117257. /**
  117258. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117259. */
  117260. size: number,
  117261. /**
  117262. * 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.
  117263. */
  117264. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117265. /**
  117266. * Dispose and release the lens flare with its associated resources.
  117267. */
  117268. dispose(): void;
  117269. }
  117270. }
  117271. declare module BABYLON {
  117272. interface AbstractScene {
  117273. /**
  117274. * The list of lens flare system added to the scene
  117275. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117276. */
  117277. lensFlareSystems: Array<LensFlareSystem>;
  117278. /**
  117279. * Removes the given lens flare system from this scene.
  117280. * @param toRemove The lens flare system to remove
  117281. * @returns The index of the removed lens flare system
  117282. */
  117283. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117284. /**
  117285. * Adds the given lens flare system to this scene
  117286. * @param newLensFlareSystem The lens flare system to add
  117287. */
  117288. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117289. /**
  117290. * Gets a lens flare system using its name
  117291. * @param name defines the name to look for
  117292. * @returns the lens flare system or null if not found
  117293. */
  117294. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117295. /**
  117296. * Gets a lens flare system using its id
  117297. * @param id defines the id to look for
  117298. * @returns the lens flare system or null if not found
  117299. */
  117300. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117301. }
  117302. /**
  117303. * Defines the lens flare scene component responsible to manage any lens flares
  117304. * in a given scene.
  117305. */
  117306. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117307. /**
  117308. * The component name helpfull to identify the component in the list of scene components.
  117309. */
  117310. readonly name: string;
  117311. /**
  117312. * The scene the component belongs to.
  117313. */
  117314. scene: Scene;
  117315. /**
  117316. * Creates a new instance of the component for the given scene
  117317. * @param scene Defines the scene to register the component in
  117318. */
  117319. constructor(scene: Scene);
  117320. /**
  117321. * Registers the component in a given scene
  117322. */
  117323. register(): void;
  117324. /**
  117325. * Rebuilds the elements related to this component in case of
  117326. * context lost for instance.
  117327. */
  117328. rebuild(): void;
  117329. /**
  117330. * Adds all the elements from the container to the scene
  117331. * @param container the container holding the elements
  117332. */
  117333. addFromContainer(container: AbstractScene): void;
  117334. /**
  117335. * Removes all the elements in the container from the scene
  117336. * @param container contains the elements to remove
  117337. * @param dispose if the removed element should be disposed (default: false)
  117338. */
  117339. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117340. /**
  117341. * Serializes the component data to the specified json object
  117342. * @param serializationObject The object to serialize to
  117343. */
  117344. serialize(serializationObject: any): void;
  117345. /**
  117346. * Disposes the component and the associated ressources.
  117347. */
  117348. dispose(): void;
  117349. private _draw;
  117350. }
  117351. }
  117352. declare module BABYLON {
  117353. /**
  117354. * Defines the shadow generator component responsible to manage any shadow generators
  117355. * in a given scene.
  117356. */
  117357. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117358. /**
  117359. * The component name helpfull to identify the component in the list of scene components.
  117360. */
  117361. readonly name: string;
  117362. /**
  117363. * The scene the component belongs to.
  117364. */
  117365. scene: Scene;
  117366. /**
  117367. * Creates a new instance of the component for the given scene
  117368. * @param scene Defines the scene to register the component in
  117369. */
  117370. constructor(scene: Scene);
  117371. /**
  117372. * Registers the component in a given scene
  117373. */
  117374. register(): void;
  117375. /**
  117376. * Rebuilds the elements related to this component in case of
  117377. * context lost for instance.
  117378. */
  117379. rebuild(): void;
  117380. /**
  117381. * Serializes the component data to the specified json object
  117382. * @param serializationObject The object to serialize to
  117383. */
  117384. serialize(serializationObject: any): void;
  117385. /**
  117386. * Adds all the elements from the container to the scene
  117387. * @param container the container holding the elements
  117388. */
  117389. addFromContainer(container: AbstractScene): void;
  117390. /**
  117391. * Removes all the elements in the container from the scene
  117392. * @param container contains the elements to remove
  117393. * @param dispose if the removed element should be disposed (default: false)
  117394. */
  117395. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117396. /**
  117397. * Rebuilds the elements related to this component in case of
  117398. * context lost for instance.
  117399. */
  117400. dispose(): void;
  117401. private _gatherRenderTargets;
  117402. }
  117403. }
  117404. declare module BABYLON {
  117405. /**
  117406. * A point light is a light defined by an unique point in world space.
  117407. * The light is emitted in every direction from this point.
  117408. * A good example of a point light is a standard light bulb.
  117409. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117410. */
  117411. export class PointLight extends ShadowLight {
  117412. private _shadowAngle;
  117413. /**
  117414. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117415. * This specifies what angle the shadow will use to be created.
  117416. *
  117417. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117418. */
  117419. /**
  117420. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117421. * This specifies what angle the shadow will use to be created.
  117422. *
  117423. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117424. */
  117425. shadowAngle: number;
  117426. /**
  117427. * Gets the direction if it has been set.
  117428. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117429. */
  117430. /**
  117431. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117432. */
  117433. direction: Vector3;
  117434. /**
  117435. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117436. * A PointLight emits the light in every direction.
  117437. * It can cast shadows.
  117438. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117439. * ```javascript
  117440. * var pointLight = new PointLight("pl", camera.position, scene);
  117441. * ```
  117442. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117443. * @param name The light friendly name
  117444. * @param position The position of the point light in the scene
  117445. * @param scene The scene the lights belongs to
  117446. */
  117447. constructor(name: string, position: Vector3, scene: Scene);
  117448. /**
  117449. * Returns the string "PointLight"
  117450. * @returns the class name
  117451. */
  117452. getClassName(): string;
  117453. /**
  117454. * Returns the integer 0.
  117455. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117456. */
  117457. getTypeID(): number;
  117458. /**
  117459. * Specifies wether or not the shadowmap should be a cube texture.
  117460. * @returns true if the shadowmap needs to be a cube texture.
  117461. */
  117462. needCube(): boolean;
  117463. /**
  117464. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117465. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117466. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117467. */
  117468. getShadowDirection(faceIndex?: number): Vector3;
  117469. /**
  117470. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117471. * - fov = PI / 2
  117472. * - aspect ratio : 1.0
  117473. * - z-near and far equal to the active camera minZ and maxZ.
  117474. * Returns the PointLight.
  117475. */
  117476. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117477. protected _buildUniformLayout(): void;
  117478. /**
  117479. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117480. * @param effect The effect to update
  117481. * @param lightIndex The index of the light in the effect to update
  117482. * @returns The point light
  117483. */
  117484. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117485. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117486. /**
  117487. * Prepares the list of defines specific to the light type.
  117488. * @param defines the list of defines
  117489. * @param lightIndex defines the index of the light for the effect
  117490. */
  117491. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117492. }
  117493. }
  117494. declare module BABYLON {
  117495. /**
  117496. * Header information of HDR texture files.
  117497. */
  117498. export interface HDRInfo {
  117499. /**
  117500. * The height of the texture in pixels.
  117501. */
  117502. height: number;
  117503. /**
  117504. * The width of the texture in pixels.
  117505. */
  117506. width: number;
  117507. /**
  117508. * The index of the beginning of the data in the binary file.
  117509. */
  117510. dataPosition: number;
  117511. }
  117512. /**
  117513. * This groups tools to convert HDR texture to native colors array.
  117514. */
  117515. export class HDRTools {
  117516. private static Ldexp;
  117517. private static Rgbe2float;
  117518. private static readStringLine;
  117519. /**
  117520. * Reads header information from an RGBE texture stored in a native array.
  117521. * More information on this format are available here:
  117522. * https://en.wikipedia.org/wiki/RGBE_image_format
  117523. *
  117524. * @param uint8array The binary file stored in native array.
  117525. * @return The header information.
  117526. */
  117527. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117528. /**
  117529. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117530. * This RGBE texture needs to store the information as a panorama.
  117531. *
  117532. * More information on this format are available here:
  117533. * https://en.wikipedia.org/wiki/RGBE_image_format
  117534. *
  117535. * @param buffer The binary file stored in an array buffer.
  117536. * @param size The expected size of the extracted cubemap.
  117537. * @return The Cube Map information.
  117538. */
  117539. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117540. /**
  117541. * Returns the pixels data extracted from an RGBE texture.
  117542. * This pixels will be stored left to right up to down in the R G B order in one array.
  117543. *
  117544. * More information on this format are available here:
  117545. * https://en.wikipedia.org/wiki/RGBE_image_format
  117546. *
  117547. * @param uint8array The binary file stored in an array buffer.
  117548. * @param hdrInfo The header information of the file.
  117549. * @return The pixels data in RGB right to left up to down order.
  117550. */
  117551. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117552. private static RGBE_ReadPixels_RLE;
  117553. }
  117554. }
  117555. declare module BABYLON {
  117556. /**
  117557. * This represents a texture coming from an HDR input.
  117558. *
  117559. * The only supported format is currently panorama picture stored in RGBE format.
  117560. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117561. */
  117562. export class HDRCubeTexture extends BaseTexture {
  117563. private static _facesMapping;
  117564. private _generateHarmonics;
  117565. private _noMipmap;
  117566. private _textureMatrix;
  117567. private _size;
  117568. private _onLoad;
  117569. private _onError;
  117570. /**
  117571. * The texture URL.
  117572. */
  117573. url: string;
  117574. /**
  117575. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117576. */
  117577. coordinatesMode: number;
  117578. protected _isBlocking: boolean;
  117579. /**
  117580. * Sets wether or not the texture is blocking during loading.
  117581. */
  117582. /**
  117583. * Gets wether or not the texture is blocking during loading.
  117584. */
  117585. isBlocking: boolean;
  117586. protected _rotationY: number;
  117587. /**
  117588. * Sets texture matrix rotation angle around Y axis in radians.
  117589. */
  117590. /**
  117591. * Gets texture matrix rotation angle around Y axis radians.
  117592. */
  117593. rotationY: number;
  117594. /**
  117595. * Gets or sets the center of the bounding box associated with the cube texture
  117596. * It must define where the camera used to render the texture was set
  117597. */
  117598. boundingBoxPosition: Vector3;
  117599. private _boundingBoxSize;
  117600. /**
  117601. * Gets or sets the size of the bounding box associated with the cube texture
  117602. * When defined, the cubemap will switch to local mode
  117603. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117604. * @example https://www.babylonjs-playground.com/#RNASML
  117605. */
  117606. boundingBoxSize: Vector3;
  117607. /**
  117608. * Instantiates an HDRTexture from the following parameters.
  117609. *
  117610. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117611. * @param scene The scene the texture will be used in
  117612. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117613. * @param noMipmap Forces to not generate the mipmap if true
  117614. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117615. * @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)
  117616. * @param reserved Reserved flag for internal use.
  117617. */
  117618. 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>);
  117619. /**
  117620. * Get the current class name of the texture useful for serialization or dynamic coding.
  117621. * @returns "HDRCubeTexture"
  117622. */
  117623. getClassName(): string;
  117624. /**
  117625. * Occurs when the file is raw .hdr file.
  117626. */
  117627. private loadTexture;
  117628. clone(): HDRCubeTexture;
  117629. delayLoad(): void;
  117630. /**
  117631. * Get the texture reflection matrix used to rotate/transform the reflection.
  117632. * @returns the reflection matrix
  117633. */
  117634. getReflectionTextureMatrix(): Matrix;
  117635. /**
  117636. * Set the texture reflection matrix used to rotate/transform the reflection.
  117637. * @param value Define the reflection matrix to set
  117638. */
  117639. setReflectionTextureMatrix(value: Matrix): void;
  117640. /**
  117641. * Parses a JSON representation of an HDR Texture in order to create the texture
  117642. * @param parsedTexture Define the JSON representation
  117643. * @param scene Define the scene the texture should be created in
  117644. * @param rootUrl Define the root url in case we need to load relative dependencies
  117645. * @returns the newly created texture after parsing
  117646. */
  117647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117648. serialize(): any;
  117649. }
  117650. }
  117651. declare module BABYLON {
  117652. /**
  117653. * Class used to control physics engine
  117654. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117655. */
  117656. export class PhysicsEngine implements IPhysicsEngine {
  117657. private _physicsPlugin;
  117658. /**
  117659. * Global value used to control the smallest number supported by the simulation
  117660. */
  117661. static Epsilon: number;
  117662. private _impostors;
  117663. private _joints;
  117664. /**
  117665. * Gets the gravity vector used by the simulation
  117666. */
  117667. gravity: Vector3;
  117668. /**
  117669. * Factory used to create the default physics plugin.
  117670. * @returns The default physics plugin
  117671. */
  117672. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117673. /**
  117674. * Creates a new Physics Engine
  117675. * @param gravity defines the gravity vector used by the simulation
  117676. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117677. */
  117678. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117679. /**
  117680. * Sets the gravity vector used by the simulation
  117681. * @param gravity defines the gravity vector to use
  117682. */
  117683. setGravity(gravity: Vector3): void;
  117684. /**
  117685. * Set the time step of the physics engine.
  117686. * Default is 1/60.
  117687. * To slow it down, enter 1/600 for example.
  117688. * To speed it up, 1/30
  117689. * @param newTimeStep defines the new timestep to apply to this world.
  117690. */
  117691. setTimeStep(newTimeStep?: number): void;
  117692. /**
  117693. * Get the time step of the physics engine.
  117694. * @returns the current time step
  117695. */
  117696. getTimeStep(): number;
  117697. /**
  117698. * Release all resources
  117699. */
  117700. dispose(): void;
  117701. /**
  117702. * Gets the name of the current physics plugin
  117703. * @returns the name of the plugin
  117704. */
  117705. getPhysicsPluginName(): string;
  117706. /**
  117707. * Adding a new impostor for the impostor tracking.
  117708. * This will be done by the impostor itself.
  117709. * @param impostor the impostor to add
  117710. */
  117711. addImpostor(impostor: PhysicsImpostor): void;
  117712. /**
  117713. * Remove an impostor from the engine.
  117714. * This impostor and its mesh will not longer be updated by the physics engine.
  117715. * @param impostor the impostor to remove
  117716. */
  117717. removeImpostor(impostor: PhysicsImpostor): void;
  117718. /**
  117719. * Add a joint to the physics engine
  117720. * @param mainImpostor defines the main impostor to which the joint is added.
  117721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117722. * @param joint defines the joint that will connect both impostors.
  117723. */
  117724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117725. /**
  117726. * Removes a joint from the simulation
  117727. * @param mainImpostor defines the impostor used with the joint
  117728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117729. * @param joint defines the joint to remove
  117730. */
  117731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117732. /**
  117733. * Called by the scene. No need to call it.
  117734. * @param delta defines the timespam between frames
  117735. */
  117736. _step(delta: number): void;
  117737. /**
  117738. * Gets the current plugin used to run the simulation
  117739. * @returns current plugin
  117740. */
  117741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117742. /**
  117743. * Gets the list of physic impostors
  117744. * @returns an array of PhysicsImpostor
  117745. */
  117746. getImpostors(): Array<PhysicsImpostor>;
  117747. /**
  117748. * Gets the impostor for a physics enabled object
  117749. * @param object defines the object impersonated by the impostor
  117750. * @returns the PhysicsImpostor or null if not found
  117751. */
  117752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117753. /**
  117754. * Gets the impostor for a physics body object
  117755. * @param body defines physics body used by the impostor
  117756. * @returns the PhysicsImpostor or null if not found
  117757. */
  117758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117759. /**
  117760. * Does a raycast in the physics world
  117761. * @param from when should the ray start?
  117762. * @param to when should the ray end?
  117763. * @returns PhysicsRaycastResult
  117764. */
  117765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117766. }
  117767. }
  117768. declare module BABYLON {
  117769. /** @hidden */
  117770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117771. private _useDeltaForWorldStep;
  117772. world: any;
  117773. name: string;
  117774. private _physicsMaterials;
  117775. private _fixedTimeStep;
  117776. private _cannonRaycastResult;
  117777. private _raycastResult;
  117778. private _physicsBodysToRemoveAfterStep;
  117779. BJSCANNON: any;
  117780. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117781. setGravity(gravity: Vector3): void;
  117782. setTimeStep(timeStep: number): void;
  117783. getTimeStep(): number;
  117784. executeStep(delta: number): void;
  117785. private _removeMarkedPhysicsBodiesFromWorld;
  117786. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117787. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117788. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117789. private _processChildMeshes;
  117790. removePhysicsBody(impostor: PhysicsImpostor): void;
  117791. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117792. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117793. private _addMaterial;
  117794. private _checkWithEpsilon;
  117795. private _createShape;
  117796. private _createHeightmap;
  117797. private _minus90X;
  117798. private _plus90X;
  117799. private _tmpPosition;
  117800. private _tmpDeltaPosition;
  117801. private _tmpUnityRotation;
  117802. private _updatePhysicsBodyTransformation;
  117803. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117804. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117805. isSupported(): boolean;
  117806. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117807. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117808. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117809. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117810. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117811. getBodyMass(impostor: PhysicsImpostor): number;
  117812. getBodyFriction(impostor: PhysicsImpostor): number;
  117813. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117814. getBodyRestitution(impostor: PhysicsImpostor): number;
  117815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117816. sleepBody(impostor: PhysicsImpostor): void;
  117817. wakeUpBody(impostor: PhysicsImpostor): void;
  117818. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117819. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117820. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117821. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117822. getRadius(impostor: PhysicsImpostor): number;
  117823. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117824. dispose(): void;
  117825. private _extendNamespace;
  117826. /**
  117827. * Does a raycast in the physics world
  117828. * @param from when should the ray start?
  117829. * @param to when should the ray end?
  117830. * @returns PhysicsRaycastResult
  117831. */
  117832. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117833. }
  117834. }
  117835. declare module BABYLON {
  117836. /** @hidden */
  117837. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117838. world: any;
  117839. name: string;
  117840. BJSOIMO: any;
  117841. private _raycastResult;
  117842. constructor(iterations?: number, oimoInjection?: any);
  117843. setGravity(gravity: Vector3): void;
  117844. setTimeStep(timeStep: number): void;
  117845. getTimeStep(): number;
  117846. private _tmpImpostorsArray;
  117847. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117848. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117849. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117850. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117851. private _tmpPositionVector;
  117852. removePhysicsBody(impostor: PhysicsImpostor): void;
  117853. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117854. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117855. isSupported(): boolean;
  117856. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117857. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117858. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117859. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117860. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117861. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117862. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117863. getBodyMass(impostor: PhysicsImpostor): number;
  117864. getBodyFriction(impostor: PhysicsImpostor): number;
  117865. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117866. getBodyRestitution(impostor: PhysicsImpostor): number;
  117867. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117868. sleepBody(impostor: PhysicsImpostor): void;
  117869. wakeUpBody(impostor: PhysicsImpostor): void;
  117870. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117871. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117872. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117873. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117874. getRadius(impostor: PhysicsImpostor): number;
  117875. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117876. dispose(): void;
  117877. /**
  117878. * Does a raycast in the physics world
  117879. * @param from when should the ray start?
  117880. * @param to when should the ray end?
  117881. * @returns PhysicsRaycastResult
  117882. */
  117883. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117884. }
  117885. }
  117886. declare module BABYLON {
  117887. /**
  117888. * Class containing static functions to help procedurally build meshes
  117889. */
  117890. export class RibbonBuilder {
  117891. /**
  117892. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117893. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117894. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117895. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117896. * * 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
  117897. * * 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
  117898. * * 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
  117899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117902. * * 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
  117903. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117904. * * 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
  117905. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117907. * @param name defines the name of the mesh
  117908. * @param options defines the options used to create the mesh
  117909. * @param scene defines the hosting scene
  117910. * @returns the ribbon mesh
  117911. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117913. */
  117914. static CreateRibbon(name: string, options: {
  117915. pathArray: Vector3[][];
  117916. closeArray?: boolean;
  117917. closePath?: boolean;
  117918. offset?: number;
  117919. updatable?: boolean;
  117920. sideOrientation?: number;
  117921. frontUVs?: Vector4;
  117922. backUVs?: Vector4;
  117923. instance?: Mesh;
  117924. invertUV?: boolean;
  117925. uvs?: Vector2[];
  117926. colors?: Color4[];
  117927. }, scene?: Nullable<Scene>): Mesh;
  117928. }
  117929. }
  117930. declare module BABYLON {
  117931. /**
  117932. * Class containing static functions to help procedurally build meshes
  117933. */
  117934. export class ShapeBuilder {
  117935. /**
  117936. * 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.
  117937. * * 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.
  117938. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117939. * * 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.
  117940. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117941. * * 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
  117942. * * 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
  117943. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117944. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117945. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117946. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117948. * @param name defines the name of the mesh
  117949. * @param options defines the options used to create the mesh
  117950. * @param scene defines the hosting scene
  117951. * @returns the extruded shape mesh
  117952. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117954. */
  117955. static ExtrudeShape(name: string, options: {
  117956. shape: Vector3[];
  117957. path: Vector3[];
  117958. scale?: number;
  117959. rotation?: number;
  117960. cap?: number;
  117961. updatable?: boolean;
  117962. sideOrientation?: number;
  117963. frontUVs?: Vector4;
  117964. backUVs?: Vector4;
  117965. instance?: Mesh;
  117966. invertUV?: boolean;
  117967. }, scene?: Nullable<Scene>): Mesh;
  117968. /**
  117969. * Creates an custom extruded shape mesh.
  117970. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117971. * * 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.
  117972. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117973. * * 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
  117974. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117975. * * 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
  117976. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117977. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117978. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117979. * * 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
  117980. * * 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
  117981. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117986. * @param name defines the name of the mesh
  117987. * @param options defines the options used to create the mesh
  117988. * @param scene defines the hosting scene
  117989. * @returns the custom extruded shape mesh
  117990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117991. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117992. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117993. */
  117994. static ExtrudeShapeCustom(name: string, options: {
  117995. shape: Vector3[];
  117996. path: Vector3[];
  117997. scaleFunction?: any;
  117998. rotationFunction?: any;
  117999. ribbonCloseArray?: boolean;
  118000. ribbonClosePath?: boolean;
  118001. cap?: number;
  118002. updatable?: boolean;
  118003. sideOrientation?: number;
  118004. frontUVs?: Vector4;
  118005. backUVs?: Vector4;
  118006. instance?: Mesh;
  118007. invertUV?: boolean;
  118008. }, scene?: Nullable<Scene>): Mesh;
  118009. private static _ExtrudeShapeGeneric;
  118010. }
  118011. }
  118012. declare module BABYLON {
  118013. /**
  118014. * AmmoJS Physics plugin
  118015. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118016. * @see https://github.com/kripken/ammo.js/
  118017. */
  118018. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118019. private _useDeltaForWorldStep;
  118020. /**
  118021. * Reference to the Ammo library
  118022. */
  118023. bjsAMMO: any;
  118024. /**
  118025. * Created ammoJS world which physics bodies are added to
  118026. */
  118027. world: any;
  118028. /**
  118029. * Name of the plugin
  118030. */
  118031. name: string;
  118032. private _timeStep;
  118033. private _fixedTimeStep;
  118034. private _maxSteps;
  118035. private _tmpQuaternion;
  118036. private _tmpAmmoTransform;
  118037. private _tmpAmmoQuaternion;
  118038. private _tmpAmmoConcreteContactResultCallback;
  118039. private _collisionConfiguration;
  118040. private _dispatcher;
  118041. private _overlappingPairCache;
  118042. private _solver;
  118043. private _softBodySolver;
  118044. private _tmpAmmoVectorA;
  118045. private _tmpAmmoVectorB;
  118046. private _tmpAmmoVectorC;
  118047. private _tmpAmmoVectorD;
  118048. private _tmpContactCallbackResult;
  118049. private _tmpAmmoVectorRCA;
  118050. private _tmpAmmoVectorRCB;
  118051. private _raycastResult;
  118052. private static readonly DISABLE_COLLISION_FLAG;
  118053. private static readonly KINEMATIC_FLAG;
  118054. private static readonly DISABLE_DEACTIVATION_FLAG;
  118055. /**
  118056. * Initializes the ammoJS plugin
  118057. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118058. * @param ammoInjection can be used to inject your own ammo reference
  118059. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118060. */
  118061. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118062. /**
  118063. * Sets the gravity of the physics world (m/(s^2))
  118064. * @param gravity Gravity to set
  118065. */
  118066. setGravity(gravity: Vector3): void;
  118067. /**
  118068. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118069. * @param timeStep timestep to use in seconds
  118070. */
  118071. setTimeStep(timeStep: number): void;
  118072. /**
  118073. * 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)
  118074. * @param fixedTimeStep fixedTimeStep to use in seconds
  118075. */
  118076. setFixedTimeStep(fixedTimeStep: number): void;
  118077. /**
  118078. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118079. * @param maxSteps the maximum number of steps by the physics engine per frame
  118080. */
  118081. setMaxSteps(maxSteps: number): void;
  118082. /**
  118083. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118084. * @returns the current timestep in seconds
  118085. */
  118086. getTimeStep(): number;
  118087. private _isImpostorInContact;
  118088. private _isImpostorPairInContact;
  118089. private _stepSimulation;
  118090. /**
  118091. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118092. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118093. * After the step the babylon meshes are set to the position of the physics imposters
  118094. * @param delta amount of time to step forward
  118095. * @param impostors array of imposters to update before/after the step
  118096. */
  118097. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118098. /**
  118099. * Update babylon mesh to match physics world object
  118100. * @param impostor imposter to match
  118101. */
  118102. private _afterSoftStep;
  118103. /**
  118104. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118105. * @param impostor imposter to match
  118106. */
  118107. private _ropeStep;
  118108. /**
  118109. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118110. * @param impostor imposter to match
  118111. */
  118112. private _softbodyOrClothStep;
  118113. private _tmpVector;
  118114. private _tmpMatrix;
  118115. /**
  118116. * Applies an impulse on the imposter
  118117. * @param impostor imposter to apply impulse to
  118118. * @param force amount of force to be applied to the imposter
  118119. * @param contactPoint the location to apply the impulse on the imposter
  118120. */
  118121. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118122. /**
  118123. * Applies a force on the imposter
  118124. * @param impostor imposter to apply force
  118125. * @param force amount of force to be applied to the imposter
  118126. * @param contactPoint the location to apply the force on the imposter
  118127. */
  118128. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118129. /**
  118130. * Creates a physics body using the plugin
  118131. * @param impostor the imposter to create the physics body on
  118132. */
  118133. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118134. /**
  118135. * Removes the physics body from the imposter and disposes of the body's memory
  118136. * @param impostor imposter to remove the physics body from
  118137. */
  118138. removePhysicsBody(impostor: PhysicsImpostor): void;
  118139. /**
  118140. * Generates a joint
  118141. * @param impostorJoint the imposter joint to create the joint with
  118142. */
  118143. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118144. /**
  118145. * Removes a joint
  118146. * @param impostorJoint the imposter joint to remove the joint from
  118147. */
  118148. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118149. private _addMeshVerts;
  118150. /**
  118151. * Initialise the soft body vertices to match its object's (mesh) vertices
  118152. * Softbody vertices (nodes) are in world space and to match this
  118153. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118154. * @param impostor to create the softbody for
  118155. */
  118156. private _softVertexData;
  118157. /**
  118158. * Create an impostor's soft body
  118159. * @param impostor to create the softbody for
  118160. */
  118161. private _createSoftbody;
  118162. /**
  118163. * Create cloth for an impostor
  118164. * @param impostor to create the softbody for
  118165. */
  118166. private _createCloth;
  118167. /**
  118168. * Create rope for an impostor
  118169. * @param impostor to create the softbody for
  118170. */
  118171. private _createRope;
  118172. private _addHullVerts;
  118173. private _createShape;
  118174. /**
  118175. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118176. * @param impostor imposter containing the physics body and babylon object
  118177. */
  118178. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118179. /**
  118180. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118181. * @param impostor imposter containing the physics body and babylon object
  118182. * @param newPosition new position
  118183. * @param newRotation new rotation
  118184. */
  118185. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118186. /**
  118187. * If this plugin is supported
  118188. * @returns true if its supported
  118189. */
  118190. isSupported(): boolean;
  118191. /**
  118192. * Sets the linear velocity of the physics body
  118193. * @param impostor imposter to set the velocity on
  118194. * @param velocity velocity to set
  118195. */
  118196. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118197. /**
  118198. * Sets the angular velocity of the physics body
  118199. * @param impostor imposter to set the velocity on
  118200. * @param velocity velocity to set
  118201. */
  118202. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118203. /**
  118204. * gets the linear velocity
  118205. * @param impostor imposter to get linear velocity from
  118206. * @returns linear velocity
  118207. */
  118208. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118209. /**
  118210. * gets the angular velocity
  118211. * @param impostor imposter to get angular velocity from
  118212. * @returns angular velocity
  118213. */
  118214. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118215. /**
  118216. * Sets the mass of physics body
  118217. * @param impostor imposter to set the mass on
  118218. * @param mass mass to set
  118219. */
  118220. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118221. /**
  118222. * Gets the mass of the physics body
  118223. * @param impostor imposter to get the mass from
  118224. * @returns mass
  118225. */
  118226. getBodyMass(impostor: PhysicsImpostor): number;
  118227. /**
  118228. * Gets friction of the impostor
  118229. * @param impostor impostor to get friction from
  118230. * @returns friction value
  118231. */
  118232. getBodyFriction(impostor: PhysicsImpostor): number;
  118233. /**
  118234. * Sets friction of the impostor
  118235. * @param impostor impostor to set friction on
  118236. * @param friction friction value
  118237. */
  118238. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118239. /**
  118240. * Gets restitution of the impostor
  118241. * @param impostor impostor to get restitution from
  118242. * @returns restitution value
  118243. */
  118244. getBodyRestitution(impostor: PhysicsImpostor): number;
  118245. /**
  118246. * Sets resitution of the impostor
  118247. * @param impostor impostor to set resitution on
  118248. * @param restitution resitution value
  118249. */
  118250. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118251. /**
  118252. * Gets pressure inside the impostor
  118253. * @param impostor impostor to get pressure from
  118254. * @returns pressure value
  118255. */
  118256. getBodyPressure(impostor: PhysicsImpostor): number;
  118257. /**
  118258. * Sets pressure inside a soft body impostor
  118259. * Cloth and rope must remain 0 pressure
  118260. * @param impostor impostor to set pressure on
  118261. * @param pressure pressure value
  118262. */
  118263. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118264. /**
  118265. * Gets stiffness of the impostor
  118266. * @param impostor impostor to get stiffness from
  118267. * @returns pressure value
  118268. */
  118269. getBodyStiffness(impostor: PhysicsImpostor): number;
  118270. /**
  118271. * Sets stiffness of the impostor
  118272. * @param impostor impostor to set stiffness on
  118273. * @param stiffness stiffness value from 0 to 1
  118274. */
  118275. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118276. /**
  118277. * Gets velocityIterations of the impostor
  118278. * @param impostor impostor to get velocity iterations from
  118279. * @returns velocityIterations value
  118280. */
  118281. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118282. /**
  118283. * Sets velocityIterations of the impostor
  118284. * @param impostor impostor to set velocity iterations on
  118285. * @param velocityIterations velocityIterations value
  118286. */
  118287. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118288. /**
  118289. * Gets positionIterations of the impostor
  118290. * @param impostor impostor to get position iterations from
  118291. * @returns positionIterations value
  118292. */
  118293. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118294. /**
  118295. * Sets positionIterations of the impostor
  118296. * @param impostor impostor to set position on
  118297. * @param positionIterations positionIterations value
  118298. */
  118299. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118300. /**
  118301. * Append an anchor to a cloth object
  118302. * @param impostor is the cloth impostor to add anchor to
  118303. * @param otherImpostor is the rigid impostor to anchor to
  118304. * @param width ratio across width from 0 to 1
  118305. * @param height ratio up height from 0 to 1
  118306. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118307. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118308. */
  118309. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118310. /**
  118311. * Append an hook to a rope object
  118312. * @param impostor is the rope impostor to add hook to
  118313. * @param otherImpostor is the rigid impostor to hook to
  118314. * @param length ratio along the rope from 0 to 1
  118315. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118316. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118317. */
  118318. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118319. /**
  118320. * Sleeps the physics body and stops it from being active
  118321. * @param impostor impostor to sleep
  118322. */
  118323. sleepBody(impostor: PhysicsImpostor): void;
  118324. /**
  118325. * Activates the physics body
  118326. * @param impostor impostor to activate
  118327. */
  118328. wakeUpBody(impostor: PhysicsImpostor): void;
  118329. /**
  118330. * Updates the distance parameters of the joint
  118331. * @param joint joint to update
  118332. * @param maxDistance maximum distance of the joint
  118333. * @param minDistance minimum distance of the joint
  118334. */
  118335. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118336. /**
  118337. * Sets a motor on the joint
  118338. * @param joint joint to set motor on
  118339. * @param speed speed of the motor
  118340. * @param maxForce maximum force of the motor
  118341. * @param motorIndex index of the motor
  118342. */
  118343. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118344. /**
  118345. * Sets the motors limit
  118346. * @param joint joint to set limit on
  118347. * @param upperLimit upper limit
  118348. * @param lowerLimit lower limit
  118349. */
  118350. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118351. /**
  118352. * Syncs the position and rotation of a mesh with the impostor
  118353. * @param mesh mesh to sync
  118354. * @param impostor impostor to update the mesh with
  118355. */
  118356. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118357. /**
  118358. * Gets the radius of the impostor
  118359. * @param impostor impostor to get radius from
  118360. * @returns the radius
  118361. */
  118362. getRadius(impostor: PhysicsImpostor): number;
  118363. /**
  118364. * Gets the box size of the impostor
  118365. * @param impostor impostor to get box size from
  118366. * @param result the resulting box size
  118367. */
  118368. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118369. /**
  118370. * Disposes of the impostor
  118371. */
  118372. dispose(): void;
  118373. /**
  118374. * Does a raycast in the physics world
  118375. * @param from when should the ray start?
  118376. * @param to when should the ray end?
  118377. * @returns PhysicsRaycastResult
  118378. */
  118379. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118380. }
  118381. }
  118382. declare module BABYLON {
  118383. interface AbstractScene {
  118384. /**
  118385. * The list of reflection probes added to the scene
  118386. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118387. */
  118388. reflectionProbes: Array<ReflectionProbe>;
  118389. /**
  118390. * Removes the given reflection probe from this scene.
  118391. * @param toRemove The reflection probe to remove
  118392. * @returns The index of the removed reflection probe
  118393. */
  118394. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118395. /**
  118396. * Adds the given reflection probe to this scene.
  118397. * @param newReflectionProbe The reflection probe to add
  118398. */
  118399. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118400. }
  118401. /**
  118402. * Class used to generate realtime reflection / refraction cube textures
  118403. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118404. */
  118405. export class ReflectionProbe {
  118406. /** defines the name of the probe */
  118407. name: string;
  118408. private _scene;
  118409. private _renderTargetTexture;
  118410. private _projectionMatrix;
  118411. private _viewMatrix;
  118412. private _target;
  118413. private _add;
  118414. private _attachedMesh;
  118415. private _invertYAxis;
  118416. /** Gets or sets probe position (center of the cube map) */
  118417. position: Vector3;
  118418. /**
  118419. * Creates a new reflection probe
  118420. * @param name defines the name of the probe
  118421. * @param size defines the texture resolution (for each face)
  118422. * @param scene defines the hosting scene
  118423. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118424. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118425. */
  118426. constructor(
  118427. /** defines the name of the probe */
  118428. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118429. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118430. samples: number;
  118431. /** Gets or sets the refresh rate to use (on every frame by default) */
  118432. refreshRate: number;
  118433. /**
  118434. * Gets the hosting scene
  118435. * @returns a Scene
  118436. */
  118437. getScene(): Scene;
  118438. /** Gets the internal CubeTexture used to render to */
  118439. readonly cubeTexture: RenderTargetTexture;
  118440. /** Gets the list of meshes to render */
  118441. readonly renderList: Nullable<AbstractMesh[]>;
  118442. /**
  118443. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118444. * @param mesh defines the mesh to attach to
  118445. */
  118446. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118447. /**
  118448. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118449. * @param renderingGroupId The rendering group id corresponding to its index
  118450. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118451. */
  118452. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118453. /**
  118454. * Clean all associated resources
  118455. */
  118456. dispose(): void;
  118457. /**
  118458. * Converts the reflection probe information to a readable string for debug purpose.
  118459. * @param fullDetails Supports for multiple levels of logging within scene loading
  118460. * @returns the human readable reflection probe info
  118461. */
  118462. toString(fullDetails?: boolean): string;
  118463. /**
  118464. * Get the class name of the relfection probe.
  118465. * @returns "ReflectionProbe"
  118466. */
  118467. getClassName(): string;
  118468. /**
  118469. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118470. * @returns The JSON representation of the texture
  118471. */
  118472. serialize(): any;
  118473. /**
  118474. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118475. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118476. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118477. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118478. * @returns The parsed reflection probe if successful
  118479. */
  118480. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118481. }
  118482. }
  118483. declare module BABYLON {
  118484. /** @hidden */
  118485. export var _BabylonLoaderRegistered: boolean;
  118486. }
  118487. declare module BABYLON {
  118488. /**
  118489. * The Physically based simple base material of BJS.
  118490. *
  118491. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118492. * It is used as the base class for both the specGloss and metalRough conventions.
  118493. */
  118494. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118495. /**
  118496. * Number of Simultaneous lights allowed on the material.
  118497. */
  118498. maxSimultaneousLights: number;
  118499. /**
  118500. * If sets to true, disables all the lights affecting the material.
  118501. */
  118502. disableLighting: boolean;
  118503. /**
  118504. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118505. */
  118506. environmentTexture: BaseTexture;
  118507. /**
  118508. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118509. */
  118510. invertNormalMapX: boolean;
  118511. /**
  118512. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118513. */
  118514. invertNormalMapY: boolean;
  118515. /**
  118516. * Normal map used in the model.
  118517. */
  118518. normalTexture: BaseTexture;
  118519. /**
  118520. * Emissivie color used to self-illuminate the model.
  118521. */
  118522. emissiveColor: Color3;
  118523. /**
  118524. * Emissivie texture used to self-illuminate the model.
  118525. */
  118526. emissiveTexture: BaseTexture;
  118527. /**
  118528. * Occlusion Channel Strenght.
  118529. */
  118530. occlusionStrength: number;
  118531. /**
  118532. * Occlusion Texture of the material (adding extra occlusion effects).
  118533. */
  118534. occlusionTexture: BaseTexture;
  118535. /**
  118536. * Defines the alpha limits in alpha test mode.
  118537. */
  118538. alphaCutOff: number;
  118539. /**
  118540. * Gets the current double sided mode.
  118541. */
  118542. /**
  118543. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118544. */
  118545. doubleSided: boolean;
  118546. /**
  118547. * Stores the pre-calculated light information of a mesh in a texture.
  118548. */
  118549. lightmapTexture: BaseTexture;
  118550. /**
  118551. * If true, the light map contains occlusion information instead of lighting info.
  118552. */
  118553. useLightmapAsShadowmap: boolean;
  118554. /**
  118555. * Instantiates a new PBRMaterial instance.
  118556. *
  118557. * @param name The material name
  118558. * @param scene The scene the material will be use in.
  118559. */
  118560. constructor(name: string, scene: Scene);
  118561. getClassName(): string;
  118562. }
  118563. }
  118564. declare module BABYLON {
  118565. /**
  118566. * The PBR material of BJS following the metal roughness convention.
  118567. *
  118568. * This fits to the PBR convention in the GLTF definition:
  118569. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118570. */
  118571. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118572. /**
  118573. * The base color has two different interpretations depending on the value of metalness.
  118574. * When the material is a metal, the base color is the specific measured reflectance value
  118575. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118576. * of the material.
  118577. */
  118578. baseColor: Color3;
  118579. /**
  118580. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118581. * well as opacity information in the alpha channel.
  118582. */
  118583. baseTexture: BaseTexture;
  118584. /**
  118585. * Specifies the metallic scalar value of the material.
  118586. * Can also be used to scale the metalness values of the metallic texture.
  118587. */
  118588. metallic: number;
  118589. /**
  118590. * Specifies the roughness scalar value of the material.
  118591. * Can also be used to scale the roughness values of the metallic texture.
  118592. */
  118593. roughness: number;
  118594. /**
  118595. * Texture containing both the metallic value in the B channel and the
  118596. * roughness value in the G channel to keep better precision.
  118597. */
  118598. metallicRoughnessTexture: BaseTexture;
  118599. /**
  118600. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118601. *
  118602. * @param name The material name
  118603. * @param scene The scene the material will be use in.
  118604. */
  118605. constructor(name: string, scene: Scene);
  118606. /**
  118607. * Return the currrent class name of the material.
  118608. */
  118609. getClassName(): string;
  118610. /**
  118611. * Makes a duplicate of the current material.
  118612. * @param name - name to use for the new material.
  118613. */
  118614. clone(name: string): PBRMetallicRoughnessMaterial;
  118615. /**
  118616. * Serialize the material to a parsable JSON object.
  118617. */
  118618. serialize(): any;
  118619. /**
  118620. * Parses a JSON object correponding to the serialize function.
  118621. */
  118622. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118623. }
  118624. }
  118625. declare module BABYLON {
  118626. /**
  118627. * The PBR material of BJS following the specular glossiness convention.
  118628. *
  118629. * This fits to the PBR convention in the GLTF definition:
  118630. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118631. */
  118632. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118633. /**
  118634. * Specifies the diffuse color of the material.
  118635. */
  118636. diffuseColor: Color3;
  118637. /**
  118638. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118639. * channel.
  118640. */
  118641. diffuseTexture: BaseTexture;
  118642. /**
  118643. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118644. */
  118645. specularColor: Color3;
  118646. /**
  118647. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118648. */
  118649. glossiness: number;
  118650. /**
  118651. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118652. */
  118653. specularGlossinessTexture: BaseTexture;
  118654. /**
  118655. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118656. *
  118657. * @param name The material name
  118658. * @param scene The scene the material will be use in.
  118659. */
  118660. constructor(name: string, scene: Scene);
  118661. /**
  118662. * Return the currrent class name of the material.
  118663. */
  118664. getClassName(): string;
  118665. /**
  118666. * Makes a duplicate of the current material.
  118667. * @param name - name to use for the new material.
  118668. */
  118669. clone(name: string): PBRSpecularGlossinessMaterial;
  118670. /**
  118671. * Serialize the material to a parsable JSON object.
  118672. */
  118673. serialize(): any;
  118674. /**
  118675. * Parses a JSON object correponding to the serialize function.
  118676. */
  118677. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118678. }
  118679. }
  118680. declare module BABYLON {
  118681. /**
  118682. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118683. * It can help converting any input color in a desired output one. This can then be used to create effects
  118684. * from sepia, black and white to sixties or futuristic rendering...
  118685. *
  118686. * The only supported format is currently 3dl.
  118687. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118688. */
  118689. export class ColorGradingTexture extends BaseTexture {
  118690. /**
  118691. * The current texture matrix. (will always be identity in color grading texture)
  118692. */
  118693. private _textureMatrix;
  118694. /**
  118695. * The texture URL.
  118696. */
  118697. url: string;
  118698. /**
  118699. * Empty line regex stored for GC.
  118700. */
  118701. private static _noneEmptyLineRegex;
  118702. private _engine;
  118703. /**
  118704. * Instantiates a ColorGradingTexture from the following parameters.
  118705. *
  118706. * @param url The location of the color gradind data (currently only supporting 3dl)
  118707. * @param scene The scene the texture will be used in
  118708. */
  118709. constructor(url: string, scene: Scene);
  118710. /**
  118711. * Returns the texture matrix used in most of the material.
  118712. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118713. */
  118714. getTextureMatrix(): Matrix;
  118715. /**
  118716. * Occurs when the file being loaded is a .3dl LUT file.
  118717. */
  118718. private load3dlTexture;
  118719. /**
  118720. * Starts the loading process of the texture.
  118721. */
  118722. private loadTexture;
  118723. /**
  118724. * Clones the color gradind texture.
  118725. */
  118726. clone(): ColorGradingTexture;
  118727. /**
  118728. * Called during delayed load for textures.
  118729. */
  118730. delayLoad(): void;
  118731. /**
  118732. * Parses a color grading texture serialized by Babylon.
  118733. * @param parsedTexture The texture information being parsedTexture
  118734. * @param scene The scene to load the texture in
  118735. * @param rootUrl The root url of the data assets to load
  118736. * @return A color gradind texture
  118737. */
  118738. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118739. /**
  118740. * Serializes the LUT texture to json format.
  118741. */
  118742. serialize(): any;
  118743. }
  118744. }
  118745. declare module BABYLON {
  118746. /**
  118747. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118748. */
  118749. export class EquiRectangularCubeTexture extends BaseTexture {
  118750. /** The six faces of the cube. */
  118751. private static _FacesMapping;
  118752. private _noMipmap;
  118753. private _onLoad;
  118754. private _onError;
  118755. /** The size of the cubemap. */
  118756. private _size;
  118757. /** The buffer of the image. */
  118758. private _buffer;
  118759. /** The width of the input image. */
  118760. private _width;
  118761. /** The height of the input image. */
  118762. private _height;
  118763. /** The URL to the image. */
  118764. url: string;
  118765. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118766. coordinatesMode: number;
  118767. /**
  118768. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118769. * @param url The location of the image
  118770. * @param scene The scene the texture will be used in
  118771. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118772. * @param noMipmap Forces to not generate the mipmap if true
  118773. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118774. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118775. * @param onLoad — defines a callback called when texture is loaded
  118776. * @param onError — defines a callback called if there is an error
  118777. */
  118778. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118779. /**
  118780. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118781. */
  118782. private loadImage;
  118783. /**
  118784. * Convert the image buffer into a cubemap and create a CubeTexture.
  118785. */
  118786. private loadTexture;
  118787. /**
  118788. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118789. * @param buffer The ArrayBuffer that should be converted.
  118790. * @returns The buffer as Float32Array.
  118791. */
  118792. private getFloat32ArrayFromArrayBuffer;
  118793. /**
  118794. * Get the current class name of the texture useful for serialization or dynamic coding.
  118795. * @returns "EquiRectangularCubeTexture"
  118796. */
  118797. getClassName(): string;
  118798. /**
  118799. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118800. * @returns A clone of the current EquiRectangularCubeTexture.
  118801. */
  118802. clone(): EquiRectangularCubeTexture;
  118803. }
  118804. }
  118805. declare module BABYLON {
  118806. /**
  118807. * Based on jsTGALoader - Javascript loader for TGA file
  118808. * By Vincent Thibault
  118809. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118810. */
  118811. export class TGATools {
  118812. private static _TYPE_INDEXED;
  118813. private static _TYPE_RGB;
  118814. private static _TYPE_GREY;
  118815. private static _TYPE_RLE_INDEXED;
  118816. private static _TYPE_RLE_RGB;
  118817. private static _TYPE_RLE_GREY;
  118818. private static _ORIGIN_MASK;
  118819. private static _ORIGIN_SHIFT;
  118820. private static _ORIGIN_BL;
  118821. private static _ORIGIN_BR;
  118822. private static _ORIGIN_UL;
  118823. private static _ORIGIN_UR;
  118824. /**
  118825. * Gets the header of a TGA file
  118826. * @param data defines the TGA data
  118827. * @returns the header
  118828. */
  118829. static GetTGAHeader(data: Uint8Array): any;
  118830. /**
  118831. * Uploads TGA content to a Babylon Texture
  118832. * @hidden
  118833. */
  118834. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118835. /** @hidden */
  118836. 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;
  118837. /** @hidden */
  118838. 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;
  118839. /** @hidden */
  118840. 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;
  118841. /** @hidden */
  118842. 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;
  118843. /** @hidden */
  118844. 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;
  118845. /** @hidden */
  118846. 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;
  118847. }
  118848. }
  118849. declare module BABYLON {
  118850. /**
  118851. * Implementation of the TGA Texture Loader.
  118852. * @hidden
  118853. */
  118854. export class _TGATextureLoader implements IInternalTextureLoader {
  118855. /**
  118856. * Defines wether the loader supports cascade loading the different faces.
  118857. */
  118858. readonly supportCascades: boolean;
  118859. /**
  118860. * This returns if the loader support the current file information.
  118861. * @param extension defines the file extension of the file being loaded
  118862. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118863. * @param fallback defines the fallback internal texture if any
  118864. * @param isBase64 defines whether the texture is encoded as a base64
  118865. * @param isBuffer defines whether the texture data are stored as a buffer
  118866. * @returns true if the loader can load the specified file
  118867. */
  118868. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118869. /**
  118870. * Transform the url before loading if required.
  118871. * @param rootUrl the url of the texture
  118872. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118873. * @returns the transformed texture
  118874. */
  118875. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118876. /**
  118877. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118878. * @param rootUrl the url of the texture
  118879. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118880. * @returns the fallback texture
  118881. */
  118882. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118883. /**
  118884. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118885. * @param data contains the texture data
  118886. * @param texture defines the BabylonJS internal texture
  118887. * @param createPolynomials will be true if polynomials have been requested
  118888. * @param onLoad defines the callback to trigger once the texture is ready
  118889. * @param onError defines the callback to trigger in case of error
  118890. */
  118891. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118892. /**
  118893. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118894. * @param data contains the texture data
  118895. * @param texture defines the BabylonJS internal texture
  118896. * @param callback defines the method to call once ready to upload
  118897. */
  118898. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118899. }
  118900. }
  118901. declare module BABYLON {
  118902. /**
  118903. * Info about the .basis files
  118904. */
  118905. class BasisFileInfo {
  118906. /**
  118907. * If the file has alpha
  118908. */
  118909. hasAlpha: boolean;
  118910. /**
  118911. * Info about each image of the basis file
  118912. */
  118913. images: Array<{
  118914. levels: Array<{
  118915. width: number;
  118916. height: number;
  118917. transcodedPixels: ArrayBufferView;
  118918. }>;
  118919. }>;
  118920. }
  118921. /**
  118922. * Result of transcoding a basis file
  118923. */
  118924. class TranscodeResult {
  118925. /**
  118926. * Info about the .basis file
  118927. */
  118928. fileInfo: BasisFileInfo;
  118929. /**
  118930. * Format to use when loading the file
  118931. */
  118932. format: number;
  118933. }
  118934. /**
  118935. * Configuration options for the Basis transcoder
  118936. */
  118937. export class BasisTranscodeConfiguration {
  118938. /**
  118939. * Supported compression formats used to determine the supported output format of the transcoder
  118940. */
  118941. supportedCompressionFormats?: {
  118942. /**
  118943. * etc1 compression format
  118944. */
  118945. etc1?: boolean;
  118946. /**
  118947. * s3tc compression format
  118948. */
  118949. s3tc?: boolean;
  118950. /**
  118951. * pvrtc compression format
  118952. */
  118953. pvrtc?: boolean;
  118954. /**
  118955. * etc2 compression format
  118956. */
  118957. etc2?: boolean;
  118958. };
  118959. /**
  118960. * If mipmap levels should be loaded for transcoded images (Default: true)
  118961. */
  118962. loadMipmapLevels?: boolean;
  118963. /**
  118964. * Index of a single image to load (Default: all images)
  118965. */
  118966. loadSingleImage?: number;
  118967. }
  118968. /**
  118969. * Used to load .Basis files
  118970. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118971. */
  118972. export class BasisTools {
  118973. private static _IgnoreSupportedFormats;
  118974. /**
  118975. * URL to use when loading the basis transcoder
  118976. */
  118977. static JSModuleURL: string;
  118978. /**
  118979. * URL to use when loading the wasm module for the transcoder
  118980. */
  118981. static WasmModuleURL: string;
  118982. /**
  118983. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118984. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118985. * @returns internal format corresponding to the Basis format
  118986. */
  118987. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118988. private static _WorkerPromise;
  118989. private static _Worker;
  118990. private static _actionId;
  118991. private static _CreateWorkerAsync;
  118992. /**
  118993. * Transcodes a loaded image file to compressed pixel data
  118994. * @param imageData image data to transcode
  118995. * @param config configuration options for the transcoding
  118996. * @returns a promise resulting in the transcoded image
  118997. */
  118998. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118999. /**
  119000. * Loads a texture from the transcode result
  119001. * @param texture texture load to
  119002. * @param transcodeResult the result of transcoding the basis file to load from
  119003. */
  119004. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119005. }
  119006. }
  119007. declare module BABYLON {
  119008. /**
  119009. * Loader for .basis file format
  119010. */
  119011. export class _BasisTextureLoader implements IInternalTextureLoader {
  119012. /**
  119013. * Defines whether the loader supports cascade loading the different faces.
  119014. */
  119015. readonly supportCascades: boolean;
  119016. /**
  119017. * This returns if the loader support the current file information.
  119018. * @param extension defines the file extension of the file being loaded
  119019. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119020. * @param fallback defines the fallback internal texture if any
  119021. * @param isBase64 defines whether the texture is encoded as a base64
  119022. * @param isBuffer defines whether the texture data are stored as a buffer
  119023. * @returns true if the loader can load the specified file
  119024. */
  119025. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119026. /**
  119027. * Transform the url before loading if required.
  119028. * @param rootUrl the url of the texture
  119029. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119030. * @returns the transformed texture
  119031. */
  119032. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119033. /**
  119034. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119035. * @param rootUrl the url of the texture
  119036. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119037. * @returns the fallback texture
  119038. */
  119039. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119040. /**
  119041. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119042. * @param data contains the texture data
  119043. * @param texture defines the BabylonJS internal texture
  119044. * @param createPolynomials will be true if polynomials have been requested
  119045. * @param onLoad defines the callback to trigger once the texture is ready
  119046. * @param onError defines the callback to trigger in case of error
  119047. */
  119048. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119049. /**
  119050. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119051. * @param data contains the texture data
  119052. * @param texture defines the BabylonJS internal texture
  119053. * @param callback defines the method to call once ready to upload
  119054. */
  119055. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119056. }
  119057. }
  119058. declare module BABYLON {
  119059. /**
  119060. * 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.
  119061. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119062. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119063. */
  119064. export class CustomProceduralTexture extends ProceduralTexture {
  119065. private _animate;
  119066. private _time;
  119067. private _config;
  119068. private _texturePath;
  119069. /**
  119070. * Instantiates a new Custom Procedural Texture.
  119071. * 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.
  119072. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119073. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119074. * @param name Define the name of the texture
  119075. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119076. * @param size Define the size of the texture to create
  119077. * @param scene Define the scene the texture belongs to
  119078. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119079. * @param generateMipMaps Define if the texture should creates mip maps or not
  119080. */
  119081. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119082. private _loadJson;
  119083. /**
  119084. * Is the texture ready to be used ? (rendered at least once)
  119085. * @returns true if ready, otherwise, false.
  119086. */
  119087. isReady(): boolean;
  119088. /**
  119089. * Render the texture to its associated render target.
  119090. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119091. */
  119092. render(useCameraPostProcess?: boolean): void;
  119093. /**
  119094. * Update the list of dependant textures samplers in the shader.
  119095. */
  119096. updateTextures(): void;
  119097. /**
  119098. * Update the uniform values of the procedural texture in the shader.
  119099. */
  119100. updateShaderUniforms(): void;
  119101. /**
  119102. * Define if the texture animates or not.
  119103. */
  119104. animate: boolean;
  119105. }
  119106. }
  119107. declare module BABYLON {
  119108. /** @hidden */
  119109. export var noisePixelShader: {
  119110. name: string;
  119111. shader: string;
  119112. };
  119113. }
  119114. declare module BABYLON {
  119115. /**
  119116. * Class used to generate noise procedural textures
  119117. */
  119118. export class NoiseProceduralTexture extends ProceduralTexture {
  119119. private _time;
  119120. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119121. brightness: number;
  119122. /** Defines the number of octaves to process */
  119123. octaves: number;
  119124. /** Defines the level of persistence (0.8 by default) */
  119125. persistence: number;
  119126. /** Gets or sets animation speed factor (default is 1) */
  119127. animationSpeedFactor: number;
  119128. /**
  119129. * Creates a new NoiseProceduralTexture
  119130. * @param name defines the name fo the texture
  119131. * @param size defines the size of the texture (default is 256)
  119132. * @param scene defines the hosting scene
  119133. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119134. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119135. */
  119136. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119137. private _updateShaderUniforms;
  119138. protected _getDefines(): string;
  119139. /** Generate the current state of the procedural texture */
  119140. render(useCameraPostProcess?: boolean): void;
  119141. /**
  119142. * Serializes this noise procedural texture
  119143. * @returns a serialized noise procedural texture object
  119144. */
  119145. serialize(): any;
  119146. /**
  119147. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119148. * @param parsedTexture defines parsed texture data
  119149. * @param scene defines the current scene
  119150. * @param rootUrl defines the root URL containing noise procedural texture information
  119151. * @returns a parsed NoiseProceduralTexture
  119152. */
  119153. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119154. }
  119155. }
  119156. declare module BABYLON {
  119157. /**
  119158. * Raw cube texture where the raw buffers are passed in
  119159. */
  119160. export class RawCubeTexture extends CubeTexture {
  119161. /**
  119162. * Creates a cube texture where the raw buffers are passed in.
  119163. * @param scene defines the scene the texture is attached to
  119164. * @param data defines the array of data to use to create each face
  119165. * @param size defines the size of the textures
  119166. * @param format defines the format of the data
  119167. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119168. * @param generateMipMaps defines if the engine should generate the mip levels
  119169. * @param invertY defines if data must be stored with Y axis inverted
  119170. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119171. * @param compression defines the compression used (null by default)
  119172. */
  119173. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119174. /**
  119175. * Updates the raw cube texture.
  119176. * @param data defines the data to store
  119177. * @param format defines the data format
  119178. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119179. * @param invertY defines if data must be stored with Y axis inverted
  119180. * @param compression defines the compression used (null by default)
  119181. * @param level defines which level of the texture to update
  119182. */
  119183. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119184. /**
  119185. * Updates a raw cube texture with RGBD encoded data.
  119186. * @param data defines the array of data [mipmap][face] to use to create each face
  119187. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119188. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119189. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119190. * @returns a promsie that resolves when the operation is complete
  119191. */
  119192. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119193. /**
  119194. * Clones the raw cube texture.
  119195. * @return a new cube texture
  119196. */
  119197. clone(): CubeTexture;
  119198. /** @hidden */
  119199. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119200. }
  119201. }
  119202. declare module BABYLON {
  119203. /**
  119204. * Class used to store 3D textures containing user data
  119205. */
  119206. export class RawTexture3D extends Texture {
  119207. /** Gets or sets the texture format to use */
  119208. format: number;
  119209. private _engine;
  119210. /**
  119211. * Create a new RawTexture3D
  119212. * @param data defines the data of the texture
  119213. * @param width defines the width of the texture
  119214. * @param height defines the height of the texture
  119215. * @param depth defines the depth of the texture
  119216. * @param format defines the texture format to use
  119217. * @param scene defines the hosting scene
  119218. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119219. * @param invertY defines if texture must be stored with Y axis inverted
  119220. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119221. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119222. */
  119223. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119224. /** Gets or sets the texture format to use */
  119225. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119226. /**
  119227. * Update the texture with new data
  119228. * @param data defines the data to store in the texture
  119229. */
  119230. update(data: ArrayBufferView): void;
  119231. }
  119232. }
  119233. declare module BABYLON {
  119234. /**
  119235. * Creates a refraction texture used by refraction channel of the standard material.
  119236. * It is like a mirror but to see through a material.
  119237. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119238. */
  119239. export class RefractionTexture extends RenderTargetTexture {
  119240. /**
  119241. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119242. * 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.
  119243. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119244. */
  119245. refractionPlane: Plane;
  119246. /**
  119247. * Define how deep under the surface we should see.
  119248. */
  119249. depth: number;
  119250. /**
  119251. * Creates a refraction texture used by refraction channel of the standard material.
  119252. * It is like a mirror but to see through a material.
  119253. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119254. * @param name Define the texture name
  119255. * @param size Define the size of the underlying texture
  119256. * @param scene Define the scene the refraction belongs to
  119257. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119258. */
  119259. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119260. /**
  119261. * Clone the refraction texture.
  119262. * @returns the cloned texture
  119263. */
  119264. clone(): RefractionTexture;
  119265. /**
  119266. * Serialize the texture to a JSON representation you could use in Parse later on
  119267. * @returns the serialized JSON representation
  119268. */
  119269. serialize(): any;
  119270. }
  119271. }
  119272. declare module BABYLON {
  119273. /**
  119274. * Defines the options related to the creation of an HtmlElementTexture
  119275. */
  119276. export interface IHtmlElementTextureOptions {
  119277. /**
  119278. * Defines wether mip maps should be created or not.
  119279. */
  119280. generateMipMaps?: boolean;
  119281. /**
  119282. * Defines the sampling mode of the texture.
  119283. */
  119284. samplingMode?: number;
  119285. /**
  119286. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119287. */
  119288. engine: Nullable<ThinEngine>;
  119289. /**
  119290. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119291. */
  119292. scene: Nullable<Scene>;
  119293. }
  119294. /**
  119295. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119296. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119297. * is automatically managed.
  119298. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119299. * in your application.
  119300. *
  119301. * As the update is not automatic, you need to call them manually.
  119302. */
  119303. export class HtmlElementTexture extends BaseTexture {
  119304. /**
  119305. * The texture URL.
  119306. */
  119307. element: HTMLVideoElement | HTMLCanvasElement;
  119308. private static readonly DefaultOptions;
  119309. private _textureMatrix;
  119310. private _engine;
  119311. private _isVideo;
  119312. private _generateMipMaps;
  119313. private _samplingMode;
  119314. /**
  119315. * Instantiates a HtmlElementTexture from the following parameters.
  119316. *
  119317. * @param name Defines the name of the texture
  119318. * @param element Defines the video or canvas the texture is filled with
  119319. * @param options Defines the other none mandatory texture creation options
  119320. */
  119321. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119322. private _createInternalTexture;
  119323. /**
  119324. * Returns the texture matrix used in most of the material.
  119325. */
  119326. getTextureMatrix(): Matrix;
  119327. /**
  119328. * Updates the content of the texture.
  119329. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119330. */
  119331. update(invertY?: Nullable<boolean>): void;
  119332. }
  119333. }
  119334. declare module BABYLON {
  119335. /**
  119336. * Enum used to define the target of a block
  119337. */
  119338. export enum NodeMaterialBlockTargets {
  119339. /** Vertex shader */
  119340. Vertex = 1,
  119341. /** Fragment shader */
  119342. Fragment = 2,
  119343. /** Neutral */
  119344. Neutral = 4,
  119345. /** Vertex and Fragment */
  119346. VertexAndFragment = 3
  119347. }
  119348. }
  119349. declare module BABYLON {
  119350. /**
  119351. * Defines the kind of connection point for node based material
  119352. */
  119353. export enum NodeMaterialBlockConnectionPointTypes {
  119354. /** Float */
  119355. Float = 1,
  119356. /** Int */
  119357. Int = 2,
  119358. /** Vector2 */
  119359. Vector2 = 4,
  119360. /** Vector3 */
  119361. Vector3 = 8,
  119362. /** Vector4 */
  119363. Vector4 = 16,
  119364. /** Color3 */
  119365. Color3 = 32,
  119366. /** Color4 */
  119367. Color4 = 64,
  119368. /** Matrix */
  119369. Matrix = 128,
  119370. /** Detect type based on connection */
  119371. AutoDetect = 1024,
  119372. /** Output type that will be defined by input type */
  119373. BasedOnInput = 2048
  119374. }
  119375. }
  119376. declare module BABYLON {
  119377. /**
  119378. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119379. */
  119380. export enum NodeMaterialBlockConnectionPointMode {
  119381. /** Value is an uniform */
  119382. Uniform = 0,
  119383. /** Value is a mesh attribute */
  119384. Attribute = 1,
  119385. /** Value is a varying between vertex and fragment shaders */
  119386. Varying = 2,
  119387. /** Mode is undefined */
  119388. Undefined = 3
  119389. }
  119390. }
  119391. declare module BABYLON {
  119392. /**
  119393. * Enum used to define system values e.g. values automatically provided by the system
  119394. */
  119395. export enum NodeMaterialSystemValues {
  119396. /** World */
  119397. World = 1,
  119398. /** View */
  119399. View = 2,
  119400. /** Projection */
  119401. Projection = 3,
  119402. /** ViewProjection */
  119403. ViewProjection = 4,
  119404. /** WorldView */
  119405. WorldView = 5,
  119406. /** WorldViewProjection */
  119407. WorldViewProjection = 6,
  119408. /** CameraPosition */
  119409. CameraPosition = 7,
  119410. /** Fog Color */
  119411. FogColor = 8,
  119412. /** Delta time */
  119413. DeltaTime = 9
  119414. }
  119415. }
  119416. declare module BABYLON {
  119417. /**
  119418. * Root class for all node material optimizers
  119419. */
  119420. export class NodeMaterialOptimizer {
  119421. /**
  119422. * Function used to optimize a NodeMaterial graph
  119423. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119424. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119425. */
  119426. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119427. }
  119428. }
  119429. declare module BABYLON {
  119430. /**
  119431. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119432. */
  119433. export class TransformBlock extends NodeMaterialBlock {
  119434. /**
  119435. * Defines the value to use to complement W value to transform it to a Vector4
  119436. */
  119437. complementW: number;
  119438. /**
  119439. * Defines the value to use to complement z value to transform it to a Vector4
  119440. */
  119441. complementZ: number;
  119442. /**
  119443. * Creates a new TransformBlock
  119444. * @param name defines the block name
  119445. */
  119446. constructor(name: string);
  119447. /**
  119448. * Gets the current class name
  119449. * @returns the class name
  119450. */
  119451. getClassName(): string;
  119452. /**
  119453. * Gets the vector input
  119454. */
  119455. readonly vector: NodeMaterialConnectionPoint;
  119456. /**
  119457. * Gets the output component
  119458. */
  119459. readonly output: NodeMaterialConnectionPoint;
  119460. /**
  119461. * Gets the matrix transform input
  119462. */
  119463. readonly transform: NodeMaterialConnectionPoint;
  119464. protected _buildBlock(state: NodeMaterialBuildState): this;
  119465. serialize(): any;
  119466. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119467. protected _dumpPropertiesCode(): string;
  119468. }
  119469. }
  119470. declare module BABYLON {
  119471. /**
  119472. * Block used to output the vertex position
  119473. */
  119474. export class VertexOutputBlock extends NodeMaterialBlock {
  119475. /**
  119476. * Creates a new VertexOutputBlock
  119477. * @param name defines the block name
  119478. */
  119479. constructor(name: string);
  119480. /**
  119481. * Gets the current class name
  119482. * @returns the class name
  119483. */
  119484. getClassName(): string;
  119485. /**
  119486. * Gets the vector input component
  119487. */
  119488. readonly vector: NodeMaterialConnectionPoint;
  119489. protected _buildBlock(state: NodeMaterialBuildState): this;
  119490. }
  119491. }
  119492. declare module BABYLON {
  119493. /**
  119494. * Block used to output the final color
  119495. */
  119496. export class FragmentOutputBlock extends NodeMaterialBlock {
  119497. /**
  119498. * Create a new FragmentOutputBlock
  119499. * @param name defines the block name
  119500. */
  119501. constructor(name: string);
  119502. /**
  119503. * Gets the current class name
  119504. * @returns the class name
  119505. */
  119506. getClassName(): string;
  119507. /**
  119508. * Gets the rgba input component
  119509. */
  119510. readonly rgba: NodeMaterialConnectionPoint;
  119511. /**
  119512. * Gets the rgb input component
  119513. */
  119514. readonly rgb: NodeMaterialConnectionPoint;
  119515. /**
  119516. * Gets the a input component
  119517. */
  119518. readonly a: NodeMaterialConnectionPoint;
  119519. protected _buildBlock(state: NodeMaterialBuildState): this;
  119520. }
  119521. }
  119522. declare module BABYLON {
  119523. /**
  119524. * Block used to read a reflection texture from a sampler
  119525. */
  119526. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119527. private _define3DName;
  119528. private _defineCubicName;
  119529. private _defineExplicitName;
  119530. private _defineProjectionName;
  119531. private _defineLocalCubicName;
  119532. private _defineSphericalName;
  119533. private _definePlanarName;
  119534. private _defineEquirectangularName;
  119535. private _defineMirroredEquirectangularFixedName;
  119536. private _defineEquirectangularFixedName;
  119537. private _defineSkyboxName;
  119538. private _cubeSamplerName;
  119539. private _2DSamplerName;
  119540. private _positionUVWName;
  119541. private _directionWName;
  119542. private _reflectionCoordsName;
  119543. private _reflection2DCoordsName;
  119544. private _reflectionColorName;
  119545. private _reflectionMatrixName;
  119546. /**
  119547. * Gets or sets the texture associated with the node
  119548. */
  119549. texture: Nullable<BaseTexture>;
  119550. /**
  119551. * Create a new TextureBlock
  119552. * @param name defines the block name
  119553. */
  119554. constructor(name: string);
  119555. /**
  119556. * Gets the current class name
  119557. * @returns the class name
  119558. */
  119559. getClassName(): string;
  119560. /**
  119561. * Gets the world position input component
  119562. */
  119563. readonly position: NodeMaterialConnectionPoint;
  119564. /**
  119565. * Gets the world position input component
  119566. */
  119567. readonly worldPosition: NodeMaterialConnectionPoint;
  119568. /**
  119569. * Gets the world normal input component
  119570. */
  119571. readonly worldNormal: NodeMaterialConnectionPoint;
  119572. /**
  119573. * Gets the world input component
  119574. */
  119575. readonly world: NodeMaterialConnectionPoint;
  119576. /**
  119577. * Gets the camera (or eye) position component
  119578. */
  119579. readonly cameraPosition: NodeMaterialConnectionPoint;
  119580. /**
  119581. * Gets the view input component
  119582. */
  119583. readonly view: NodeMaterialConnectionPoint;
  119584. /**
  119585. * Gets the rgb output component
  119586. */
  119587. readonly rgb: NodeMaterialConnectionPoint;
  119588. /**
  119589. * Gets the r output component
  119590. */
  119591. readonly r: NodeMaterialConnectionPoint;
  119592. /**
  119593. * Gets the g output component
  119594. */
  119595. readonly g: NodeMaterialConnectionPoint;
  119596. /**
  119597. * Gets the b output component
  119598. */
  119599. readonly b: NodeMaterialConnectionPoint;
  119600. autoConfigure(material: NodeMaterial): void;
  119601. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119602. isReady(): boolean;
  119603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119604. private _injectVertexCode;
  119605. private _writeOutput;
  119606. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119607. serialize(): any;
  119608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119609. }
  119610. }
  119611. declare module BABYLON {
  119612. /**
  119613. * Interface used to configure the node material editor
  119614. */
  119615. export interface INodeMaterialEditorOptions {
  119616. /** Define the URl to load node editor script */
  119617. editorURL?: string;
  119618. }
  119619. /** @hidden */
  119620. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119621. /** BONES */
  119622. NUM_BONE_INFLUENCERS: number;
  119623. BonesPerMesh: number;
  119624. BONETEXTURE: boolean;
  119625. /** MORPH TARGETS */
  119626. MORPHTARGETS: boolean;
  119627. MORPHTARGETS_NORMAL: boolean;
  119628. MORPHTARGETS_TANGENT: boolean;
  119629. MORPHTARGETS_UV: boolean;
  119630. NUM_MORPH_INFLUENCERS: number;
  119631. /** IMAGE PROCESSING */
  119632. IMAGEPROCESSING: boolean;
  119633. VIGNETTE: boolean;
  119634. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119635. VIGNETTEBLENDMODEOPAQUE: boolean;
  119636. TONEMAPPING: boolean;
  119637. TONEMAPPING_ACES: boolean;
  119638. CONTRAST: boolean;
  119639. EXPOSURE: boolean;
  119640. COLORCURVES: boolean;
  119641. COLORGRADING: boolean;
  119642. COLORGRADING3D: boolean;
  119643. SAMPLER3DGREENDEPTH: boolean;
  119644. SAMPLER3DBGRMAP: boolean;
  119645. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119646. /** MISC. */
  119647. BUMPDIRECTUV: number;
  119648. constructor();
  119649. setValue(name: string, value: boolean): void;
  119650. }
  119651. /**
  119652. * Class used to configure NodeMaterial
  119653. */
  119654. export interface INodeMaterialOptions {
  119655. /**
  119656. * Defines if blocks should emit comments
  119657. */
  119658. emitComments: boolean;
  119659. }
  119660. /**
  119661. * Class used to create a node based material built by assembling shader blocks
  119662. */
  119663. export class NodeMaterial extends PushMaterial {
  119664. private static _BuildIdGenerator;
  119665. private _options;
  119666. private _vertexCompilationState;
  119667. private _fragmentCompilationState;
  119668. private _sharedData;
  119669. private _buildId;
  119670. private _buildWasSuccessful;
  119671. private _cachedWorldViewMatrix;
  119672. private _cachedWorldViewProjectionMatrix;
  119673. private _optimizers;
  119674. private _animationFrame;
  119675. /** Define the URl to load node editor script */
  119676. static EditorURL: string;
  119677. private BJSNODEMATERIALEDITOR;
  119678. /** Get the inspector from bundle or global */
  119679. private _getGlobalNodeMaterialEditor;
  119680. /**
  119681. * 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)
  119682. */
  119683. ignoreAlpha: boolean;
  119684. /**
  119685. * Defines the maximum number of lights that can be used in the material
  119686. */
  119687. maxSimultaneousLights: number;
  119688. /**
  119689. * Observable raised when the material is built
  119690. */
  119691. onBuildObservable: Observable<NodeMaterial>;
  119692. /**
  119693. * Gets or sets the root nodes of the material vertex shader
  119694. */
  119695. _vertexOutputNodes: NodeMaterialBlock[];
  119696. /**
  119697. * Gets or sets the root nodes of the material fragment (pixel) shader
  119698. */
  119699. _fragmentOutputNodes: NodeMaterialBlock[];
  119700. /** Gets or sets options to control the node material overall behavior */
  119701. options: INodeMaterialOptions;
  119702. /**
  119703. * Default configuration related to image processing available in the standard Material.
  119704. */
  119705. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119706. /**
  119707. * Gets the image processing configuration used either in this material.
  119708. */
  119709. /**
  119710. * Sets the Default image processing configuration used either in the this material.
  119711. *
  119712. * If sets to null, the scene one is in use.
  119713. */
  119714. imageProcessingConfiguration: ImageProcessingConfiguration;
  119715. /**
  119716. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119717. */
  119718. attachedBlocks: NodeMaterialBlock[];
  119719. /**
  119720. * Create a new node based material
  119721. * @param name defines the material name
  119722. * @param scene defines the hosting scene
  119723. * @param options defines creation option
  119724. */
  119725. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119726. /**
  119727. * Gets the current class name of the material e.g. "NodeMaterial"
  119728. * @returns the class name
  119729. */
  119730. getClassName(): string;
  119731. /**
  119732. * Keep track of the image processing observer to allow dispose and replace.
  119733. */
  119734. private _imageProcessingObserver;
  119735. /**
  119736. * Attaches a new image processing configuration to the Standard Material.
  119737. * @param configuration
  119738. */
  119739. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119740. /**
  119741. * Get a block by its name
  119742. * @param name defines the name of the block to retrieve
  119743. * @returns the required block or null if not found
  119744. */
  119745. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119746. /**
  119747. * Get a block by its name
  119748. * @param predicate defines the predicate used to find the good candidate
  119749. * @returns the required block or null if not found
  119750. */
  119751. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119752. /**
  119753. * Get an input block by its name
  119754. * @param predicate defines the predicate used to find the good candidate
  119755. * @returns the required input block or null if not found
  119756. */
  119757. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119758. /**
  119759. * Gets the list of input blocks attached to this material
  119760. * @returns an array of InputBlocks
  119761. */
  119762. getInputBlocks(): InputBlock[];
  119763. /**
  119764. * Adds a new optimizer to the list of optimizers
  119765. * @param optimizer defines the optimizers to add
  119766. * @returns the current material
  119767. */
  119768. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119769. /**
  119770. * Remove an optimizer from the list of optimizers
  119771. * @param optimizer defines the optimizers to remove
  119772. * @returns the current material
  119773. */
  119774. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119775. /**
  119776. * Add a new block to the list of output nodes
  119777. * @param node defines the node to add
  119778. * @returns the current material
  119779. */
  119780. addOutputNode(node: NodeMaterialBlock): this;
  119781. /**
  119782. * Remove a block from the list of root nodes
  119783. * @param node defines the node to remove
  119784. * @returns the current material
  119785. */
  119786. removeOutputNode(node: NodeMaterialBlock): this;
  119787. private _addVertexOutputNode;
  119788. private _removeVertexOutputNode;
  119789. private _addFragmentOutputNode;
  119790. private _removeFragmentOutputNode;
  119791. /**
  119792. * Specifies if the material will require alpha blending
  119793. * @returns a boolean specifying if alpha blending is needed
  119794. */
  119795. needAlphaBlending(): boolean;
  119796. /**
  119797. * Specifies if this material should be rendered in alpha test mode
  119798. * @returns a boolean specifying if an alpha test is needed.
  119799. */
  119800. needAlphaTesting(): boolean;
  119801. private _initializeBlock;
  119802. private _resetDualBlocks;
  119803. /**
  119804. * Build the material and generates the inner effect
  119805. * @param verbose defines if the build should log activity
  119806. */
  119807. build(verbose?: boolean): void;
  119808. /**
  119809. * Runs an otpimization phase to try to improve the shader code
  119810. */
  119811. optimize(): void;
  119812. private _prepareDefinesForAttributes;
  119813. /**
  119814. * Get if the submesh is ready to be used and all its information available.
  119815. * Child classes can use it to update shaders
  119816. * @param mesh defines the mesh to check
  119817. * @param subMesh defines which submesh to check
  119818. * @param useInstances specifies that instances should be used
  119819. * @returns a boolean indicating that the submesh is ready or not
  119820. */
  119821. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119822. /**
  119823. * Get a string representing the shaders built by the current node graph
  119824. */
  119825. readonly compiledShaders: string;
  119826. /**
  119827. * Binds the world matrix to the material
  119828. * @param world defines the world transformation matrix
  119829. */
  119830. bindOnlyWorldMatrix(world: Matrix): void;
  119831. /**
  119832. * Binds the submesh to this material by preparing the effect and shader to draw
  119833. * @param world defines the world transformation matrix
  119834. * @param mesh defines the mesh containing the submesh
  119835. * @param subMesh defines the submesh to bind the material to
  119836. */
  119837. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119838. /**
  119839. * Gets the active textures from the material
  119840. * @returns an array of textures
  119841. */
  119842. getActiveTextures(): BaseTexture[];
  119843. /**
  119844. * Gets the list of texture blocks
  119845. * @returns an array of texture blocks
  119846. */
  119847. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119848. /**
  119849. * Specifies if the material uses a texture
  119850. * @param texture defines the texture to check against the material
  119851. * @returns a boolean specifying if the material uses the texture
  119852. */
  119853. hasTexture(texture: BaseTexture): boolean;
  119854. /**
  119855. * Disposes the material
  119856. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119857. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119858. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119859. */
  119860. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119861. /** Creates the node editor window. */
  119862. private _createNodeEditor;
  119863. /**
  119864. * Launch the node material editor
  119865. * @param config Define the configuration of the editor
  119866. * @return a promise fulfilled when the node editor is visible
  119867. */
  119868. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119869. /**
  119870. * Clear the current material
  119871. */
  119872. clear(): void;
  119873. /**
  119874. * Clear the current material and set it to a default state
  119875. */
  119876. setToDefault(): void;
  119877. /**
  119878. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119879. * @param url defines the url to load from
  119880. * @returns a promise that will fullfil when the material is fully loaded
  119881. */
  119882. loadAsync(url: string): Promise<unknown>;
  119883. private _gatherBlocks;
  119884. /**
  119885. * Generate a string containing the code declaration required to create an equivalent of this material
  119886. * @returns a string
  119887. */
  119888. generateCode(): string;
  119889. /**
  119890. * Serializes this material in a JSON representation
  119891. * @returns the serialized material object
  119892. */
  119893. serialize(): any;
  119894. private _restoreConnections;
  119895. /**
  119896. * Clear the current graph and load a new one from a serialization object
  119897. * @param source defines the JSON representation of the material
  119898. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119899. */
  119900. loadFromSerialization(source: any, rootUrl?: string): void;
  119901. /**
  119902. * Creates a node material from parsed material data
  119903. * @param source defines the JSON representation of the material
  119904. * @param scene defines the hosting scene
  119905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119906. * @returns a new node material
  119907. */
  119908. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119909. /**
  119910. * Creates a new node material set to default basic configuration
  119911. * @param name defines the name of the material
  119912. * @param scene defines the hosting scene
  119913. * @returns a new NodeMaterial
  119914. */
  119915. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119916. }
  119917. }
  119918. declare module BABYLON {
  119919. /**
  119920. * Block used to read a texture from a sampler
  119921. */
  119922. export class TextureBlock extends NodeMaterialBlock {
  119923. private _defineName;
  119924. private _linearDefineName;
  119925. private _samplerName;
  119926. private _transformedUVName;
  119927. private _textureTransformName;
  119928. private _textureInfoName;
  119929. private _mainUVName;
  119930. private _mainUVDefineName;
  119931. /**
  119932. * Gets or sets the texture associated with the node
  119933. */
  119934. texture: Nullable<Texture>;
  119935. /**
  119936. * Create a new TextureBlock
  119937. * @param name defines the block name
  119938. */
  119939. constructor(name: string);
  119940. /**
  119941. * Gets the current class name
  119942. * @returns the class name
  119943. */
  119944. getClassName(): string;
  119945. /**
  119946. * Gets the uv input component
  119947. */
  119948. readonly uv: NodeMaterialConnectionPoint;
  119949. /**
  119950. * Gets the rgba output component
  119951. */
  119952. readonly rgba: NodeMaterialConnectionPoint;
  119953. /**
  119954. * Gets the rgb output component
  119955. */
  119956. readonly rgb: NodeMaterialConnectionPoint;
  119957. /**
  119958. * Gets the r output component
  119959. */
  119960. readonly r: NodeMaterialConnectionPoint;
  119961. /**
  119962. * Gets the g output component
  119963. */
  119964. readonly g: NodeMaterialConnectionPoint;
  119965. /**
  119966. * Gets the b output component
  119967. */
  119968. readonly b: NodeMaterialConnectionPoint;
  119969. /**
  119970. * Gets the a output component
  119971. */
  119972. readonly a: NodeMaterialConnectionPoint;
  119973. readonly target: NodeMaterialBlockTargets;
  119974. autoConfigure(material: NodeMaterial): void;
  119975. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119977. isReady(): boolean;
  119978. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119979. private readonly _isMixed;
  119980. private _injectVertexCode;
  119981. private _writeOutput;
  119982. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119983. protected _dumpPropertiesCode(): string;
  119984. serialize(): any;
  119985. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119986. }
  119987. }
  119988. declare module BABYLON {
  119989. /**
  119990. * Class used to store shared data between 2 NodeMaterialBuildState
  119991. */
  119992. export class NodeMaterialBuildStateSharedData {
  119993. /**
  119994. * Gets the list of emitted varyings
  119995. */
  119996. temps: string[];
  119997. /**
  119998. * Gets the list of emitted varyings
  119999. */
  120000. varyings: string[];
  120001. /**
  120002. * Gets the varying declaration string
  120003. */
  120004. varyingDeclaration: string;
  120005. /**
  120006. * Input blocks
  120007. */
  120008. inputBlocks: InputBlock[];
  120009. /**
  120010. * Input blocks
  120011. */
  120012. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120013. /**
  120014. * Bindable blocks (Blocks that need to set data to the effect)
  120015. */
  120016. bindableBlocks: NodeMaterialBlock[];
  120017. /**
  120018. * List of blocks that can provide a compilation fallback
  120019. */
  120020. blocksWithFallbacks: NodeMaterialBlock[];
  120021. /**
  120022. * List of blocks that can provide a define update
  120023. */
  120024. blocksWithDefines: NodeMaterialBlock[];
  120025. /**
  120026. * List of blocks that can provide a repeatable content
  120027. */
  120028. repeatableContentBlocks: NodeMaterialBlock[];
  120029. /**
  120030. * List of blocks that can provide a dynamic list of uniforms
  120031. */
  120032. dynamicUniformBlocks: NodeMaterialBlock[];
  120033. /**
  120034. * List of blocks that can block the isReady function for the material
  120035. */
  120036. blockingBlocks: NodeMaterialBlock[];
  120037. /**
  120038. * Gets the list of animated inputs
  120039. */
  120040. animatedInputs: InputBlock[];
  120041. /**
  120042. * Build Id used to avoid multiple recompilations
  120043. */
  120044. buildId: number;
  120045. /** List of emitted variables */
  120046. variableNames: {
  120047. [key: string]: number;
  120048. };
  120049. /** List of emitted defines */
  120050. defineNames: {
  120051. [key: string]: number;
  120052. };
  120053. /** Should emit comments? */
  120054. emitComments: boolean;
  120055. /** Emit build activity */
  120056. verbose: boolean;
  120057. /** Gets or sets the hosting scene */
  120058. scene: Scene;
  120059. /**
  120060. * Gets the compilation hints emitted at compilation time
  120061. */
  120062. hints: {
  120063. needWorldViewMatrix: boolean;
  120064. needWorldViewProjectionMatrix: boolean;
  120065. needAlphaBlending: boolean;
  120066. needAlphaTesting: boolean;
  120067. };
  120068. /**
  120069. * List of compilation checks
  120070. */
  120071. checks: {
  120072. emitVertex: boolean;
  120073. emitFragment: boolean;
  120074. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120075. };
  120076. /** Creates a new shared data */
  120077. constructor();
  120078. /**
  120079. * Emits console errors and exceptions if there is a failing check
  120080. */
  120081. emitErrors(): void;
  120082. }
  120083. }
  120084. declare module BABYLON {
  120085. /**
  120086. * Class used to store node based material build state
  120087. */
  120088. export class NodeMaterialBuildState {
  120089. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120090. supportUniformBuffers: boolean;
  120091. /**
  120092. * Gets the list of emitted attributes
  120093. */
  120094. attributes: string[];
  120095. /**
  120096. * Gets the list of emitted uniforms
  120097. */
  120098. uniforms: string[];
  120099. /**
  120100. * Gets the list of emitted constants
  120101. */
  120102. constants: string[];
  120103. /**
  120104. * Gets the list of emitted uniform buffers
  120105. */
  120106. uniformBuffers: string[];
  120107. /**
  120108. * Gets the list of emitted samplers
  120109. */
  120110. samplers: string[];
  120111. /**
  120112. * Gets the list of emitted functions
  120113. */
  120114. functions: {
  120115. [key: string]: string;
  120116. };
  120117. /**
  120118. * Gets the list of emitted extensions
  120119. */
  120120. extensions: {
  120121. [key: string]: string;
  120122. };
  120123. /**
  120124. * Gets the target of the compilation state
  120125. */
  120126. target: NodeMaterialBlockTargets;
  120127. /**
  120128. * Gets the list of emitted counters
  120129. */
  120130. counters: {
  120131. [key: string]: number;
  120132. };
  120133. /**
  120134. * Shared data between multiple NodeMaterialBuildState instances
  120135. */
  120136. sharedData: NodeMaterialBuildStateSharedData;
  120137. /** @hidden */
  120138. _vertexState: NodeMaterialBuildState;
  120139. /** @hidden */
  120140. _attributeDeclaration: string;
  120141. /** @hidden */
  120142. _uniformDeclaration: string;
  120143. /** @hidden */
  120144. _constantDeclaration: string;
  120145. /** @hidden */
  120146. _samplerDeclaration: string;
  120147. /** @hidden */
  120148. _varyingTransfer: string;
  120149. private _repeatableContentAnchorIndex;
  120150. /** @hidden */
  120151. _builtCompilationString: string;
  120152. /**
  120153. * Gets the emitted compilation strings
  120154. */
  120155. compilationString: string;
  120156. /**
  120157. * Finalize the compilation strings
  120158. * @param state defines the current compilation state
  120159. */
  120160. finalize(state: NodeMaterialBuildState): void;
  120161. /** @hidden */
  120162. readonly _repeatableContentAnchor: string;
  120163. /** @hidden */
  120164. _getFreeVariableName(prefix: string): string;
  120165. /** @hidden */
  120166. _getFreeDefineName(prefix: string): string;
  120167. /** @hidden */
  120168. _excludeVariableName(name: string): void;
  120169. /** @hidden */
  120170. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120171. /** @hidden */
  120172. _emitExtension(name: string, extension: string): void;
  120173. /** @hidden */
  120174. _emitFunction(name: string, code: string, comments: string): void;
  120175. /** @hidden */
  120176. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120177. replaceStrings?: {
  120178. search: RegExp;
  120179. replace: string;
  120180. }[];
  120181. repeatKey?: string;
  120182. }): string;
  120183. /** @hidden */
  120184. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120185. repeatKey?: string;
  120186. removeAttributes?: boolean;
  120187. removeUniforms?: boolean;
  120188. removeVaryings?: boolean;
  120189. removeIfDef?: boolean;
  120190. replaceStrings?: {
  120191. search: RegExp;
  120192. replace: string;
  120193. }[];
  120194. }, storeKey?: string): void;
  120195. /** @hidden */
  120196. _registerTempVariable(name: string): boolean;
  120197. /** @hidden */
  120198. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120199. /** @hidden */
  120200. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120201. /** @hidden */
  120202. _emitFloat(value: number): string;
  120203. }
  120204. }
  120205. declare module BABYLON {
  120206. /**
  120207. * Defines a block that can be used inside a node based material
  120208. */
  120209. export class NodeMaterialBlock {
  120210. private _buildId;
  120211. private _buildTarget;
  120212. private _target;
  120213. private _isFinalMerger;
  120214. private _isInput;
  120215. /** @hidden */
  120216. _codeVariableName: string;
  120217. /** @hidden */
  120218. _inputs: NodeMaterialConnectionPoint[];
  120219. /** @hidden */
  120220. _outputs: NodeMaterialConnectionPoint[];
  120221. /** @hidden */
  120222. _preparationId: number;
  120223. /**
  120224. * Gets or sets the name of the block
  120225. */
  120226. name: string;
  120227. /**
  120228. * Gets or sets the unique id of the node
  120229. */
  120230. uniqueId: number;
  120231. /**
  120232. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120233. */
  120234. readonly isFinalMerger: boolean;
  120235. /**
  120236. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120237. */
  120238. readonly isInput: boolean;
  120239. /**
  120240. * Gets or sets the build Id
  120241. */
  120242. buildId: number;
  120243. /**
  120244. * Gets or sets the target of the block
  120245. */
  120246. target: NodeMaterialBlockTargets;
  120247. /**
  120248. * Gets the list of input points
  120249. */
  120250. readonly inputs: NodeMaterialConnectionPoint[];
  120251. /** Gets the list of output points */
  120252. readonly outputs: NodeMaterialConnectionPoint[];
  120253. /**
  120254. * Find an input by its name
  120255. * @param name defines the name of the input to look for
  120256. * @returns the input or null if not found
  120257. */
  120258. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120259. /**
  120260. * Find an output by its name
  120261. * @param name defines the name of the outputto look for
  120262. * @returns the output or null if not found
  120263. */
  120264. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120265. /**
  120266. * Creates a new NodeMaterialBlock
  120267. * @param name defines the block name
  120268. * @param target defines the target of that block (Vertex by default)
  120269. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120270. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120271. */
  120272. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120273. /**
  120274. * Initialize the block and prepare the context for build
  120275. * @param state defines the state that will be used for the build
  120276. */
  120277. initialize(state: NodeMaterialBuildState): void;
  120278. /**
  120279. * Bind data to effect. Will only be called for blocks with isBindable === true
  120280. * @param effect defines the effect to bind data to
  120281. * @param nodeMaterial defines the hosting NodeMaterial
  120282. * @param mesh defines the mesh that will be rendered
  120283. */
  120284. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120285. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120286. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120287. protected _writeFloat(value: number): string;
  120288. /**
  120289. * Gets the current class name e.g. "NodeMaterialBlock"
  120290. * @returns the class name
  120291. */
  120292. getClassName(): string;
  120293. /**
  120294. * Register a new input. Must be called inside a block constructor
  120295. * @param name defines the connection point name
  120296. * @param type defines the connection point type
  120297. * @param isOptional defines a boolean indicating that this input can be omitted
  120298. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120299. * @returns the current block
  120300. */
  120301. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120302. /**
  120303. * Register a new output. Must be called inside a block constructor
  120304. * @param name defines the connection point name
  120305. * @param type defines the connection point type
  120306. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120307. * @returns the current block
  120308. */
  120309. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120310. /**
  120311. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120312. * @param forOutput defines an optional connection point to check compatibility with
  120313. * @returns the first available input or null
  120314. */
  120315. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120316. /**
  120317. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120318. * @param forBlock defines an optional block to check compatibility with
  120319. * @returns the first available input or null
  120320. */
  120321. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120322. /**
  120323. * Gets the sibling of the given output
  120324. * @param current defines the current output
  120325. * @returns the next output in the list or null
  120326. */
  120327. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120328. /**
  120329. * Connect current block with another block
  120330. * @param other defines the block to connect with
  120331. * @param options define the various options to help pick the right connections
  120332. * @returns the current block
  120333. */
  120334. connectTo(other: NodeMaterialBlock, options?: {
  120335. input?: string;
  120336. output?: string;
  120337. outputSwizzle?: string;
  120338. }): this | undefined;
  120339. protected _buildBlock(state: NodeMaterialBuildState): void;
  120340. /**
  120341. * Add uniforms, samplers and uniform buffers at compilation time
  120342. * @param state defines the state to update
  120343. * @param nodeMaterial defines the node material requesting the update
  120344. * @param defines defines the material defines to update
  120345. */
  120346. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120347. /**
  120348. * Add potential fallbacks if shader compilation fails
  120349. * @param mesh defines the mesh to be rendered
  120350. * @param fallbacks defines the current prioritized list of fallbacks
  120351. */
  120352. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120353. /**
  120354. * Initialize defines for shader compilation
  120355. * @param mesh defines the mesh to be rendered
  120356. * @param nodeMaterial defines the node material requesting the update
  120357. * @param defines defines the material defines to update
  120358. * @param useInstances specifies that instances should be used
  120359. */
  120360. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120361. /**
  120362. * Update defines for shader compilation
  120363. * @param mesh defines the mesh to be rendered
  120364. * @param nodeMaterial defines the node material requesting the update
  120365. * @param defines defines the material defines to update
  120366. * @param useInstances specifies that instances should be used
  120367. */
  120368. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120369. /**
  120370. * Lets the block try to connect some inputs automatically
  120371. * @param material defines the hosting NodeMaterial
  120372. */
  120373. autoConfigure(material: NodeMaterial): void;
  120374. /**
  120375. * Function called when a block is declared as repeatable content generator
  120376. * @param vertexShaderState defines the current compilation state for the vertex shader
  120377. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120378. * @param mesh defines the mesh to be rendered
  120379. * @param defines defines the material defines to update
  120380. */
  120381. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120382. /**
  120383. * Checks if the block is ready
  120384. * @param mesh defines the mesh to be rendered
  120385. * @param nodeMaterial defines the node material requesting the update
  120386. * @param defines defines the material defines to update
  120387. * @param useInstances specifies that instances should be used
  120388. * @returns true if the block is ready
  120389. */
  120390. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120391. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120392. private _processBuild;
  120393. /**
  120394. * Compile the current node and generate the shader code
  120395. * @param state defines the current compilation state (uniforms, samplers, current string)
  120396. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120397. * @returns true if already built
  120398. */
  120399. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120400. protected _inputRename(name: string): string;
  120401. protected _outputRename(name: string): string;
  120402. protected _dumpPropertiesCode(): string;
  120403. /** @hidden */
  120404. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120405. /**
  120406. * Clone the current block to a new identical block
  120407. * @param scene defines the hosting scene
  120408. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120409. * @returns a copy of the current block
  120410. */
  120411. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120412. /**
  120413. * Serializes this block in a JSON representation
  120414. * @returns the serialized block object
  120415. */
  120416. serialize(): any;
  120417. /** @hidden */
  120418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120419. }
  120420. }
  120421. declare module BABYLON {
  120422. /**
  120423. * Enum defining the type of animations supported by InputBlock
  120424. */
  120425. export enum AnimatedInputBlockTypes {
  120426. /** No animation */
  120427. None = 0,
  120428. /** Time based animation. Will only work for floats */
  120429. Time = 1
  120430. }
  120431. }
  120432. declare module BABYLON {
  120433. /**
  120434. * Block used to expose an input value
  120435. */
  120436. export class InputBlock extends NodeMaterialBlock {
  120437. private _mode;
  120438. private _associatedVariableName;
  120439. private _storedValue;
  120440. private _valueCallback;
  120441. private _type;
  120442. private _animationType;
  120443. /** Gets or set a value used to limit the range of float values */
  120444. min: number;
  120445. /** Gets or set a value used to limit the range of float values */
  120446. max: number;
  120447. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120448. matrixMode: number;
  120449. /** @hidden */
  120450. _systemValue: Nullable<NodeMaterialSystemValues>;
  120451. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120452. visibleInInspector: boolean;
  120453. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120454. isConstant: boolean;
  120455. /**
  120456. * Gets or sets the connection point type (default is float)
  120457. */
  120458. readonly type: NodeMaterialBlockConnectionPointTypes;
  120459. /**
  120460. * Creates a new InputBlock
  120461. * @param name defines the block name
  120462. * @param target defines the target of that block (Vertex by default)
  120463. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120464. */
  120465. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120466. /**
  120467. * Gets the output component
  120468. */
  120469. readonly output: NodeMaterialConnectionPoint;
  120470. /**
  120471. * Set the source of this connection point to a vertex attribute
  120472. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120473. * @returns the current connection point
  120474. */
  120475. setAsAttribute(attributeName?: string): InputBlock;
  120476. /**
  120477. * Set the source of this connection point to a system value
  120478. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120479. * @returns the current connection point
  120480. */
  120481. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120482. /**
  120483. * Gets or sets the value of that point.
  120484. * Please note that this value will be ignored if valueCallback is defined
  120485. */
  120486. value: any;
  120487. /**
  120488. * Gets or sets a callback used to get the value of that point.
  120489. * Please note that setting this value will force the connection point to ignore the value property
  120490. */
  120491. valueCallback: () => any;
  120492. /**
  120493. * Gets or sets the associated variable name in the shader
  120494. */
  120495. associatedVariableName: string;
  120496. /** Gets or sets the type of animation applied to the input */
  120497. animationType: AnimatedInputBlockTypes;
  120498. /**
  120499. * Gets a boolean indicating that this connection point not defined yet
  120500. */
  120501. readonly isUndefined: boolean;
  120502. /**
  120503. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120504. * In this case the connection point name must be the name of the uniform to use.
  120505. * Can only be set on inputs
  120506. */
  120507. isUniform: boolean;
  120508. /**
  120509. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120510. * In this case the connection point name must be the name of the attribute to use
  120511. * Can only be set on inputs
  120512. */
  120513. isAttribute: boolean;
  120514. /**
  120515. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120516. * Can only be set on exit points
  120517. */
  120518. isVarying: boolean;
  120519. /**
  120520. * Gets a boolean indicating that the current connection point is a system value
  120521. */
  120522. readonly isSystemValue: boolean;
  120523. /**
  120524. * Gets or sets the current well known value or null if not defined as a system value
  120525. */
  120526. systemValue: Nullable<NodeMaterialSystemValues>;
  120527. /**
  120528. * Gets the current class name
  120529. * @returns the class name
  120530. */
  120531. getClassName(): string;
  120532. /**
  120533. * Animate the input if animationType !== None
  120534. * @param scene defines the rendering scene
  120535. */
  120536. animate(scene: Scene): void;
  120537. private _emitDefine;
  120538. initialize(state: NodeMaterialBuildState): void;
  120539. /**
  120540. * Set the input block to its default value (based on its type)
  120541. */
  120542. setDefaultValue(): void;
  120543. private _emitConstant;
  120544. private _emit;
  120545. /** @hidden */
  120546. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120547. /** @hidden */
  120548. _transmit(effect: Effect, scene: Scene): void;
  120549. protected _buildBlock(state: NodeMaterialBuildState): void;
  120550. protected _dumpPropertiesCode(): string;
  120551. serialize(): any;
  120552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120553. }
  120554. }
  120555. declare module BABYLON {
  120556. /**
  120557. * Defines a connection point for a block
  120558. */
  120559. export class NodeMaterialConnectionPoint {
  120560. /** @hidden */
  120561. _ownerBlock: NodeMaterialBlock;
  120562. /** @hidden */
  120563. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120564. private _endpoints;
  120565. private _associatedVariableName;
  120566. /** @hidden */
  120567. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120568. /** @hidden */
  120569. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120570. private _type;
  120571. /** @hidden */
  120572. _enforceAssociatedVariableName: boolean;
  120573. /**
  120574. * Gets or sets the additional types supported by this connection point
  120575. */
  120576. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120577. /**
  120578. * Gets or sets the additional types excluded by this connection point
  120579. */
  120580. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120581. /**
  120582. * Gets or sets the associated variable name in the shader
  120583. */
  120584. associatedVariableName: string;
  120585. /**
  120586. * Gets or sets the connection point type (default is float)
  120587. */
  120588. type: NodeMaterialBlockConnectionPointTypes;
  120589. /**
  120590. * Gets or sets the connection point name
  120591. */
  120592. name: string;
  120593. /**
  120594. * Gets or sets a boolean indicating that this connection point can be omitted
  120595. */
  120596. isOptional: boolean;
  120597. /**
  120598. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120599. */
  120600. define: string;
  120601. /** Gets or sets the target of that connection point */
  120602. target: NodeMaterialBlockTargets;
  120603. /**
  120604. * Gets a boolean indicating that the current point is connected
  120605. */
  120606. readonly isConnected: boolean;
  120607. /**
  120608. * Gets a boolean indicating that the current point is connected to an input block
  120609. */
  120610. readonly isConnectedToInputBlock: boolean;
  120611. /**
  120612. * Gets a the connected input block (if any)
  120613. */
  120614. readonly connectInputBlock: Nullable<InputBlock>;
  120615. /** Get the other side of the connection (if any) */
  120616. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120617. /** Get the block that owns this connection point */
  120618. readonly ownerBlock: NodeMaterialBlock;
  120619. /** Get the block connected on the other side of this connection (if any) */
  120620. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120621. /** Get the block connected on the endpoints of this connection (if any) */
  120622. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120623. /** Gets the list of connected endpoints */
  120624. readonly endpoints: NodeMaterialConnectionPoint[];
  120625. /** Gets a boolean indicating if that output point is connected to at least one input */
  120626. readonly hasEndpoints: boolean;
  120627. /**
  120628. * Creates a new connection point
  120629. * @param name defines the connection point name
  120630. * @param ownerBlock defines the block hosting this connection point
  120631. */
  120632. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120633. /**
  120634. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120635. * @returns the class name
  120636. */
  120637. getClassName(): string;
  120638. /**
  120639. * Gets an boolean indicating if the current point can be connected to another point
  120640. * @param connectionPoint defines the other connection point
  120641. * @returns true if the connection is possible
  120642. */
  120643. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120644. /**
  120645. * Connect this point to another connection point
  120646. * @param connectionPoint defines the other connection point
  120647. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120648. * @returns the current connection point
  120649. */
  120650. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120651. /**
  120652. * Disconnect this point from one of his endpoint
  120653. * @param endpoint defines the other connection point
  120654. * @returns the current connection point
  120655. */
  120656. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120657. /**
  120658. * Serializes this point in a JSON representation
  120659. * @returns the serialized point object
  120660. */
  120661. serialize(): any;
  120662. }
  120663. }
  120664. declare module BABYLON {
  120665. /**
  120666. * Block used to add support for vertex skinning (bones)
  120667. */
  120668. export class BonesBlock extends NodeMaterialBlock {
  120669. /**
  120670. * Creates a new BonesBlock
  120671. * @param name defines the block name
  120672. */
  120673. constructor(name: string);
  120674. /**
  120675. * Initialize the block and prepare the context for build
  120676. * @param state defines the state that will be used for the build
  120677. */
  120678. initialize(state: NodeMaterialBuildState): void;
  120679. /**
  120680. * Gets the current class name
  120681. * @returns the class name
  120682. */
  120683. getClassName(): string;
  120684. /**
  120685. * Gets the matrix indices input component
  120686. */
  120687. readonly matricesIndices: NodeMaterialConnectionPoint;
  120688. /**
  120689. * Gets the matrix weights input component
  120690. */
  120691. readonly matricesWeights: NodeMaterialConnectionPoint;
  120692. /**
  120693. * Gets the extra matrix indices input component
  120694. */
  120695. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120696. /**
  120697. * Gets the extra matrix weights input component
  120698. */
  120699. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120700. /**
  120701. * Gets the world input component
  120702. */
  120703. readonly world: NodeMaterialConnectionPoint;
  120704. /**
  120705. * Gets the output component
  120706. */
  120707. readonly output: NodeMaterialConnectionPoint;
  120708. autoConfigure(material: NodeMaterial): void;
  120709. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120710. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120711. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120712. protected _buildBlock(state: NodeMaterialBuildState): this;
  120713. }
  120714. }
  120715. declare module BABYLON {
  120716. /**
  120717. * Block used to add support for instances
  120718. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120719. */
  120720. export class InstancesBlock extends NodeMaterialBlock {
  120721. /**
  120722. * Creates a new InstancesBlock
  120723. * @param name defines the block name
  120724. */
  120725. constructor(name: string);
  120726. /**
  120727. * Gets the current class name
  120728. * @returns the class name
  120729. */
  120730. getClassName(): string;
  120731. /**
  120732. * Gets the first world row input component
  120733. */
  120734. readonly world0: NodeMaterialConnectionPoint;
  120735. /**
  120736. * Gets the second world row input component
  120737. */
  120738. readonly world1: NodeMaterialConnectionPoint;
  120739. /**
  120740. * Gets the third world row input component
  120741. */
  120742. readonly world2: NodeMaterialConnectionPoint;
  120743. /**
  120744. * Gets the forth world row input component
  120745. */
  120746. readonly world3: NodeMaterialConnectionPoint;
  120747. /**
  120748. * Gets the world input component
  120749. */
  120750. readonly world: NodeMaterialConnectionPoint;
  120751. /**
  120752. * Gets the output component
  120753. */
  120754. readonly output: NodeMaterialConnectionPoint;
  120755. autoConfigure(material: NodeMaterial): void;
  120756. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120757. protected _buildBlock(state: NodeMaterialBuildState): this;
  120758. }
  120759. }
  120760. declare module BABYLON {
  120761. /**
  120762. * Block used to add morph targets support to vertex shader
  120763. */
  120764. export class MorphTargetsBlock extends NodeMaterialBlock {
  120765. private _repeatableContentAnchor;
  120766. private _repeatebleContentGenerated;
  120767. /**
  120768. * Create a new MorphTargetsBlock
  120769. * @param name defines the block name
  120770. */
  120771. constructor(name: string);
  120772. /**
  120773. * Gets the current class name
  120774. * @returns the class name
  120775. */
  120776. getClassName(): string;
  120777. /**
  120778. * Gets the position input component
  120779. */
  120780. readonly position: NodeMaterialConnectionPoint;
  120781. /**
  120782. * Gets the normal input component
  120783. */
  120784. readonly normal: NodeMaterialConnectionPoint;
  120785. /**
  120786. * Gets the tangent input component
  120787. */
  120788. readonly tangent: NodeMaterialConnectionPoint;
  120789. /**
  120790. * Gets the tangent input component
  120791. */
  120792. readonly uv: NodeMaterialConnectionPoint;
  120793. /**
  120794. * Gets the position output component
  120795. */
  120796. readonly positionOutput: NodeMaterialConnectionPoint;
  120797. /**
  120798. * Gets the normal output component
  120799. */
  120800. readonly normalOutput: NodeMaterialConnectionPoint;
  120801. /**
  120802. * Gets the tangent output component
  120803. */
  120804. readonly tangentOutput: NodeMaterialConnectionPoint;
  120805. /**
  120806. * Gets the tangent output component
  120807. */
  120808. readonly uvOutput: NodeMaterialConnectionPoint;
  120809. initialize(state: NodeMaterialBuildState): void;
  120810. autoConfigure(material: NodeMaterial): void;
  120811. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120812. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120813. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120814. protected _buildBlock(state: NodeMaterialBuildState): this;
  120815. }
  120816. }
  120817. declare module BABYLON {
  120818. /**
  120819. * Block used to get data information from a light
  120820. */
  120821. export class LightInformationBlock extends NodeMaterialBlock {
  120822. private _lightDataUniformName;
  120823. private _lightColorUniformName;
  120824. private _lightTypeDefineName;
  120825. /**
  120826. * Gets or sets the light associated with this block
  120827. */
  120828. light: Nullable<Light>;
  120829. /**
  120830. * Creates a new LightInformationBlock
  120831. * @param name defines the block name
  120832. */
  120833. constructor(name: string);
  120834. /**
  120835. * Gets the current class name
  120836. * @returns the class name
  120837. */
  120838. getClassName(): string;
  120839. /**
  120840. * Gets the world position input component
  120841. */
  120842. readonly worldPosition: NodeMaterialConnectionPoint;
  120843. /**
  120844. * Gets the direction output component
  120845. */
  120846. readonly direction: NodeMaterialConnectionPoint;
  120847. /**
  120848. * Gets the direction output component
  120849. */
  120850. readonly color: NodeMaterialConnectionPoint;
  120851. /**
  120852. * Gets the direction output component
  120853. */
  120854. readonly intensity: NodeMaterialConnectionPoint;
  120855. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120856. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120857. protected _buildBlock(state: NodeMaterialBuildState): this;
  120858. serialize(): any;
  120859. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120860. }
  120861. }
  120862. declare module BABYLON {
  120863. /**
  120864. * Block used to add image processing support to fragment shader
  120865. */
  120866. export class ImageProcessingBlock extends NodeMaterialBlock {
  120867. /**
  120868. * Create a new ImageProcessingBlock
  120869. * @param name defines the block name
  120870. */
  120871. constructor(name: string);
  120872. /**
  120873. * Gets the current class name
  120874. * @returns the class name
  120875. */
  120876. getClassName(): string;
  120877. /**
  120878. * Gets the color input component
  120879. */
  120880. readonly color: NodeMaterialConnectionPoint;
  120881. /**
  120882. * Gets the output component
  120883. */
  120884. readonly output: NodeMaterialConnectionPoint;
  120885. /**
  120886. * Initialize the block and prepare the context for build
  120887. * @param state defines the state that will be used for the build
  120888. */
  120889. initialize(state: NodeMaterialBuildState): void;
  120890. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120892. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120893. protected _buildBlock(state: NodeMaterialBuildState): this;
  120894. }
  120895. }
  120896. declare module BABYLON {
  120897. /**
  120898. * Block used to pertub normals based on a normal map
  120899. */
  120900. export class PerturbNormalBlock extends NodeMaterialBlock {
  120901. private _tangentSpaceParameterName;
  120902. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120903. invertX: boolean;
  120904. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120905. invertY: boolean;
  120906. /**
  120907. * Create a new PerturbNormalBlock
  120908. * @param name defines the block name
  120909. */
  120910. constructor(name: string);
  120911. /**
  120912. * Gets the current class name
  120913. * @returns the class name
  120914. */
  120915. getClassName(): string;
  120916. /**
  120917. * Gets the world position input component
  120918. */
  120919. readonly worldPosition: NodeMaterialConnectionPoint;
  120920. /**
  120921. * Gets the world normal input component
  120922. */
  120923. readonly worldNormal: NodeMaterialConnectionPoint;
  120924. /**
  120925. * Gets the uv input component
  120926. */
  120927. readonly uv: NodeMaterialConnectionPoint;
  120928. /**
  120929. * Gets the normal map color input component
  120930. */
  120931. readonly normalMapColor: NodeMaterialConnectionPoint;
  120932. /**
  120933. * Gets the strength input component
  120934. */
  120935. readonly strength: NodeMaterialConnectionPoint;
  120936. /**
  120937. * Gets the output component
  120938. */
  120939. readonly output: NodeMaterialConnectionPoint;
  120940. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120941. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120942. autoConfigure(material: NodeMaterial): void;
  120943. protected _buildBlock(state: NodeMaterialBuildState): this;
  120944. protected _dumpPropertiesCode(): string;
  120945. serialize(): any;
  120946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120947. }
  120948. }
  120949. declare module BABYLON {
  120950. /**
  120951. * Block used to discard a pixel if a value is smaller than a cutoff
  120952. */
  120953. export class DiscardBlock extends NodeMaterialBlock {
  120954. /**
  120955. * Create a new DiscardBlock
  120956. * @param name defines the block name
  120957. */
  120958. constructor(name: string);
  120959. /**
  120960. * Gets the current class name
  120961. * @returns the class name
  120962. */
  120963. getClassName(): string;
  120964. /**
  120965. * Gets the color input component
  120966. */
  120967. readonly value: NodeMaterialConnectionPoint;
  120968. /**
  120969. * Gets the cutoff input component
  120970. */
  120971. readonly cutoff: NodeMaterialConnectionPoint;
  120972. protected _buildBlock(state: NodeMaterialBuildState): this;
  120973. }
  120974. }
  120975. declare module BABYLON {
  120976. /**
  120977. * Block used to add support for scene fog
  120978. */
  120979. export class FogBlock extends NodeMaterialBlock {
  120980. private _fogDistanceName;
  120981. private _fogParameters;
  120982. /**
  120983. * Create a new FogBlock
  120984. * @param name defines the block name
  120985. */
  120986. constructor(name: string);
  120987. /**
  120988. * Gets the current class name
  120989. * @returns the class name
  120990. */
  120991. getClassName(): string;
  120992. /**
  120993. * Gets the world position input component
  120994. */
  120995. readonly worldPosition: NodeMaterialConnectionPoint;
  120996. /**
  120997. * Gets the view input component
  120998. */
  120999. readonly view: NodeMaterialConnectionPoint;
  121000. /**
  121001. * Gets the color input component
  121002. */
  121003. readonly input: NodeMaterialConnectionPoint;
  121004. /**
  121005. * Gets the fog color input component
  121006. */
  121007. readonly fogColor: NodeMaterialConnectionPoint;
  121008. /**
  121009. * Gets the output component
  121010. */
  121011. readonly output: NodeMaterialConnectionPoint;
  121012. autoConfigure(material: NodeMaterial): void;
  121013. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121015. protected _buildBlock(state: NodeMaterialBuildState): this;
  121016. }
  121017. }
  121018. declare module BABYLON {
  121019. /**
  121020. * Block used to add light in the fragment shader
  121021. */
  121022. export class LightBlock extends NodeMaterialBlock {
  121023. private _lightId;
  121024. /**
  121025. * Gets or sets the light associated with this block
  121026. */
  121027. light: Nullable<Light>;
  121028. /**
  121029. * Create a new LightBlock
  121030. * @param name defines the block name
  121031. */
  121032. constructor(name: string);
  121033. /**
  121034. * Gets the current class name
  121035. * @returns the class name
  121036. */
  121037. getClassName(): string;
  121038. /**
  121039. * Gets the world position input component
  121040. */
  121041. readonly worldPosition: NodeMaterialConnectionPoint;
  121042. /**
  121043. * Gets the world normal input component
  121044. */
  121045. readonly worldNormal: NodeMaterialConnectionPoint;
  121046. /**
  121047. * Gets the camera (or eye) position component
  121048. */
  121049. readonly cameraPosition: NodeMaterialConnectionPoint;
  121050. /**
  121051. * Gets the glossiness component
  121052. */
  121053. readonly glossiness: NodeMaterialConnectionPoint;
  121054. /**
  121055. * Gets the glossinness power component
  121056. */
  121057. readonly glossPower: NodeMaterialConnectionPoint;
  121058. /**
  121059. * Gets the diffuse color component
  121060. */
  121061. readonly diffuseColor: NodeMaterialConnectionPoint;
  121062. /**
  121063. * Gets the specular color component
  121064. */
  121065. readonly specularColor: NodeMaterialConnectionPoint;
  121066. /**
  121067. * Gets the diffuse output component
  121068. */
  121069. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121070. /**
  121071. * Gets the specular output component
  121072. */
  121073. readonly specularOutput: NodeMaterialConnectionPoint;
  121074. autoConfigure(material: NodeMaterial): void;
  121075. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121076. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121077. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121078. private _injectVertexCode;
  121079. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121080. serialize(): any;
  121081. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121082. }
  121083. }
  121084. declare module BABYLON {
  121085. /**
  121086. * Block used to multiply 2 values
  121087. */
  121088. export class MultiplyBlock extends NodeMaterialBlock {
  121089. /**
  121090. * Creates a new MultiplyBlock
  121091. * @param name defines the block name
  121092. */
  121093. constructor(name: string);
  121094. /**
  121095. * Gets the current class name
  121096. * @returns the class name
  121097. */
  121098. getClassName(): string;
  121099. /**
  121100. * Gets the left operand input component
  121101. */
  121102. readonly left: NodeMaterialConnectionPoint;
  121103. /**
  121104. * Gets the right operand input component
  121105. */
  121106. readonly right: NodeMaterialConnectionPoint;
  121107. /**
  121108. * Gets the output component
  121109. */
  121110. readonly output: NodeMaterialConnectionPoint;
  121111. protected _buildBlock(state: NodeMaterialBuildState): this;
  121112. }
  121113. }
  121114. declare module BABYLON {
  121115. /**
  121116. * Block used to add 2 vectors
  121117. */
  121118. export class AddBlock extends NodeMaterialBlock {
  121119. /**
  121120. * Creates a new AddBlock
  121121. * @param name defines the block name
  121122. */
  121123. constructor(name: string);
  121124. /**
  121125. * Gets the current class name
  121126. * @returns the class name
  121127. */
  121128. getClassName(): string;
  121129. /**
  121130. * Gets the left operand input component
  121131. */
  121132. readonly left: NodeMaterialConnectionPoint;
  121133. /**
  121134. * Gets the right operand input component
  121135. */
  121136. readonly right: NodeMaterialConnectionPoint;
  121137. /**
  121138. * Gets the output component
  121139. */
  121140. readonly output: NodeMaterialConnectionPoint;
  121141. protected _buildBlock(state: NodeMaterialBuildState): this;
  121142. }
  121143. }
  121144. declare module BABYLON {
  121145. /**
  121146. * Block used to scale a vector by a float
  121147. */
  121148. export class ScaleBlock extends NodeMaterialBlock {
  121149. /**
  121150. * Creates a new ScaleBlock
  121151. * @param name defines the block name
  121152. */
  121153. constructor(name: string);
  121154. /**
  121155. * Gets the current class name
  121156. * @returns the class name
  121157. */
  121158. getClassName(): string;
  121159. /**
  121160. * Gets the input component
  121161. */
  121162. readonly input: NodeMaterialConnectionPoint;
  121163. /**
  121164. * Gets the factor input component
  121165. */
  121166. readonly factor: NodeMaterialConnectionPoint;
  121167. /**
  121168. * Gets the output component
  121169. */
  121170. readonly output: NodeMaterialConnectionPoint;
  121171. protected _buildBlock(state: NodeMaterialBuildState): this;
  121172. }
  121173. }
  121174. declare module BABYLON {
  121175. /**
  121176. * Block used to clamp a float
  121177. */
  121178. export class ClampBlock extends NodeMaterialBlock {
  121179. /** Gets or sets the minimum range */
  121180. minimum: number;
  121181. /** Gets or sets the maximum range */
  121182. maximum: number;
  121183. /**
  121184. * Creates a new ClampBlock
  121185. * @param name defines the block name
  121186. */
  121187. constructor(name: string);
  121188. /**
  121189. * Gets the current class name
  121190. * @returns the class name
  121191. */
  121192. getClassName(): string;
  121193. /**
  121194. * Gets the value input component
  121195. */
  121196. readonly value: NodeMaterialConnectionPoint;
  121197. /**
  121198. * Gets the output component
  121199. */
  121200. readonly output: NodeMaterialConnectionPoint;
  121201. protected _buildBlock(state: NodeMaterialBuildState): this;
  121202. protected _dumpPropertiesCode(): string;
  121203. serialize(): any;
  121204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121205. }
  121206. }
  121207. declare module BABYLON {
  121208. /**
  121209. * Block used to apply a cross product between 2 vectors
  121210. */
  121211. export class CrossBlock extends NodeMaterialBlock {
  121212. /**
  121213. * Creates a new CrossBlock
  121214. * @param name defines the block name
  121215. */
  121216. constructor(name: string);
  121217. /**
  121218. * Gets the current class name
  121219. * @returns the class name
  121220. */
  121221. getClassName(): string;
  121222. /**
  121223. * Gets the left operand input component
  121224. */
  121225. readonly left: NodeMaterialConnectionPoint;
  121226. /**
  121227. * Gets the right operand input component
  121228. */
  121229. readonly right: NodeMaterialConnectionPoint;
  121230. /**
  121231. * Gets the output component
  121232. */
  121233. readonly output: NodeMaterialConnectionPoint;
  121234. protected _buildBlock(state: NodeMaterialBuildState): this;
  121235. }
  121236. }
  121237. declare module BABYLON {
  121238. /**
  121239. * Block used to apply a dot product between 2 vectors
  121240. */
  121241. export class DotBlock extends NodeMaterialBlock {
  121242. /**
  121243. * Creates a new DotBlock
  121244. * @param name defines the block name
  121245. */
  121246. constructor(name: string);
  121247. /**
  121248. * Gets the current class name
  121249. * @returns the class name
  121250. */
  121251. getClassName(): string;
  121252. /**
  121253. * Gets the left operand input component
  121254. */
  121255. readonly left: NodeMaterialConnectionPoint;
  121256. /**
  121257. * Gets the right operand input component
  121258. */
  121259. readonly right: NodeMaterialConnectionPoint;
  121260. /**
  121261. * Gets the output component
  121262. */
  121263. readonly output: NodeMaterialConnectionPoint;
  121264. protected _buildBlock(state: NodeMaterialBuildState): this;
  121265. }
  121266. }
  121267. declare module BABYLON {
  121268. /**
  121269. * Block used to remap a float from a range to a new one
  121270. */
  121271. export class RemapBlock extends NodeMaterialBlock {
  121272. /**
  121273. * Gets or sets the source range
  121274. */
  121275. sourceRange: Vector2;
  121276. /**
  121277. * Gets or sets the target range
  121278. */
  121279. targetRange: Vector2;
  121280. /**
  121281. * Creates a new RemapBlock
  121282. * @param name defines the block name
  121283. */
  121284. constructor(name: string);
  121285. /**
  121286. * Gets the current class name
  121287. * @returns the class name
  121288. */
  121289. getClassName(): string;
  121290. /**
  121291. * Gets the input component
  121292. */
  121293. readonly input: NodeMaterialConnectionPoint;
  121294. /**
  121295. * Gets the source min input component
  121296. */
  121297. readonly sourceMin: NodeMaterialConnectionPoint;
  121298. /**
  121299. * Gets the source max input component
  121300. */
  121301. readonly sourceMax: NodeMaterialConnectionPoint;
  121302. /**
  121303. * Gets the target min input component
  121304. */
  121305. readonly targetMin: NodeMaterialConnectionPoint;
  121306. /**
  121307. * Gets the target max input component
  121308. */
  121309. readonly targetMax: NodeMaterialConnectionPoint;
  121310. /**
  121311. * Gets the output component
  121312. */
  121313. readonly output: NodeMaterialConnectionPoint;
  121314. protected _buildBlock(state: NodeMaterialBuildState): this;
  121315. protected _dumpPropertiesCode(): string;
  121316. serialize(): any;
  121317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121318. }
  121319. }
  121320. declare module BABYLON {
  121321. /**
  121322. * Block used to normalize a vector
  121323. */
  121324. export class NormalizeBlock extends NodeMaterialBlock {
  121325. /**
  121326. * Creates a new NormalizeBlock
  121327. * @param name defines the block name
  121328. */
  121329. constructor(name: string);
  121330. /**
  121331. * Gets the current class name
  121332. * @returns the class name
  121333. */
  121334. getClassName(): string;
  121335. /**
  121336. * Gets the input component
  121337. */
  121338. readonly input: NodeMaterialConnectionPoint;
  121339. /**
  121340. * Gets the output component
  121341. */
  121342. readonly output: NodeMaterialConnectionPoint;
  121343. protected _buildBlock(state: NodeMaterialBuildState): this;
  121344. }
  121345. }
  121346. declare module BABYLON {
  121347. /**
  121348. * Operations supported by the Trigonometry block
  121349. */
  121350. export enum TrigonometryBlockOperations {
  121351. /** Cos */
  121352. Cos = 0,
  121353. /** Sin */
  121354. Sin = 1,
  121355. /** Abs */
  121356. Abs = 2,
  121357. /** Exp */
  121358. Exp = 3,
  121359. /** Exp2 */
  121360. Exp2 = 4,
  121361. /** Round */
  121362. Round = 5,
  121363. /** Floor */
  121364. Floor = 6,
  121365. /** Ceiling */
  121366. Ceiling = 7,
  121367. /** Square root */
  121368. Sqrt = 8,
  121369. /** Log */
  121370. Log = 9,
  121371. /** Tangent */
  121372. Tan = 10,
  121373. /** Arc tangent */
  121374. ArcTan = 11,
  121375. /** Arc cosinus */
  121376. ArcCos = 12,
  121377. /** Arc sinus */
  121378. ArcSin = 13,
  121379. /** Fraction */
  121380. Fract = 14,
  121381. /** Sign */
  121382. Sign = 15,
  121383. /** To radians (from degrees) */
  121384. Radians = 16,
  121385. /** To degrees (from radians) */
  121386. Degrees = 17
  121387. }
  121388. /**
  121389. * Block used to apply trigonometry operation to floats
  121390. */
  121391. export class TrigonometryBlock extends NodeMaterialBlock {
  121392. /**
  121393. * Gets or sets the operation applied by the block
  121394. */
  121395. operation: TrigonometryBlockOperations;
  121396. /**
  121397. * Creates a new TrigonometryBlock
  121398. * @param name defines the block name
  121399. */
  121400. constructor(name: string);
  121401. /**
  121402. * Gets the current class name
  121403. * @returns the class name
  121404. */
  121405. getClassName(): string;
  121406. /**
  121407. * Gets the input component
  121408. */
  121409. readonly input: NodeMaterialConnectionPoint;
  121410. /**
  121411. * Gets the output component
  121412. */
  121413. readonly output: NodeMaterialConnectionPoint;
  121414. protected _buildBlock(state: NodeMaterialBuildState): this;
  121415. serialize(): any;
  121416. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121417. }
  121418. }
  121419. declare module BABYLON {
  121420. /**
  121421. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121422. */
  121423. export class ColorMergerBlock extends NodeMaterialBlock {
  121424. /**
  121425. * Create a new ColorMergerBlock
  121426. * @param name defines the block name
  121427. */
  121428. constructor(name: string);
  121429. /**
  121430. * Gets the current class name
  121431. * @returns the class name
  121432. */
  121433. getClassName(): string;
  121434. /**
  121435. * Gets the r component (input)
  121436. */
  121437. readonly r: NodeMaterialConnectionPoint;
  121438. /**
  121439. * Gets the g component (input)
  121440. */
  121441. readonly g: NodeMaterialConnectionPoint;
  121442. /**
  121443. * Gets the b component (input)
  121444. */
  121445. readonly b: NodeMaterialConnectionPoint;
  121446. /**
  121447. * Gets the a component (input)
  121448. */
  121449. readonly a: NodeMaterialConnectionPoint;
  121450. /**
  121451. * Gets the rgba component (output)
  121452. */
  121453. readonly rgba: NodeMaterialConnectionPoint;
  121454. /**
  121455. * Gets the rgb component (output)
  121456. */
  121457. readonly rgb: NodeMaterialConnectionPoint;
  121458. protected _buildBlock(state: NodeMaterialBuildState): this;
  121459. }
  121460. }
  121461. declare module BABYLON {
  121462. /**
  121463. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121464. */
  121465. export class VectorMergerBlock extends NodeMaterialBlock {
  121466. /**
  121467. * Create a new VectorMergerBlock
  121468. * @param name defines the block name
  121469. */
  121470. constructor(name: string);
  121471. /**
  121472. * Gets the current class name
  121473. * @returns the class name
  121474. */
  121475. getClassName(): string;
  121476. /**
  121477. * Gets the x component (input)
  121478. */
  121479. readonly x: NodeMaterialConnectionPoint;
  121480. /**
  121481. * Gets the y component (input)
  121482. */
  121483. readonly y: NodeMaterialConnectionPoint;
  121484. /**
  121485. * Gets the z component (input)
  121486. */
  121487. readonly z: NodeMaterialConnectionPoint;
  121488. /**
  121489. * Gets the w component (input)
  121490. */
  121491. readonly w: NodeMaterialConnectionPoint;
  121492. /**
  121493. * Gets the xyzw component (output)
  121494. */
  121495. readonly xyzw: NodeMaterialConnectionPoint;
  121496. /**
  121497. * Gets the xyz component (output)
  121498. */
  121499. readonly xyz: NodeMaterialConnectionPoint;
  121500. /**
  121501. * Gets the xy component (output)
  121502. */
  121503. readonly xy: NodeMaterialConnectionPoint;
  121504. protected _buildBlock(state: NodeMaterialBuildState): this;
  121505. }
  121506. }
  121507. declare module BABYLON {
  121508. /**
  121509. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121510. */
  121511. export class ColorSplitterBlock extends NodeMaterialBlock {
  121512. /**
  121513. * Create a new ColorSplitterBlock
  121514. * @param name defines the block name
  121515. */
  121516. constructor(name: string);
  121517. /**
  121518. * Gets the current class name
  121519. * @returns the class name
  121520. */
  121521. getClassName(): string;
  121522. /**
  121523. * Gets the rgba component (input)
  121524. */
  121525. readonly rgba: NodeMaterialConnectionPoint;
  121526. /**
  121527. * Gets the rgb component (input)
  121528. */
  121529. readonly rgbIn: NodeMaterialConnectionPoint;
  121530. /**
  121531. * Gets the rgb component (output)
  121532. */
  121533. readonly rgbOut: NodeMaterialConnectionPoint;
  121534. /**
  121535. * Gets the r component (output)
  121536. */
  121537. readonly r: NodeMaterialConnectionPoint;
  121538. /**
  121539. * Gets the g component (output)
  121540. */
  121541. readonly g: NodeMaterialConnectionPoint;
  121542. /**
  121543. * Gets the b component (output)
  121544. */
  121545. readonly b: NodeMaterialConnectionPoint;
  121546. /**
  121547. * Gets the a component (output)
  121548. */
  121549. readonly a: NodeMaterialConnectionPoint;
  121550. protected _inputRename(name: string): string;
  121551. protected _outputRename(name: string): string;
  121552. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121553. }
  121554. }
  121555. declare module BABYLON {
  121556. /**
  121557. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121558. */
  121559. export class VectorSplitterBlock extends NodeMaterialBlock {
  121560. /**
  121561. * Create a new VectorSplitterBlock
  121562. * @param name defines the block name
  121563. */
  121564. constructor(name: string);
  121565. /**
  121566. * Gets the current class name
  121567. * @returns the class name
  121568. */
  121569. getClassName(): string;
  121570. /**
  121571. * Gets the xyzw component (input)
  121572. */
  121573. readonly xyzw: NodeMaterialConnectionPoint;
  121574. /**
  121575. * Gets the xyz component (input)
  121576. */
  121577. readonly xyzIn: NodeMaterialConnectionPoint;
  121578. /**
  121579. * Gets the xy component (input)
  121580. */
  121581. readonly xyIn: NodeMaterialConnectionPoint;
  121582. /**
  121583. * Gets the xyz component (output)
  121584. */
  121585. readonly xyzOut: NodeMaterialConnectionPoint;
  121586. /**
  121587. * Gets the xy component (output)
  121588. */
  121589. readonly xyOut: NodeMaterialConnectionPoint;
  121590. /**
  121591. * Gets the x component (output)
  121592. */
  121593. readonly x: NodeMaterialConnectionPoint;
  121594. /**
  121595. * Gets the y component (output)
  121596. */
  121597. readonly y: NodeMaterialConnectionPoint;
  121598. /**
  121599. * Gets the z component (output)
  121600. */
  121601. readonly z: NodeMaterialConnectionPoint;
  121602. /**
  121603. * Gets the w component (output)
  121604. */
  121605. readonly w: NodeMaterialConnectionPoint;
  121606. protected _inputRename(name: string): string;
  121607. protected _outputRename(name: string): string;
  121608. protected _buildBlock(state: NodeMaterialBuildState): this;
  121609. }
  121610. }
  121611. declare module BABYLON {
  121612. /**
  121613. * Block used to lerp between 2 values
  121614. */
  121615. export class LerpBlock extends NodeMaterialBlock {
  121616. /**
  121617. * Creates a new LerpBlock
  121618. * @param name defines the block name
  121619. */
  121620. constructor(name: string);
  121621. /**
  121622. * Gets the current class name
  121623. * @returns the class name
  121624. */
  121625. getClassName(): string;
  121626. /**
  121627. * Gets the left operand input component
  121628. */
  121629. readonly left: NodeMaterialConnectionPoint;
  121630. /**
  121631. * Gets the right operand input component
  121632. */
  121633. readonly right: NodeMaterialConnectionPoint;
  121634. /**
  121635. * Gets the gradient operand input component
  121636. */
  121637. readonly gradient: NodeMaterialConnectionPoint;
  121638. /**
  121639. * Gets the output component
  121640. */
  121641. readonly output: NodeMaterialConnectionPoint;
  121642. protected _buildBlock(state: NodeMaterialBuildState): this;
  121643. }
  121644. }
  121645. declare module BABYLON {
  121646. /**
  121647. * Block used to divide 2 vectors
  121648. */
  121649. export class DivideBlock extends NodeMaterialBlock {
  121650. /**
  121651. * Creates a new DivideBlock
  121652. * @param name defines the block name
  121653. */
  121654. constructor(name: string);
  121655. /**
  121656. * Gets the current class name
  121657. * @returns the class name
  121658. */
  121659. getClassName(): string;
  121660. /**
  121661. * Gets the left operand input component
  121662. */
  121663. readonly left: NodeMaterialConnectionPoint;
  121664. /**
  121665. * Gets the right operand input component
  121666. */
  121667. readonly right: NodeMaterialConnectionPoint;
  121668. /**
  121669. * Gets the output component
  121670. */
  121671. readonly output: NodeMaterialConnectionPoint;
  121672. protected _buildBlock(state: NodeMaterialBuildState): this;
  121673. }
  121674. }
  121675. declare module BABYLON {
  121676. /**
  121677. * Block used to subtract 2 vectors
  121678. */
  121679. export class SubtractBlock extends NodeMaterialBlock {
  121680. /**
  121681. * Creates a new SubtractBlock
  121682. * @param name defines the block name
  121683. */
  121684. constructor(name: string);
  121685. /**
  121686. * Gets the current class name
  121687. * @returns the class name
  121688. */
  121689. getClassName(): string;
  121690. /**
  121691. * Gets the left operand input component
  121692. */
  121693. readonly left: NodeMaterialConnectionPoint;
  121694. /**
  121695. * Gets the right operand input component
  121696. */
  121697. readonly right: NodeMaterialConnectionPoint;
  121698. /**
  121699. * Gets the output component
  121700. */
  121701. readonly output: NodeMaterialConnectionPoint;
  121702. protected _buildBlock(state: NodeMaterialBuildState): this;
  121703. }
  121704. }
  121705. declare module BABYLON {
  121706. /**
  121707. * Block used to step a value
  121708. */
  121709. export class StepBlock extends NodeMaterialBlock {
  121710. /**
  121711. * Creates a new StepBlock
  121712. * @param name defines the block name
  121713. */
  121714. constructor(name: string);
  121715. /**
  121716. * Gets the current class name
  121717. * @returns the class name
  121718. */
  121719. getClassName(): string;
  121720. /**
  121721. * Gets the value operand input component
  121722. */
  121723. readonly value: NodeMaterialConnectionPoint;
  121724. /**
  121725. * Gets the edge operand input component
  121726. */
  121727. readonly edge: NodeMaterialConnectionPoint;
  121728. /**
  121729. * Gets the output component
  121730. */
  121731. readonly output: NodeMaterialConnectionPoint;
  121732. protected _buildBlock(state: NodeMaterialBuildState): this;
  121733. }
  121734. }
  121735. declare module BABYLON {
  121736. /**
  121737. * Block used to get the opposite (1 - x) of a value
  121738. */
  121739. export class OneMinusBlock extends NodeMaterialBlock {
  121740. /**
  121741. * Creates a new OneMinusBlock
  121742. * @param name defines the block name
  121743. */
  121744. constructor(name: string);
  121745. /**
  121746. * Gets the current class name
  121747. * @returns the class name
  121748. */
  121749. getClassName(): string;
  121750. /**
  121751. * Gets the input component
  121752. */
  121753. readonly input: NodeMaterialConnectionPoint;
  121754. /**
  121755. * Gets the output component
  121756. */
  121757. readonly output: NodeMaterialConnectionPoint;
  121758. protected _buildBlock(state: NodeMaterialBuildState): this;
  121759. }
  121760. }
  121761. declare module BABYLON {
  121762. /**
  121763. * Block used to get the view direction
  121764. */
  121765. export class ViewDirectionBlock extends NodeMaterialBlock {
  121766. /**
  121767. * Creates a new ViewDirectionBlock
  121768. * @param name defines the block name
  121769. */
  121770. constructor(name: string);
  121771. /**
  121772. * Gets the current class name
  121773. * @returns the class name
  121774. */
  121775. getClassName(): string;
  121776. /**
  121777. * Gets the world position component
  121778. */
  121779. readonly worldPosition: NodeMaterialConnectionPoint;
  121780. /**
  121781. * Gets the camera position component
  121782. */
  121783. readonly cameraPosition: NodeMaterialConnectionPoint;
  121784. /**
  121785. * Gets the output component
  121786. */
  121787. readonly output: NodeMaterialConnectionPoint;
  121788. autoConfigure(material: NodeMaterial): void;
  121789. protected _buildBlock(state: NodeMaterialBuildState): this;
  121790. }
  121791. }
  121792. declare module BABYLON {
  121793. /**
  121794. * Block used to compute fresnel value
  121795. */
  121796. export class FresnelBlock extends NodeMaterialBlock {
  121797. /**
  121798. * Create a new FresnelBlock
  121799. * @param name defines the block name
  121800. */
  121801. constructor(name: string);
  121802. /**
  121803. * Gets the current class name
  121804. * @returns the class name
  121805. */
  121806. getClassName(): string;
  121807. /**
  121808. * Gets the world normal input component
  121809. */
  121810. readonly worldNormal: NodeMaterialConnectionPoint;
  121811. /**
  121812. * Gets the view direction input component
  121813. */
  121814. readonly viewDirection: NodeMaterialConnectionPoint;
  121815. /**
  121816. * Gets the bias input component
  121817. */
  121818. readonly bias: NodeMaterialConnectionPoint;
  121819. /**
  121820. * Gets the camera (or eye) position component
  121821. */
  121822. readonly power: NodeMaterialConnectionPoint;
  121823. /**
  121824. * Gets the fresnel output component
  121825. */
  121826. readonly fresnel: NodeMaterialConnectionPoint;
  121827. autoConfigure(material: NodeMaterial): void;
  121828. protected _buildBlock(state: NodeMaterialBuildState): this;
  121829. }
  121830. }
  121831. declare module BABYLON {
  121832. /**
  121833. * Block used to get the max of 2 values
  121834. */
  121835. export class MaxBlock extends NodeMaterialBlock {
  121836. /**
  121837. * Creates a new MaxBlock
  121838. * @param name defines the block name
  121839. */
  121840. constructor(name: string);
  121841. /**
  121842. * Gets the current class name
  121843. * @returns the class name
  121844. */
  121845. getClassName(): string;
  121846. /**
  121847. * Gets the left operand input component
  121848. */
  121849. readonly left: NodeMaterialConnectionPoint;
  121850. /**
  121851. * Gets the right operand input component
  121852. */
  121853. readonly right: NodeMaterialConnectionPoint;
  121854. /**
  121855. * Gets the output component
  121856. */
  121857. readonly output: NodeMaterialConnectionPoint;
  121858. protected _buildBlock(state: NodeMaterialBuildState): this;
  121859. }
  121860. }
  121861. declare module BABYLON {
  121862. /**
  121863. * Block used to get the min of 2 values
  121864. */
  121865. export class MinBlock extends NodeMaterialBlock {
  121866. /**
  121867. * Creates a new MinBlock
  121868. * @param name defines the block name
  121869. */
  121870. constructor(name: string);
  121871. /**
  121872. * Gets the current class name
  121873. * @returns the class name
  121874. */
  121875. getClassName(): string;
  121876. /**
  121877. * Gets the left operand input component
  121878. */
  121879. readonly left: NodeMaterialConnectionPoint;
  121880. /**
  121881. * Gets the right operand input component
  121882. */
  121883. readonly right: NodeMaterialConnectionPoint;
  121884. /**
  121885. * Gets the output component
  121886. */
  121887. readonly output: NodeMaterialConnectionPoint;
  121888. protected _buildBlock(state: NodeMaterialBuildState): this;
  121889. }
  121890. }
  121891. declare module BABYLON {
  121892. /**
  121893. * Block used to get the distance between 2 values
  121894. */
  121895. export class DistanceBlock extends NodeMaterialBlock {
  121896. /**
  121897. * Creates a new DistanceBlock
  121898. * @param name defines the block name
  121899. */
  121900. constructor(name: string);
  121901. /**
  121902. * Gets the current class name
  121903. * @returns the class name
  121904. */
  121905. getClassName(): string;
  121906. /**
  121907. * Gets the left operand input component
  121908. */
  121909. readonly left: NodeMaterialConnectionPoint;
  121910. /**
  121911. * Gets the right operand input component
  121912. */
  121913. readonly right: NodeMaterialConnectionPoint;
  121914. /**
  121915. * Gets the output component
  121916. */
  121917. readonly output: NodeMaterialConnectionPoint;
  121918. protected _buildBlock(state: NodeMaterialBuildState): this;
  121919. }
  121920. }
  121921. declare module BABYLON {
  121922. /**
  121923. * Block used to get the length of a vector
  121924. */
  121925. export class LengthBlock extends NodeMaterialBlock {
  121926. /**
  121927. * Creates a new LengthBlock
  121928. * @param name defines the block name
  121929. */
  121930. constructor(name: string);
  121931. /**
  121932. * Gets the current class name
  121933. * @returns the class name
  121934. */
  121935. getClassName(): string;
  121936. /**
  121937. * Gets the value input component
  121938. */
  121939. readonly value: NodeMaterialConnectionPoint;
  121940. /**
  121941. * Gets the output component
  121942. */
  121943. readonly output: NodeMaterialConnectionPoint;
  121944. protected _buildBlock(state: NodeMaterialBuildState): this;
  121945. }
  121946. }
  121947. declare module BABYLON {
  121948. /**
  121949. * Block used to get negative version of a value (i.e. x * -1)
  121950. */
  121951. export class NegateBlock extends NodeMaterialBlock {
  121952. /**
  121953. * Creates a new NegateBlock
  121954. * @param name defines the block name
  121955. */
  121956. constructor(name: string);
  121957. /**
  121958. * Gets the current class name
  121959. * @returns the class name
  121960. */
  121961. getClassName(): string;
  121962. /**
  121963. * Gets the value input component
  121964. */
  121965. readonly value: NodeMaterialConnectionPoint;
  121966. /**
  121967. * Gets the output component
  121968. */
  121969. readonly output: NodeMaterialConnectionPoint;
  121970. protected _buildBlock(state: NodeMaterialBuildState): this;
  121971. }
  121972. }
  121973. declare module BABYLON {
  121974. /**
  121975. * Block used to get the value of the first parameter raised to the power of the second
  121976. */
  121977. export class PowBlock extends NodeMaterialBlock {
  121978. /**
  121979. * Creates a new PowBlock
  121980. * @param name defines the block name
  121981. */
  121982. constructor(name: string);
  121983. /**
  121984. * Gets the current class name
  121985. * @returns the class name
  121986. */
  121987. getClassName(): string;
  121988. /**
  121989. * Gets the value operand input component
  121990. */
  121991. readonly value: NodeMaterialConnectionPoint;
  121992. /**
  121993. * Gets the power operand input component
  121994. */
  121995. readonly power: NodeMaterialConnectionPoint;
  121996. /**
  121997. * Gets the output component
  121998. */
  121999. readonly output: NodeMaterialConnectionPoint;
  122000. protected _buildBlock(state: NodeMaterialBuildState): this;
  122001. }
  122002. }
  122003. declare module BABYLON {
  122004. /**
  122005. * Block used to get a random number
  122006. */
  122007. export class RandomNumberBlock extends NodeMaterialBlock {
  122008. /**
  122009. * Creates a new RandomNumberBlock
  122010. * @param name defines the block name
  122011. */
  122012. constructor(name: string);
  122013. /**
  122014. * Gets the current class name
  122015. * @returns the class name
  122016. */
  122017. getClassName(): string;
  122018. /**
  122019. * Gets the seed input component
  122020. */
  122021. readonly seed: NodeMaterialConnectionPoint;
  122022. /**
  122023. * Gets the output component
  122024. */
  122025. readonly output: NodeMaterialConnectionPoint;
  122026. protected _buildBlock(state: NodeMaterialBuildState): this;
  122027. }
  122028. }
  122029. declare module BABYLON {
  122030. /**
  122031. * Block used to compute arc tangent of 2 values
  122032. */
  122033. export class ArcTan2Block extends NodeMaterialBlock {
  122034. /**
  122035. * Creates a new ArcTan2Block
  122036. * @param name defines the block name
  122037. */
  122038. constructor(name: string);
  122039. /**
  122040. * Gets the current class name
  122041. * @returns the class name
  122042. */
  122043. getClassName(): string;
  122044. /**
  122045. * Gets the x operand input component
  122046. */
  122047. readonly x: NodeMaterialConnectionPoint;
  122048. /**
  122049. * Gets the y operand input component
  122050. */
  122051. readonly y: NodeMaterialConnectionPoint;
  122052. /**
  122053. * Gets the output component
  122054. */
  122055. readonly output: NodeMaterialConnectionPoint;
  122056. protected _buildBlock(state: NodeMaterialBuildState): this;
  122057. }
  122058. }
  122059. declare module BABYLON {
  122060. /**
  122061. * Block used to smooth step a value
  122062. */
  122063. export class SmoothStepBlock extends NodeMaterialBlock {
  122064. /**
  122065. * Creates a new SmoothStepBlock
  122066. * @param name defines the block name
  122067. */
  122068. constructor(name: string);
  122069. /**
  122070. * Gets the current class name
  122071. * @returns the class name
  122072. */
  122073. getClassName(): string;
  122074. /**
  122075. * Gets the value operand input component
  122076. */
  122077. readonly value: NodeMaterialConnectionPoint;
  122078. /**
  122079. * Gets the first edge operand input component
  122080. */
  122081. readonly edge0: NodeMaterialConnectionPoint;
  122082. /**
  122083. * Gets the second edge operand input component
  122084. */
  122085. readonly edge1: NodeMaterialConnectionPoint;
  122086. /**
  122087. * Gets the output component
  122088. */
  122089. readonly output: NodeMaterialConnectionPoint;
  122090. protected _buildBlock(state: NodeMaterialBuildState): this;
  122091. }
  122092. }
  122093. declare module BABYLON {
  122094. /**
  122095. * Block used to get the reciprocal (1 / x) of a value
  122096. */
  122097. export class ReciprocalBlock extends NodeMaterialBlock {
  122098. /**
  122099. * Creates a new ReciprocalBlock
  122100. * @param name defines the block name
  122101. */
  122102. constructor(name: string);
  122103. /**
  122104. * Gets the current class name
  122105. * @returns the class name
  122106. */
  122107. getClassName(): string;
  122108. /**
  122109. * Gets the input component
  122110. */
  122111. readonly input: NodeMaterialConnectionPoint;
  122112. /**
  122113. * Gets the output component
  122114. */
  122115. readonly output: NodeMaterialConnectionPoint;
  122116. protected _buildBlock(state: NodeMaterialBuildState): this;
  122117. }
  122118. }
  122119. declare module BABYLON {
  122120. /**
  122121. * Block used to replace a color by another one
  122122. */
  122123. export class ReplaceColorBlock extends NodeMaterialBlock {
  122124. /**
  122125. * Creates a new ReplaceColorBlock
  122126. * @param name defines the block name
  122127. */
  122128. constructor(name: string);
  122129. /**
  122130. * Gets the current class name
  122131. * @returns the class name
  122132. */
  122133. getClassName(): string;
  122134. /**
  122135. * Gets the value input component
  122136. */
  122137. readonly value: NodeMaterialConnectionPoint;
  122138. /**
  122139. * Gets the reference input component
  122140. */
  122141. readonly reference: NodeMaterialConnectionPoint;
  122142. /**
  122143. * Gets the distance input component
  122144. */
  122145. readonly distance: NodeMaterialConnectionPoint;
  122146. /**
  122147. * Gets the replacement input component
  122148. */
  122149. readonly replacement: NodeMaterialConnectionPoint;
  122150. /**
  122151. * Gets the output component
  122152. */
  122153. readonly output: NodeMaterialConnectionPoint;
  122154. protected _buildBlock(state: NodeMaterialBuildState): this;
  122155. }
  122156. }
  122157. declare module BABYLON {
  122158. /**
  122159. * Block used to posterize a value
  122160. * @see https://en.wikipedia.org/wiki/Posterization
  122161. */
  122162. export class PosterizeBlock extends NodeMaterialBlock {
  122163. /**
  122164. * Creates a new PosterizeBlock
  122165. * @param name defines the block name
  122166. */
  122167. constructor(name: string);
  122168. /**
  122169. * Gets the current class name
  122170. * @returns the class name
  122171. */
  122172. getClassName(): string;
  122173. /**
  122174. * Gets the value input component
  122175. */
  122176. readonly value: NodeMaterialConnectionPoint;
  122177. /**
  122178. * Gets the steps input component
  122179. */
  122180. readonly steps: NodeMaterialConnectionPoint;
  122181. /**
  122182. * Gets the output component
  122183. */
  122184. readonly output: NodeMaterialConnectionPoint;
  122185. protected _buildBlock(state: NodeMaterialBuildState): this;
  122186. }
  122187. }
  122188. declare module BABYLON {
  122189. /**
  122190. * Operations supported by the Wave block
  122191. */
  122192. export enum WaveBlockKind {
  122193. /** SawTooth */
  122194. SawTooth = 0,
  122195. /** Square */
  122196. Square = 1,
  122197. /** Triangle */
  122198. Triangle = 2
  122199. }
  122200. /**
  122201. * Block used to apply wave operation to floats
  122202. */
  122203. export class WaveBlock extends NodeMaterialBlock {
  122204. /**
  122205. * Gets or sets the kibnd of wave to be applied by the block
  122206. */
  122207. kind: WaveBlockKind;
  122208. /**
  122209. * Creates a new WaveBlock
  122210. * @param name defines the block name
  122211. */
  122212. constructor(name: string);
  122213. /**
  122214. * Gets the current class name
  122215. * @returns the class name
  122216. */
  122217. getClassName(): string;
  122218. /**
  122219. * Gets the input component
  122220. */
  122221. readonly input: NodeMaterialConnectionPoint;
  122222. /**
  122223. * Gets the output component
  122224. */
  122225. readonly output: NodeMaterialConnectionPoint;
  122226. protected _buildBlock(state: NodeMaterialBuildState): this;
  122227. serialize(): any;
  122228. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122229. }
  122230. }
  122231. declare module BABYLON {
  122232. /**
  122233. * Class used to store a color step for the GradientBlock
  122234. */
  122235. export class GradientBlockColorStep {
  122236. /**
  122237. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122238. */
  122239. step: number;
  122240. /**
  122241. * Gets or sets the color associated with this step
  122242. */
  122243. color: Color3;
  122244. /**
  122245. * Creates a new GradientBlockColorStep
  122246. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122247. * @param color defines the color associated with this step
  122248. */
  122249. constructor(
  122250. /**
  122251. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122252. */
  122253. step: number,
  122254. /**
  122255. * Gets or sets the color associated with this step
  122256. */
  122257. color: Color3);
  122258. }
  122259. /**
  122260. * Block used to return a color from a gradient based on an input value between 0 and 1
  122261. */
  122262. export class GradientBlock extends NodeMaterialBlock {
  122263. /**
  122264. * Gets or sets the list of color steps
  122265. */
  122266. colorSteps: GradientBlockColorStep[];
  122267. /**
  122268. * Creates a new GradientBlock
  122269. * @param name defines the block name
  122270. */
  122271. constructor(name: string);
  122272. /**
  122273. * Gets the current class name
  122274. * @returns the class name
  122275. */
  122276. getClassName(): string;
  122277. /**
  122278. * Gets the gradient input component
  122279. */
  122280. readonly gradient: NodeMaterialConnectionPoint;
  122281. /**
  122282. * Gets the output component
  122283. */
  122284. readonly output: NodeMaterialConnectionPoint;
  122285. private _writeColorConstant;
  122286. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122287. serialize(): any;
  122288. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122289. protected _dumpPropertiesCode(): string;
  122290. }
  122291. }
  122292. declare module BABYLON {
  122293. /**
  122294. * Block used to normalize lerp between 2 values
  122295. */
  122296. export class NLerpBlock extends NodeMaterialBlock {
  122297. /**
  122298. * Creates a new NLerpBlock
  122299. * @param name defines the block name
  122300. */
  122301. constructor(name: string);
  122302. /**
  122303. * Gets the current class name
  122304. * @returns the class name
  122305. */
  122306. getClassName(): string;
  122307. /**
  122308. * Gets the left operand input component
  122309. */
  122310. readonly left: NodeMaterialConnectionPoint;
  122311. /**
  122312. * Gets the right operand input component
  122313. */
  122314. readonly right: NodeMaterialConnectionPoint;
  122315. /**
  122316. * Gets the gradient operand input component
  122317. */
  122318. readonly gradient: NodeMaterialConnectionPoint;
  122319. /**
  122320. * Gets the output component
  122321. */
  122322. readonly output: NodeMaterialConnectionPoint;
  122323. protected _buildBlock(state: NodeMaterialBuildState): this;
  122324. }
  122325. }
  122326. declare module BABYLON {
  122327. /**
  122328. * Effect Render Options
  122329. */
  122330. export interface IEffectRendererOptions {
  122331. /**
  122332. * Defines the vertices positions.
  122333. */
  122334. positions?: number[];
  122335. /**
  122336. * Defines the indices.
  122337. */
  122338. indices?: number[];
  122339. }
  122340. /**
  122341. * Helper class to render one or more effects
  122342. */
  122343. export class EffectRenderer {
  122344. private engine;
  122345. private static _DefaultOptions;
  122346. private _vertexBuffers;
  122347. private _indexBuffer;
  122348. private _ringBufferIndex;
  122349. private _ringScreenBuffer;
  122350. private _fullscreenViewport;
  122351. private _getNextFrameBuffer;
  122352. /**
  122353. * Creates an effect renderer
  122354. * @param engine the engine to use for rendering
  122355. * @param options defines the options of the effect renderer
  122356. */
  122357. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122358. /**
  122359. * Sets the current viewport in normalized coordinates 0-1
  122360. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122361. */
  122362. setViewport(viewport?: Viewport): void;
  122363. /**
  122364. * Binds the embedded attributes buffer to the effect.
  122365. * @param effect Defines the effect to bind the attributes for
  122366. */
  122367. bindBuffers(effect: Effect): void;
  122368. /**
  122369. * Sets the current effect wrapper to use during draw.
  122370. * The effect needs to be ready before calling this api.
  122371. * This also sets the default full screen position attribute.
  122372. * @param effectWrapper Defines the effect to draw with
  122373. */
  122374. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122375. /**
  122376. * Draws a full screen quad.
  122377. */
  122378. draw(): void;
  122379. /**
  122380. * renders one or more effects to a specified texture
  122381. * @param effectWrappers list of effects to renderer
  122382. * @param outputTexture texture to draw to, if null it will render to the screen
  122383. */
  122384. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122385. /**
  122386. * Disposes of the effect renderer
  122387. */
  122388. dispose(): void;
  122389. }
  122390. /**
  122391. * Options to create an EffectWrapper
  122392. */
  122393. interface EffectWrapperCreationOptions {
  122394. /**
  122395. * Engine to use to create the effect
  122396. */
  122397. engine: ThinEngine;
  122398. /**
  122399. * Fragment shader for the effect
  122400. */
  122401. fragmentShader: string;
  122402. /**
  122403. * Vertex shader for the effect
  122404. */
  122405. vertexShader?: string;
  122406. /**
  122407. * Attributes to use in the shader
  122408. */
  122409. attributeNames?: Array<string>;
  122410. /**
  122411. * Uniforms to use in the shader
  122412. */
  122413. uniformNames?: Array<string>;
  122414. /**
  122415. * Texture sampler names to use in the shader
  122416. */
  122417. samplerNames?: Array<string>;
  122418. /**
  122419. * The friendly name of the effect displayed in Spector.
  122420. */
  122421. name?: string;
  122422. }
  122423. /**
  122424. * Wraps an effect to be used for rendering
  122425. */
  122426. export class EffectWrapper {
  122427. /**
  122428. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122429. */
  122430. onApplyObservable: Observable<{}>;
  122431. /**
  122432. * The underlying effect
  122433. */
  122434. effect: Effect;
  122435. /**
  122436. * Creates an effect to be renderer
  122437. * @param creationOptions options to create the effect
  122438. */
  122439. constructor(creationOptions: EffectWrapperCreationOptions);
  122440. /**
  122441. * Disposes of the effect wrapper
  122442. */
  122443. dispose(): void;
  122444. }
  122445. }
  122446. declare module BABYLON {
  122447. /**
  122448. * Helper class to push actions to a pool of workers.
  122449. */
  122450. export class WorkerPool implements IDisposable {
  122451. private _workerInfos;
  122452. private _pendingActions;
  122453. /**
  122454. * Constructor
  122455. * @param workers Array of workers to use for actions
  122456. */
  122457. constructor(workers: Array<Worker>);
  122458. /**
  122459. * Terminates all workers and clears any pending actions.
  122460. */
  122461. dispose(): void;
  122462. /**
  122463. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122464. * pended until a worker has completed its action.
  122465. * @param action The action to perform. Call onComplete when the action is complete.
  122466. */
  122467. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122468. private _execute;
  122469. }
  122470. }
  122471. declare module BABYLON {
  122472. /**
  122473. * Configuration for Draco compression
  122474. */
  122475. export interface IDracoCompressionConfiguration {
  122476. /**
  122477. * Configuration for the decoder.
  122478. */
  122479. decoder: {
  122480. /**
  122481. * The url to the WebAssembly module.
  122482. */
  122483. wasmUrl?: string;
  122484. /**
  122485. * The url to the WebAssembly binary.
  122486. */
  122487. wasmBinaryUrl?: string;
  122488. /**
  122489. * The url to the fallback JavaScript module.
  122490. */
  122491. fallbackUrl?: string;
  122492. };
  122493. }
  122494. /**
  122495. * Draco compression (https://google.github.io/draco/)
  122496. *
  122497. * This class wraps the Draco module.
  122498. *
  122499. * **Encoder**
  122500. *
  122501. * The encoder is not currently implemented.
  122502. *
  122503. * **Decoder**
  122504. *
  122505. * 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.
  122506. *
  122507. * To update the configuration, use the following code:
  122508. * ```javascript
  122509. * DracoCompression.Configuration = {
  122510. * decoder: {
  122511. * wasmUrl: "<url to the WebAssembly library>",
  122512. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122513. * fallbackUrl: "<url to the fallback JavaScript library>",
  122514. * }
  122515. * };
  122516. * ```
  122517. *
  122518. * 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.
  122519. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122520. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122521. *
  122522. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122523. * ```javascript
  122524. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122525. * ```
  122526. *
  122527. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122528. */
  122529. export class DracoCompression implements IDisposable {
  122530. private _workerPoolPromise?;
  122531. private _decoderModulePromise?;
  122532. /**
  122533. * The configuration. Defaults to the following urls:
  122534. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122535. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122536. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122537. */
  122538. static Configuration: IDracoCompressionConfiguration;
  122539. /**
  122540. * Returns true if the decoder configuration is available.
  122541. */
  122542. static readonly DecoderAvailable: boolean;
  122543. /**
  122544. * Default number of workers to create when creating the draco compression object.
  122545. */
  122546. static DefaultNumWorkers: number;
  122547. private static GetDefaultNumWorkers;
  122548. private static _Default;
  122549. /**
  122550. * Default instance for the draco compression object.
  122551. */
  122552. static readonly Default: DracoCompression;
  122553. /**
  122554. * Constructor
  122555. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122556. */
  122557. constructor(numWorkers?: number);
  122558. /**
  122559. * Stop all async operations and release resources.
  122560. */
  122561. dispose(): void;
  122562. /**
  122563. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122564. * @returns a promise that resolves when ready
  122565. */
  122566. whenReadyAsync(): Promise<void>;
  122567. /**
  122568. * Decode Draco compressed mesh data to vertex data.
  122569. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122570. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122571. * @returns A promise that resolves with the decoded vertex data
  122572. */
  122573. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122574. [kind: string]: number;
  122575. }): Promise<VertexData>;
  122576. }
  122577. }
  122578. declare module BABYLON {
  122579. /**
  122580. * Class for building Constructive Solid Geometry
  122581. */
  122582. export class CSG {
  122583. private polygons;
  122584. /**
  122585. * The world matrix
  122586. */
  122587. matrix: Matrix;
  122588. /**
  122589. * Stores the position
  122590. */
  122591. position: Vector3;
  122592. /**
  122593. * Stores the rotation
  122594. */
  122595. rotation: Vector3;
  122596. /**
  122597. * Stores the rotation quaternion
  122598. */
  122599. rotationQuaternion: Nullable<Quaternion>;
  122600. /**
  122601. * Stores the scaling vector
  122602. */
  122603. scaling: Vector3;
  122604. /**
  122605. * Convert the Mesh to CSG
  122606. * @param mesh The Mesh to convert to CSG
  122607. * @returns A new CSG from the Mesh
  122608. */
  122609. static FromMesh(mesh: Mesh): CSG;
  122610. /**
  122611. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122612. * @param polygons Polygons used to construct a CSG solid
  122613. */
  122614. private static FromPolygons;
  122615. /**
  122616. * Clones, or makes a deep copy, of the CSG
  122617. * @returns A new CSG
  122618. */
  122619. clone(): CSG;
  122620. /**
  122621. * Unions this CSG with another CSG
  122622. * @param csg The CSG to union against this CSG
  122623. * @returns The unioned CSG
  122624. */
  122625. union(csg: CSG): CSG;
  122626. /**
  122627. * Unions this CSG with another CSG in place
  122628. * @param csg The CSG to union against this CSG
  122629. */
  122630. unionInPlace(csg: CSG): void;
  122631. /**
  122632. * Subtracts this CSG with another CSG
  122633. * @param csg The CSG to subtract against this CSG
  122634. * @returns A new CSG
  122635. */
  122636. subtract(csg: CSG): CSG;
  122637. /**
  122638. * Subtracts this CSG with another CSG in place
  122639. * @param csg The CSG to subtact against this CSG
  122640. */
  122641. subtractInPlace(csg: CSG): void;
  122642. /**
  122643. * Intersect this CSG with another CSG
  122644. * @param csg The CSG to intersect against this CSG
  122645. * @returns A new CSG
  122646. */
  122647. intersect(csg: CSG): CSG;
  122648. /**
  122649. * Intersects this CSG with another CSG in place
  122650. * @param csg The CSG to intersect against this CSG
  122651. */
  122652. intersectInPlace(csg: CSG): void;
  122653. /**
  122654. * Return a new CSG solid with solid and empty space switched. This solid is
  122655. * not modified.
  122656. * @returns A new CSG solid with solid and empty space switched
  122657. */
  122658. inverse(): CSG;
  122659. /**
  122660. * Inverses the CSG in place
  122661. */
  122662. inverseInPlace(): void;
  122663. /**
  122664. * This is used to keep meshes transformations so they can be restored
  122665. * when we build back a Babylon Mesh
  122666. * NB : All CSG operations are performed in world coordinates
  122667. * @param csg The CSG to copy the transform attributes from
  122668. * @returns This CSG
  122669. */
  122670. copyTransformAttributes(csg: CSG): CSG;
  122671. /**
  122672. * Build Raw mesh from CSG
  122673. * Coordinates here are in world space
  122674. * @param name The name of the mesh geometry
  122675. * @param scene The Scene
  122676. * @param keepSubMeshes Specifies if the submeshes should be kept
  122677. * @returns A new Mesh
  122678. */
  122679. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122680. /**
  122681. * Build Mesh from CSG taking material and transforms into account
  122682. * @param name The name of the Mesh
  122683. * @param material The material of the Mesh
  122684. * @param scene The Scene
  122685. * @param keepSubMeshes Specifies if submeshes should be kept
  122686. * @returns The new Mesh
  122687. */
  122688. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122689. }
  122690. }
  122691. declare module BABYLON {
  122692. /**
  122693. * Class used to create a trail following a mesh
  122694. */
  122695. export class TrailMesh extends Mesh {
  122696. private _generator;
  122697. private _autoStart;
  122698. private _running;
  122699. private _diameter;
  122700. private _length;
  122701. private _sectionPolygonPointsCount;
  122702. private _sectionVectors;
  122703. private _sectionNormalVectors;
  122704. private _beforeRenderObserver;
  122705. /**
  122706. * @constructor
  122707. * @param name The value used by scene.getMeshByName() to do a lookup.
  122708. * @param generator The mesh to generate a trail.
  122709. * @param scene The scene to add this mesh to.
  122710. * @param diameter Diameter of trailing mesh. Default is 1.
  122711. * @param length Length of trailing mesh. Default is 60.
  122712. * @param autoStart Automatically start trailing mesh. Default true.
  122713. */
  122714. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122715. /**
  122716. * "TrailMesh"
  122717. * @returns "TrailMesh"
  122718. */
  122719. getClassName(): string;
  122720. private _createMesh;
  122721. /**
  122722. * Start trailing mesh.
  122723. */
  122724. start(): void;
  122725. /**
  122726. * Stop trailing mesh.
  122727. */
  122728. stop(): void;
  122729. /**
  122730. * Update trailing mesh geometry.
  122731. */
  122732. update(): void;
  122733. /**
  122734. * Returns a new TrailMesh object.
  122735. * @param name is a string, the name given to the new mesh
  122736. * @param newGenerator use new generator object for cloned trail mesh
  122737. * @returns a new mesh
  122738. */
  122739. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122740. /**
  122741. * Serializes this trail mesh
  122742. * @param serializationObject object to write serialization to
  122743. */
  122744. serialize(serializationObject: any): void;
  122745. /**
  122746. * Parses a serialized trail mesh
  122747. * @param parsedMesh the serialized mesh
  122748. * @param scene the scene to create the trail mesh in
  122749. * @returns the created trail mesh
  122750. */
  122751. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122752. }
  122753. }
  122754. declare module BABYLON {
  122755. /**
  122756. * Class containing static functions to help procedurally build meshes
  122757. */
  122758. export class TiledBoxBuilder {
  122759. /**
  122760. * Creates a box mesh
  122761. * 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)
  122762. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122764. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122766. * @param name defines the name of the mesh
  122767. * @param options defines the options used to create the mesh
  122768. * @param scene defines the hosting scene
  122769. * @returns the box mesh
  122770. */
  122771. static CreateTiledBox(name: string, options: {
  122772. pattern?: number;
  122773. width?: number;
  122774. height?: number;
  122775. depth?: number;
  122776. tileSize?: number;
  122777. tileWidth?: number;
  122778. tileHeight?: number;
  122779. alignHorizontal?: number;
  122780. alignVertical?: number;
  122781. faceUV?: Vector4[];
  122782. faceColors?: Color4[];
  122783. sideOrientation?: number;
  122784. updatable?: boolean;
  122785. }, scene?: Nullable<Scene>): Mesh;
  122786. }
  122787. }
  122788. declare module BABYLON {
  122789. /**
  122790. * Class containing static functions to help procedurally build meshes
  122791. */
  122792. export class TorusKnotBuilder {
  122793. /**
  122794. * Creates a torus knot mesh
  122795. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122796. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122797. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122798. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122799. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122800. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122801. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122802. * @param name defines the name of the mesh
  122803. * @param options defines the options used to create the mesh
  122804. * @param scene defines the hosting scene
  122805. * @returns the torus knot mesh
  122806. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122807. */
  122808. static CreateTorusKnot(name: string, options: {
  122809. radius?: number;
  122810. tube?: number;
  122811. radialSegments?: number;
  122812. tubularSegments?: number;
  122813. p?: number;
  122814. q?: number;
  122815. updatable?: boolean;
  122816. sideOrientation?: number;
  122817. frontUVs?: Vector4;
  122818. backUVs?: Vector4;
  122819. }, scene: any): Mesh;
  122820. }
  122821. }
  122822. declare module BABYLON {
  122823. /**
  122824. * Polygon
  122825. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122826. */
  122827. export class Polygon {
  122828. /**
  122829. * Creates a rectangle
  122830. * @param xmin bottom X coord
  122831. * @param ymin bottom Y coord
  122832. * @param xmax top X coord
  122833. * @param ymax top Y coord
  122834. * @returns points that make the resulting rectation
  122835. */
  122836. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122837. /**
  122838. * Creates a circle
  122839. * @param radius radius of circle
  122840. * @param cx scale in x
  122841. * @param cy scale in y
  122842. * @param numberOfSides number of sides that make up the circle
  122843. * @returns points that make the resulting circle
  122844. */
  122845. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122846. /**
  122847. * Creates a polygon from input string
  122848. * @param input Input polygon data
  122849. * @returns the parsed points
  122850. */
  122851. static Parse(input: string): Vector2[];
  122852. /**
  122853. * Starts building a polygon from x and y coordinates
  122854. * @param x x coordinate
  122855. * @param y y coordinate
  122856. * @returns the started path2
  122857. */
  122858. static StartingAt(x: number, y: number): Path2;
  122859. }
  122860. /**
  122861. * Builds a polygon
  122862. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122863. */
  122864. export class PolygonMeshBuilder {
  122865. private _points;
  122866. private _outlinepoints;
  122867. private _holes;
  122868. private _name;
  122869. private _scene;
  122870. private _epoints;
  122871. private _eholes;
  122872. private _addToepoint;
  122873. /**
  122874. * Babylon reference to the earcut plugin.
  122875. */
  122876. bjsEarcut: any;
  122877. /**
  122878. * Creates a PolygonMeshBuilder
  122879. * @param name name of the builder
  122880. * @param contours Path of the polygon
  122881. * @param scene scene to add to when creating the mesh
  122882. * @param earcutInjection can be used to inject your own earcut reference
  122883. */
  122884. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122885. /**
  122886. * Adds a whole within the polygon
  122887. * @param hole Array of points defining the hole
  122888. * @returns this
  122889. */
  122890. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122891. /**
  122892. * Creates the polygon
  122893. * @param updatable If the mesh should be updatable
  122894. * @param depth The depth of the mesh created
  122895. * @returns the created mesh
  122896. */
  122897. build(updatable?: boolean, depth?: number): Mesh;
  122898. /**
  122899. * Creates the polygon
  122900. * @param depth The depth of the mesh created
  122901. * @returns the created VertexData
  122902. */
  122903. buildVertexData(depth?: number): VertexData;
  122904. /**
  122905. * Adds a side to the polygon
  122906. * @param positions points that make the polygon
  122907. * @param normals normals of the polygon
  122908. * @param uvs uvs of the polygon
  122909. * @param indices indices of the polygon
  122910. * @param bounds bounds of the polygon
  122911. * @param points points of the polygon
  122912. * @param depth depth of the polygon
  122913. * @param flip flip of the polygon
  122914. */
  122915. private addSide;
  122916. }
  122917. }
  122918. declare module BABYLON {
  122919. /**
  122920. * Class containing static functions to help procedurally build meshes
  122921. */
  122922. export class PolygonBuilder {
  122923. /**
  122924. * Creates a polygon mesh
  122925. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122926. * * 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
  122927. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122930. * * Remember you can only change the shape positions, not their number when updating a polygon
  122931. * @param name defines the name of the mesh
  122932. * @param options defines the options used to create the mesh
  122933. * @param scene defines the hosting scene
  122934. * @param earcutInjection can be used to inject your own earcut reference
  122935. * @returns the polygon mesh
  122936. */
  122937. static CreatePolygon(name: string, options: {
  122938. shape: Vector3[];
  122939. holes?: Vector3[][];
  122940. depth?: number;
  122941. faceUV?: Vector4[];
  122942. faceColors?: Color4[];
  122943. updatable?: boolean;
  122944. sideOrientation?: number;
  122945. frontUVs?: Vector4;
  122946. backUVs?: Vector4;
  122947. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122948. /**
  122949. * Creates an extruded polygon mesh, with depth in the Y direction.
  122950. * * 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)
  122951. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122952. * @param name defines the name of the mesh
  122953. * @param options defines the options used to create the mesh
  122954. * @param scene defines the hosting scene
  122955. * @param earcutInjection can be used to inject your own earcut reference
  122956. * @returns the polygon mesh
  122957. */
  122958. static ExtrudePolygon(name: string, options: {
  122959. shape: Vector3[];
  122960. holes?: Vector3[][];
  122961. depth?: number;
  122962. faceUV?: Vector4[];
  122963. faceColors?: Color4[];
  122964. updatable?: boolean;
  122965. sideOrientation?: number;
  122966. frontUVs?: Vector4;
  122967. backUVs?: Vector4;
  122968. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122969. }
  122970. }
  122971. declare module BABYLON {
  122972. /**
  122973. * Class containing static functions to help procedurally build meshes
  122974. */
  122975. export class LatheBuilder {
  122976. /**
  122977. * Creates lathe mesh.
  122978. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122979. * * 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
  122980. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122981. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122982. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122983. * * 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
  122984. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122985. * * 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
  122986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122988. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122989. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122990. * @param name defines the name of the mesh
  122991. * @param options defines the options used to create the mesh
  122992. * @param scene defines the hosting scene
  122993. * @returns the lathe mesh
  122994. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122995. */
  122996. static CreateLathe(name: string, options: {
  122997. shape: Vector3[];
  122998. radius?: number;
  122999. tessellation?: number;
  123000. clip?: number;
  123001. arc?: number;
  123002. closed?: boolean;
  123003. updatable?: boolean;
  123004. sideOrientation?: number;
  123005. frontUVs?: Vector4;
  123006. backUVs?: Vector4;
  123007. cap?: number;
  123008. invertUV?: boolean;
  123009. }, scene?: Nullable<Scene>): Mesh;
  123010. }
  123011. }
  123012. declare module BABYLON {
  123013. /**
  123014. * Class containing static functions to help procedurally build meshes
  123015. */
  123016. export class TiledPlaneBuilder {
  123017. /**
  123018. * Creates a tiled plane mesh
  123019. * * The parameter `pattern` will, depending on value, do nothing or
  123020. * * * flip (reflect about central vertical) alternate tiles across and up
  123021. * * * flip every tile on alternate rows
  123022. * * * rotate (180 degs) alternate tiles across and up
  123023. * * * rotate every tile on alternate rows
  123024. * * * flip and rotate alternate tiles across and up
  123025. * * * flip and rotate every tile on alternate rows
  123026. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123027. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123029. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123030. * * 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)
  123031. * * 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)
  123032. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123033. * @param name defines the name of the mesh
  123034. * @param options defines the options used to create the mesh
  123035. * @param scene defines the hosting scene
  123036. * @returns the box mesh
  123037. */
  123038. static CreateTiledPlane(name: string, options: {
  123039. pattern?: number;
  123040. tileSize?: number;
  123041. tileWidth?: number;
  123042. tileHeight?: number;
  123043. size?: number;
  123044. width?: number;
  123045. height?: number;
  123046. alignHorizontal?: number;
  123047. alignVertical?: number;
  123048. sideOrientation?: number;
  123049. frontUVs?: Vector4;
  123050. backUVs?: Vector4;
  123051. updatable?: boolean;
  123052. }, scene?: Nullable<Scene>): Mesh;
  123053. }
  123054. }
  123055. declare module BABYLON {
  123056. /**
  123057. * Class containing static functions to help procedurally build meshes
  123058. */
  123059. export class TubeBuilder {
  123060. /**
  123061. * Creates a tube mesh.
  123062. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123063. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123064. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123065. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123066. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123067. * * 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)
  123068. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123069. * * 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
  123070. * * 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
  123071. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123072. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123073. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123074. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123075. * @param name defines the name of the mesh
  123076. * @param options defines the options used to create the mesh
  123077. * @param scene defines the hosting scene
  123078. * @returns the tube mesh
  123079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123080. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123081. */
  123082. static CreateTube(name: string, options: {
  123083. path: Vector3[];
  123084. radius?: number;
  123085. tessellation?: number;
  123086. radiusFunction?: {
  123087. (i: number, distance: number): number;
  123088. };
  123089. cap?: number;
  123090. arc?: number;
  123091. updatable?: boolean;
  123092. sideOrientation?: number;
  123093. frontUVs?: Vector4;
  123094. backUVs?: Vector4;
  123095. instance?: Mesh;
  123096. invertUV?: boolean;
  123097. }, scene?: Nullable<Scene>): Mesh;
  123098. }
  123099. }
  123100. declare module BABYLON {
  123101. /**
  123102. * Class containing static functions to help procedurally build meshes
  123103. */
  123104. export class IcoSphereBuilder {
  123105. /**
  123106. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123107. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123108. * * 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`)
  123109. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123110. * * 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
  123111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123112. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123114. * @param name defines the name of the mesh
  123115. * @param options defines the options used to create the mesh
  123116. * @param scene defines the hosting scene
  123117. * @returns the icosahedron mesh
  123118. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123119. */
  123120. static CreateIcoSphere(name: string, options: {
  123121. radius?: number;
  123122. radiusX?: number;
  123123. radiusY?: number;
  123124. radiusZ?: number;
  123125. flat?: boolean;
  123126. subdivisions?: number;
  123127. sideOrientation?: number;
  123128. frontUVs?: Vector4;
  123129. backUVs?: Vector4;
  123130. updatable?: boolean;
  123131. }, scene?: Nullable<Scene>): Mesh;
  123132. }
  123133. }
  123134. declare module BABYLON {
  123135. /**
  123136. * Class containing static functions to help procedurally build meshes
  123137. */
  123138. export class DecalBuilder {
  123139. /**
  123140. * Creates a decal mesh.
  123141. * 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
  123142. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123143. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123144. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123145. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123146. * @param name defines the name of the mesh
  123147. * @param sourceMesh defines the mesh where the decal must be applied
  123148. * @param options defines the options used to create the mesh
  123149. * @param scene defines the hosting scene
  123150. * @returns the decal mesh
  123151. * @see https://doc.babylonjs.com/how_to/decals
  123152. */
  123153. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123154. position?: Vector3;
  123155. normal?: Vector3;
  123156. size?: Vector3;
  123157. angle?: number;
  123158. }): Mesh;
  123159. }
  123160. }
  123161. declare module BABYLON {
  123162. /**
  123163. * Class containing static functions to help procedurally build meshes
  123164. */
  123165. export class MeshBuilder {
  123166. /**
  123167. * Creates a box mesh
  123168. * * The parameter `size` sets the size (float) of each box side (default 1)
  123169. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123170. * * 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)
  123171. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123172. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123173. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123174. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123175. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  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 box mesh
  123180. */
  123181. static CreateBox(name: string, options: {
  123182. size?: number;
  123183. width?: number;
  123184. height?: number;
  123185. depth?: number;
  123186. faceUV?: Vector4[];
  123187. faceColors?: Color4[];
  123188. sideOrientation?: number;
  123189. frontUVs?: Vector4;
  123190. backUVs?: Vector4;
  123191. updatable?: boolean;
  123192. }, scene?: Nullable<Scene>): Mesh;
  123193. /**
  123194. * Creates a tiled box mesh
  123195. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123197. * @param name defines the name of the mesh
  123198. * @param options defines the options used to create the mesh
  123199. * @param scene defines the hosting scene
  123200. * @returns the tiled box mesh
  123201. */
  123202. static CreateTiledBox(name: string, options: {
  123203. pattern?: number;
  123204. size?: number;
  123205. width?: number;
  123206. height?: number;
  123207. depth: number;
  123208. tileSize?: number;
  123209. tileWidth?: number;
  123210. tileHeight?: number;
  123211. faceUV?: Vector4[];
  123212. faceColors?: Color4[];
  123213. alignHorizontal?: number;
  123214. alignVertical?: number;
  123215. sideOrientation?: number;
  123216. updatable?: boolean;
  123217. }, scene?: Nullable<Scene>): Mesh;
  123218. /**
  123219. * Creates a sphere mesh
  123220. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123221. * * 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`)
  123222. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123223. * * 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
  123224. * * 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)
  123225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123228. * @param name defines the name of the mesh
  123229. * @param options defines the options used to create the mesh
  123230. * @param scene defines the hosting scene
  123231. * @returns the sphere mesh
  123232. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123233. */
  123234. static CreateSphere(name: string, options: {
  123235. segments?: number;
  123236. diameter?: number;
  123237. diameterX?: number;
  123238. diameterY?: number;
  123239. diameterZ?: number;
  123240. arc?: number;
  123241. slice?: number;
  123242. sideOrientation?: number;
  123243. frontUVs?: Vector4;
  123244. backUVs?: Vector4;
  123245. updatable?: boolean;
  123246. }, scene?: Nullable<Scene>): Mesh;
  123247. /**
  123248. * Creates a plane polygonal mesh. By default, this is a disc
  123249. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123250. * * 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
  123251. * * 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
  123252. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123253. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123255. * @param name defines the name of the mesh
  123256. * @param options defines the options used to create the mesh
  123257. * @param scene defines the hosting scene
  123258. * @returns the plane polygonal mesh
  123259. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123260. */
  123261. static CreateDisc(name: string, options: {
  123262. radius?: number;
  123263. tessellation?: number;
  123264. arc?: number;
  123265. updatable?: boolean;
  123266. sideOrientation?: number;
  123267. frontUVs?: Vector4;
  123268. backUVs?: Vector4;
  123269. }, scene?: Nullable<Scene>): Mesh;
  123270. /**
  123271. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123272. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123273. * * 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`)
  123274. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123275. * * 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
  123276. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123277. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123279. * @param name defines the name of the mesh
  123280. * @param options defines the options used to create the mesh
  123281. * @param scene defines the hosting scene
  123282. * @returns the icosahedron mesh
  123283. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123284. */
  123285. static CreateIcoSphere(name: string, options: {
  123286. radius?: number;
  123287. radiusX?: number;
  123288. radiusY?: number;
  123289. radiusZ?: number;
  123290. flat?: boolean;
  123291. subdivisions?: number;
  123292. sideOrientation?: number;
  123293. frontUVs?: Vector4;
  123294. backUVs?: Vector4;
  123295. updatable?: boolean;
  123296. }, scene?: Nullable<Scene>): Mesh;
  123297. /**
  123298. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123299. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123300. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123301. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123302. * * 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
  123303. * * 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
  123304. * * 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
  123305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123307. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123308. * * 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
  123309. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123310. * * 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
  123311. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123312. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123313. * @param name defines the name of the mesh
  123314. * @param options defines the options used to create the mesh
  123315. * @param scene defines the hosting scene
  123316. * @returns the ribbon mesh
  123317. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123319. */
  123320. static CreateRibbon(name: string, options: {
  123321. pathArray: Vector3[][];
  123322. closeArray?: boolean;
  123323. closePath?: boolean;
  123324. offset?: number;
  123325. updatable?: boolean;
  123326. sideOrientation?: number;
  123327. frontUVs?: Vector4;
  123328. backUVs?: Vector4;
  123329. instance?: Mesh;
  123330. invertUV?: boolean;
  123331. uvs?: Vector2[];
  123332. colors?: Color4[];
  123333. }, scene?: Nullable<Scene>): Mesh;
  123334. /**
  123335. * Creates a cylinder or a cone mesh
  123336. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123337. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123338. * * 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.
  123339. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123340. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123341. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123342. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123343. * * 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).
  123344. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123345. * * 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).
  123346. * * 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
  123347. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123348. * * 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
  123349. * * 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.
  123350. * * If `enclose` is false, a ring surface is one element.
  123351. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123352. * * 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
  123353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123356. * @param name defines the name of the mesh
  123357. * @param options defines the options used to create the mesh
  123358. * @param scene defines the hosting scene
  123359. * @returns the cylinder mesh
  123360. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123361. */
  123362. static CreateCylinder(name: string, options: {
  123363. height?: number;
  123364. diameterTop?: number;
  123365. diameterBottom?: number;
  123366. diameter?: number;
  123367. tessellation?: number;
  123368. subdivisions?: number;
  123369. arc?: number;
  123370. faceColors?: Color4[];
  123371. faceUV?: Vector4[];
  123372. updatable?: boolean;
  123373. hasRings?: boolean;
  123374. enclose?: boolean;
  123375. cap?: number;
  123376. sideOrientation?: number;
  123377. frontUVs?: Vector4;
  123378. backUVs?: Vector4;
  123379. }, scene?: Nullable<Scene>): Mesh;
  123380. /**
  123381. * Creates a torus mesh
  123382. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123383. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123384. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123385. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123386. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123387. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123388. * @param name defines the name of the mesh
  123389. * @param options defines the options used to create the mesh
  123390. * @param scene defines the hosting scene
  123391. * @returns the torus mesh
  123392. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123393. */
  123394. static CreateTorus(name: string, options: {
  123395. diameter?: number;
  123396. thickness?: number;
  123397. tessellation?: number;
  123398. updatable?: boolean;
  123399. sideOrientation?: number;
  123400. frontUVs?: Vector4;
  123401. backUVs?: Vector4;
  123402. }, scene?: Nullable<Scene>): Mesh;
  123403. /**
  123404. * Creates a torus knot mesh
  123405. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123406. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123407. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123408. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123410. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 torus knot mesh
  123416. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123417. */
  123418. static CreateTorusKnot(name: string, options: {
  123419. radius?: number;
  123420. tube?: number;
  123421. radialSegments?: number;
  123422. tubularSegments?: number;
  123423. p?: number;
  123424. q?: number;
  123425. updatable?: boolean;
  123426. sideOrientation?: number;
  123427. frontUVs?: Vector4;
  123428. backUVs?: Vector4;
  123429. }, scene?: Nullable<Scene>): Mesh;
  123430. /**
  123431. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123432. * * 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
  123433. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123434. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123435. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123436. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123437. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123438. * * 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
  123439. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123441. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123442. * @param name defines the name of the new line system
  123443. * @param options defines the options used to create the line system
  123444. * @param scene defines the hosting scene
  123445. * @returns a new line system mesh
  123446. */
  123447. static CreateLineSystem(name: string, options: {
  123448. lines: Vector3[][];
  123449. updatable?: boolean;
  123450. instance?: Nullable<LinesMesh>;
  123451. colors?: Nullable<Color4[][]>;
  123452. useVertexAlpha?: boolean;
  123453. }, scene: Nullable<Scene>): LinesMesh;
  123454. /**
  123455. * Creates a line mesh
  123456. * 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
  123457. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123458. * * The parameter `points` is an array successive Vector3
  123459. * * 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
  123460. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123461. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123462. * * When updating an instance, remember that only point positions can change, not the number of points
  123463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123464. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123465. * @param name defines the name of the new line system
  123466. * @param options defines the options used to create the line system
  123467. * @param scene defines the hosting scene
  123468. * @returns a new line mesh
  123469. */
  123470. static CreateLines(name: string, options: {
  123471. points: Vector3[];
  123472. updatable?: boolean;
  123473. instance?: Nullable<LinesMesh>;
  123474. colors?: Color4[];
  123475. useVertexAlpha?: boolean;
  123476. }, scene?: Nullable<Scene>): LinesMesh;
  123477. /**
  123478. * Creates a dashed line mesh
  123479. * * 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
  123480. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123481. * * The parameter `points` is an array successive Vector3
  123482. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123483. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123484. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123485. * * 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
  123486. * * When updating an instance, remember that only point positions can change, not the number of points
  123487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123488. * @param name defines the name of the mesh
  123489. * @param options defines the options used to create the mesh
  123490. * @param scene defines the hosting scene
  123491. * @returns the dashed line mesh
  123492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123493. */
  123494. static CreateDashedLines(name: string, options: {
  123495. points: Vector3[];
  123496. dashSize?: number;
  123497. gapSize?: number;
  123498. dashNb?: number;
  123499. updatable?: boolean;
  123500. instance?: LinesMesh;
  123501. }, scene?: Nullable<Scene>): LinesMesh;
  123502. /**
  123503. * 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.
  123504. * * 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.
  123505. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123506. * * 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.
  123507. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123508. * * 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
  123509. * * 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
  123510. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123511. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123512. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123513. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123515. * @param name defines the name of the mesh
  123516. * @param options defines the options used to create the mesh
  123517. * @param scene defines the hosting scene
  123518. * @returns the extruded shape mesh
  123519. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123520. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123521. */
  123522. static ExtrudeShape(name: string, options: {
  123523. shape: Vector3[];
  123524. path: Vector3[];
  123525. scale?: number;
  123526. rotation?: number;
  123527. cap?: number;
  123528. updatable?: boolean;
  123529. sideOrientation?: number;
  123530. frontUVs?: Vector4;
  123531. backUVs?: Vector4;
  123532. instance?: Mesh;
  123533. invertUV?: boolean;
  123534. }, scene?: Nullable<Scene>): Mesh;
  123535. /**
  123536. * Creates an custom extruded shape mesh.
  123537. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123538. * * 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.
  123539. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123540. * * 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
  123541. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123542. * * 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
  123543. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123544. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123545. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123546. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  123547. * * 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
  123548. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123549. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123550. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123551. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123552. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123553. * @param name defines the name of the mesh
  123554. * @param options defines the options used to create the mesh
  123555. * @param scene defines the hosting scene
  123556. * @returns the custom extruded shape mesh
  123557. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123558. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123559. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123560. */
  123561. static ExtrudeShapeCustom(name: string, options: {
  123562. shape: Vector3[];
  123563. path: Vector3[];
  123564. scaleFunction?: any;
  123565. rotationFunction?: any;
  123566. ribbonCloseArray?: boolean;
  123567. ribbonClosePath?: boolean;
  123568. cap?: number;
  123569. updatable?: boolean;
  123570. sideOrientation?: number;
  123571. frontUVs?: Vector4;
  123572. backUVs?: Vector4;
  123573. instance?: Mesh;
  123574. invertUV?: boolean;
  123575. }, scene?: Nullable<Scene>): Mesh;
  123576. /**
  123577. * Creates lathe mesh.
  123578. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123579. * * 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
  123580. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123581. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123582. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123583. * * 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
  123584. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123585. * * 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
  123586. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123587. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123588. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123590. * @param name defines the name of the mesh
  123591. * @param options defines the options used to create the mesh
  123592. * @param scene defines the hosting scene
  123593. * @returns the lathe mesh
  123594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123595. */
  123596. static CreateLathe(name: string, options: {
  123597. shape: Vector3[];
  123598. radius?: number;
  123599. tessellation?: number;
  123600. clip?: number;
  123601. arc?: number;
  123602. closed?: boolean;
  123603. updatable?: boolean;
  123604. sideOrientation?: number;
  123605. frontUVs?: Vector4;
  123606. backUVs?: Vector4;
  123607. cap?: number;
  123608. invertUV?: boolean;
  123609. }, scene?: Nullable<Scene>): Mesh;
  123610. /**
  123611. * Creates a tiled plane mesh
  123612. * * You can set a limited pattern arrangement with the tiles
  123613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 options defines the options used to create the mesh
  123618. * @param scene defines the hosting scene
  123619. * @returns the plane mesh
  123620. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123621. */
  123622. static CreateTiledPlane(name: string, options: {
  123623. pattern?: number;
  123624. tileSize?: number;
  123625. tileWidth?: number;
  123626. tileHeight?: number;
  123627. size?: number;
  123628. width?: number;
  123629. height?: number;
  123630. alignHorizontal?: number;
  123631. alignVertical?: number;
  123632. sideOrientation?: number;
  123633. frontUVs?: Vector4;
  123634. backUVs?: Vector4;
  123635. updatable?: boolean;
  123636. }, scene?: Nullable<Scene>): Mesh;
  123637. /**
  123638. * Creates a plane mesh
  123639. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123640. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123641. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123642. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123643. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123644. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123645. * @param name defines the name of the mesh
  123646. * @param options defines the options used to create the mesh
  123647. * @param scene defines the hosting scene
  123648. * @returns the plane mesh
  123649. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123650. */
  123651. static CreatePlane(name: string, options: {
  123652. size?: number;
  123653. width?: number;
  123654. height?: number;
  123655. sideOrientation?: number;
  123656. frontUVs?: Vector4;
  123657. backUVs?: Vector4;
  123658. updatable?: boolean;
  123659. sourcePlane?: Plane;
  123660. }, scene?: Nullable<Scene>): Mesh;
  123661. /**
  123662. * Creates a ground mesh
  123663. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123664. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123666. * @param name defines the name of the mesh
  123667. * @param options defines the options used to create the mesh
  123668. * @param scene defines the hosting scene
  123669. * @returns the ground mesh
  123670. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123671. */
  123672. static CreateGround(name: string, options: {
  123673. width?: number;
  123674. height?: number;
  123675. subdivisions?: number;
  123676. subdivisionsX?: number;
  123677. subdivisionsY?: number;
  123678. updatable?: boolean;
  123679. }, scene?: Nullable<Scene>): Mesh;
  123680. /**
  123681. * Creates a tiled ground mesh
  123682. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123683. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123684. * * 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
  123685. * * 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
  123686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123687. * @param name defines the name of the mesh
  123688. * @param options defines the options used to create the mesh
  123689. * @param scene defines the hosting scene
  123690. * @returns the tiled ground mesh
  123691. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123692. */
  123693. static CreateTiledGround(name: string, options: {
  123694. xmin: number;
  123695. zmin: number;
  123696. xmax: number;
  123697. zmax: number;
  123698. subdivisions?: {
  123699. w: number;
  123700. h: number;
  123701. };
  123702. precision?: {
  123703. w: number;
  123704. h: number;
  123705. };
  123706. updatable?: boolean;
  123707. }, scene?: Nullable<Scene>): Mesh;
  123708. /**
  123709. * Creates a ground mesh from a height map
  123710. * * The parameter `url` sets the URL of the height map image resource.
  123711. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123712. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123713. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123714. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123715. * * 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.
  123716. * * 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).
  123717. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123719. * @param name defines the name of the mesh
  123720. * @param url defines the url to the height map
  123721. * @param options defines the options used to create the mesh
  123722. * @param scene defines the hosting scene
  123723. * @returns the ground mesh
  123724. * @see https://doc.babylonjs.com/babylon101/height_map
  123725. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123726. */
  123727. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123728. width?: number;
  123729. height?: number;
  123730. subdivisions?: number;
  123731. minHeight?: number;
  123732. maxHeight?: number;
  123733. colorFilter?: Color3;
  123734. alphaFilter?: number;
  123735. updatable?: boolean;
  123736. onReady?: (mesh: GroundMesh) => void;
  123737. }, scene?: Nullable<Scene>): GroundMesh;
  123738. /**
  123739. * Creates a polygon mesh
  123740. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123741. * * 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
  123742. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123745. * * Remember you can only change the shape positions, not their number when updating a polygon
  123746. * @param name defines the name of the mesh
  123747. * @param options defines the options used to create the mesh
  123748. * @param scene defines the hosting scene
  123749. * @param earcutInjection can be used to inject your own earcut reference
  123750. * @returns the polygon mesh
  123751. */
  123752. static CreatePolygon(name: string, options: {
  123753. shape: Vector3[];
  123754. holes?: Vector3[][];
  123755. depth?: number;
  123756. faceUV?: Vector4[];
  123757. faceColors?: Color4[];
  123758. updatable?: boolean;
  123759. sideOrientation?: number;
  123760. frontUVs?: Vector4;
  123761. backUVs?: Vector4;
  123762. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123763. /**
  123764. * Creates an extruded polygon mesh, with depth in the Y direction.
  123765. * * 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)
  123766. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123767. * @param name defines the name of the mesh
  123768. * @param options defines the options used to create the mesh
  123769. * @param scene defines the hosting scene
  123770. * @param earcutInjection can be used to inject your own earcut reference
  123771. * @returns the polygon mesh
  123772. */
  123773. static ExtrudePolygon(name: string, options: {
  123774. shape: Vector3[];
  123775. holes?: Vector3[][];
  123776. depth?: number;
  123777. faceUV?: Vector4[];
  123778. faceColors?: Color4[];
  123779. updatable?: boolean;
  123780. sideOrientation?: number;
  123781. frontUVs?: Vector4;
  123782. backUVs?: Vector4;
  123783. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123784. /**
  123785. * Creates a tube mesh.
  123786. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123787. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123788. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123789. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123790. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123791. * * 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)
  123792. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123793. * * 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
  123794. * * 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
  123795. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123796. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123797. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123799. * @param name defines the name of the mesh
  123800. * @param options defines the options used to create the mesh
  123801. * @param scene defines the hosting scene
  123802. * @returns the tube mesh
  123803. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123804. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123805. */
  123806. static CreateTube(name: string, options: {
  123807. path: Vector3[];
  123808. radius?: number;
  123809. tessellation?: number;
  123810. radiusFunction?: {
  123811. (i: number, distance: number): number;
  123812. };
  123813. cap?: number;
  123814. arc?: number;
  123815. updatable?: boolean;
  123816. sideOrientation?: number;
  123817. frontUVs?: Vector4;
  123818. backUVs?: Vector4;
  123819. instance?: Mesh;
  123820. invertUV?: boolean;
  123821. }, scene?: Nullable<Scene>): Mesh;
  123822. /**
  123823. * Creates a polyhedron mesh
  123824. * * 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
  123825. * * The parameter `size` (positive float, default 1) sets the polygon size
  123826. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123827. * * 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`
  123828. * * 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
  123829. * * 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)`)
  123830. * * 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
  123831. * * 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
  123832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123833. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123835. * @param name defines the name of the mesh
  123836. * @param options defines the options used to create the mesh
  123837. * @param scene defines the hosting scene
  123838. * @returns the polyhedron mesh
  123839. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123840. */
  123841. static CreatePolyhedron(name: string, options: {
  123842. type?: number;
  123843. size?: number;
  123844. sizeX?: number;
  123845. sizeY?: number;
  123846. sizeZ?: number;
  123847. custom?: any;
  123848. faceUV?: Vector4[];
  123849. faceColors?: Color4[];
  123850. flat?: boolean;
  123851. updatable?: boolean;
  123852. sideOrientation?: number;
  123853. frontUVs?: Vector4;
  123854. backUVs?: Vector4;
  123855. }, scene?: Nullable<Scene>): Mesh;
  123856. /**
  123857. * Creates a decal mesh.
  123858. * 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
  123859. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123860. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123861. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123862. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123863. * @param name defines the name of the mesh
  123864. * @param sourceMesh defines the mesh where the decal must be applied
  123865. * @param options defines the options used to create the mesh
  123866. * @param scene defines the hosting scene
  123867. * @returns the decal mesh
  123868. * @see https://doc.babylonjs.com/how_to/decals
  123869. */
  123870. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123871. position?: Vector3;
  123872. normal?: Vector3;
  123873. size?: Vector3;
  123874. angle?: number;
  123875. }): Mesh;
  123876. }
  123877. }
  123878. declare module BABYLON {
  123879. /**
  123880. * A simplifier interface for future simplification implementations
  123881. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123882. */
  123883. export interface ISimplifier {
  123884. /**
  123885. * Simplification of a given mesh according to the given settings.
  123886. * Since this requires computation, it is assumed that the function runs async.
  123887. * @param settings The settings of the simplification, including quality and distance
  123888. * @param successCallback A callback that will be called after the mesh was simplified.
  123889. * @param errorCallback in case of an error, this callback will be called. optional.
  123890. */
  123891. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123892. }
  123893. /**
  123894. * Expected simplification settings.
  123895. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123896. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123897. */
  123898. export interface ISimplificationSettings {
  123899. /**
  123900. * Gets or sets the expected quality
  123901. */
  123902. quality: number;
  123903. /**
  123904. * Gets or sets the distance when this optimized version should be used
  123905. */
  123906. distance: number;
  123907. /**
  123908. * Gets an already optimized mesh
  123909. */
  123910. optimizeMesh?: boolean;
  123911. }
  123912. /**
  123913. * Class used to specify simplification options
  123914. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123915. */
  123916. export class SimplificationSettings implements ISimplificationSettings {
  123917. /** expected quality */
  123918. quality: number;
  123919. /** distance when this optimized version should be used */
  123920. distance: number;
  123921. /** already optimized mesh */
  123922. optimizeMesh?: boolean | undefined;
  123923. /**
  123924. * Creates a SimplificationSettings
  123925. * @param quality expected quality
  123926. * @param distance distance when this optimized version should be used
  123927. * @param optimizeMesh already optimized mesh
  123928. */
  123929. constructor(
  123930. /** expected quality */
  123931. quality: number,
  123932. /** distance when this optimized version should be used */
  123933. distance: number,
  123934. /** already optimized mesh */
  123935. optimizeMesh?: boolean | undefined);
  123936. }
  123937. /**
  123938. * Interface used to define a simplification task
  123939. */
  123940. export interface ISimplificationTask {
  123941. /**
  123942. * Array of settings
  123943. */
  123944. settings: Array<ISimplificationSettings>;
  123945. /**
  123946. * Simplification type
  123947. */
  123948. simplificationType: SimplificationType;
  123949. /**
  123950. * Mesh to simplify
  123951. */
  123952. mesh: Mesh;
  123953. /**
  123954. * Callback called on success
  123955. */
  123956. successCallback?: () => void;
  123957. /**
  123958. * Defines if parallel processing can be used
  123959. */
  123960. parallelProcessing: boolean;
  123961. }
  123962. /**
  123963. * Queue used to order the simplification tasks
  123964. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123965. */
  123966. export class SimplificationQueue {
  123967. private _simplificationArray;
  123968. /**
  123969. * Gets a boolean indicating that the process is still running
  123970. */
  123971. running: boolean;
  123972. /**
  123973. * Creates a new queue
  123974. */
  123975. constructor();
  123976. /**
  123977. * Adds a new simplification task
  123978. * @param task defines a task to add
  123979. */
  123980. addTask(task: ISimplificationTask): void;
  123981. /**
  123982. * Execute next task
  123983. */
  123984. executeNext(): void;
  123985. /**
  123986. * Execute a simplification task
  123987. * @param task defines the task to run
  123988. */
  123989. runSimplification(task: ISimplificationTask): void;
  123990. private getSimplifier;
  123991. }
  123992. /**
  123993. * The implemented types of simplification
  123994. * At the moment only Quadratic Error Decimation is implemented
  123995. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123996. */
  123997. export enum SimplificationType {
  123998. /** Quadratic error decimation */
  123999. QUADRATIC = 0
  124000. }
  124001. }
  124002. declare module BABYLON {
  124003. interface Scene {
  124004. /** @hidden (Backing field) */
  124005. _simplificationQueue: SimplificationQueue;
  124006. /**
  124007. * Gets or sets the simplification queue attached to the scene
  124008. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124009. */
  124010. simplificationQueue: SimplificationQueue;
  124011. }
  124012. interface Mesh {
  124013. /**
  124014. * Simplify the mesh according to the given array of settings.
  124015. * Function will return immediately and will simplify async
  124016. * @param settings a collection of simplification settings
  124017. * @param parallelProcessing should all levels calculate parallel or one after the other
  124018. * @param simplificationType the type of simplification to run
  124019. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124020. * @returns the current mesh
  124021. */
  124022. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124023. }
  124024. /**
  124025. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124026. * created in a scene
  124027. */
  124028. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124029. /**
  124030. * The component name helpfull to identify the component in the list of scene components.
  124031. */
  124032. readonly name: string;
  124033. /**
  124034. * The scene the component belongs to.
  124035. */
  124036. scene: Scene;
  124037. /**
  124038. * Creates a new instance of the component for the given scene
  124039. * @param scene Defines the scene to register the component in
  124040. */
  124041. constructor(scene: Scene);
  124042. /**
  124043. * Registers the component in a given scene
  124044. */
  124045. register(): void;
  124046. /**
  124047. * Rebuilds the elements related to this component in case of
  124048. * context lost for instance.
  124049. */
  124050. rebuild(): void;
  124051. /**
  124052. * Disposes the component and the associated ressources
  124053. */
  124054. dispose(): void;
  124055. private _beforeCameraUpdate;
  124056. }
  124057. }
  124058. declare module BABYLON {
  124059. /**
  124060. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124061. */
  124062. export interface INavigationEnginePlugin {
  124063. /**
  124064. * plugin name
  124065. */
  124066. name: string;
  124067. /**
  124068. * Creates a navigation mesh
  124069. * @param meshes array of all the geometry used to compute the navigatio mesh
  124070. * @param parameters bunch of parameters used to filter geometry
  124071. */
  124072. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124073. /**
  124074. * Create a navigation mesh debug mesh
  124075. * @param scene is where the mesh will be added
  124076. * @returns debug display mesh
  124077. */
  124078. createDebugNavMesh(scene: Scene): Mesh;
  124079. /**
  124080. * Get a navigation mesh constrained position, closest to the parameter position
  124081. * @param position world position
  124082. * @returns the closest point to position constrained by the navigation mesh
  124083. */
  124084. getClosestPoint(position: Vector3): Vector3;
  124085. /**
  124086. * Get a navigation mesh constrained position, within a particular radius
  124087. * @param position world position
  124088. * @param maxRadius the maximum distance to the constrained world position
  124089. * @returns the closest point to position constrained by the navigation mesh
  124090. */
  124091. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124092. /**
  124093. * Compute the final position from a segment made of destination-position
  124094. * @param position world position
  124095. * @param destination world position
  124096. * @returns the resulting point along the navmesh
  124097. */
  124098. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124099. /**
  124100. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124101. * @param start world position
  124102. * @param end world position
  124103. * @returns array containing world position composing the path
  124104. */
  124105. computePath(start: Vector3, end: Vector3): Vector3[];
  124106. /**
  124107. * If this plugin is supported
  124108. * @returns true if plugin is supported
  124109. */
  124110. isSupported(): boolean;
  124111. /**
  124112. * Create a new Crowd so you can add agents
  124113. * @param maxAgents the maximum agent count in the crowd
  124114. * @param maxAgentRadius the maximum radius an agent can have
  124115. * @param scene to attach the crowd to
  124116. * @returns the crowd you can add agents to
  124117. */
  124118. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124119. /**
  124120. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124121. * The queries will try to find a solution within those bounds
  124122. * default is (1,1,1)
  124123. * @param extent x,y,z value that define the extent around the queries point of reference
  124124. */
  124125. setDefaultQueryExtent(extent: Vector3): void;
  124126. /**
  124127. * Get the Bounding box extent specified by setDefaultQueryExtent
  124128. * @returns the box extent values
  124129. */
  124130. getDefaultQueryExtent(): Vector3;
  124131. /**
  124132. * Release all resources
  124133. */
  124134. dispose(): void;
  124135. }
  124136. /**
  124137. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124138. */
  124139. export interface ICrowd {
  124140. /**
  124141. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124142. * You can attach anything to that node. The node position is updated in the scene update tick.
  124143. * @param pos world position that will be constrained by the navigation mesh
  124144. * @param parameters agent parameters
  124145. * @param transform hooked to the agent that will be update by the scene
  124146. * @returns agent index
  124147. */
  124148. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124149. /**
  124150. * Returns the agent position in world space
  124151. * @param index agent index returned by addAgent
  124152. * @returns world space position
  124153. */
  124154. getAgentPosition(index: number): Vector3;
  124155. /**
  124156. * Gets the agent velocity in world space
  124157. * @param index agent index returned by addAgent
  124158. * @returns world space velocity
  124159. */
  124160. getAgentVelocity(index: number): Vector3;
  124161. /**
  124162. * remove a particular agent previously created
  124163. * @param index agent index returned by addAgent
  124164. */
  124165. removeAgent(index: number): void;
  124166. /**
  124167. * get the list of all agents attached to this crowd
  124168. * @returns list of agent indices
  124169. */
  124170. getAgents(): number[];
  124171. /**
  124172. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124173. * @param deltaTime in seconds
  124174. */
  124175. update(deltaTime: number): void;
  124176. /**
  124177. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124178. * @param index agent index returned by addAgent
  124179. * @param destination targeted world position
  124180. */
  124181. agentGoto(index: number, destination: Vector3): void;
  124182. /**
  124183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124184. * The queries will try to find a solution within those bounds
  124185. * default is (1,1,1)
  124186. * @param extent x,y,z value that define the extent around the queries point of reference
  124187. */
  124188. setDefaultQueryExtent(extent: Vector3): void;
  124189. /**
  124190. * Get the Bounding box extent specified by setDefaultQueryExtent
  124191. * @returns the box extent values
  124192. */
  124193. getDefaultQueryExtent(): Vector3;
  124194. /**
  124195. * Release all resources
  124196. */
  124197. dispose(): void;
  124198. }
  124199. /**
  124200. * Configures an agent
  124201. */
  124202. export interface IAgentParameters {
  124203. /**
  124204. * Agent radius. [Limit: >= 0]
  124205. */
  124206. radius: number;
  124207. /**
  124208. * Agent height. [Limit: > 0]
  124209. */
  124210. height: number;
  124211. /**
  124212. * Maximum allowed acceleration. [Limit: >= 0]
  124213. */
  124214. maxAcceleration: number;
  124215. /**
  124216. * Maximum allowed speed. [Limit: >= 0]
  124217. */
  124218. maxSpeed: number;
  124219. /**
  124220. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124221. */
  124222. collisionQueryRange: number;
  124223. /**
  124224. * The path visibility optimization range. [Limit: > 0]
  124225. */
  124226. pathOptimizationRange: number;
  124227. /**
  124228. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124229. */
  124230. separationWeight: number;
  124231. }
  124232. /**
  124233. * Configures the navigation mesh creation
  124234. */
  124235. export interface INavMeshParameters {
  124236. /**
  124237. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124238. */
  124239. cs: number;
  124240. /**
  124241. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124242. */
  124243. ch: number;
  124244. /**
  124245. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124246. */
  124247. walkableSlopeAngle: number;
  124248. /**
  124249. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124250. * be considered walkable. [Limit: >= 3] [Units: vx]
  124251. */
  124252. walkableHeight: number;
  124253. /**
  124254. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124255. */
  124256. walkableClimb: number;
  124257. /**
  124258. * The distance to erode/shrink the walkable area of the heightfield away from
  124259. * obstructions. [Limit: >=0] [Units: vx]
  124260. */
  124261. walkableRadius: number;
  124262. /**
  124263. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124264. */
  124265. maxEdgeLen: number;
  124266. /**
  124267. * The maximum distance a simplfied contour's border edges should deviate
  124268. * the original raw contour. [Limit: >=0] [Units: vx]
  124269. */
  124270. maxSimplificationError: number;
  124271. /**
  124272. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124273. */
  124274. minRegionArea: number;
  124275. /**
  124276. * Any regions with a span count smaller than this value will, if possible,
  124277. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124278. */
  124279. mergeRegionArea: number;
  124280. /**
  124281. * The maximum number of vertices allowed for polygons generated during the
  124282. * contour to polygon conversion process. [Limit: >= 3]
  124283. */
  124284. maxVertsPerPoly: number;
  124285. /**
  124286. * Sets the sampling distance to use when generating the detail mesh.
  124287. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124288. */
  124289. detailSampleDist: number;
  124290. /**
  124291. * The maximum distance the detail mesh surface should deviate from heightfield
  124292. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124293. */
  124294. detailSampleMaxError: number;
  124295. }
  124296. }
  124297. declare module BABYLON {
  124298. /**
  124299. * RecastJS navigation plugin
  124300. */
  124301. export class RecastJSPlugin implements INavigationEnginePlugin {
  124302. /**
  124303. * Reference to the Recast library
  124304. */
  124305. bjsRECAST: any;
  124306. /**
  124307. * plugin name
  124308. */
  124309. name: string;
  124310. /**
  124311. * the first navmesh created. We might extend this to support multiple navmeshes
  124312. */
  124313. navMesh: any;
  124314. /**
  124315. * Initializes the recastJS plugin
  124316. * @param recastInjection can be used to inject your own recast reference
  124317. */
  124318. constructor(recastInjection?: any);
  124319. /**
  124320. * Creates a navigation mesh
  124321. * @param meshes array of all the geometry used to compute the navigatio mesh
  124322. * @param parameters bunch of parameters used to filter geometry
  124323. */
  124324. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124325. /**
  124326. * Create a navigation mesh debug mesh
  124327. * @param scene is where the mesh will be added
  124328. * @returns debug display mesh
  124329. */
  124330. createDebugNavMesh(scene: Scene): Mesh;
  124331. /**
  124332. * Get a navigation mesh constrained position, closest to the parameter position
  124333. * @param position world position
  124334. * @returns the closest point to position constrained by the navigation mesh
  124335. */
  124336. getClosestPoint(position: Vector3): Vector3;
  124337. /**
  124338. * Get a navigation mesh constrained position, within a particular radius
  124339. * @param position world position
  124340. * @param maxRadius the maximum distance to the constrained world position
  124341. * @returns the closest point to position constrained by the navigation mesh
  124342. */
  124343. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124344. /**
  124345. * Compute the final position from a segment made of destination-position
  124346. * @param position world position
  124347. * @param destination world position
  124348. * @returns the resulting point along the navmesh
  124349. */
  124350. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124351. /**
  124352. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124353. * @param start world position
  124354. * @param end world position
  124355. * @returns array containing world position composing the path
  124356. */
  124357. computePath(start: Vector3, end: Vector3): Vector3[];
  124358. /**
  124359. * Create a new Crowd so you can add agents
  124360. * @param maxAgents the maximum agent count in the crowd
  124361. * @param maxAgentRadius the maximum radius an agent can have
  124362. * @param scene to attach the crowd to
  124363. * @returns the crowd you can add agents to
  124364. */
  124365. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124366. /**
  124367. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124368. * The queries will try to find a solution within those bounds
  124369. * default is (1,1,1)
  124370. * @param extent x,y,z value that define the extent around the queries point of reference
  124371. */
  124372. setDefaultQueryExtent(extent: Vector3): void;
  124373. /**
  124374. * Get the Bounding box extent specified by setDefaultQueryExtent
  124375. * @returns the box extent values
  124376. */
  124377. getDefaultQueryExtent(): Vector3;
  124378. /**
  124379. * Disposes
  124380. */
  124381. dispose(): void;
  124382. /**
  124383. * If this plugin is supported
  124384. * @returns true if plugin is supported
  124385. */
  124386. isSupported(): boolean;
  124387. }
  124388. /**
  124389. * Recast detour crowd implementation
  124390. */
  124391. export class RecastJSCrowd implements ICrowd {
  124392. /**
  124393. * Recast/detour plugin
  124394. */
  124395. bjsRECASTPlugin: RecastJSPlugin;
  124396. /**
  124397. * Link to the detour crowd
  124398. */
  124399. recastCrowd: any;
  124400. /**
  124401. * One transform per agent
  124402. */
  124403. transforms: TransformNode[];
  124404. /**
  124405. * All agents created
  124406. */
  124407. agents: number[];
  124408. /**
  124409. * Link to the scene is kept to unregister the crowd from the scene
  124410. */
  124411. private _scene;
  124412. /**
  124413. * Observer for crowd updates
  124414. */
  124415. private _onBeforeAnimationsObserver;
  124416. /**
  124417. * Constructor
  124418. * @param plugin recastJS plugin
  124419. * @param maxAgents the maximum agent count in the crowd
  124420. * @param maxAgentRadius the maximum radius an agent can have
  124421. * @param scene to attach the crowd to
  124422. * @returns the crowd you can add agents to
  124423. */
  124424. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124425. /**
  124426. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124427. * You can attach anything to that node. The node position is updated in the scene update tick.
  124428. * @param pos world position that will be constrained by the navigation mesh
  124429. * @param parameters agent parameters
  124430. * @param transform hooked to the agent that will be update by the scene
  124431. * @returns agent index
  124432. */
  124433. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124434. /**
  124435. * Returns the agent position in world space
  124436. * @param index agent index returned by addAgent
  124437. * @returns world space position
  124438. */
  124439. getAgentPosition(index: number): Vector3;
  124440. /**
  124441. * Returns the agent velocity in world space
  124442. * @param index agent index returned by addAgent
  124443. * @returns world space velocity
  124444. */
  124445. getAgentVelocity(index: number): Vector3;
  124446. /**
  124447. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124448. * @param index agent index returned by addAgent
  124449. * @param destination targeted world position
  124450. */
  124451. agentGoto(index: number, destination: Vector3): void;
  124452. /**
  124453. * remove a particular agent previously created
  124454. * @param index agent index returned by addAgent
  124455. */
  124456. removeAgent(index: number): void;
  124457. /**
  124458. * get the list of all agents attached to this crowd
  124459. * @returns list of agent indices
  124460. */
  124461. getAgents(): number[];
  124462. /**
  124463. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124464. * @param deltaTime in seconds
  124465. */
  124466. update(deltaTime: number): void;
  124467. /**
  124468. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124469. * The queries will try to find a solution within those bounds
  124470. * default is (1,1,1)
  124471. * @param extent x,y,z value that define the extent around the queries point of reference
  124472. */
  124473. setDefaultQueryExtent(extent: Vector3): void;
  124474. /**
  124475. * Get the Bounding box extent specified by setDefaultQueryExtent
  124476. * @returns the box extent values
  124477. */
  124478. getDefaultQueryExtent(): Vector3;
  124479. /**
  124480. * Release all resources
  124481. */
  124482. dispose(): void;
  124483. }
  124484. }
  124485. declare module BABYLON {
  124486. /**
  124487. * Class used to enable access to IndexedDB
  124488. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124489. */
  124490. export class Database implements IOfflineProvider {
  124491. private _callbackManifestChecked;
  124492. private _currentSceneUrl;
  124493. private _db;
  124494. private _enableSceneOffline;
  124495. private _enableTexturesOffline;
  124496. private _manifestVersionFound;
  124497. private _mustUpdateRessources;
  124498. private _hasReachedQuota;
  124499. private _isSupported;
  124500. private _idbFactory;
  124501. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124502. private static IsUASupportingBlobStorage;
  124503. /**
  124504. * Gets a boolean indicating if Database storate is enabled (off by default)
  124505. */
  124506. static IDBStorageEnabled: boolean;
  124507. /**
  124508. * Gets a boolean indicating if scene must be saved in the database
  124509. */
  124510. readonly enableSceneOffline: boolean;
  124511. /**
  124512. * Gets a boolean indicating if textures must be saved in the database
  124513. */
  124514. readonly enableTexturesOffline: boolean;
  124515. /**
  124516. * Creates a new Database
  124517. * @param urlToScene defines the url to load the scene
  124518. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124519. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124520. */
  124521. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124522. private static _ParseURL;
  124523. private static _ReturnFullUrlLocation;
  124524. private _checkManifestFile;
  124525. /**
  124526. * Open the database and make it available
  124527. * @param successCallback defines the callback to call on success
  124528. * @param errorCallback defines the callback to call on error
  124529. */
  124530. open(successCallback: () => void, errorCallback: () => void): void;
  124531. /**
  124532. * Loads an image from the database
  124533. * @param url defines the url to load from
  124534. * @param image defines the target DOM image
  124535. */
  124536. loadImage(url: string, image: HTMLImageElement): void;
  124537. private _loadImageFromDBAsync;
  124538. private _saveImageIntoDBAsync;
  124539. private _checkVersionFromDB;
  124540. private _loadVersionFromDBAsync;
  124541. private _saveVersionIntoDBAsync;
  124542. /**
  124543. * Loads a file from database
  124544. * @param url defines the URL to load from
  124545. * @param sceneLoaded defines a callback to call on success
  124546. * @param progressCallBack defines a callback to call when progress changed
  124547. * @param errorCallback defines a callback to call on error
  124548. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124549. */
  124550. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124551. private _loadFileAsync;
  124552. private _saveFileAsync;
  124553. /**
  124554. * Validates if xhr data is correct
  124555. * @param xhr defines the request to validate
  124556. * @param dataType defines the expected data type
  124557. * @returns true if data is correct
  124558. */
  124559. private static _ValidateXHRData;
  124560. }
  124561. }
  124562. declare module BABYLON {
  124563. /** @hidden */
  124564. export var gpuUpdateParticlesPixelShader: {
  124565. name: string;
  124566. shader: string;
  124567. };
  124568. }
  124569. declare module BABYLON {
  124570. /** @hidden */
  124571. export var gpuUpdateParticlesVertexShader: {
  124572. name: string;
  124573. shader: string;
  124574. };
  124575. }
  124576. declare module BABYLON {
  124577. /** @hidden */
  124578. export var clipPlaneFragmentDeclaration2: {
  124579. name: string;
  124580. shader: string;
  124581. };
  124582. }
  124583. declare module BABYLON {
  124584. /** @hidden */
  124585. export var gpuRenderParticlesPixelShader: {
  124586. name: string;
  124587. shader: string;
  124588. };
  124589. }
  124590. declare module BABYLON {
  124591. /** @hidden */
  124592. export var clipPlaneVertexDeclaration2: {
  124593. name: string;
  124594. shader: string;
  124595. };
  124596. }
  124597. declare module BABYLON {
  124598. /** @hidden */
  124599. export var gpuRenderParticlesVertexShader: {
  124600. name: string;
  124601. shader: string;
  124602. };
  124603. }
  124604. declare module BABYLON {
  124605. /**
  124606. * This represents a GPU particle system in Babylon
  124607. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124608. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124609. */
  124610. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124611. /**
  124612. * The layer mask we are rendering the particles through.
  124613. */
  124614. layerMask: number;
  124615. private _capacity;
  124616. private _activeCount;
  124617. private _currentActiveCount;
  124618. private _accumulatedCount;
  124619. private _renderEffect;
  124620. private _updateEffect;
  124621. private _buffer0;
  124622. private _buffer1;
  124623. private _spriteBuffer;
  124624. private _updateVAO;
  124625. private _renderVAO;
  124626. private _targetIndex;
  124627. private _sourceBuffer;
  124628. private _targetBuffer;
  124629. private _engine;
  124630. private _currentRenderId;
  124631. private _started;
  124632. private _stopped;
  124633. private _timeDelta;
  124634. private _randomTexture;
  124635. private _randomTexture2;
  124636. private _attributesStrideSize;
  124637. private _updateEffectOptions;
  124638. private _randomTextureSize;
  124639. private _actualFrame;
  124640. private readonly _rawTextureWidth;
  124641. /**
  124642. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124643. */
  124644. static readonly IsSupported: boolean;
  124645. /**
  124646. * An event triggered when the system is disposed.
  124647. */
  124648. onDisposeObservable: Observable<GPUParticleSystem>;
  124649. /**
  124650. * Gets the maximum number of particles active at the same time.
  124651. * @returns The max number of active particles.
  124652. */
  124653. getCapacity(): number;
  124654. /**
  124655. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124656. * to override the particles.
  124657. */
  124658. forceDepthWrite: boolean;
  124659. /**
  124660. * Gets or set the number of active particles
  124661. */
  124662. activeParticleCount: number;
  124663. private _preWarmDone;
  124664. /**
  124665. * Is this system ready to be used/rendered
  124666. * @return true if the system is ready
  124667. */
  124668. isReady(): boolean;
  124669. /**
  124670. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124671. * @returns True if it has been started, otherwise false.
  124672. */
  124673. isStarted(): boolean;
  124674. /**
  124675. * Starts the particle system and begins to emit
  124676. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124677. */
  124678. start(delay?: number): void;
  124679. /**
  124680. * Stops the particle system.
  124681. */
  124682. stop(): void;
  124683. /**
  124684. * Remove all active particles
  124685. */
  124686. reset(): void;
  124687. /**
  124688. * Returns the string "GPUParticleSystem"
  124689. * @returns a string containing the class name
  124690. */
  124691. getClassName(): string;
  124692. private _colorGradientsTexture;
  124693. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124694. /**
  124695. * Adds a new color gradient
  124696. * @param gradient defines the gradient to use (between 0 and 1)
  124697. * @param color1 defines the color to affect to the specified gradient
  124698. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124699. * @returns the current particle system
  124700. */
  124701. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124702. /**
  124703. * Remove a specific color gradient
  124704. * @param gradient defines the gradient to remove
  124705. * @returns the current particle system
  124706. */
  124707. removeColorGradient(gradient: number): GPUParticleSystem;
  124708. private _angularSpeedGradientsTexture;
  124709. private _sizeGradientsTexture;
  124710. private _velocityGradientsTexture;
  124711. private _limitVelocityGradientsTexture;
  124712. private _dragGradientsTexture;
  124713. private _addFactorGradient;
  124714. /**
  124715. * Adds a new size gradient
  124716. * @param gradient defines the gradient to use (between 0 and 1)
  124717. * @param factor defines the size factor to affect to the specified gradient
  124718. * @returns the current particle system
  124719. */
  124720. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124721. /**
  124722. * Remove a specific size gradient
  124723. * @param gradient defines the gradient to remove
  124724. * @returns the current particle system
  124725. */
  124726. removeSizeGradient(gradient: number): GPUParticleSystem;
  124727. /**
  124728. * Adds a new angular speed gradient
  124729. * @param gradient defines the gradient to use (between 0 and 1)
  124730. * @param factor defines the angular speed to affect to the specified gradient
  124731. * @returns the current particle system
  124732. */
  124733. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124734. /**
  124735. * Remove a specific angular speed gradient
  124736. * @param gradient defines the gradient to remove
  124737. * @returns the current particle system
  124738. */
  124739. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124740. /**
  124741. * Adds a new velocity gradient
  124742. * @param gradient defines the gradient to use (between 0 and 1)
  124743. * @param factor defines the velocity to affect to the specified gradient
  124744. * @returns the current particle system
  124745. */
  124746. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124747. /**
  124748. * Remove a specific velocity gradient
  124749. * @param gradient defines the gradient to remove
  124750. * @returns the current particle system
  124751. */
  124752. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124753. /**
  124754. * Adds a new limit velocity gradient
  124755. * @param gradient defines the gradient to use (between 0 and 1)
  124756. * @param factor defines the limit velocity value to affect to the specified gradient
  124757. * @returns the current particle system
  124758. */
  124759. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124760. /**
  124761. * Remove a specific limit velocity gradient
  124762. * @param gradient defines the gradient to remove
  124763. * @returns the current particle system
  124764. */
  124765. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124766. /**
  124767. * Adds a new drag gradient
  124768. * @param gradient defines the gradient to use (between 0 and 1)
  124769. * @param factor defines the drag value to affect to the specified gradient
  124770. * @returns the current particle system
  124771. */
  124772. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124773. /**
  124774. * Remove a specific drag gradient
  124775. * @param gradient defines the gradient to remove
  124776. * @returns the current particle system
  124777. */
  124778. removeDragGradient(gradient: number): GPUParticleSystem;
  124779. /**
  124780. * Not supported by GPUParticleSystem
  124781. * @param gradient defines the gradient to use (between 0 and 1)
  124782. * @param factor defines the emit rate value to affect to the specified gradient
  124783. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124784. * @returns the current particle system
  124785. */
  124786. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124787. /**
  124788. * Not supported by GPUParticleSystem
  124789. * @param gradient defines the gradient to remove
  124790. * @returns the current particle system
  124791. */
  124792. removeEmitRateGradient(gradient: number): IParticleSystem;
  124793. /**
  124794. * Not supported by GPUParticleSystem
  124795. * @param gradient defines the gradient to use (between 0 and 1)
  124796. * @param factor defines the start size value to affect to the specified gradient
  124797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124798. * @returns the current particle system
  124799. */
  124800. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124801. /**
  124802. * Not supported by GPUParticleSystem
  124803. * @param gradient defines the gradient to remove
  124804. * @returns the current particle system
  124805. */
  124806. removeStartSizeGradient(gradient: number): IParticleSystem;
  124807. /**
  124808. * Not supported by GPUParticleSystem
  124809. * @param gradient defines the gradient to use (between 0 and 1)
  124810. * @param min defines the color remap minimal range
  124811. * @param max defines the color remap maximal range
  124812. * @returns the current particle system
  124813. */
  124814. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124815. /**
  124816. * Not supported by GPUParticleSystem
  124817. * @param gradient defines the gradient to remove
  124818. * @returns the current particle system
  124819. */
  124820. removeColorRemapGradient(): IParticleSystem;
  124821. /**
  124822. * Not supported by GPUParticleSystem
  124823. * @param gradient defines the gradient to use (between 0 and 1)
  124824. * @param min defines the alpha remap minimal range
  124825. * @param max defines the alpha remap maximal range
  124826. * @returns the current particle system
  124827. */
  124828. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124829. /**
  124830. * Not supported by GPUParticleSystem
  124831. * @param gradient defines the gradient to remove
  124832. * @returns the current particle system
  124833. */
  124834. removeAlphaRemapGradient(): IParticleSystem;
  124835. /**
  124836. * Not supported by GPUParticleSystem
  124837. * @param gradient defines the gradient to use (between 0 and 1)
  124838. * @param color defines the color to affect to the specified gradient
  124839. * @returns the current particle system
  124840. */
  124841. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124842. /**
  124843. * Not supported by GPUParticleSystem
  124844. * @param gradient defines the gradient to remove
  124845. * @returns the current particle system
  124846. */
  124847. removeRampGradient(): IParticleSystem;
  124848. /**
  124849. * Not supported by GPUParticleSystem
  124850. * @returns the list of ramp gradients
  124851. */
  124852. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124853. /**
  124854. * Not supported by GPUParticleSystem
  124855. * Gets or sets a boolean indicating that ramp gradients must be used
  124856. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124857. */
  124858. useRampGradients: boolean;
  124859. /**
  124860. * Not supported by GPUParticleSystem
  124861. * @param gradient defines the gradient to use (between 0 and 1)
  124862. * @param factor defines the life time factor to affect to the specified gradient
  124863. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124864. * @returns the current particle system
  124865. */
  124866. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124867. /**
  124868. * Not supported by GPUParticleSystem
  124869. * @param gradient defines the gradient to remove
  124870. * @returns the current particle system
  124871. */
  124872. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124873. /**
  124874. * Instantiates a GPU particle system.
  124875. * 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.
  124876. * @param name The name of the particle system
  124877. * @param options The options used to create the system
  124878. * @param scene The scene the particle system belongs to
  124879. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124880. */
  124881. constructor(name: string, options: Partial<{
  124882. capacity: number;
  124883. randomTextureSize: number;
  124884. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124885. protected _reset(): void;
  124886. private _createUpdateVAO;
  124887. private _createRenderVAO;
  124888. private _initialize;
  124889. /** @hidden */
  124890. _recreateUpdateEffect(): void;
  124891. /** @hidden */
  124892. _recreateRenderEffect(): void;
  124893. /**
  124894. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124895. * @param preWarm defines if we are in the pre-warmimg phase
  124896. */
  124897. animate(preWarm?: boolean): void;
  124898. private _createFactorGradientTexture;
  124899. private _createSizeGradientTexture;
  124900. private _createAngularSpeedGradientTexture;
  124901. private _createVelocityGradientTexture;
  124902. private _createLimitVelocityGradientTexture;
  124903. private _createDragGradientTexture;
  124904. private _createColorGradientTexture;
  124905. /**
  124906. * Renders the particle system in its current state
  124907. * @param preWarm defines if the system should only update the particles but not render them
  124908. * @returns the current number of particles
  124909. */
  124910. render(preWarm?: boolean): number;
  124911. /**
  124912. * Rebuilds the particle system
  124913. */
  124914. rebuild(): void;
  124915. private _releaseBuffers;
  124916. private _releaseVAOs;
  124917. /**
  124918. * Disposes the particle system and free the associated resources
  124919. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124920. */
  124921. dispose(disposeTexture?: boolean): void;
  124922. /**
  124923. * Clones the particle system.
  124924. * @param name The name of the cloned object
  124925. * @param newEmitter The new emitter to use
  124926. * @returns the cloned particle system
  124927. */
  124928. clone(name: string, newEmitter: any): GPUParticleSystem;
  124929. /**
  124930. * Serializes the particle system to a JSON object.
  124931. * @returns the JSON object
  124932. */
  124933. serialize(): any;
  124934. /**
  124935. * Parses a JSON object to create a GPU particle system.
  124936. * @param parsedParticleSystem The JSON object to parse
  124937. * @param scene The scene to create the particle system in
  124938. * @param rootUrl The root url to use to load external dependencies like texture
  124939. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124940. * @returns the parsed GPU particle system
  124941. */
  124942. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124943. }
  124944. }
  124945. declare module BABYLON {
  124946. /**
  124947. * Represents a set of particle systems working together to create a specific effect
  124948. */
  124949. export class ParticleSystemSet implements IDisposable {
  124950. private _emitterCreationOptions;
  124951. private _emitterNode;
  124952. /**
  124953. * Gets the particle system list
  124954. */
  124955. systems: IParticleSystem[];
  124956. /**
  124957. * Gets the emitter node used with this set
  124958. */
  124959. readonly emitterNode: Nullable<TransformNode>;
  124960. /**
  124961. * Creates a new emitter mesh as a sphere
  124962. * @param options defines the options used to create the sphere
  124963. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124964. * @param scene defines the hosting scene
  124965. */
  124966. setEmitterAsSphere(options: {
  124967. diameter: number;
  124968. segments: number;
  124969. color: Color3;
  124970. }, renderingGroupId: number, scene: Scene): void;
  124971. /**
  124972. * Starts all particle systems of the set
  124973. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124974. */
  124975. start(emitter?: AbstractMesh): void;
  124976. /**
  124977. * Release all associated resources
  124978. */
  124979. dispose(): void;
  124980. /**
  124981. * Serialize the set into a JSON compatible object
  124982. * @returns a JSON compatible representation of the set
  124983. */
  124984. serialize(): any;
  124985. /**
  124986. * Parse a new ParticleSystemSet from a serialized source
  124987. * @param data defines a JSON compatible representation of the set
  124988. * @param scene defines the hosting scene
  124989. * @param gpu defines if we want GPU particles or CPU particles
  124990. * @returns a new ParticleSystemSet
  124991. */
  124992. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124993. }
  124994. }
  124995. declare module BABYLON {
  124996. /**
  124997. * This class is made for on one-liner static method to help creating particle system set.
  124998. */
  124999. export class ParticleHelper {
  125000. /**
  125001. * Gets or sets base Assets URL
  125002. */
  125003. static BaseAssetsUrl: string;
  125004. /**
  125005. * Create a default particle system that you can tweak
  125006. * @param emitter defines the emitter to use
  125007. * @param capacity defines the system capacity (default is 500 particles)
  125008. * @param scene defines the hosting scene
  125009. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125010. * @returns the new Particle system
  125011. */
  125012. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125013. /**
  125014. * This is the main static method (one-liner) of this helper to create different particle systems
  125015. * @param type This string represents the type to the particle system to create
  125016. * @param scene The scene where the particle system should live
  125017. * @param gpu If the system will use gpu
  125018. * @returns the ParticleSystemSet created
  125019. */
  125020. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125021. /**
  125022. * Static function used to export a particle system to a ParticleSystemSet variable.
  125023. * Please note that the emitter shape is not exported
  125024. * @param systems defines the particle systems to export
  125025. * @returns the created particle system set
  125026. */
  125027. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125028. }
  125029. }
  125030. declare module BABYLON {
  125031. interface Engine {
  125032. /**
  125033. * Create an effect to use with particle systems.
  125034. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125035. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125036. * @param uniformsNames defines a list of attribute names
  125037. * @param samplers defines an array of string used to represent textures
  125038. * @param defines defines the string containing the defines to use to compile the shaders
  125039. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125040. * @param onCompiled defines a function to call when the effect creation is successful
  125041. * @param onError defines a function to call when the effect creation has failed
  125042. * @returns the new Effect
  125043. */
  125044. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125045. }
  125046. interface Mesh {
  125047. /**
  125048. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125049. * @returns an array of IParticleSystem
  125050. */
  125051. getEmittedParticleSystems(): IParticleSystem[];
  125052. /**
  125053. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125054. * @returns an array of IParticleSystem
  125055. */
  125056. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125057. }
  125058. /**
  125059. * @hidden
  125060. */
  125061. export var _IDoNeedToBeInTheBuild: number;
  125062. }
  125063. declare module BABYLON {
  125064. interface Scene {
  125065. /** @hidden (Backing field) */
  125066. _physicsEngine: Nullable<IPhysicsEngine>;
  125067. /**
  125068. * Gets the current physics engine
  125069. * @returns a IPhysicsEngine or null if none attached
  125070. */
  125071. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125072. /**
  125073. * Enables physics to the current scene
  125074. * @param gravity defines the scene's gravity for the physics engine
  125075. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125076. * @return a boolean indicating if the physics engine was initialized
  125077. */
  125078. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125079. /**
  125080. * Disables and disposes the physics engine associated with the scene
  125081. */
  125082. disablePhysicsEngine(): void;
  125083. /**
  125084. * Gets a boolean indicating if there is an active physics engine
  125085. * @returns a boolean indicating if there is an active physics engine
  125086. */
  125087. isPhysicsEnabled(): boolean;
  125088. /**
  125089. * Deletes a physics compound impostor
  125090. * @param compound defines the compound to delete
  125091. */
  125092. deleteCompoundImpostor(compound: any): void;
  125093. /**
  125094. * An event triggered when physic simulation is about to be run
  125095. */
  125096. onBeforePhysicsObservable: Observable<Scene>;
  125097. /**
  125098. * An event triggered when physic simulation has been done
  125099. */
  125100. onAfterPhysicsObservable: Observable<Scene>;
  125101. }
  125102. interface AbstractMesh {
  125103. /** @hidden */
  125104. _physicsImpostor: Nullable<PhysicsImpostor>;
  125105. /**
  125106. * Gets or sets impostor used for physic simulation
  125107. * @see http://doc.babylonjs.com/features/physics_engine
  125108. */
  125109. physicsImpostor: Nullable<PhysicsImpostor>;
  125110. /**
  125111. * Gets the current physics impostor
  125112. * @see http://doc.babylonjs.com/features/physics_engine
  125113. * @returns a physics impostor or null
  125114. */
  125115. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125116. /** Apply a physic impulse to the mesh
  125117. * @param force defines the force to apply
  125118. * @param contactPoint defines where to apply the force
  125119. * @returns the current mesh
  125120. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125121. */
  125122. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125123. /**
  125124. * Creates a physic joint between two meshes
  125125. * @param otherMesh defines the other mesh to use
  125126. * @param pivot1 defines the pivot to use on this mesh
  125127. * @param pivot2 defines the pivot to use on the other mesh
  125128. * @param options defines additional options (can be plugin dependent)
  125129. * @returns the current mesh
  125130. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125131. */
  125132. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125133. /** @hidden */
  125134. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125135. }
  125136. /**
  125137. * Defines the physics engine scene component responsible to manage a physics engine
  125138. */
  125139. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125140. /**
  125141. * The component name helpful to identify the component in the list of scene components.
  125142. */
  125143. readonly name: string;
  125144. /**
  125145. * The scene the component belongs to.
  125146. */
  125147. scene: Scene;
  125148. /**
  125149. * Creates a new instance of the component for the given scene
  125150. * @param scene Defines the scene to register the component in
  125151. */
  125152. constructor(scene: Scene);
  125153. /**
  125154. * Registers the component in a given scene
  125155. */
  125156. register(): void;
  125157. /**
  125158. * Rebuilds the elements related to this component in case of
  125159. * context lost for instance.
  125160. */
  125161. rebuild(): void;
  125162. /**
  125163. * Disposes the component and the associated ressources
  125164. */
  125165. dispose(): void;
  125166. }
  125167. }
  125168. declare module BABYLON {
  125169. /**
  125170. * A helper for physics simulations
  125171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125172. */
  125173. export class PhysicsHelper {
  125174. private _scene;
  125175. private _physicsEngine;
  125176. /**
  125177. * Initializes the Physics helper
  125178. * @param scene Babylon.js scene
  125179. */
  125180. constructor(scene: Scene);
  125181. /**
  125182. * Applies a radial explosion impulse
  125183. * @param origin the origin of the explosion
  125184. * @param radiusOrEventOptions the radius or the options of radial explosion
  125185. * @param strength the explosion strength
  125186. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125187. * @returns A physics radial explosion event, or null
  125188. */
  125189. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125190. /**
  125191. * Applies a radial explosion force
  125192. * @param origin the origin of the explosion
  125193. * @param radiusOrEventOptions the radius or the options of radial explosion
  125194. * @param strength the explosion strength
  125195. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125196. * @returns A physics radial explosion event, or null
  125197. */
  125198. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125199. /**
  125200. * Creates a gravitational field
  125201. * @param origin the origin of the explosion
  125202. * @param radiusOrEventOptions the radius or the options of radial explosion
  125203. * @param strength the explosion strength
  125204. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125205. * @returns A physics gravitational field event, or null
  125206. */
  125207. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125208. /**
  125209. * Creates a physics updraft event
  125210. * @param origin the origin of the updraft
  125211. * @param radiusOrEventOptions the radius or the options of the updraft
  125212. * @param strength the strength of the updraft
  125213. * @param height the height of the updraft
  125214. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125215. * @returns A physics updraft event, or null
  125216. */
  125217. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125218. /**
  125219. * Creates a physics vortex event
  125220. * @param origin the of the vortex
  125221. * @param radiusOrEventOptions the radius or the options of the vortex
  125222. * @param strength the strength of the vortex
  125223. * @param height the height of the vortex
  125224. * @returns a Physics vortex event, or null
  125225. * A physics vortex event or null
  125226. */
  125227. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125228. }
  125229. /**
  125230. * Represents a physics radial explosion event
  125231. */
  125232. class PhysicsRadialExplosionEvent {
  125233. private _scene;
  125234. private _options;
  125235. private _sphere;
  125236. private _dataFetched;
  125237. /**
  125238. * Initializes a radial explosioin event
  125239. * @param _scene BabylonJS scene
  125240. * @param _options The options for the vortex event
  125241. */
  125242. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125243. /**
  125244. * Returns the data related to the radial explosion event (sphere).
  125245. * @returns The radial explosion event data
  125246. */
  125247. getData(): PhysicsRadialExplosionEventData;
  125248. /**
  125249. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125250. * @param impostor A physics imposter
  125251. * @param origin the origin of the explosion
  125252. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125253. */
  125254. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125255. /**
  125256. * Triggers affecterd impostors callbacks
  125257. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125258. */
  125259. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125260. /**
  125261. * Disposes the sphere.
  125262. * @param force Specifies if the sphere should be disposed by force
  125263. */
  125264. dispose(force?: boolean): void;
  125265. /*** Helpers ***/
  125266. private _prepareSphere;
  125267. private _intersectsWithSphere;
  125268. }
  125269. /**
  125270. * Represents a gravitational field event
  125271. */
  125272. class PhysicsGravitationalFieldEvent {
  125273. private _physicsHelper;
  125274. private _scene;
  125275. private _origin;
  125276. private _options;
  125277. private _tickCallback;
  125278. private _sphere;
  125279. private _dataFetched;
  125280. /**
  125281. * Initializes the physics gravitational field event
  125282. * @param _physicsHelper A physics helper
  125283. * @param _scene BabylonJS scene
  125284. * @param _origin The origin position of the gravitational field event
  125285. * @param _options The options for the vortex event
  125286. */
  125287. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125288. /**
  125289. * Returns the data related to the gravitational field event (sphere).
  125290. * @returns A gravitational field event
  125291. */
  125292. getData(): PhysicsGravitationalFieldEventData;
  125293. /**
  125294. * Enables the gravitational field.
  125295. */
  125296. enable(): void;
  125297. /**
  125298. * Disables the gravitational field.
  125299. */
  125300. disable(): void;
  125301. /**
  125302. * Disposes the sphere.
  125303. * @param force The force to dispose from the gravitational field event
  125304. */
  125305. dispose(force?: boolean): void;
  125306. private _tick;
  125307. }
  125308. /**
  125309. * Represents a physics updraft event
  125310. */
  125311. class PhysicsUpdraftEvent {
  125312. private _scene;
  125313. private _origin;
  125314. private _options;
  125315. private _physicsEngine;
  125316. private _originTop;
  125317. private _originDirection;
  125318. private _tickCallback;
  125319. private _cylinder;
  125320. private _cylinderPosition;
  125321. private _dataFetched;
  125322. /**
  125323. * Initializes the physics updraft event
  125324. * @param _scene BabylonJS scene
  125325. * @param _origin The origin position of the updraft
  125326. * @param _options The options for the updraft event
  125327. */
  125328. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125329. /**
  125330. * Returns the data related to the updraft event (cylinder).
  125331. * @returns A physics updraft event
  125332. */
  125333. getData(): PhysicsUpdraftEventData;
  125334. /**
  125335. * Enables the updraft.
  125336. */
  125337. enable(): void;
  125338. /**
  125339. * Disables the updraft.
  125340. */
  125341. disable(): void;
  125342. /**
  125343. * Disposes the cylinder.
  125344. * @param force Specifies if the updraft should be disposed by force
  125345. */
  125346. dispose(force?: boolean): void;
  125347. private getImpostorHitData;
  125348. private _tick;
  125349. /*** Helpers ***/
  125350. private _prepareCylinder;
  125351. private _intersectsWithCylinder;
  125352. }
  125353. /**
  125354. * Represents a physics vortex event
  125355. */
  125356. class PhysicsVortexEvent {
  125357. private _scene;
  125358. private _origin;
  125359. private _options;
  125360. private _physicsEngine;
  125361. private _originTop;
  125362. private _tickCallback;
  125363. private _cylinder;
  125364. private _cylinderPosition;
  125365. private _dataFetched;
  125366. /**
  125367. * Initializes the physics vortex event
  125368. * @param _scene The BabylonJS scene
  125369. * @param _origin The origin position of the vortex
  125370. * @param _options The options for the vortex event
  125371. */
  125372. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125373. /**
  125374. * Returns the data related to the vortex event (cylinder).
  125375. * @returns The physics vortex event data
  125376. */
  125377. getData(): PhysicsVortexEventData;
  125378. /**
  125379. * Enables the vortex.
  125380. */
  125381. enable(): void;
  125382. /**
  125383. * Disables the cortex.
  125384. */
  125385. disable(): void;
  125386. /**
  125387. * Disposes the sphere.
  125388. * @param force
  125389. */
  125390. dispose(force?: boolean): void;
  125391. private getImpostorHitData;
  125392. private _tick;
  125393. /*** Helpers ***/
  125394. private _prepareCylinder;
  125395. private _intersectsWithCylinder;
  125396. }
  125397. /**
  125398. * Options fot the radial explosion event
  125399. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125400. */
  125401. export class PhysicsRadialExplosionEventOptions {
  125402. /**
  125403. * The radius of the sphere for the radial explosion.
  125404. */
  125405. radius: number;
  125406. /**
  125407. * The strenth of the explosion.
  125408. */
  125409. strength: number;
  125410. /**
  125411. * The strenght of the force in correspondence to the distance of the affected object
  125412. */
  125413. falloff: PhysicsRadialImpulseFalloff;
  125414. /**
  125415. * Sphere options for the radial explosion.
  125416. */
  125417. sphere: {
  125418. segments: number;
  125419. diameter: number;
  125420. };
  125421. /**
  125422. * Sphere options for the radial explosion.
  125423. */
  125424. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125425. }
  125426. /**
  125427. * Options fot the updraft event
  125428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125429. */
  125430. export class PhysicsUpdraftEventOptions {
  125431. /**
  125432. * The radius of the cylinder for the vortex
  125433. */
  125434. radius: number;
  125435. /**
  125436. * The strenth of the updraft.
  125437. */
  125438. strength: number;
  125439. /**
  125440. * The height of the cylinder for the updraft.
  125441. */
  125442. height: number;
  125443. /**
  125444. * The mode for the the updraft.
  125445. */
  125446. updraftMode: PhysicsUpdraftMode;
  125447. }
  125448. /**
  125449. * Options fot the vortex event
  125450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125451. */
  125452. export class PhysicsVortexEventOptions {
  125453. /**
  125454. * The radius of the cylinder for the vortex
  125455. */
  125456. radius: number;
  125457. /**
  125458. * The strenth of the vortex.
  125459. */
  125460. strength: number;
  125461. /**
  125462. * The height of the cylinder for the vortex.
  125463. */
  125464. height: number;
  125465. /**
  125466. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125467. */
  125468. centripetalForceThreshold: number;
  125469. /**
  125470. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125471. */
  125472. centripetalForceMultiplier: number;
  125473. /**
  125474. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125475. */
  125476. centrifugalForceMultiplier: number;
  125477. /**
  125478. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125479. */
  125480. updraftForceMultiplier: number;
  125481. }
  125482. /**
  125483. * The strenght of the force in correspondence to the distance of the affected object
  125484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125485. */
  125486. export enum PhysicsRadialImpulseFalloff {
  125487. /** Defines that impulse is constant in strength across it's whole radius */
  125488. Constant = 0,
  125489. /** Defines that impulse gets weaker if it's further from the origin */
  125490. Linear = 1
  125491. }
  125492. /**
  125493. * The strength of the force in correspondence to the distance of the affected object
  125494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125495. */
  125496. export enum PhysicsUpdraftMode {
  125497. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125498. Center = 0,
  125499. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125500. Perpendicular = 1
  125501. }
  125502. /**
  125503. * Interface for a physics hit data
  125504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125505. */
  125506. export interface PhysicsHitData {
  125507. /**
  125508. * The force applied at the contact point
  125509. */
  125510. force: Vector3;
  125511. /**
  125512. * The contact point
  125513. */
  125514. contactPoint: Vector3;
  125515. /**
  125516. * The distance from the origin to the contact point
  125517. */
  125518. distanceFromOrigin: number;
  125519. }
  125520. /**
  125521. * Interface for radial explosion event data
  125522. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125523. */
  125524. export interface PhysicsRadialExplosionEventData {
  125525. /**
  125526. * A sphere used for the radial explosion event
  125527. */
  125528. sphere: Mesh;
  125529. }
  125530. /**
  125531. * Interface for gravitational field event data
  125532. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125533. */
  125534. export interface PhysicsGravitationalFieldEventData {
  125535. /**
  125536. * A sphere mesh used for the gravitational field event
  125537. */
  125538. sphere: Mesh;
  125539. }
  125540. /**
  125541. * Interface for updraft event data
  125542. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125543. */
  125544. export interface PhysicsUpdraftEventData {
  125545. /**
  125546. * A cylinder used for the updraft event
  125547. */
  125548. cylinder: Mesh;
  125549. }
  125550. /**
  125551. * Interface for vortex event data
  125552. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125553. */
  125554. export interface PhysicsVortexEventData {
  125555. /**
  125556. * A cylinder used for the vortex event
  125557. */
  125558. cylinder: Mesh;
  125559. }
  125560. /**
  125561. * Interface for an affected physics impostor
  125562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125563. */
  125564. export interface PhysicsAffectedImpostorWithData {
  125565. /**
  125566. * The impostor affected by the effect
  125567. */
  125568. impostor: PhysicsImpostor;
  125569. /**
  125570. * The data about the hit/horce from the explosion
  125571. */
  125572. hitData: PhysicsHitData;
  125573. }
  125574. }
  125575. declare module BABYLON {
  125576. /** @hidden */
  125577. export var blackAndWhitePixelShader: {
  125578. name: string;
  125579. shader: string;
  125580. };
  125581. }
  125582. declare module BABYLON {
  125583. /**
  125584. * Post process used to render in black and white
  125585. */
  125586. export class BlackAndWhitePostProcess extends PostProcess {
  125587. /**
  125588. * Linear about to convert he result to black and white (default: 1)
  125589. */
  125590. degree: number;
  125591. /**
  125592. * Creates a black and white post process
  125593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125594. * @param name The name of the effect.
  125595. * @param options The required width/height ratio to downsize to before computing the render pass.
  125596. * @param camera The camera to apply the render pass to.
  125597. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125598. * @param engine The engine which the post process will be applied. (default: current engine)
  125599. * @param reusable If the post process can be reused on the same frame. (default: false)
  125600. */
  125601. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125602. }
  125603. }
  125604. declare module BABYLON {
  125605. /**
  125606. * This represents a set of one or more post processes in Babylon.
  125607. * A post process can be used to apply a shader to a texture after it is rendered.
  125608. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125609. */
  125610. export class PostProcessRenderEffect {
  125611. private _postProcesses;
  125612. private _getPostProcesses;
  125613. private _singleInstance;
  125614. private _cameras;
  125615. private _indicesForCamera;
  125616. /**
  125617. * Name of the effect
  125618. * @hidden
  125619. */
  125620. _name: string;
  125621. /**
  125622. * Instantiates a post process render effect.
  125623. * A post process can be used to apply a shader to a texture after it is rendered.
  125624. * @param engine The engine the effect is tied to
  125625. * @param name The name of the effect
  125626. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125627. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125628. */
  125629. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125630. /**
  125631. * Checks if all the post processes in the effect are supported.
  125632. */
  125633. readonly isSupported: boolean;
  125634. /**
  125635. * Updates the current state of the effect
  125636. * @hidden
  125637. */
  125638. _update(): void;
  125639. /**
  125640. * Attaches the effect on cameras
  125641. * @param cameras The camera to attach to.
  125642. * @hidden
  125643. */
  125644. _attachCameras(cameras: Camera): void;
  125645. /**
  125646. * Attaches the effect on cameras
  125647. * @param cameras The camera to attach to.
  125648. * @hidden
  125649. */
  125650. _attachCameras(cameras: Camera[]): void;
  125651. /**
  125652. * Detaches the effect on cameras
  125653. * @param cameras The camera to detatch from.
  125654. * @hidden
  125655. */
  125656. _detachCameras(cameras: Camera): void;
  125657. /**
  125658. * Detatches the effect on cameras
  125659. * @param cameras The camera to detatch from.
  125660. * @hidden
  125661. */
  125662. _detachCameras(cameras: Camera[]): void;
  125663. /**
  125664. * Enables the effect on given cameras
  125665. * @param cameras The camera to enable.
  125666. * @hidden
  125667. */
  125668. _enable(cameras: Camera): void;
  125669. /**
  125670. * Enables the effect on given cameras
  125671. * @param cameras The camera to enable.
  125672. * @hidden
  125673. */
  125674. _enable(cameras: Nullable<Camera[]>): void;
  125675. /**
  125676. * Disables the effect on the given cameras
  125677. * @param cameras The camera to disable.
  125678. * @hidden
  125679. */
  125680. _disable(cameras: Camera): void;
  125681. /**
  125682. * Disables the effect on the given cameras
  125683. * @param cameras The camera to disable.
  125684. * @hidden
  125685. */
  125686. _disable(cameras: Nullable<Camera[]>): void;
  125687. /**
  125688. * Gets a list of the post processes contained in the effect.
  125689. * @param camera The camera to get the post processes on.
  125690. * @returns The list of the post processes in the effect.
  125691. */
  125692. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125693. }
  125694. }
  125695. declare module BABYLON {
  125696. /** @hidden */
  125697. export var extractHighlightsPixelShader: {
  125698. name: string;
  125699. shader: string;
  125700. };
  125701. }
  125702. declare module BABYLON {
  125703. /**
  125704. * 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.
  125705. */
  125706. export class ExtractHighlightsPostProcess extends PostProcess {
  125707. /**
  125708. * The luminance threshold, pixels below this value will be set to black.
  125709. */
  125710. threshold: number;
  125711. /** @hidden */
  125712. _exposure: number;
  125713. /**
  125714. * Post process which has the input texture to be used when performing highlight extraction
  125715. * @hidden
  125716. */
  125717. _inputPostProcess: Nullable<PostProcess>;
  125718. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125719. }
  125720. }
  125721. declare module BABYLON {
  125722. /** @hidden */
  125723. export var bloomMergePixelShader: {
  125724. name: string;
  125725. shader: string;
  125726. };
  125727. }
  125728. declare module BABYLON {
  125729. /**
  125730. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125731. */
  125732. export class BloomMergePostProcess extends PostProcess {
  125733. /** Weight of the bloom to be added to the original input. */
  125734. weight: number;
  125735. /**
  125736. * Creates a new instance of @see BloomMergePostProcess
  125737. * @param name The name of the effect.
  125738. * @param originalFromInput Post process which's input will be used for the merge.
  125739. * @param blurred Blurred highlights post process which's output will be used.
  125740. * @param weight Weight of the bloom to be added to the original input.
  125741. * @param options The required width/height ratio to downsize to before computing the render pass.
  125742. * @param camera The camera to apply the render pass to.
  125743. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125744. * @param engine The engine which the post process will be applied. (default: current engine)
  125745. * @param reusable If the post process can be reused on the same frame. (default: false)
  125746. * @param textureType Type of textures used when performing the post process. (default: 0)
  125747. * @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)
  125748. */
  125749. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125750. /** Weight of the bloom to be added to the original input. */
  125751. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125752. }
  125753. }
  125754. declare module BABYLON {
  125755. /**
  125756. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125757. */
  125758. export class BloomEffect extends PostProcessRenderEffect {
  125759. private bloomScale;
  125760. /**
  125761. * @hidden Internal
  125762. */
  125763. _effects: Array<PostProcess>;
  125764. /**
  125765. * @hidden Internal
  125766. */
  125767. _downscale: ExtractHighlightsPostProcess;
  125768. private _blurX;
  125769. private _blurY;
  125770. private _merge;
  125771. /**
  125772. * The luminance threshold to find bright areas of the image to bloom.
  125773. */
  125774. threshold: number;
  125775. /**
  125776. * The strength of the bloom.
  125777. */
  125778. weight: number;
  125779. /**
  125780. * Specifies the size of the bloom blur kernel, relative to the final output size
  125781. */
  125782. kernel: number;
  125783. /**
  125784. * Creates a new instance of @see BloomEffect
  125785. * @param scene The scene the effect belongs to.
  125786. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125787. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125788. * @param bloomWeight The the strength of bloom.
  125789. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  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(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125793. /**
  125794. * Disposes each of the internal effects for a given camera.
  125795. * @param camera The camera to dispose the effect on.
  125796. */
  125797. disposeEffects(camera: Camera): void;
  125798. /**
  125799. * @hidden Internal
  125800. */
  125801. _updateEffects(): void;
  125802. /**
  125803. * Internal
  125804. * @returns if all the contained post processes are ready.
  125805. * @hidden
  125806. */
  125807. _isReady(): boolean;
  125808. }
  125809. }
  125810. declare module BABYLON {
  125811. /** @hidden */
  125812. export var chromaticAberrationPixelShader: {
  125813. name: string;
  125814. shader: string;
  125815. };
  125816. }
  125817. declare module BABYLON {
  125818. /**
  125819. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125820. */
  125821. export class ChromaticAberrationPostProcess extends PostProcess {
  125822. /**
  125823. * The amount of seperation of rgb channels (default: 30)
  125824. */
  125825. aberrationAmount: number;
  125826. /**
  125827. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125828. */
  125829. radialIntensity: number;
  125830. /**
  125831. * 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))
  125832. */
  125833. direction: Vector2;
  125834. /**
  125835. * 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))
  125836. */
  125837. centerPosition: Vector2;
  125838. /**
  125839. * Creates a new instance ChromaticAberrationPostProcess
  125840. * @param name The name of the effect.
  125841. * @param screenWidth The width of the screen to apply the effect on.
  125842. * @param screenHeight The height of the screen to apply the effect on.
  125843. * @param options The required width/height ratio to downsize to before computing the render pass.
  125844. * @param camera The camera to apply the render pass to.
  125845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125846. * @param engine The engine which the post process will be applied. (default: current engine)
  125847. * @param reusable If the post process can be reused on the same frame. (default: false)
  125848. * @param textureType Type of textures used when performing the post process. (default: 0)
  125849. * @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)
  125850. */
  125851. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125852. }
  125853. }
  125854. declare module BABYLON {
  125855. /** @hidden */
  125856. export var circleOfConfusionPixelShader: {
  125857. name: string;
  125858. shader: string;
  125859. };
  125860. }
  125861. declare module BABYLON {
  125862. /**
  125863. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125864. */
  125865. export class CircleOfConfusionPostProcess extends PostProcess {
  125866. /**
  125867. * 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.
  125868. */
  125869. lensSize: number;
  125870. /**
  125871. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125872. */
  125873. fStop: number;
  125874. /**
  125875. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125876. */
  125877. focusDistance: number;
  125878. /**
  125879. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125880. */
  125881. focalLength: number;
  125882. private _depthTexture;
  125883. /**
  125884. * Creates a new instance CircleOfConfusionPostProcess
  125885. * @param name The name of the effect.
  125886. * @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.
  125887. * @param options The required width/height ratio to downsize to before computing the render pass.
  125888. * @param camera The camera to apply the render pass to.
  125889. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125890. * @param engine The engine which the post process will be applied. (default: current engine)
  125891. * @param reusable If the post process can be reused on the same frame. (default: false)
  125892. * @param textureType Type of textures used when performing the post process. (default: 0)
  125893. * @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)
  125894. */
  125895. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125896. /**
  125897. * 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.
  125898. */
  125899. depthTexture: RenderTargetTexture;
  125900. }
  125901. }
  125902. declare module BABYLON {
  125903. /** @hidden */
  125904. export var colorCorrectionPixelShader: {
  125905. name: string;
  125906. shader: string;
  125907. };
  125908. }
  125909. declare module BABYLON {
  125910. /**
  125911. *
  125912. * This post-process allows the modification of rendered colors by using
  125913. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125914. *
  125915. * The object needs to be provided an url to a texture containing the color
  125916. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125917. * Use an image editing software to tweak the LUT to match your needs.
  125918. *
  125919. * For an example of a color LUT, see here:
  125920. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125921. * For explanations on color grading, see here:
  125922. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125923. *
  125924. */
  125925. export class ColorCorrectionPostProcess extends PostProcess {
  125926. private _colorTableTexture;
  125927. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125928. }
  125929. }
  125930. declare module BABYLON {
  125931. /** @hidden */
  125932. export var convolutionPixelShader: {
  125933. name: string;
  125934. shader: string;
  125935. };
  125936. }
  125937. declare module BABYLON {
  125938. /**
  125939. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125940. * input texture to perform effects such as edge detection or sharpening
  125941. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125942. */
  125943. export class ConvolutionPostProcess extends PostProcess {
  125944. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125945. kernel: number[];
  125946. /**
  125947. * Creates a new instance ConvolutionPostProcess
  125948. * @param name The name of the effect.
  125949. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125950. * @param options The required width/height ratio to downsize to before computing the render pass.
  125951. * @param camera The camera to apply the render pass to.
  125952. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125953. * @param engine The engine which the post process will be applied. (default: current engine)
  125954. * @param reusable If the post process can be reused on the same frame. (default: false)
  125955. * @param textureType Type of textures used when performing the post process. (default: 0)
  125956. */
  125957. constructor(name: string,
  125958. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125959. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125960. /**
  125961. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125962. */
  125963. static EdgeDetect0Kernel: number[];
  125964. /**
  125965. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125966. */
  125967. static EdgeDetect1Kernel: number[];
  125968. /**
  125969. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125970. */
  125971. static EdgeDetect2Kernel: number[];
  125972. /**
  125973. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125974. */
  125975. static SharpenKernel: number[];
  125976. /**
  125977. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125978. */
  125979. static EmbossKernel: number[];
  125980. /**
  125981. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125982. */
  125983. static GaussianKernel: number[];
  125984. }
  125985. }
  125986. declare module BABYLON {
  125987. /**
  125988. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125989. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125990. * based on samples that have a large difference in distance than the center pixel.
  125991. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125992. */
  125993. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125994. direction: Vector2;
  125995. /**
  125996. * Creates a new instance CircleOfConfusionPostProcess
  125997. * @param name The name of the effect.
  125998. * @param scene The scene the effect belongs to.
  125999. * @param direction The direction the blur should be applied.
  126000. * @param kernel The size of the kernel used to blur.
  126001. * @param options The required width/height ratio to downsize to before computing the render pass.
  126002. * @param camera The camera to apply the render pass to.
  126003. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126004. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126006. * @param engine The engine which the post process will be applied. (default: current engine)
  126007. * @param reusable If the post process can be reused on the same frame. (default: false)
  126008. * @param textureType Type of textures used when performing the post process. (default: 0)
  126009. * @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)
  126010. */
  126011. 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);
  126012. }
  126013. }
  126014. declare module BABYLON {
  126015. /** @hidden */
  126016. export var depthOfFieldMergePixelShader: {
  126017. name: string;
  126018. shader: string;
  126019. };
  126020. }
  126021. declare module BABYLON {
  126022. /**
  126023. * Options to be set when merging outputs from the default pipeline.
  126024. */
  126025. export class DepthOfFieldMergePostProcessOptions {
  126026. /**
  126027. * The original image to merge on top of
  126028. */
  126029. originalFromInput: PostProcess;
  126030. /**
  126031. * Parameters to perform the merge of the depth of field effect
  126032. */
  126033. depthOfField?: {
  126034. circleOfConfusion: PostProcess;
  126035. blurSteps: Array<PostProcess>;
  126036. };
  126037. /**
  126038. * Parameters to perform the merge of bloom effect
  126039. */
  126040. bloom?: {
  126041. blurred: PostProcess;
  126042. weight: number;
  126043. };
  126044. }
  126045. /**
  126046. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126047. */
  126048. export class DepthOfFieldMergePostProcess extends PostProcess {
  126049. private blurSteps;
  126050. /**
  126051. * Creates a new instance of DepthOfFieldMergePostProcess
  126052. * @param name The name of the effect.
  126053. * @param originalFromInput Post process which's input will be used for the merge.
  126054. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126055. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126056. * @param options The required width/height ratio to downsize to before computing the render pass.
  126057. * @param camera The camera to apply the render pass to.
  126058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126059. * @param engine The engine which the post process will be applied. (default: current engine)
  126060. * @param reusable If the post process can be reused on the same frame. (default: false)
  126061. * @param textureType Type of textures used when performing the post process. (default: 0)
  126062. * @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)
  126063. */
  126064. 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);
  126065. /**
  126066. * Updates the effect with the current post process compile time values and recompiles the shader.
  126067. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126068. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126069. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126070. * @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
  126071. * @param onCompiled Called when the shader has been compiled.
  126072. * @param onError Called if there is an error when compiling a shader.
  126073. */
  126074. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126075. }
  126076. }
  126077. declare module BABYLON {
  126078. /**
  126079. * Specifies the level of max blur that should be applied when using the depth of field effect
  126080. */
  126081. export enum DepthOfFieldEffectBlurLevel {
  126082. /**
  126083. * Subtle blur
  126084. */
  126085. Low = 0,
  126086. /**
  126087. * Medium blur
  126088. */
  126089. Medium = 1,
  126090. /**
  126091. * Large blur
  126092. */
  126093. High = 2
  126094. }
  126095. /**
  126096. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126097. */
  126098. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126099. private _circleOfConfusion;
  126100. /**
  126101. * @hidden Internal, blurs from high to low
  126102. */
  126103. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126104. private _depthOfFieldBlurY;
  126105. private _dofMerge;
  126106. /**
  126107. * @hidden Internal post processes in depth of field effect
  126108. */
  126109. _effects: Array<PostProcess>;
  126110. /**
  126111. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126112. */
  126113. focalLength: number;
  126114. /**
  126115. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126116. */
  126117. fStop: number;
  126118. /**
  126119. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126120. */
  126121. focusDistance: number;
  126122. /**
  126123. * 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.
  126124. */
  126125. lensSize: number;
  126126. /**
  126127. * Creates a new instance DepthOfFieldEffect
  126128. * @param scene The scene the effect belongs to.
  126129. * @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.
  126130. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126131. * @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)
  126132. */
  126133. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126134. /**
  126135. * Get the current class name of the current effet
  126136. * @returns "DepthOfFieldEffect"
  126137. */
  126138. getClassName(): string;
  126139. /**
  126140. * 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.
  126141. */
  126142. depthTexture: RenderTargetTexture;
  126143. /**
  126144. * Disposes each of the internal effects for a given camera.
  126145. * @param camera The camera to dispose the effect on.
  126146. */
  126147. disposeEffects(camera: Camera): void;
  126148. /**
  126149. * @hidden Internal
  126150. */
  126151. _updateEffects(): void;
  126152. /**
  126153. * Internal
  126154. * @returns if all the contained post processes are ready.
  126155. * @hidden
  126156. */
  126157. _isReady(): boolean;
  126158. }
  126159. }
  126160. declare module BABYLON {
  126161. /** @hidden */
  126162. export var displayPassPixelShader: {
  126163. name: string;
  126164. shader: string;
  126165. };
  126166. }
  126167. declare module BABYLON {
  126168. /**
  126169. * DisplayPassPostProcess which produces an output the same as it's input
  126170. */
  126171. export class DisplayPassPostProcess extends PostProcess {
  126172. /**
  126173. * Creates the DisplayPassPostProcess
  126174. * @param name The name of the effect.
  126175. * @param options The required width/height ratio to downsize to before computing the render pass.
  126176. * @param camera The camera to apply the render pass to.
  126177. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126178. * @param engine The engine which the post process will be applied. (default: current engine)
  126179. * @param reusable If the post process can be reused on the same frame. (default: false)
  126180. */
  126181. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126182. }
  126183. }
  126184. declare module BABYLON {
  126185. /** @hidden */
  126186. export var filterPixelShader: {
  126187. name: string;
  126188. shader: string;
  126189. };
  126190. }
  126191. declare module BABYLON {
  126192. /**
  126193. * Applies a kernel filter to the image
  126194. */
  126195. export class FilterPostProcess extends PostProcess {
  126196. /** The matrix to be applied to the image */
  126197. kernelMatrix: Matrix;
  126198. /**
  126199. *
  126200. * @param name The name of the effect.
  126201. * @param kernelMatrix The matrix to be applied to the image
  126202. * @param options The required width/height ratio to downsize to before computing the render pass.
  126203. * @param camera The camera to apply the render pass to.
  126204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126205. * @param engine The engine which the post process will be applied. (default: current engine)
  126206. * @param reusable If the post process can be reused on the same frame. (default: false)
  126207. */
  126208. constructor(name: string,
  126209. /** The matrix to be applied to the image */
  126210. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126211. }
  126212. }
  126213. declare module BABYLON {
  126214. /** @hidden */
  126215. export var fxaaPixelShader: {
  126216. name: string;
  126217. shader: string;
  126218. };
  126219. }
  126220. declare module BABYLON {
  126221. /** @hidden */
  126222. export var fxaaVertexShader: {
  126223. name: string;
  126224. shader: string;
  126225. };
  126226. }
  126227. declare module BABYLON {
  126228. /**
  126229. * Fxaa post process
  126230. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126231. */
  126232. export class FxaaPostProcess extends PostProcess {
  126233. /** @hidden */
  126234. texelWidth: number;
  126235. /** @hidden */
  126236. texelHeight: number;
  126237. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126238. private _getDefines;
  126239. }
  126240. }
  126241. declare module BABYLON {
  126242. /** @hidden */
  126243. export var grainPixelShader: {
  126244. name: string;
  126245. shader: string;
  126246. };
  126247. }
  126248. declare module BABYLON {
  126249. /**
  126250. * The GrainPostProcess adds noise to the image at mid luminance levels
  126251. */
  126252. export class GrainPostProcess extends PostProcess {
  126253. /**
  126254. * The intensity of the grain added (default: 30)
  126255. */
  126256. intensity: number;
  126257. /**
  126258. * If the grain should be randomized on every frame
  126259. */
  126260. animated: boolean;
  126261. /**
  126262. * Creates a new instance of @see GrainPostProcess
  126263. * @param name The name of the effect.
  126264. * @param options The required width/height ratio to downsize to before computing the render pass.
  126265. * @param camera The camera to apply the render pass to.
  126266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126267. * @param engine The engine which the post process will be applied. (default: current engine)
  126268. * @param reusable If the post process can be reused on the same frame. (default: false)
  126269. * @param textureType Type of textures used when performing the post process. (default: 0)
  126270. * @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)
  126271. */
  126272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126273. }
  126274. }
  126275. declare module BABYLON {
  126276. /** @hidden */
  126277. export var highlightsPixelShader: {
  126278. name: string;
  126279. shader: string;
  126280. };
  126281. }
  126282. declare module BABYLON {
  126283. /**
  126284. * Extracts highlights from the image
  126285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126286. */
  126287. export class HighlightsPostProcess extends PostProcess {
  126288. /**
  126289. * Extracts highlights from the image
  126290. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126291. * @param name The name of the effect.
  126292. * @param options The required width/height ratio to downsize to before computing the render pass.
  126293. * @param camera The camera to apply the render pass to.
  126294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126295. * @param engine The engine which the post process will be applied. (default: current engine)
  126296. * @param reusable If the post process can be reused on the same frame. (default: false)
  126297. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126298. */
  126299. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126300. }
  126301. }
  126302. declare module BABYLON {
  126303. /** @hidden */
  126304. export var mrtFragmentDeclaration: {
  126305. name: string;
  126306. shader: string;
  126307. };
  126308. }
  126309. declare module BABYLON {
  126310. /** @hidden */
  126311. export var geometryPixelShader: {
  126312. name: string;
  126313. shader: string;
  126314. };
  126315. }
  126316. declare module BABYLON {
  126317. /** @hidden */
  126318. export var geometryVertexShader: {
  126319. name: string;
  126320. shader: string;
  126321. };
  126322. }
  126323. declare module BABYLON {
  126324. /** @hidden */
  126325. interface ISavedTransformationMatrix {
  126326. world: Matrix;
  126327. viewProjection: Matrix;
  126328. }
  126329. /**
  126330. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126331. */
  126332. export class GeometryBufferRenderer {
  126333. /**
  126334. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126335. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126336. */
  126337. static readonly POSITION_TEXTURE_TYPE: number;
  126338. /**
  126339. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126340. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126341. */
  126342. static readonly VELOCITY_TEXTURE_TYPE: number;
  126343. /**
  126344. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126345. * in order to compute objects velocities when enableVelocity is set to "true"
  126346. * @hidden
  126347. */
  126348. _previousTransformationMatrices: {
  126349. [index: number]: ISavedTransformationMatrix;
  126350. };
  126351. /**
  126352. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126353. * in order to compute objects velocities when enableVelocity is set to "true"
  126354. * @hidden
  126355. */
  126356. _previousBonesTransformationMatrices: {
  126357. [index: number]: Float32Array;
  126358. };
  126359. /**
  126360. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126361. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126362. */
  126363. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126364. private _scene;
  126365. private _multiRenderTarget;
  126366. private _ratio;
  126367. private _enablePosition;
  126368. private _enableVelocity;
  126369. private _positionIndex;
  126370. private _velocityIndex;
  126371. protected _effect: Effect;
  126372. protected _cachedDefines: string;
  126373. /**
  126374. * Set the render list (meshes to be rendered) used in the G buffer.
  126375. */
  126376. renderList: Mesh[];
  126377. /**
  126378. * Gets wether or not G buffer are supported by the running hardware.
  126379. * This requires draw buffer supports
  126380. */
  126381. readonly isSupported: boolean;
  126382. /**
  126383. * Returns the index of the given texture type in the G-Buffer textures array
  126384. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126385. * @returns the index of the given texture type in the G-Buffer textures array
  126386. */
  126387. getTextureIndex(textureType: number): number;
  126388. /**
  126389. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126390. */
  126391. /**
  126392. * Sets whether or not objects positions are enabled for the G buffer.
  126393. */
  126394. enablePosition: boolean;
  126395. /**
  126396. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126397. */
  126398. /**
  126399. * Sets wether or not objects velocities are enabled for the G buffer.
  126400. */
  126401. enableVelocity: boolean;
  126402. /**
  126403. * Gets the scene associated with the buffer.
  126404. */
  126405. readonly scene: Scene;
  126406. /**
  126407. * Gets the ratio used by the buffer during its creation.
  126408. * How big is the buffer related to the main canvas.
  126409. */
  126410. readonly ratio: number;
  126411. /** @hidden */
  126412. static _SceneComponentInitialization: (scene: Scene) => void;
  126413. /**
  126414. * Creates a new G Buffer for the scene
  126415. * @param scene The scene the buffer belongs to
  126416. * @param ratio How big is the buffer related to the main canvas.
  126417. */
  126418. constructor(scene: Scene, ratio?: number);
  126419. /**
  126420. * Checks wether everything is ready to render a submesh to the G buffer.
  126421. * @param subMesh the submesh to check readiness for
  126422. * @param useInstances is the mesh drawn using instance or not
  126423. * @returns true if ready otherwise false
  126424. */
  126425. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126426. /**
  126427. * Gets the current underlying G Buffer.
  126428. * @returns the buffer
  126429. */
  126430. getGBuffer(): MultiRenderTarget;
  126431. /**
  126432. * Gets the number of samples used to render the buffer (anti aliasing).
  126433. */
  126434. /**
  126435. * Sets the number of samples used to render the buffer (anti aliasing).
  126436. */
  126437. samples: number;
  126438. /**
  126439. * Disposes the renderer and frees up associated resources.
  126440. */
  126441. dispose(): void;
  126442. protected _createRenderTargets(): void;
  126443. private _copyBonesTransformationMatrices;
  126444. }
  126445. }
  126446. declare module BABYLON {
  126447. interface Scene {
  126448. /** @hidden (Backing field) */
  126449. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126450. /**
  126451. * Gets or Sets the current geometry buffer associated to the scene.
  126452. */
  126453. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126454. /**
  126455. * Enables a GeometryBufferRender and associates it with the scene
  126456. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126457. * @returns the GeometryBufferRenderer
  126458. */
  126459. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126460. /**
  126461. * Disables the GeometryBufferRender associated with the scene
  126462. */
  126463. disableGeometryBufferRenderer(): void;
  126464. }
  126465. /**
  126466. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126467. * in several rendering techniques.
  126468. */
  126469. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126470. /**
  126471. * The component name helpful to identify the component in the list of scene components.
  126472. */
  126473. readonly name: string;
  126474. /**
  126475. * The scene the component belongs to.
  126476. */
  126477. scene: Scene;
  126478. /**
  126479. * Creates a new instance of the component for the given scene
  126480. * @param scene Defines the scene to register the component in
  126481. */
  126482. constructor(scene: Scene);
  126483. /**
  126484. * Registers the component in a given scene
  126485. */
  126486. register(): void;
  126487. /**
  126488. * Rebuilds the elements related to this component in case of
  126489. * context lost for instance.
  126490. */
  126491. rebuild(): void;
  126492. /**
  126493. * Disposes the component and the associated ressources
  126494. */
  126495. dispose(): void;
  126496. private _gatherRenderTargets;
  126497. }
  126498. }
  126499. declare module BABYLON {
  126500. /** @hidden */
  126501. export var motionBlurPixelShader: {
  126502. name: string;
  126503. shader: string;
  126504. };
  126505. }
  126506. declare module BABYLON {
  126507. /**
  126508. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126509. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126510. * As an example, all you have to do is to create the post-process:
  126511. * var mb = new BABYLON.MotionBlurPostProcess(
  126512. * 'mb', // The name of the effect.
  126513. * scene, // The scene containing the objects to blur according to their velocity.
  126514. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126515. * camera // The camera to apply the render pass to.
  126516. * );
  126517. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126518. */
  126519. export class MotionBlurPostProcess extends PostProcess {
  126520. /**
  126521. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126522. */
  126523. motionStrength: number;
  126524. /**
  126525. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126526. */
  126527. /**
  126528. * Sets the number of iterations to be used for motion blur quality
  126529. */
  126530. motionBlurSamples: number;
  126531. private _motionBlurSamples;
  126532. private _geometryBufferRenderer;
  126533. /**
  126534. * Creates a new instance MotionBlurPostProcess
  126535. * @param name The name of the effect.
  126536. * @param scene The scene containing the objects to blur according to their velocity.
  126537. * @param options The required width/height ratio to downsize to before computing the render pass.
  126538. * @param camera The camera to apply the render pass to.
  126539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126540. * @param engine The engine which the post process will be applied. (default: current engine)
  126541. * @param reusable If the post process can be reused on the same frame. (default: false)
  126542. * @param textureType Type of textures used when performing the post process. (default: 0)
  126543. * @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)
  126544. */
  126545. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126546. /**
  126547. * Excludes the given skinned mesh from computing bones velocities.
  126548. * 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.
  126549. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126550. */
  126551. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126552. /**
  126553. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126554. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126555. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126556. */
  126557. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126558. /**
  126559. * Disposes the post process.
  126560. * @param camera The camera to dispose the post process on.
  126561. */
  126562. dispose(camera?: Camera): void;
  126563. }
  126564. }
  126565. declare module BABYLON {
  126566. /** @hidden */
  126567. export var refractionPixelShader: {
  126568. name: string;
  126569. shader: string;
  126570. };
  126571. }
  126572. declare module BABYLON {
  126573. /**
  126574. * Post process which applies a refractin texture
  126575. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126576. */
  126577. export class RefractionPostProcess extends PostProcess {
  126578. /** the base color of the refraction (used to taint the rendering) */
  126579. color: Color3;
  126580. /** simulated refraction depth */
  126581. depth: number;
  126582. /** the coefficient of the base color (0 to remove base color tainting) */
  126583. colorLevel: number;
  126584. private _refTexture;
  126585. private _ownRefractionTexture;
  126586. /**
  126587. * Gets or sets the refraction texture
  126588. * Please note that you are responsible for disposing the texture if you set it manually
  126589. */
  126590. refractionTexture: Texture;
  126591. /**
  126592. * Initializes the RefractionPostProcess
  126593. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126594. * @param name The name of the effect.
  126595. * @param refractionTextureUrl Url of the refraction texture to use
  126596. * @param color the base color of the refraction (used to taint the rendering)
  126597. * @param depth simulated refraction depth
  126598. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126599. * @param camera The camera to apply the render pass to.
  126600. * @param options The required width/height ratio to downsize to before computing the render pass.
  126601. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126602. * @param engine The engine which the post process will be applied. (default: current engine)
  126603. * @param reusable If the post process can be reused on the same frame. (default: false)
  126604. */
  126605. constructor(name: string, refractionTextureUrl: string,
  126606. /** the base color of the refraction (used to taint the rendering) */
  126607. color: Color3,
  126608. /** simulated refraction depth */
  126609. depth: number,
  126610. /** the coefficient of the base color (0 to remove base color tainting) */
  126611. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126612. /**
  126613. * Disposes of the post process
  126614. * @param camera Camera to dispose post process on
  126615. */
  126616. dispose(camera: Camera): void;
  126617. }
  126618. }
  126619. declare module BABYLON {
  126620. /** @hidden */
  126621. export var sharpenPixelShader: {
  126622. name: string;
  126623. shader: string;
  126624. };
  126625. }
  126626. declare module BABYLON {
  126627. /**
  126628. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126629. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126630. */
  126631. export class SharpenPostProcess extends PostProcess {
  126632. /**
  126633. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126634. */
  126635. colorAmount: number;
  126636. /**
  126637. * How much sharpness should be applied (default: 0.3)
  126638. */
  126639. edgeAmount: number;
  126640. /**
  126641. * Creates a new instance ConvolutionPostProcess
  126642. * @param name The name of the effect.
  126643. * @param options The required width/height ratio to downsize to before computing the render pass.
  126644. * @param camera The camera to apply the render pass to.
  126645. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126646. * @param engine The engine which the post process will be applied. (default: current engine)
  126647. * @param reusable If the post process can be reused on the same frame. (default: false)
  126648. * @param textureType Type of textures used when performing the post process. (default: 0)
  126649. * @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)
  126650. */
  126651. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126652. }
  126653. }
  126654. declare module BABYLON {
  126655. /**
  126656. * PostProcessRenderPipeline
  126657. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126658. */
  126659. export class PostProcessRenderPipeline {
  126660. private engine;
  126661. private _renderEffects;
  126662. private _renderEffectsForIsolatedPass;
  126663. /**
  126664. * List of inspectable custom properties (used by the Inspector)
  126665. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126666. */
  126667. inspectableCustomProperties: IInspectable[];
  126668. /**
  126669. * @hidden
  126670. */
  126671. protected _cameras: Camera[];
  126672. /** @hidden */
  126673. _name: string;
  126674. /**
  126675. * Gets pipeline name
  126676. */
  126677. readonly name: string;
  126678. /**
  126679. * Initializes a PostProcessRenderPipeline
  126680. * @param engine engine to add the pipeline to
  126681. * @param name name of the pipeline
  126682. */
  126683. constructor(engine: Engine, name: string);
  126684. /**
  126685. * Gets the class name
  126686. * @returns "PostProcessRenderPipeline"
  126687. */
  126688. getClassName(): string;
  126689. /**
  126690. * If all the render effects in the pipeline are supported
  126691. */
  126692. readonly isSupported: boolean;
  126693. /**
  126694. * Adds an effect to the pipeline
  126695. * @param renderEffect the effect to add
  126696. */
  126697. addEffect(renderEffect: PostProcessRenderEffect): void;
  126698. /** @hidden */
  126699. _rebuild(): void;
  126700. /** @hidden */
  126701. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126702. /** @hidden */
  126703. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126704. /** @hidden */
  126705. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126706. /** @hidden */
  126707. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126708. /** @hidden */
  126709. _attachCameras(cameras: Camera, unique: boolean): void;
  126710. /** @hidden */
  126711. _attachCameras(cameras: Camera[], unique: boolean): void;
  126712. /** @hidden */
  126713. _detachCameras(cameras: Camera): void;
  126714. /** @hidden */
  126715. _detachCameras(cameras: Nullable<Camera[]>): void;
  126716. /** @hidden */
  126717. _update(): void;
  126718. /** @hidden */
  126719. _reset(): void;
  126720. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126721. /**
  126722. * Disposes of the pipeline
  126723. */
  126724. dispose(): void;
  126725. }
  126726. }
  126727. declare module BABYLON {
  126728. /**
  126729. * PostProcessRenderPipelineManager class
  126730. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126731. */
  126732. export class PostProcessRenderPipelineManager {
  126733. private _renderPipelines;
  126734. /**
  126735. * Initializes a PostProcessRenderPipelineManager
  126736. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126737. */
  126738. constructor();
  126739. /**
  126740. * Gets the list of supported render pipelines
  126741. */
  126742. readonly supportedPipelines: PostProcessRenderPipeline[];
  126743. /**
  126744. * Adds a pipeline to the manager
  126745. * @param renderPipeline The pipeline to add
  126746. */
  126747. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126748. /**
  126749. * Attaches a camera to the pipeline
  126750. * @param renderPipelineName The name of the pipeline to attach to
  126751. * @param cameras the camera to attach
  126752. * @param unique if the camera can be attached multiple times to the pipeline
  126753. */
  126754. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126755. /**
  126756. * Detaches a camera from the pipeline
  126757. * @param renderPipelineName The name of the pipeline to detach from
  126758. * @param cameras the camera to detach
  126759. */
  126760. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126761. /**
  126762. * Enables an effect by name on a pipeline
  126763. * @param renderPipelineName the name of the pipeline to enable the effect in
  126764. * @param renderEffectName the name of the effect to enable
  126765. * @param cameras the cameras that the effect should be enabled on
  126766. */
  126767. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126768. /**
  126769. * Disables an effect by name on a pipeline
  126770. * @param renderPipelineName the name of the pipeline to disable the effect in
  126771. * @param renderEffectName the name of the effect to disable
  126772. * @param cameras the cameras that the effect should be disabled on
  126773. */
  126774. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126775. /**
  126776. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126777. */
  126778. update(): void;
  126779. /** @hidden */
  126780. _rebuild(): void;
  126781. /**
  126782. * Disposes of the manager and pipelines
  126783. */
  126784. dispose(): void;
  126785. }
  126786. }
  126787. declare module BABYLON {
  126788. interface Scene {
  126789. /** @hidden (Backing field) */
  126790. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126791. /**
  126792. * Gets the postprocess render pipeline manager
  126793. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126794. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126795. */
  126796. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126797. }
  126798. /**
  126799. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126800. */
  126801. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126802. /**
  126803. * The component name helpfull to identify the component in the list of scene components.
  126804. */
  126805. readonly name: string;
  126806. /**
  126807. * The scene the component belongs to.
  126808. */
  126809. scene: Scene;
  126810. /**
  126811. * Creates a new instance of the component for the given scene
  126812. * @param scene Defines the scene to register the component in
  126813. */
  126814. constructor(scene: Scene);
  126815. /**
  126816. * Registers the component in a given scene
  126817. */
  126818. register(): void;
  126819. /**
  126820. * Rebuilds the elements related to this component in case of
  126821. * context lost for instance.
  126822. */
  126823. rebuild(): void;
  126824. /**
  126825. * Disposes the component and the associated ressources
  126826. */
  126827. dispose(): void;
  126828. private _gatherRenderTargets;
  126829. }
  126830. }
  126831. declare module BABYLON {
  126832. /**
  126833. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126834. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126835. */
  126836. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126837. private _scene;
  126838. private _camerasToBeAttached;
  126839. /**
  126840. * ID of the sharpen post process,
  126841. */
  126842. private readonly SharpenPostProcessId;
  126843. /**
  126844. * @ignore
  126845. * ID of the image processing post process;
  126846. */
  126847. readonly ImageProcessingPostProcessId: string;
  126848. /**
  126849. * @ignore
  126850. * ID of the Fast Approximate Anti-Aliasing post process;
  126851. */
  126852. readonly FxaaPostProcessId: string;
  126853. /**
  126854. * ID of the chromatic aberration post process,
  126855. */
  126856. private readonly ChromaticAberrationPostProcessId;
  126857. /**
  126858. * ID of the grain post process
  126859. */
  126860. private readonly GrainPostProcessId;
  126861. /**
  126862. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126863. */
  126864. sharpen: SharpenPostProcess;
  126865. private _sharpenEffect;
  126866. private bloom;
  126867. /**
  126868. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126869. */
  126870. depthOfField: DepthOfFieldEffect;
  126871. /**
  126872. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126873. */
  126874. fxaa: FxaaPostProcess;
  126875. /**
  126876. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126877. */
  126878. imageProcessing: ImageProcessingPostProcess;
  126879. /**
  126880. * Chromatic aberration post process which will shift rgb colors in the image
  126881. */
  126882. chromaticAberration: ChromaticAberrationPostProcess;
  126883. private _chromaticAberrationEffect;
  126884. /**
  126885. * Grain post process which add noise to the image
  126886. */
  126887. grain: GrainPostProcess;
  126888. private _grainEffect;
  126889. /**
  126890. * Glow post process which adds a glow to emissive areas of the image
  126891. */
  126892. private _glowLayer;
  126893. /**
  126894. * Animations which can be used to tweak settings over a period of time
  126895. */
  126896. animations: Animation[];
  126897. private _imageProcessingConfigurationObserver;
  126898. private _sharpenEnabled;
  126899. private _bloomEnabled;
  126900. private _depthOfFieldEnabled;
  126901. private _depthOfFieldBlurLevel;
  126902. private _fxaaEnabled;
  126903. private _imageProcessingEnabled;
  126904. private _defaultPipelineTextureType;
  126905. private _bloomScale;
  126906. private _chromaticAberrationEnabled;
  126907. private _grainEnabled;
  126908. private _buildAllowed;
  126909. /**
  126910. * Gets active scene
  126911. */
  126912. readonly scene: Scene;
  126913. /**
  126914. * Enable or disable the sharpen process from the pipeline
  126915. */
  126916. sharpenEnabled: boolean;
  126917. private _resizeObserver;
  126918. private _hardwareScaleLevel;
  126919. private _bloomKernel;
  126920. /**
  126921. * Specifies the size of the bloom blur kernel, relative to the final output size
  126922. */
  126923. bloomKernel: number;
  126924. /**
  126925. * Specifies the weight of the bloom in the final rendering
  126926. */
  126927. private _bloomWeight;
  126928. /**
  126929. * Specifies the luma threshold for the area that will be blurred by the bloom
  126930. */
  126931. private _bloomThreshold;
  126932. private _hdr;
  126933. /**
  126934. * The strength of the bloom.
  126935. */
  126936. bloomWeight: number;
  126937. /**
  126938. * The strength of the bloom.
  126939. */
  126940. bloomThreshold: number;
  126941. /**
  126942. * The scale of the bloom, lower value will provide better performance.
  126943. */
  126944. bloomScale: number;
  126945. /**
  126946. * Enable or disable the bloom from the pipeline
  126947. */
  126948. bloomEnabled: boolean;
  126949. private _rebuildBloom;
  126950. /**
  126951. * If the depth of field is enabled.
  126952. */
  126953. depthOfFieldEnabled: boolean;
  126954. /**
  126955. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126956. */
  126957. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126958. /**
  126959. * If the anti aliasing is enabled.
  126960. */
  126961. fxaaEnabled: boolean;
  126962. private _samples;
  126963. /**
  126964. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126965. */
  126966. samples: number;
  126967. /**
  126968. * If image processing is enabled.
  126969. */
  126970. imageProcessingEnabled: boolean;
  126971. /**
  126972. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126973. */
  126974. glowLayerEnabled: boolean;
  126975. /**
  126976. * Gets the glow layer (or null if not defined)
  126977. */
  126978. readonly glowLayer: Nullable<GlowLayer>;
  126979. /**
  126980. * Enable or disable the chromaticAberration process from the pipeline
  126981. */
  126982. chromaticAberrationEnabled: boolean;
  126983. /**
  126984. * Enable or disable the grain process from the pipeline
  126985. */
  126986. grainEnabled: boolean;
  126987. /**
  126988. * @constructor
  126989. * @param name - The rendering pipeline name (default: "")
  126990. * @param hdr - If high dynamic range textures should be used (default: true)
  126991. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126992. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126993. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126994. */
  126995. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126996. /**
  126997. * Get the class name
  126998. * @returns "DefaultRenderingPipeline"
  126999. */
  127000. getClassName(): string;
  127001. /**
  127002. * Force the compilation of the entire pipeline.
  127003. */
  127004. prepare(): void;
  127005. private _hasCleared;
  127006. private _prevPostProcess;
  127007. private _prevPrevPostProcess;
  127008. private _setAutoClearAndTextureSharing;
  127009. private _depthOfFieldSceneObserver;
  127010. private _buildPipeline;
  127011. private _disposePostProcesses;
  127012. /**
  127013. * Adds a camera to the pipeline
  127014. * @param camera the camera to be added
  127015. */
  127016. addCamera(camera: Camera): void;
  127017. /**
  127018. * Removes a camera from the pipeline
  127019. * @param camera the camera to remove
  127020. */
  127021. removeCamera(camera: Camera): void;
  127022. /**
  127023. * Dispose of the pipeline and stop all post processes
  127024. */
  127025. dispose(): void;
  127026. /**
  127027. * Serialize the rendering pipeline (Used when exporting)
  127028. * @returns the serialized object
  127029. */
  127030. serialize(): any;
  127031. /**
  127032. * Parse the serialized pipeline
  127033. * @param source Source pipeline.
  127034. * @param scene The scene to load the pipeline to.
  127035. * @param rootUrl The URL of the serialized pipeline.
  127036. * @returns An instantiated pipeline from the serialized object.
  127037. */
  127038. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127039. }
  127040. }
  127041. declare module BABYLON {
  127042. /** @hidden */
  127043. export var lensHighlightsPixelShader: {
  127044. name: string;
  127045. shader: string;
  127046. };
  127047. }
  127048. declare module BABYLON {
  127049. /** @hidden */
  127050. export var depthOfFieldPixelShader: {
  127051. name: string;
  127052. shader: string;
  127053. };
  127054. }
  127055. declare module BABYLON {
  127056. /**
  127057. * BABYLON.JS Chromatic Aberration GLSL Shader
  127058. * Author: Olivier Guyot
  127059. * Separates very slightly R, G and B colors on the edges of the screen
  127060. * Inspired by Francois Tarlier & Martins Upitis
  127061. */
  127062. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127063. /**
  127064. * @ignore
  127065. * The chromatic aberration PostProcess id in the pipeline
  127066. */
  127067. LensChromaticAberrationEffect: string;
  127068. /**
  127069. * @ignore
  127070. * The highlights enhancing PostProcess id in the pipeline
  127071. */
  127072. HighlightsEnhancingEffect: string;
  127073. /**
  127074. * @ignore
  127075. * The depth-of-field PostProcess id in the pipeline
  127076. */
  127077. LensDepthOfFieldEffect: string;
  127078. private _scene;
  127079. private _depthTexture;
  127080. private _grainTexture;
  127081. private _chromaticAberrationPostProcess;
  127082. private _highlightsPostProcess;
  127083. private _depthOfFieldPostProcess;
  127084. private _edgeBlur;
  127085. private _grainAmount;
  127086. private _chromaticAberration;
  127087. private _distortion;
  127088. private _highlightsGain;
  127089. private _highlightsThreshold;
  127090. private _dofDistance;
  127091. private _dofAperture;
  127092. private _dofDarken;
  127093. private _dofPentagon;
  127094. private _blurNoise;
  127095. /**
  127096. * @constructor
  127097. *
  127098. * Effect parameters are as follow:
  127099. * {
  127100. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127101. * edge_blur: number; // from 0 to x (1 for realism)
  127102. * distortion: number; // from 0 to x (1 for realism)
  127103. * grain_amount: number; // from 0 to 1
  127104. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127105. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127106. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127107. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127108. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127109. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127110. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127111. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127112. * }
  127113. * Note: if an effect parameter is unset, effect is disabled
  127114. *
  127115. * @param name The rendering pipeline name
  127116. * @param parameters - An object containing all parameters (see above)
  127117. * @param scene The scene linked to this pipeline
  127118. * @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)
  127119. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127120. */
  127121. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127122. /**
  127123. * Get the class name
  127124. * @returns "LensRenderingPipeline"
  127125. */
  127126. getClassName(): string;
  127127. /**
  127128. * Gets associated scene
  127129. */
  127130. readonly scene: Scene;
  127131. /**
  127132. * Gets or sets the edge blur
  127133. */
  127134. edgeBlur: number;
  127135. /**
  127136. * Gets or sets the grain amount
  127137. */
  127138. grainAmount: number;
  127139. /**
  127140. * Gets or sets the chromatic aberration amount
  127141. */
  127142. chromaticAberration: number;
  127143. /**
  127144. * Gets or sets the depth of field aperture
  127145. */
  127146. dofAperture: number;
  127147. /**
  127148. * Gets or sets the edge distortion
  127149. */
  127150. edgeDistortion: number;
  127151. /**
  127152. * Gets or sets the depth of field distortion
  127153. */
  127154. dofDistortion: number;
  127155. /**
  127156. * Gets or sets the darken out of focus amount
  127157. */
  127158. darkenOutOfFocus: number;
  127159. /**
  127160. * Gets or sets a boolean indicating if blur noise is enabled
  127161. */
  127162. blurNoise: boolean;
  127163. /**
  127164. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127165. */
  127166. pentagonBokeh: boolean;
  127167. /**
  127168. * Gets or sets the highlight grain amount
  127169. */
  127170. highlightsGain: number;
  127171. /**
  127172. * Gets or sets the highlight threshold
  127173. */
  127174. highlightsThreshold: number;
  127175. /**
  127176. * Sets the amount of blur at the edges
  127177. * @param amount blur amount
  127178. */
  127179. setEdgeBlur(amount: number): void;
  127180. /**
  127181. * Sets edge blur to 0
  127182. */
  127183. disableEdgeBlur(): void;
  127184. /**
  127185. * Sets the amout of grain
  127186. * @param amount Amount of grain
  127187. */
  127188. setGrainAmount(amount: number): void;
  127189. /**
  127190. * Set grain amount to 0
  127191. */
  127192. disableGrain(): void;
  127193. /**
  127194. * Sets the chromatic aberration amount
  127195. * @param amount amount of chromatic aberration
  127196. */
  127197. setChromaticAberration(amount: number): void;
  127198. /**
  127199. * Sets chromatic aberration amount to 0
  127200. */
  127201. disableChromaticAberration(): void;
  127202. /**
  127203. * Sets the EdgeDistortion amount
  127204. * @param amount amount of EdgeDistortion
  127205. */
  127206. setEdgeDistortion(amount: number): void;
  127207. /**
  127208. * Sets edge distortion to 0
  127209. */
  127210. disableEdgeDistortion(): void;
  127211. /**
  127212. * Sets the FocusDistance amount
  127213. * @param amount amount of FocusDistance
  127214. */
  127215. setFocusDistance(amount: number): void;
  127216. /**
  127217. * Disables depth of field
  127218. */
  127219. disableDepthOfField(): void;
  127220. /**
  127221. * Sets the Aperture amount
  127222. * @param amount amount of Aperture
  127223. */
  127224. setAperture(amount: number): void;
  127225. /**
  127226. * Sets the DarkenOutOfFocus amount
  127227. * @param amount amount of DarkenOutOfFocus
  127228. */
  127229. setDarkenOutOfFocus(amount: number): void;
  127230. private _pentagonBokehIsEnabled;
  127231. /**
  127232. * Creates a pentagon bokeh effect
  127233. */
  127234. enablePentagonBokeh(): void;
  127235. /**
  127236. * Disables the pentagon bokeh effect
  127237. */
  127238. disablePentagonBokeh(): void;
  127239. /**
  127240. * Enables noise blur
  127241. */
  127242. enableNoiseBlur(): void;
  127243. /**
  127244. * Disables noise blur
  127245. */
  127246. disableNoiseBlur(): void;
  127247. /**
  127248. * Sets the HighlightsGain amount
  127249. * @param amount amount of HighlightsGain
  127250. */
  127251. setHighlightsGain(amount: number): void;
  127252. /**
  127253. * Sets the HighlightsThreshold amount
  127254. * @param amount amount of HighlightsThreshold
  127255. */
  127256. setHighlightsThreshold(amount: number): void;
  127257. /**
  127258. * Disables highlights
  127259. */
  127260. disableHighlights(): void;
  127261. /**
  127262. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127263. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127264. */
  127265. dispose(disableDepthRender?: boolean): void;
  127266. private _createChromaticAberrationPostProcess;
  127267. private _createHighlightsPostProcess;
  127268. private _createDepthOfFieldPostProcess;
  127269. private _createGrainTexture;
  127270. }
  127271. }
  127272. declare module BABYLON {
  127273. /** @hidden */
  127274. export var ssao2PixelShader: {
  127275. name: string;
  127276. shader: string;
  127277. };
  127278. }
  127279. declare module BABYLON {
  127280. /** @hidden */
  127281. export var ssaoCombinePixelShader: {
  127282. name: string;
  127283. shader: string;
  127284. };
  127285. }
  127286. declare module BABYLON {
  127287. /**
  127288. * Render pipeline to produce ssao effect
  127289. */
  127290. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127291. /**
  127292. * @ignore
  127293. * The PassPostProcess id in the pipeline that contains the original scene color
  127294. */
  127295. SSAOOriginalSceneColorEffect: string;
  127296. /**
  127297. * @ignore
  127298. * The SSAO PostProcess id in the pipeline
  127299. */
  127300. SSAORenderEffect: string;
  127301. /**
  127302. * @ignore
  127303. * The horizontal blur PostProcess id in the pipeline
  127304. */
  127305. SSAOBlurHRenderEffect: string;
  127306. /**
  127307. * @ignore
  127308. * The vertical blur PostProcess id in the pipeline
  127309. */
  127310. SSAOBlurVRenderEffect: string;
  127311. /**
  127312. * @ignore
  127313. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127314. */
  127315. SSAOCombineRenderEffect: string;
  127316. /**
  127317. * The output strength of the SSAO post-process. Default value is 1.0.
  127318. */
  127319. totalStrength: number;
  127320. /**
  127321. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127322. */
  127323. maxZ: number;
  127324. /**
  127325. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127326. */
  127327. minZAspect: number;
  127328. private _samples;
  127329. /**
  127330. * Number of samples used for the SSAO calculations. Default value is 8
  127331. */
  127332. samples: number;
  127333. private _textureSamples;
  127334. /**
  127335. * Number of samples to use for antialiasing
  127336. */
  127337. textureSamples: number;
  127338. /**
  127339. * Ratio object used for SSAO ratio and blur ratio
  127340. */
  127341. private _ratio;
  127342. /**
  127343. * Dynamically generated sphere sampler.
  127344. */
  127345. private _sampleSphere;
  127346. /**
  127347. * Blur filter offsets
  127348. */
  127349. private _samplerOffsets;
  127350. private _expensiveBlur;
  127351. /**
  127352. * If bilateral blur should be used
  127353. */
  127354. expensiveBlur: boolean;
  127355. /**
  127356. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127357. */
  127358. radius: number;
  127359. /**
  127360. * The base color of the SSAO post-process
  127361. * The final result is "base + ssao" between [0, 1]
  127362. */
  127363. base: number;
  127364. /**
  127365. * Support test.
  127366. */
  127367. static readonly IsSupported: boolean;
  127368. private _scene;
  127369. private _depthTexture;
  127370. private _normalTexture;
  127371. private _randomTexture;
  127372. private _originalColorPostProcess;
  127373. private _ssaoPostProcess;
  127374. private _blurHPostProcess;
  127375. private _blurVPostProcess;
  127376. private _ssaoCombinePostProcess;
  127377. private _firstUpdate;
  127378. /**
  127379. * Gets active scene
  127380. */
  127381. readonly scene: Scene;
  127382. /**
  127383. * @constructor
  127384. * @param name The rendering pipeline name
  127385. * @param scene The scene linked to this pipeline
  127386. * @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 }
  127387. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127388. */
  127389. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127390. /**
  127391. * Get the class name
  127392. * @returns "SSAO2RenderingPipeline"
  127393. */
  127394. getClassName(): string;
  127395. /**
  127396. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127397. */
  127398. dispose(disableGeometryBufferRenderer?: boolean): void;
  127399. private _createBlurPostProcess;
  127400. /** @hidden */
  127401. _rebuild(): void;
  127402. private _bits;
  127403. private _radicalInverse_VdC;
  127404. private _hammersley;
  127405. private _hemisphereSample_uniform;
  127406. private _generateHemisphere;
  127407. private _createSSAOPostProcess;
  127408. private _createSSAOCombinePostProcess;
  127409. private _createRandomTexture;
  127410. /**
  127411. * Serialize the rendering pipeline (Used when exporting)
  127412. * @returns the serialized object
  127413. */
  127414. serialize(): any;
  127415. /**
  127416. * Parse the serialized pipeline
  127417. * @param source Source pipeline.
  127418. * @param scene The scene to load the pipeline to.
  127419. * @param rootUrl The URL of the serialized pipeline.
  127420. * @returns An instantiated pipeline from the serialized object.
  127421. */
  127422. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127423. }
  127424. }
  127425. declare module BABYLON {
  127426. /** @hidden */
  127427. export var ssaoPixelShader: {
  127428. name: string;
  127429. shader: string;
  127430. };
  127431. }
  127432. declare module BABYLON {
  127433. /**
  127434. * Render pipeline to produce ssao effect
  127435. */
  127436. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127437. /**
  127438. * @ignore
  127439. * The PassPostProcess id in the pipeline that contains the original scene color
  127440. */
  127441. SSAOOriginalSceneColorEffect: string;
  127442. /**
  127443. * @ignore
  127444. * The SSAO PostProcess id in the pipeline
  127445. */
  127446. SSAORenderEffect: string;
  127447. /**
  127448. * @ignore
  127449. * The horizontal blur PostProcess id in the pipeline
  127450. */
  127451. SSAOBlurHRenderEffect: string;
  127452. /**
  127453. * @ignore
  127454. * The vertical blur PostProcess id in the pipeline
  127455. */
  127456. SSAOBlurVRenderEffect: string;
  127457. /**
  127458. * @ignore
  127459. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127460. */
  127461. SSAOCombineRenderEffect: string;
  127462. /**
  127463. * The output strength of the SSAO post-process. Default value is 1.0.
  127464. */
  127465. totalStrength: number;
  127466. /**
  127467. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127468. */
  127469. radius: number;
  127470. /**
  127471. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127472. * Must not be equal to fallOff and superior to fallOff.
  127473. * Default value is 0.0075
  127474. */
  127475. area: number;
  127476. /**
  127477. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127478. * Must not be equal to area and inferior to area.
  127479. * Default value is 0.000001
  127480. */
  127481. fallOff: number;
  127482. /**
  127483. * The base color of the SSAO post-process
  127484. * The final result is "base + ssao" between [0, 1]
  127485. */
  127486. base: number;
  127487. private _scene;
  127488. private _depthTexture;
  127489. private _randomTexture;
  127490. private _originalColorPostProcess;
  127491. private _ssaoPostProcess;
  127492. private _blurHPostProcess;
  127493. private _blurVPostProcess;
  127494. private _ssaoCombinePostProcess;
  127495. private _firstUpdate;
  127496. /**
  127497. * Gets active scene
  127498. */
  127499. readonly scene: Scene;
  127500. /**
  127501. * @constructor
  127502. * @param name - The rendering pipeline name
  127503. * @param scene - The scene linked to this pipeline
  127504. * @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 }
  127505. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127506. */
  127507. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127508. /**
  127509. * Get the class name
  127510. * @returns "SSAORenderingPipeline"
  127511. */
  127512. getClassName(): string;
  127513. /**
  127514. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127515. */
  127516. dispose(disableDepthRender?: boolean): void;
  127517. private _createBlurPostProcess;
  127518. /** @hidden */
  127519. _rebuild(): void;
  127520. private _createSSAOPostProcess;
  127521. private _createSSAOCombinePostProcess;
  127522. private _createRandomTexture;
  127523. }
  127524. }
  127525. declare module BABYLON {
  127526. /** @hidden */
  127527. export var standardPixelShader: {
  127528. name: string;
  127529. shader: string;
  127530. };
  127531. }
  127532. declare module BABYLON {
  127533. /**
  127534. * Standard rendering pipeline
  127535. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127536. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127537. */
  127538. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127539. /**
  127540. * Public members
  127541. */
  127542. /**
  127543. * Post-process which contains the original scene color before the pipeline applies all the effects
  127544. */
  127545. originalPostProcess: Nullable<PostProcess>;
  127546. /**
  127547. * Post-process used to down scale an image x4
  127548. */
  127549. downSampleX4PostProcess: Nullable<PostProcess>;
  127550. /**
  127551. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127552. */
  127553. brightPassPostProcess: Nullable<PostProcess>;
  127554. /**
  127555. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127556. */
  127557. blurHPostProcesses: PostProcess[];
  127558. /**
  127559. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127560. */
  127561. blurVPostProcesses: PostProcess[];
  127562. /**
  127563. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127564. */
  127565. textureAdderPostProcess: Nullable<PostProcess>;
  127566. /**
  127567. * Post-process used to create volumetric lighting effect
  127568. */
  127569. volumetricLightPostProcess: Nullable<PostProcess>;
  127570. /**
  127571. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127572. */
  127573. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127574. /**
  127575. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127576. */
  127577. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127578. /**
  127579. * Post-process used to merge the volumetric light effect and the real scene color
  127580. */
  127581. volumetricLightMergePostProces: Nullable<PostProcess>;
  127582. /**
  127583. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127584. */
  127585. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127586. /**
  127587. * Base post-process used to calculate the average luminance of the final image for HDR
  127588. */
  127589. luminancePostProcess: Nullable<PostProcess>;
  127590. /**
  127591. * Post-processes used to create down sample post-processes in order to get
  127592. * the average luminance of the final image for HDR
  127593. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127594. */
  127595. luminanceDownSamplePostProcesses: PostProcess[];
  127596. /**
  127597. * Post-process used to create a HDR effect (light adaptation)
  127598. */
  127599. hdrPostProcess: Nullable<PostProcess>;
  127600. /**
  127601. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127602. */
  127603. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127604. /**
  127605. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127606. */
  127607. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127608. /**
  127609. * Post-process used to merge the final HDR post-process and the real scene color
  127610. */
  127611. hdrFinalPostProcess: Nullable<PostProcess>;
  127612. /**
  127613. * Post-process used to create a lens flare effect
  127614. */
  127615. lensFlarePostProcess: Nullable<PostProcess>;
  127616. /**
  127617. * Post-process that merges the result of the lens flare post-process and the real scene color
  127618. */
  127619. lensFlareComposePostProcess: Nullable<PostProcess>;
  127620. /**
  127621. * Post-process used to create a motion blur effect
  127622. */
  127623. motionBlurPostProcess: Nullable<PostProcess>;
  127624. /**
  127625. * Post-process used to create a depth of field effect
  127626. */
  127627. depthOfFieldPostProcess: Nullable<PostProcess>;
  127628. /**
  127629. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127630. */
  127631. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127632. /**
  127633. * Represents the brightness threshold in order to configure the illuminated surfaces
  127634. */
  127635. brightThreshold: number;
  127636. /**
  127637. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127638. */
  127639. blurWidth: number;
  127640. /**
  127641. * Sets if the blur for highlighted surfaces must be only horizontal
  127642. */
  127643. horizontalBlur: boolean;
  127644. /**
  127645. * Gets the overall exposure used by the pipeline
  127646. */
  127647. /**
  127648. * Sets the overall exposure used by the pipeline
  127649. */
  127650. exposure: number;
  127651. /**
  127652. * Texture used typically to simulate "dirty" on camera lens
  127653. */
  127654. lensTexture: Nullable<Texture>;
  127655. /**
  127656. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127657. */
  127658. volumetricLightCoefficient: number;
  127659. /**
  127660. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127661. */
  127662. volumetricLightPower: number;
  127663. /**
  127664. * Used the set the blur intensity to smooth the volumetric lights
  127665. */
  127666. volumetricLightBlurScale: number;
  127667. /**
  127668. * Light (spot or directional) used to generate the volumetric lights rays
  127669. * The source light must have a shadow generate so the pipeline can get its
  127670. * depth map
  127671. */
  127672. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127673. /**
  127674. * For eye adaptation, represents the minimum luminance the eye can see
  127675. */
  127676. hdrMinimumLuminance: number;
  127677. /**
  127678. * For eye adaptation, represents the decrease luminance speed
  127679. */
  127680. hdrDecreaseRate: number;
  127681. /**
  127682. * For eye adaptation, represents the increase luminance speed
  127683. */
  127684. hdrIncreaseRate: number;
  127685. /**
  127686. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127687. */
  127688. /**
  127689. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127690. */
  127691. hdrAutoExposure: boolean;
  127692. /**
  127693. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127694. */
  127695. lensColorTexture: Nullable<Texture>;
  127696. /**
  127697. * The overall strengh for the lens flare effect
  127698. */
  127699. lensFlareStrength: number;
  127700. /**
  127701. * Dispersion coefficient for lens flare ghosts
  127702. */
  127703. lensFlareGhostDispersal: number;
  127704. /**
  127705. * Main lens flare halo width
  127706. */
  127707. lensFlareHaloWidth: number;
  127708. /**
  127709. * Based on the lens distortion effect, defines how much the lens flare result
  127710. * is distorted
  127711. */
  127712. lensFlareDistortionStrength: number;
  127713. /**
  127714. * Configures the blur intensity used for for lens flare (halo)
  127715. */
  127716. lensFlareBlurWidth: number;
  127717. /**
  127718. * Lens star texture must be used to simulate rays on the flares and is available
  127719. * in the documentation
  127720. */
  127721. lensStarTexture: Nullable<Texture>;
  127722. /**
  127723. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127724. * flare effect by taking account of the dirt texture
  127725. */
  127726. lensFlareDirtTexture: Nullable<Texture>;
  127727. /**
  127728. * Represents the focal length for the depth of field effect
  127729. */
  127730. depthOfFieldDistance: number;
  127731. /**
  127732. * Represents the blur intensity for the blurred part of the depth of field effect
  127733. */
  127734. depthOfFieldBlurWidth: number;
  127735. /**
  127736. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127737. */
  127738. /**
  127739. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127740. */
  127741. motionStrength: number;
  127742. /**
  127743. * Gets wether or not the motion blur post-process is object based or screen based.
  127744. */
  127745. /**
  127746. * Sets wether or not the motion blur post-process should be object based or screen based
  127747. */
  127748. objectBasedMotionBlur: boolean;
  127749. /**
  127750. * List of animations for the pipeline (IAnimatable implementation)
  127751. */
  127752. animations: Animation[];
  127753. /**
  127754. * Private members
  127755. */
  127756. private _scene;
  127757. private _currentDepthOfFieldSource;
  127758. private _basePostProcess;
  127759. private _fixedExposure;
  127760. private _currentExposure;
  127761. private _hdrAutoExposure;
  127762. private _hdrCurrentLuminance;
  127763. private _motionStrength;
  127764. private _isObjectBasedMotionBlur;
  127765. private _floatTextureType;
  127766. private _camerasToBeAttached;
  127767. private _ratio;
  127768. private _bloomEnabled;
  127769. private _depthOfFieldEnabled;
  127770. private _vlsEnabled;
  127771. private _lensFlareEnabled;
  127772. private _hdrEnabled;
  127773. private _motionBlurEnabled;
  127774. private _fxaaEnabled;
  127775. private _motionBlurSamples;
  127776. private _volumetricLightStepsCount;
  127777. private _samples;
  127778. /**
  127779. * @ignore
  127780. * Specifies if the bloom pipeline is enabled
  127781. */
  127782. BloomEnabled: boolean;
  127783. /**
  127784. * @ignore
  127785. * Specifies if the depth of field pipeline is enabed
  127786. */
  127787. DepthOfFieldEnabled: boolean;
  127788. /**
  127789. * @ignore
  127790. * Specifies if the lens flare pipeline is enabed
  127791. */
  127792. LensFlareEnabled: boolean;
  127793. /**
  127794. * @ignore
  127795. * Specifies if the HDR pipeline is enabled
  127796. */
  127797. HDREnabled: boolean;
  127798. /**
  127799. * @ignore
  127800. * Specifies if the volumetric lights scattering effect is enabled
  127801. */
  127802. VLSEnabled: boolean;
  127803. /**
  127804. * @ignore
  127805. * Specifies if the motion blur effect is enabled
  127806. */
  127807. MotionBlurEnabled: boolean;
  127808. /**
  127809. * Specifies if anti-aliasing is enabled
  127810. */
  127811. fxaaEnabled: boolean;
  127812. /**
  127813. * Specifies the number of steps used to calculate the volumetric lights
  127814. * Typically in interval [50, 200]
  127815. */
  127816. volumetricLightStepsCount: number;
  127817. /**
  127818. * Specifies the number of samples used for the motion blur effect
  127819. * Typically in interval [16, 64]
  127820. */
  127821. motionBlurSamples: number;
  127822. /**
  127823. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127824. */
  127825. samples: number;
  127826. /**
  127827. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127828. * @constructor
  127829. * @param name The rendering pipeline name
  127830. * @param scene The scene linked to this pipeline
  127831. * @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)
  127832. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127833. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127834. */
  127835. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127836. private _buildPipeline;
  127837. private _createDownSampleX4PostProcess;
  127838. private _createBrightPassPostProcess;
  127839. private _createBlurPostProcesses;
  127840. private _createTextureAdderPostProcess;
  127841. private _createVolumetricLightPostProcess;
  127842. private _createLuminancePostProcesses;
  127843. private _createHdrPostProcess;
  127844. private _createLensFlarePostProcess;
  127845. private _createDepthOfFieldPostProcess;
  127846. private _createMotionBlurPostProcess;
  127847. private _getDepthTexture;
  127848. private _disposePostProcesses;
  127849. /**
  127850. * Dispose of the pipeline and stop all post processes
  127851. */
  127852. dispose(): void;
  127853. /**
  127854. * Serialize the rendering pipeline (Used when exporting)
  127855. * @returns the serialized object
  127856. */
  127857. serialize(): any;
  127858. /**
  127859. * Parse the serialized pipeline
  127860. * @param source Source pipeline.
  127861. * @param scene The scene to load the pipeline to.
  127862. * @param rootUrl The URL of the serialized pipeline.
  127863. * @returns An instantiated pipeline from the serialized object.
  127864. */
  127865. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127866. /**
  127867. * Luminance steps
  127868. */
  127869. static LuminanceSteps: number;
  127870. }
  127871. }
  127872. declare module BABYLON {
  127873. /** @hidden */
  127874. export var tonemapPixelShader: {
  127875. name: string;
  127876. shader: string;
  127877. };
  127878. }
  127879. declare module BABYLON {
  127880. /** Defines operator used for tonemapping */
  127881. export enum TonemappingOperator {
  127882. /** Hable */
  127883. Hable = 0,
  127884. /** Reinhard */
  127885. Reinhard = 1,
  127886. /** HejiDawson */
  127887. HejiDawson = 2,
  127888. /** Photographic */
  127889. Photographic = 3
  127890. }
  127891. /**
  127892. * Defines a post process to apply tone mapping
  127893. */
  127894. export class TonemapPostProcess extends PostProcess {
  127895. private _operator;
  127896. /** Defines the required exposure adjustement */
  127897. exposureAdjustment: number;
  127898. /**
  127899. * Creates a new TonemapPostProcess
  127900. * @param name defines the name of the postprocess
  127901. * @param _operator defines the operator to use
  127902. * @param exposureAdjustment defines the required exposure adjustement
  127903. * @param camera defines the camera to use (can be null)
  127904. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127905. * @param engine defines the hosting engine (can be ignore if camera is set)
  127906. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127907. */
  127908. constructor(name: string, _operator: TonemappingOperator,
  127909. /** Defines the required exposure adjustement */
  127910. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127911. }
  127912. }
  127913. declare module BABYLON {
  127914. /** @hidden */
  127915. export var depthVertexShader: {
  127916. name: string;
  127917. shader: string;
  127918. };
  127919. }
  127920. declare module BABYLON {
  127921. /** @hidden */
  127922. export var volumetricLightScatteringPixelShader: {
  127923. name: string;
  127924. shader: string;
  127925. };
  127926. }
  127927. declare module BABYLON {
  127928. /** @hidden */
  127929. export var volumetricLightScatteringPassVertexShader: {
  127930. name: string;
  127931. shader: string;
  127932. };
  127933. }
  127934. declare module BABYLON {
  127935. /** @hidden */
  127936. export var volumetricLightScatteringPassPixelShader: {
  127937. name: string;
  127938. shader: string;
  127939. };
  127940. }
  127941. declare module BABYLON {
  127942. /**
  127943. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127944. */
  127945. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127946. private _volumetricLightScatteringPass;
  127947. private _volumetricLightScatteringRTT;
  127948. private _viewPort;
  127949. private _screenCoordinates;
  127950. private _cachedDefines;
  127951. /**
  127952. * If not undefined, the mesh position is computed from the attached node position
  127953. */
  127954. attachedNode: {
  127955. position: Vector3;
  127956. };
  127957. /**
  127958. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127959. */
  127960. customMeshPosition: Vector3;
  127961. /**
  127962. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127963. */
  127964. useCustomMeshPosition: boolean;
  127965. /**
  127966. * If the post-process should inverse the light scattering direction
  127967. */
  127968. invert: boolean;
  127969. /**
  127970. * The internal mesh used by the post-process
  127971. */
  127972. mesh: Mesh;
  127973. /**
  127974. * @hidden
  127975. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127976. */
  127977. useDiffuseColor: boolean;
  127978. /**
  127979. * Array containing the excluded meshes not rendered in the internal pass
  127980. */
  127981. excludedMeshes: AbstractMesh[];
  127982. /**
  127983. * Controls the overall intensity of the post-process
  127984. */
  127985. exposure: number;
  127986. /**
  127987. * Dissipates each sample's contribution in range [0, 1]
  127988. */
  127989. decay: number;
  127990. /**
  127991. * Controls the overall intensity of each sample
  127992. */
  127993. weight: number;
  127994. /**
  127995. * Controls the density of each sample
  127996. */
  127997. density: number;
  127998. /**
  127999. * @constructor
  128000. * @param name The post-process name
  128001. * @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)
  128002. * @param camera The camera that the post-process will be attached to
  128003. * @param mesh The mesh used to create the light scattering
  128004. * @param samples The post-process quality, default 100
  128005. * @param samplingModeThe post-process filtering mode
  128006. * @param engine The babylon engine
  128007. * @param reusable If the post-process is reusable
  128008. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128009. */
  128010. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128011. /**
  128012. * Returns the string "VolumetricLightScatteringPostProcess"
  128013. * @returns "VolumetricLightScatteringPostProcess"
  128014. */
  128015. getClassName(): string;
  128016. private _isReady;
  128017. /**
  128018. * Sets the new light position for light scattering effect
  128019. * @param position The new custom light position
  128020. */
  128021. setCustomMeshPosition(position: Vector3): void;
  128022. /**
  128023. * Returns the light position for light scattering effect
  128024. * @return Vector3 The custom light position
  128025. */
  128026. getCustomMeshPosition(): Vector3;
  128027. /**
  128028. * Disposes the internal assets and detaches the post-process from the camera
  128029. */
  128030. dispose(camera: Camera): void;
  128031. /**
  128032. * Returns the render target texture used by the post-process
  128033. * @return the render target texture used by the post-process
  128034. */
  128035. getPass(): RenderTargetTexture;
  128036. private _meshExcluded;
  128037. private _createPass;
  128038. private _updateMeshScreenCoordinates;
  128039. /**
  128040. * Creates a default mesh for the Volumeric Light Scattering post-process
  128041. * @param name The mesh name
  128042. * @param scene The scene where to create the mesh
  128043. * @return the default mesh
  128044. */
  128045. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128046. }
  128047. }
  128048. declare module BABYLON {
  128049. interface Scene {
  128050. /** @hidden (Backing field) */
  128051. _boundingBoxRenderer: BoundingBoxRenderer;
  128052. /** @hidden (Backing field) */
  128053. _forceShowBoundingBoxes: boolean;
  128054. /**
  128055. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128056. */
  128057. forceShowBoundingBoxes: boolean;
  128058. /**
  128059. * Gets the bounding box renderer associated with the scene
  128060. * @returns a BoundingBoxRenderer
  128061. */
  128062. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128063. }
  128064. interface AbstractMesh {
  128065. /** @hidden (Backing field) */
  128066. _showBoundingBox: boolean;
  128067. /**
  128068. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128069. */
  128070. showBoundingBox: boolean;
  128071. }
  128072. /**
  128073. * Component responsible of rendering the bounding box of the meshes in a scene.
  128074. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128075. */
  128076. export class BoundingBoxRenderer implements ISceneComponent {
  128077. /**
  128078. * The component name helpfull to identify the component in the list of scene components.
  128079. */
  128080. readonly name: string;
  128081. /**
  128082. * The scene the component belongs to.
  128083. */
  128084. scene: Scene;
  128085. /**
  128086. * Color of the bounding box lines placed in front of an object
  128087. */
  128088. frontColor: Color3;
  128089. /**
  128090. * Color of the bounding box lines placed behind an object
  128091. */
  128092. backColor: Color3;
  128093. /**
  128094. * Defines if the renderer should show the back lines or not
  128095. */
  128096. showBackLines: boolean;
  128097. /**
  128098. * @hidden
  128099. */
  128100. renderList: SmartArray<BoundingBox>;
  128101. private _colorShader;
  128102. private _vertexBuffers;
  128103. private _indexBuffer;
  128104. private _fillIndexBuffer;
  128105. private _fillIndexData;
  128106. /**
  128107. * Instantiates a new bounding box renderer in a scene.
  128108. * @param scene the scene the renderer renders in
  128109. */
  128110. constructor(scene: Scene);
  128111. /**
  128112. * Registers the component in a given scene
  128113. */
  128114. register(): void;
  128115. private _evaluateSubMesh;
  128116. private _activeMesh;
  128117. private _prepareRessources;
  128118. private _createIndexBuffer;
  128119. /**
  128120. * Rebuilds the elements related to this component in case of
  128121. * context lost for instance.
  128122. */
  128123. rebuild(): void;
  128124. /**
  128125. * @hidden
  128126. */
  128127. reset(): void;
  128128. /**
  128129. * Render the bounding boxes of a specific rendering group
  128130. * @param renderingGroupId defines the rendering group to render
  128131. */
  128132. render(renderingGroupId: number): void;
  128133. /**
  128134. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128135. * @param mesh Define the mesh to render the occlusion bounding box for
  128136. */
  128137. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128138. /**
  128139. * Dispose and release the resources attached to this renderer.
  128140. */
  128141. dispose(): void;
  128142. }
  128143. }
  128144. declare module BABYLON {
  128145. /** @hidden */
  128146. export var depthPixelShader: {
  128147. name: string;
  128148. shader: string;
  128149. };
  128150. }
  128151. declare module BABYLON {
  128152. /**
  128153. * This represents a depth renderer in Babylon.
  128154. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128155. */
  128156. export class DepthRenderer {
  128157. private _scene;
  128158. private _depthMap;
  128159. private _effect;
  128160. private readonly _storeNonLinearDepth;
  128161. private readonly _clearColor;
  128162. /** Get if the depth renderer is using packed depth or not */
  128163. readonly isPacked: boolean;
  128164. private _cachedDefines;
  128165. private _camera;
  128166. /**
  128167. * Specifiess that the depth renderer will only be used within
  128168. * the camera it is created for.
  128169. * This can help forcing its rendering during the camera processing.
  128170. */
  128171. useOnlyInActiveCamera: boolean;
  128172. /** @hidden */
  128173. static _SceneComponentInitialization: (scene: Scene) => void;
  128174. /**
  128175. * Instantiates a depth renderer
  128176. * @param scene The scene the renderer belongs to
  128177. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128178. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128179. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128180. */
  128181. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128182. /**
  128183. * Creates the depth rendering effect and checks if the effect is ready.
  128184. * @param subMesh The submesh to be used to render the depth map of
  128185. * @param useInstances If multiple world instances should be used
  128186. * @returns if the depth renderer is ready to render the depth map
  128187. */
  128188. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128189. /**
  128190. * Gets the texture which the depth map will be written to.
  128191. * @returns The depth map texture
  128192. */
  128193. getDepthMap(): RenderTargetTexture;
  128194. /**
  128195. * Disposes of the depth renderer.
  128196. */
  128197. dispose(): void;
  128198. }
  128199. }
  128200. declare module BABYLON {
  128201. interface Scene {
  128202. /** @hidden (Backing field) */
  128203. _depthRenderer: {
  128204. [id: string]: DepthRenderer;
  128205. };
  128206. /**
  128207. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128208. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128209. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128210. * @returns the created depth renderer
  128211. */
  128212. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128213. /**
  128214. * Disables a depth renderer for a given camera
  128215. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128216. */
  128217. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128218. }
  128219. /**
  128220. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128221. * in several rendering techniques.
  128222. */
  128223. export class DepthRendererSceneComponent implements ISceneComponent {
  128224. /**
  128225. * The component name helpfull to identify the component in the list of scene components.
  128226. */
  128227. readonly name: string;
  128228. /**
  128229. * The scene the component belongs to.
  128230. */
  128231. scene: Scene;
  128232. /**
  128233. * Creates a new instance of the component for the given scene
  128234. * @param scene Defines the scene to register the component in
  128235. */
  128236. constructor(scene: Scene);
  128237. /**
  128238. * Registers the component in a given scene
  128239. */
  128240. register(): void;
  128241. /**
  128242. * Rebuilds the elements related to this component in case of
  128243. * context lost for instance.
  128244. */
  128245. rebuild(): void;
  128246. /**
  128247. * Disposes the component and the associated ressources
  128248. */
  128249. dispose(): void;
  128250. private _gatherRenderTargets;
  128251. private _gatherActiveCameraRenderTargets;
  128252. }
  128253. }
  128254. declare module BABYLON {
  128255. /** @hidden */
  128256. export var outlinePixelShader: {
  128257. name: string;
  128258. shader: string;
  128259. };
  128260. }
  128261. declare module BABYLON {
  128262. /** @hidden */
  128263. export var outlineVertexShader: {
  128264. name: string;
  128265. shader: string;
  128266. };
  128267. }
  128268. declare module BABYLON {
  128269. interface Scene {
  128270. /** @hidden */
  128271. _outlineRenderer: OutlineRenderer;
  128272. /**
  128273. * Gets the outline renderer associated with the scene
  128274. * @returns a OutlineRenderer
  128275. */
  128276. getOutlineRenderer(): OutlineRenderer;
  128277. }
  128278. interface AbstractMesh {
  128279. /** @hidden (Backing field) */
  128280. _renderOutline: boolean;
  128281. /**
  128282. * Gets or sets a boolean indicating if the outline must be rendered as well
  128283. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128284. */
  128285. renderOutline: boolean;
  128286. /** @hidden (Backing field) */
  128287. _renderOverlay: boolean;
  128288. /**
  128289. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128290. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128291. */
  128292. renderOverlay: boolean;
  128293. }
  128294. /**
  128295. * This class is responsible to draw bothe outline/overlay of meshes.
  128296. * It should not be used directly but through the available method on mesh.
  128297. */
  128298. export class OutlineRenderer implements ISceneComponent {
  128299. /**
  128300. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128301. */
  128302. private static _StencilReference;
  128303. /**
  128304. * The name of the component. Each component must have a unique name.
  128305. */
  128306. name: string;
  128307. /**
  128308. * The scene the component belongs to.
  128309. */
  128310. scene: Scene;
  128311. /**
  128312. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128313. */
  128314. zOffset: number;
  128315. private _engine;
  128316. private _effect;
  128317. private _cachedDefines;
  128318. private _savedDepthWrite;
  128319. /**
  128320. * Instantiates a new outline renderer. (There could be only one per scene).
  128321. * @param scene Defines the scene it belongs to
  128322. */
  128323. constructor(scene: Scene);
  128324. /**
  128325. * Register the component to one instance of a scene.
  128326. */
  128327. register(): void;
  128328. /**
  128329. * Rebuilds the elements related to this component in case of
  128330. * context lost for instance.
  128331. */
  128332. rebuild(): void;
  128333. /**
  128334. * Disposes the component and the associated ressources.
  128335. */
  128336. dispose(): void;
  128337. /**
  128338. * Renders the outline in the canvas.
  128339. * @param subMesh Defines the sumesh to render
  128340. * @param batch Defines the batch of meshes in case of instances
  128341. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128342. */
  128343. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128344. /**
  128345. * Returns whether or not the outline renderer is ready for a given submesh.
  128346. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128347. * @param subMesh Defines the submesh to check readyness for
  128348. * @param useInstances Defines wheter wee are trying to render instances or not
  128349. * @returns true if ready otherwise false
  128350. */
  128351. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128352. private _beforeRenderingMesh;
  128353. private _afterRenderingMesh;
  128354. }
  128355. }
  128356. declare module BABYLON {
  128357. /**
  128358. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128359. * @see http://doc.babylonjs.com/babylon101/sprites
  128360. */
  128361. export class SpritePackedManager extends SpriteManager {
  128362. /** defines the packed manager's name */
  128363. name: string;
  128364. /**
  128365. * Creates a new sprite manager from a packed sprite sheet
  128366. * @param name defines the manager's name
  128367. * @param imgUrl defines the sprite sheet url
  128368. * @param capacity defines the maximum allowed number of sprites
  128369. * @param scene defines the hosting scene
  128370. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128371. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128372. * @param samplingMode defines the smapling mode to use with spritesheet
  128373. * @param fromPacked set to true; do not alter
  128374. */
  128375. constructor(
  128376. /** defines the packed manager's name */
  128377. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128378. }
  128379. }
  128380. declare module BABYLON {
  128381. /**
  128382. * Defines the list of states available for a task inside a AssetsManager
  128383. */
  128384. export enum AssetTaskState {
  128385. /**
  128386. * Initialization
  128387. */
  128388. INIT = 0,
  128389. /**
  128390. * Running
  128391. */
  128392. RUNNING = 1,
  128393. /**
  128394. * Done
  128395. */
  128396. DONE = 2,
  128397. /**
  128398. * Error
  128399. */
  128400. ERROR = 3
  128401. }
  128402. /**
  128403. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128404. */
  128405. export abstract class AbstractAssetTask {
  128406. /**
  128407. * Task name
  128408. */ name: string;
  128409. /**
  128410. * Callback called when the task is successful
  128411. */
  128412. onSuccess: (task: any) => void;
  128413. /**
  128414. * Callback called when the task is not successful
  128415. */
  128416. onError: (task: any, message?: string, exception?: any) => void;
  128417. /**
  128418. * Creates a new AssetsManager
  128419. * @param name defines the name of the task
  128420. */
  128421. constructor(
  128422. /**
  128423. * Task name
  128424. */ name: string);
  128425. private _isCompleted;
  128426. private _taskState;
  128427. private _errorObject;
  128428. /**
  128429. * Get if the task is completed
  128430. */
  128431. readonly isCompleted: boolean;
  128432. /**
  128433. * Gets the current state of the task
  128434. */
  128435. readonly taskState: AssetTaskState;
  128436. /**
  128437. * Gets the current error object (if task is in error)
  128438. */
  128439. readonly errorObject: {
  128440. message?: string;
  128441. exception?: any;
  128442. };
  128443. /**
  128444. * Internal only
  128445. * @hidden
  128446. */
  128447. _setErrorObject(message?: string, exception?: any): void;
  128448. /**
  128449. * Execute the current task
  128450. * @param scene defines the scene where you want your assets to be loaded
  128451. * @param onSuccess is a callback called when the task is successfully executed
  128452. * @param onError is a callback called if an error occurs
  128453. */
  128454. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128455. /**
  128456. * Execute the current task
  128457. * @param scene defines the scene where you want your assets to be loaded
  128458. * @param onSuccess is a callback called when the task is successfully executed
  128459. * @param onError is a callback called if an error occurs
  128460. */
  128461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128462. /**
  128463. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128464. * This can be used with failed tasks that have the reason for failure fixed.
  128465. */
  128466. reset(): void;
  128467. private onErrorCallback;
  128468. private onDoneCallback;
  128469. }
  128470. /**
  128471. * Define the interface used by progress events raised during assets loading
  128472. */
  128473. export interface IAssetsProgressEvent {
  128474. /**
  128475. * Defines the number of remaining tasks to process
  128476. */
  128477. remainingCount: number;
  128478. /**
  128479. * Defines the total number of tasks
  128480. */
  128481. totalCount: number;
  128482. /**
  128483. * Defines the task that was just processed
  128484. */
  128485. task: AbstractAssetTask;
  128486. }
  128487. /**
  128488. * Class used to share progress information about assets loading
  128489. */
  128490. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128491. /**
  128492. * Defines the number of remaining tasks to process
  128493. */
  128494. remainingCount: number;
  128495. /**
  128496. * Defines the total number of tasks
  128497. */
  128498. totalCount: number;
  128499. /**
  128500. * Defines the task that was just processed
  128501. */
  128502. task: AbstractAssetTask;
  128503. /**
  128504. * Creates a AssetsProgressEvent
  128505. * @param remainingCount defines the number of remaining tasks to process
  128506. * @param totalCount defines the total number of tasks
  128507. * @param task defines the task that was just processed
  128508. */
  128509. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128510. }
  128511. /**
  128512. * Define a task used by AssetsManager to load meshes
  128513. */
  128514. export class MeshAssetTask extends AbstractAssetTask {
  128515. /**
  128516. * Defines the name of the task
  128517. */
  128518. name: string;
  128519. /**
  128520. * Defines the list of mesh's names you want to load
  128521. */
  128522. meshesNames: any;
  128523. /**
  128524. * Defines the root url to use as a base to load your meshes and associated resources
  128525. */
  128526. rootUrl: string;
  128527. /**
  128528. * Defines the filename of the scene to load from
  128529. */
  128530. sceneFilename: string;
  128531. /**
  128532. * Gets the list of loaded meshes
  128533. */
  128534. loadedMeshes: Array<AbstractMesh>;
  128535. /**
  128536. * Gets the list of loaded particle systems
  128537. */
  128538. loadedParticleSystems: Array<IParticleSystem>;
  128539. /**
  128540. * Gets the list of loaded skeletons
  128541. */
  128542. loadedSkeletons: Array<Skeleton>;
  128543. /**
  128544. * Gets the list of loaded animation groups
  128545. */
  128546. loadedAnimationGroups: Array<AnimationGroup>;
  128547. /**
  128548. * Callback called when the task is successful
  128549. */
  128550. onSuccess: (task: MeshAssetTask) => void;
  128551. /**
  128552. * Callback called when the task is successful
  128553. */
  128554. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128555. /**
  128556. * Creates a new MeshAssetTask
  128557. * @param name defines the name of the task
  128558. * @param meshesNames defines the list of mesh's names you want to load
  128559. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128560. * @param sceneFilename defines the filename of the scene to load from
  128561. */
  128562. constructor(
  128563. /**
  128564. * Defines the name of the task
  128565. */
  128566. name: string,
  128567. /**
  128568. * Defines the list of mesh's names you want to load
  128569. */
  128570. meshesNames: any,
  128571. /**
  128572. * Defines the root url to use as a base to load your meshes and associated resources
  128573. */
  128574. rootUrl: string,
  128575. /**
  128576. * Defines the filename of the scene to load from
  128577. */
  128578. sceneFilename: string);
  128579. /**
  128580. * Execute the current task
  128581. * @param scene defines the scene where you want your assets to be loaded
  128582. * @param onSuccess is a callback called when the task is successfully executed
  128583. * @param onError is a callback called if an error occurs
  128584. */
  128585. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128586. }
  128587. /**
  128588. * Define a task used by AssetsManager to load text content
  128589. */
  128590. export class TextFileAssetTask extends AbstractAssetTask {
  128591. /**
  128592. * Defines the name of the task
  128593. */
  128594. name: string;
  128595. /**
  128596. * Defines the location of the file to load
  128597. */
  128598. url: string;
  128599. /**
  128600. * Gets the loaded text string
  128601. */
  128602. text: string;
  128603. /**
  128604. * Callback called when the task is successful
  128605. */
  128606. onSuccess: (task: TextFileAssetTask) => void;
  128607. /**
  128608. * Callback called when the task is successful
  128609. */
  128610. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128611. /**
  128612. * Creates a new TextFileAssetTask object
  128613. * @param name defines the name of the task
  128614. * @param url defines the location of the file to load
  128615. */
  128616. constructor(
  128617. /**
  128618. * Defines the name of the task
  128619. */
  128620. name: string,
  128621. /**
  128622. * Defines the location of the file to load
  128623. */
  128624. url: string);
  128625. /**
  128626. * Execute the current task
  128627. * @param scene defines the scene where you want your assets to be loaded
  128628. * @param onSuccess is a callback called when the task is successfully executed
  128629. * @param onError is a callback called if an error occurs
  128630. */
  128631. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128632. }
  128633. /**
  128634. * Define a task used by AssetsManager to load binary data
  128635. */
  128636. export class BinaryFileAssetTask extends AbstractAssetTask {
  128637. /**
  128638. * Defines the name of the task
  128639. */
  128640. name: string;
  128641. /**
  128642. * Defines the location of the file to load
  128643. */
  128644. url: string;
  128645. /**
  128646. * Gets the lodaded data (as an array buffer)
  128647. */
  128648. data: ArrayBuffer;
  128649. /**
  128650. * Callback called when the task is successful
  128651. */
  128652. onSuccess: (task: BinaryFileAssetTask) => void;
  128653. /**
  128654. * Callback called when the task is successful
  128655. */
  128656. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128657. /**
  128658. * Creates a new BinaryFileAssetTask object
  128659. * @param name defines the name of the new task
  128660. * @param url defines the location of the file to load
  128661. */
  128662. constructor(
  128663. /**
  128664. * Defines the name of the task
  128665. */
  128666. name: string,
  128667. /**
  128668. * Defines the location of the file to load
  128669. */
  128670. url: string);
  128671. /**
  128672. * Execute the current task
  128673. * @param scene defines the scene where you want your assets to be loaded
  128674. * @param onSuccess is a callback called when the task is successfully executed
  128675. * @param onError is a callback called if an error occurs
  128676. */
  128677. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128678. }
  128679. /**
  128680. * Define a task used by AssetsManager to load images
  128681. */
  128682. export class ImageAssetTask extends AbstractAssetTask {
  128683. /**
  128684. * Defines the name of the task
  128685. */
  128686. name: string;
  128687. /**
  128688. * Defines the location of the image to load
  128689. */
  128690. url: string;
  128691. /**
  128692. * Gets the loaded images
  128693. */
  128694. image: HTMLImageElement;
  128695. /**
  128696. * Callback called when the task is successful
  128697. */
  128698. onSuccess: (task: ImageAssetTask) => void;
  128699. /**
  128700. * Callback called when the task is successful
  128701. */
  128702. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128703. /**
  128704. * Creates a new ImageAssetTask
  128705. * @param name defines the name of the task
  128706. * @param url defines the location of the image to load
  128707. */
  128708. constructor(
  128709. /**
  128710. * Defines the name of the task
  128711. */
  128712. name: string,
  128713. /**
  128714. * Defines the location of the image to load
  128715. */
  128716. url: string);
  128717. /**
  128718. * Execute the current task
  128719. * @param scene defines the scene where you want your assets to be loaded
  128720. * @param onSuccess is a callback called when the task is successfully executed
  128721. * @param onError is a callback called if an error occurs
  128722. */
  128723. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128724. }
  128725. /**
  128726. * Defines the interface used by texture loading tasks
  128727. */
  128728. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128729. /**
  128730. * Gets the loaded texture
  128731. */
  128732. texture: TEX;
  128733. }
  128734. /**
  128735. * Define a task used by AssetsManager to load 2D textures
  128736. */
  128737. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128738. /**
  128739. * Defines the name of the task
  128740. */
  128741. name: string;
  128742. /**
  128743. * Defines the location of the file to load
  128744. */
  128745. url: string;
  128746. /**
  128747. * Defines if mipmap should not be generated (default is false)
  128748. */
  128749. noMipmap?: boolean | undefined;
  128750. /**
  128751. * Defines if texture must be inverted on Y axis (default is false)
  128752. */
  128753. invertY?: boolean | undefined;
  128754. /**
  128755. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128756. */
  128757. samplingMode: number;
  128758. /**
  128759. * Gets the loaded texture
  128760. */
  128761. texture: Texture;
  128762. /**
  128763. * Callback called when the task is successful
  128764. */
  128765. onSuccess: (task: TextureAssetTask) => void;
  128766. /**
  128767. * Callback called when the task is successful
  128768. */
  128769. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128770. /**
  128771. * Creates a new TextureAssetTask object
  128772. * @param name defines the name of the task
  128773. * @param url defines the location of the file to load
  128774. * @param noMipmap defines if mipmap should not be generated (default is false)
  128775. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128776. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128777. */
  128778. constructor(
  128779. /**
  128780. * Defines the name of the task
  128781. */
  128782. name: string,
  128783. /**
  128784. * Defines the location of the file to load
  128785. */
  128786. url: string,
  128787. /**
  128788. * Defines if mipmap should not be generated (default is false)
  128789. */
  128790. noMipmap?: boolean | undefined,
  128791. /**
  128792. * Defines if texture must be inverted on Y axis (default is false)
  128793. */
  128794. invertY?: boolean | undefined,
  128795. /**
  128796. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128797. */
  128798. samplingMode?: number);
  128799. /**
  128800. * Execute the current task
  128801. * @param scene defines the scene where you want your assets to be loaded
  128802. * @param onSuccess is a callback called when the task is successfully executed
  128803. * @param onError is a callback called if an error occurs
  128804. */
  128805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128806. }
  128807. /**
  128808. * Define a task used by AssetsManager to load cube textures
  128809. */
  128810. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128811. /**
  128812. * Defines the name of the task
  128813. */
  128814. name: string;
  128815. /**
  128816. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128817. */
  128818. url: string;
  128819. /**
  128820. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128821. */
  128822. extensions?: string[] | undefined;
  128823. /**
  128824. * Defines if mipmaps should not be generated (default is false)
  128825. */
  128826. noMipmap?: boolean | undefined;
  128827. /**
  128828. * Defines the explicit list of files (undefined by default)
  128829. */
  128830. files?: string[] | undefined;
  128831. /**
  128832. * Gets the loaded texture
  128833. */
  128834. texture: CubeTexture;
  128835. /**
  128836. * Callback called when the task is successful
  128837. */
  128838. onSuccess: (task: CubeTextureAssetTask) => void;
  128839. /**
  128840. * Callback called when the task is successful
  128841. */
  128842. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128843. /**
  128844. * Creates a new CubeTextureAssetTask
  128845. * @param name defines the name of the task
  128846. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128847. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128848. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128849. * @param files defines the explicit list of files (undefined by default)
  128850. */
  128851. constructor(
  128852. /**
  128853. * Defines the name of the task
  128854. */
  128855. name: string,
  128856. /**
  128857. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128858. */
  128859. url: string,
  128860. /**
  128861. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128862. */
  128863. extensions?: string[] | undefined,
  128864. /**
  128865. * Defines if mipmaps should not be generated (default is false)
  128866. */
  128867. noMipmap?: boolean | undefined,
  128868. /**
  128869. * Defines the explicit list of files (undefined by default)
  128870. */
  128871. files?: string[] | undefined);
  128872. /**
  128873. * Execute the current task
  128874. * @param scene defines the scene where you want your assets to be loaded
  128875. * @param onSuccess is a callback called when the task is successfully executed
  128876. * @param onError is a callback called if an error occurs
  128877. */
  128878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128879. }
  128880. /**
  128881. * Define a task used by AssetsManager to load HDR cube textures
  128882. */
  128883. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128884. /**
  128885. * Defines the name of the task
  128886. */
  128887. name: string;
  128888. /**
  128889. * Defines the location of the file to load
  128890. */
  128891. url: string;
  128892. /**
  128893. * Defines the desired size (the more it increases the longer the generation will be)
  128894. */
  128895. size: number;
  128896. /**
  128897. * Defines if mipmaps should not be generated (default is false)
  128898. */
  128899. noMipmap: boolean;
  128900. /**
  128901. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128902. */
  128903. generateHarmonics: boolean;
  128904. /**
  128905. * 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)
  128906. */
  128907. gammaSpace: boolean;
  128908. /**
  128909. * Internal Use Only
  128910. */
  128911. reserved: boolean;
  128912. /**
  128913. * Gets the loaded texture
  128914. */
  128915. texture: HDRCubeTexture;
  128916. /**
  128917. * Callback called when the task is successful
  128918. */
  128919. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128920. /**
  128921. * Callback called when the task is successful
  128922. */
  128923. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128924. /**
  128925. * Creates a new HDRCubeTextureAssetTask object
  128926. * @param name defines the name of the task
  128927. * @param url defines the location of the file to load
  128928. * @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.
  128929. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128930. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128931. * @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)
  128932. * @param reserved Internal use only
  128933. */
  128934. constructor(
  128935. /**
  128936. * Defines the name of the task
  128937. */
  128938. name: string,
  128939. /**
  128940. * Defines the location of the file to load
  128941. */
  128942. url: string,
  128943. /**
  128944. * Defines the desired size (the more it increases the longer the generation will be)
  128945. */
  128946. size: number,
  128947. /**
  128948. * Defines if mipmaps should not be generated (default is false)
  128949. */
  128950. noMipmap?: boolean,
  128951. /**
  128952. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128953. */
  128954. generateHarmonics?: boolean,
  128955. /**
  128956. * 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)
  128957. */
  128958. gammaSpace?: boolean,
  128959. /**
  128960. * Internal Use Only
  128961. */
  128962. reserved?: boolean);
  128963. /**
  128964. * Execute the current task
  128965. * @param scene defines the scene where you want your assets to be loaded
  128966. * @param onSuccess is a callback called when the task is successfully executed
  128967. * @param onError is a callback called if an error occurs
  128968. */
  128969. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128970. }
  128971. /**
  128972. * Define a task used by AssetsManager to load Equirectangular cube textures
  128973. */
  128974. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128975. /**
  128976. * Defines the name of the task
  128977. */
  128978. name: string;
  128979. /**
  128980. * Defines the location of the file to load
  128981. */
  128982. url: string;
  128983. /**
  128984. * Defines the desired size (the more it increases the longer the generation will be)
  128985. */
  128986. size: number;
  128987. /**
  128988. * Defines if mipmaps should not be generated (default is false)
  128989. */
  128990. noMipmap: boolean;
  128991. /**
  128992. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128993. * but the standard material would require them in Gamma space) (default is true)
  128994. */
  128995. gammaSpace: boolean;
  128996. /**
  128997. * Gets the loaded texture
  128998. */
  128999. texture: EquiRectangularCubeTexture;
  129000. /**
  129001. * Callback called when the task is successful
  129002. */
  129003. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129004. /**
  129005. * Callback called when the task is successful
  129006. */
  129007. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129008. /**
  129009. * Creates a new EquiRectangularCubeTextureAssetTask object
  129010. * @param name defines the name of the task
  129011. * @param url defines the location of the file to load
  129012. * @param size defines the desired size (the more it increases the longer the generation will be)
  129013. * If the size is omitted this implies you are using a preprocessed cubemap.
  129014. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129015. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129016. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129017. * (default is true)
  129018. */
  129019. constructor(
  129020. /**
  129021. * Defines the name of the task
  129022. */
  129023. name: string,
  129024. /**
  129025. * Defines the location of the file to load
  129026. */
  129027. url: string,
  129028. /**
  129029. * Defines the desired size (the more it increases the longer the generation will be)
  129030. */
  129031. size: number,
  129032. /**
  129033. * Defines if mipmaps should not be generated (default is false)
  129034. */
  129035. noMipmap?: boolean,
  129036. /**
  129037. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129038. * but the standard material would require them in Gamma space) (default is true)
  129039. */
  129040. gammaSpace?: boolean);
  129041. /**
  129042. * Execute the current task
  129043. * @param scene defines the scene where you want your assets to be loaded
  129044. * @param onSuccess is a callback called when the task is successfully executed
  129045. * @param onError is a callback called if an error occurs
  129046. */
  129047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129048. }
  129049. /**
  129050. * This class can be used to easily import assets into a scene
  129051. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129052. */
  129053. export class AssetsManager {
  129054. private _scene;
  129055. private _isLoading;
  129056. protected _tasks: AbstractAssetTask[];
  129057. protected _waitingTasksCount: number;
  129058. protected _totalTasksCount: number;
  129059. /**
  129060. * Callback called when all tasks are processed
  129061. */
  129062. onFinish: (tasks: AbstractAssetTask[]) => void;
  129063. /**
  129064. * Callback called when a task is successful
  129065. */
  129066. onTaskSuccess: (task: AbstractAssetTask) => void;
  129067. /**
  129068. * Callback called when a task had an error
  129069. */
  129070. onTaskError: (task: AbstractAssetTask) => void;
  129071. /**
  129072. * Callback called when a task is done (whatever the result is)
  129073. */
  129074. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129075. /**
  129076. * Observable called when all tasks are processed
  129077. */
  129078. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129079. /**
  129080. * Observable called when a task had an error
  129081. */
  129082. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129083. /**
  129084. * Observable called when all tasks were executed
  129085. */
  129086. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129087. /**
  129088. * Observable called when a task is done (whatever the result is)
  129089. */
  129090. onProgressObservable: Observable<IAssetsProgressEvent>;
  129091. /**
  129092. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129093. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129094. */
  129095. useDefaultLoadingScreen: boolean;
  129096. /**
  129097. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129098. * when all assets have been downloaded.
  129099. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129100. */
  129101. autoHideLoadingUI: boolean;
  129102. /**
  129103. * Creates a new AssetsManager
  129104. * @param scene defines the scene to work on
  129105. */
  129106. constructor(scene: Scene);
  129107. /**
  129108. * Add a MeshAssetTask to the list of active tasks
  129109. * @param taskName defines the name of the new task
  129110. * @param meshesNames defines the name of meshes to load
  129111. * @param rootUrl defines the root url to use to locate files
  129112. * @param sceneFilename defines the filename of the scene file
  129113. * @returns a new MeshAssetTask object
  129114. */
  129115. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129116. /**
  129117. * Add a TextFileAssetTask to the list of active tasks
  129118. * @param taskName defines the name of the new task
  129119. * @param url defines the url of the file to load
  129120. * @returns a new TextFileAssetTask object
  129121. */
  129122. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129123. /**
  129124. * Add a BinaryFileAssetTask to the list of active tasks
  129125. * @param taskName defines the name of the new task
  129126. * @param url defines the url of the file to load
  129127. * @returns a new BinaryFileAssetTask object
  129128. */
  129129. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129130. /**
  129131. * Add a ImageAssetTask to the list of active tasks
  129132. * @param taskName defines the name of the new task
  129133. * @param url defines the url of the file to load
  129134. * @returns a new ImageAssetTask object
  129135. */
  129136. addImageTask(taskName: string, url: string): ImageAssetTask;
  129137. /**
  129138. * Add a TextureAssetTask to the list of active tasks
  129139. * @param taskName defines the name of the new task
  129140. * @param url defines the url of the file to load
  129141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129142. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129143. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129144. * @returns a new TextureAssetTask object
  129145. */
  129146. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129147. /**
  129148. * Add a CubeTextureAssetTask to the list of active tasks
  129149. * @param taskName defines the name of the new task
  129150. * @param url defines the url of the file to load
  129151. * @param extensions defines the extension to use to load the cube map (can be null)
  129152. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129153. * @param files defines the list of files to load (can be null)
  129154. * @returns a new CubeTextureAssetTask object
  129155. */
  129156. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129157. /**
  129158. *
  129159. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129160. * @param taskName defines the name of the new task
  129161. * @param url defines the url of the file to load
  129162. * @param size defines the size you want for the cubemap (can be null)
  129163. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129164. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129165. * @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)
  129166. * @param reserved Internal use only
  129167. * @returns a new HDRCubeTextureAssetTask object
  129168. */
  129169. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129170. /**
  129171. *
  129172. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129173. * @param taskName defines the name of the new task
  129174. * @param url defines the url of the file to load
  129175. * @param size defines the size you want for the cubemap (can be null)
  129176. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129177. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129178. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129179. * @returns a new EquiRectangularCubeTextureAssetTask object
  129180. */
  129181. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129182. /**
  129183. * Remove a task from the assets manager.
  129184. * @param task the task to remove
  129185. */
  129186. removeTask(task: AbstractAssetTask): void;
  129187. private _decreaseWaitingTasksCount;
  129188. private _runTask;
  129189. /**
  129190. * Reset the AssetsManager and remove all tasks
  129191. * @return the current instance of the AssetsManager
  129192. */
  129193. reset(): AssetsManager;
  129194. /**
  129195. * Start the loading process
  129196. * @return the current instance of the AssetsManager
  129197. */
  129198. load(): AssetsManager;
  129199. /**
  129200. * Start the loading process as an async operation
  129201. * @return a promise returning the list of failed tasks
  129202. */
  129203. loadAsync(): Promise<void>;
  129204. }
  129205. }
  129206. declare module BABYLON {
  129207. /**
  129208. * Wrapper class for promise with external resolve and reject.
  129209. */
  129210. export class Deferred<T> {
  129211. /**
  129212. * The promise associated with this deferred object.
  129213. */
  129214. readonly promise: Promise<T>;
  129215. private _resolve;
  129216. private _reject;
  129217. /**
  129218. * The resolve method of the promise associated with this deferred object.
  129219. */
  129220. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129221. /**
  129222. * The reject method of the promise associated with this deferred object.
  129223. */
  129224. readonly reject: (reason?: any) => void;
  129225. /**
  129226. * Constructor for this deferred object.
  129227. */
  129228. constructor();
  129229. }
  129230. }
  129231. declare module BABYLON {
  129232. /**
  129233. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129234. */
  129235. export class MeshExploder {
  129236. private _centerMesh;
  129237. private _meshes;
  129238. private _meshesOrigins;
  129239. private _toCenterVectors;
  129240. private _scaledDirection;
  129241. private _newPosition;
  129242. private _centerPosition;
  129243. /**
  129244. * Explodes meshes from a center mesh.
  129245. * @param meshes The meshes to explode.
  129246. * @param centerMesh The mesh to be center of explosion.
  129247. */
  129248. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129249. private _setCenterMesh;
  129250. /**
  129251. * Get class name
  129252. * @returns "MeshExploder"
  129253. */
  129254. getClassName(): string;
  129255. /**
  129256. * "Exploded meshes"
  129257. * @returns Array of meshes with the centerMesh at index 0.
  129258. */
  129259. getMeshes(): Array<Mesh>;
  129260. /**
  129261. * Explodes meshes giving a specific direction
  129262. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129263. */
  129264. explode(direction?: number): void;
  129265. }
  129266. }
  129267. declare module BABYLON {
  129268. /**
  129269. * Class used to help managing file picking and drag'n'drop
  129270. */
  129271. export class FilesInput {
  129272. /**
  129273. * List of files ready to be loaded
  129274. */
  129275. static readonly FilesToLoad: {
  129276. [key: string]: File;
  129277. };
  129278. /**
  129279. * Callback called when a file is processed
  129280. */
  129281. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129282. private _engine;
  129283. private _currentScene;
  129284. private _sceneLoadedCallback;
  129285. private _progressCallback;
  129286. private _additionalRenderLoopLogicCallback;
  129287. private _textureLoadingCallback;
  129288. private _startingProcessingFilesCallback;
  129289. private _onReloadCallback;
  129290. private _errorCallback;
  129291. private _elementToMonitor;
  129292. private _sceneFileToLoad;
  129293. private _filesToLoad;
  129294. /**
  129295. * Creates a new FilesInput
  129296. * @param engine defines the rendering engine
  129297. * @param scene defines the hosting scene
  129298. * @param sceneLoadedCallback callback called when scene is loaded
  129299. * @param progressCallback callback called to track progress
  129300. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129301. * @param textureLoadingCallback callback called when a texture is loading
  129302. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129303. * @param onReloadCallback callback called when a reload is requested
  129304. * @param errorCallback callback call if an error occurs
  129305. */
  129306. 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);
  129307. private _dragEnterHandler;
  129308. private _dragOverHandler;
  129309. private _dropHandler;
  129310. /**
  129311. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129312. * @param elementToMonitor defines the DOM element to track
  129313. */
  129314. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129315. /**
  129316. * Release all associated resources
  129317. */
  129318. dispose(): void;
  129319. private renderFunction;
  129320. private drag;
  129321. private drop;
  129322. private _traverseFolder;
  129323. private _processFiles;
  129324. /**
  129325. * Load files from a drop event
  129326. * @param event defines the drop event to use as source
  129327. */
  129328. loadFiles(event: any): void;
  129329. private _processReload;
  129330. /**
  129331. * Reload the current scene from the loaded files
  129332. */
  129333. reload(): void;
  129334. }
  129335. }
  129336. declare module BABYLON {
  129337. /**
  129338. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129339. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129340. */
  129341. export class SceneOptimization {
  129342. /**
  129343. * Defines the priority of this optimization (0 by default which means first in the list)
  129344. */
  129345. priority: number;
  129346. /**
  129347. * Gets a string describing the action executed by the current optimization
  129348. * @returns description string
  129349. */
  129350. getDescription(): string;
  129351. /**
  129352. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129353. * @param scene defines the current scene where to apply this optimization
  129354. * @param optimizer defines the current optimizer
  129355. * @returns true if everything that can be done was applied
  129356. */
  129357. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129358. /**
  129359. * Creates the SceneOptimization object
  129360. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129361. * @param desc defines the description associated with the optimization
  129362. */
  129363. constructor(
  129364. /**
  129365. * Defines the priority of this optimization (0 by default which means first in the list)
  129366. */
  129367. priority?: number);
  129368. }
  129369. /**
  129370. * Defines an optimization used to reduce the size of render target textures
  129371. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129372. */
  129373. export class TextureOptimization extends SceneOptimization {
  129374. /**
  129375. * Defines the priority of this optimization (0 by default which means first in the list)
  129376. */
  129377. priority: number;
  129378. /**
  129379. * 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
  129380. */
  129381. maximumSize: number;
  129382. /**
  129383. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129384. */
  129385. step: number;
  129386. /**
  129387. * Gets a string describing the action executed by the current optimization
  129388. * @returns description string
  129389. */
  129390. getDescription(): string;
  129391. /**
  129392. * Creates the TextureOptimization object
  129393. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129394. * @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
  129395. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129396. */
  129397. constructor(
  129398. /**
  129399. * Defines the priority of this optimization (0 by default which means first in the list)
  129400. */
  129401. priority?: number,
  129402. /**
  129403. * 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
  129404. */
  129405. maximumSize?: number,
  129406. /**
  129407. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129408. */
  129409. step?: number);
  129410. /**
  129411. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129412. * @param scene defines the current scene where to apply this optimization
  129413. * @param optimizer defines the current optimizer
  129414. * @returns true if everything that can be done was applied
  129415. */
  129416. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129417. }
  129418. /**
  129419. * Defines an optimization used to increase or decrease the rendering resolution
  129420. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129421. */
  129422. export class HardwareScalingOptimization extends SceneOptimization {
  129423. /**
  129424. * Defines the priority of this optimization (0 by default which means first in the list)
  129425. */
  129426. priority: number;
  129427. /**
  129428. * Defines the maximum scale to use (2 by default)
  129429. */
  129430. maximumScale: number;
  129431. /**
  129432. * Defines the step to use between two passes (0.5 by default)
  129433. */
  129434. step: number;
  129435. private _currentScale;
  129436. private _directionOffset;
  129437. /**
  129438. * Gets a string describing the action executed by the current optimization
  129439. * @return description string
  129440. */
  129441. getDescription(): string;
  129442. /**
  129443. * Creates the HardwareScalingOptimization object
  129444. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129445. * @param maximumScale defines the maximum scale to use (2 by default)
  129446. * @param step defines the step to use between two passes (0.5 by default)
  129447. */
  129448. constructor(
  129449. /**
  129450. * Defines the priority of this optimization (0 by default which means first in the list)
  129451. */
  129452. priority?: number,
  129453. /**
  129454. * Defines the maximum scale to use (2 by default)
  129455. */
  129456. maximumScale?: number,
  129457. /**
  129458. * Defines the step to use between two passes (0.5 by default)
  129459. */
  129460. step?: number);
  129461. /**
  129462. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129463. * @param scene defines the current scene where to apply this optimization
  129464. * @param optimizer defines the current optimizer
  129465. * @returns true if everything that can be done was applied
  129466. */
  129467. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129468. }
  129469. /**
  129470. * Defines an optimization used to remove shadows
  129471. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129472. */
  129473. export class ShadowsOptimization extends SceneOptimization {
  129474. /**
  129475. * Gets a string describing the action executed by the current optimization
  129476. * @return description string
  129477. */
  129478. getDescription(): string;
  129479. /**
  129480. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129481. * @param scene defines the current scene where to apply this optimization
  129482. * @param optimizer defines the current optimizer
  129483. * @returns true if everything that can be done was applied
  129484. */
  129485. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129486. }
  129487. /**
  129488. * Defines an optimization used to turn post-processes off
  129489. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129490. */
  129491. export class PostProcessesOptimization extends SceneOptimization {
  129492. /**
  129493. * Gets a string describing the action executed by the current optimization
  129494. * @return description string
  129495. */
  129496. getDescription(): string;
  129497. /**
  129498. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129499. * @param scene defines the current scene where to apply this optimization
  129500. * @param optimizer defines the current optimizer
  129501. * @returns true if everything that can be done was applied
  129502. */
  129503. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129504. }
  129505. /**
  129506. * Defines an optimization used to turn lens flares off
  129507. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129508. */
  129509. export class LensFlaresOptimization extends SceneOptimization {
  129510. /**
  129511. * Gets a string describing the action executed by the current optimization
  129512. * @return description string
  129513. */
  129514. getDescription(): string;
  129515. /**
  129516. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129517. * @param scene defines the current scene where to apply this optimization
  129518. * @param optimizer defines the current optimizer
  129519. * @returns true if everything that can be done was applied
  129520. */
  129521. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129522. }
  129523. /**
  129524. * Defines an optimization based on user defined callback.
  129525. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129526. */
  129527. export class CustomOptimization extends SceneOptimization {
  129528. /**
  129529. * Callback called to apply the custom optimization.
  129530. */
  129531. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129532. /**
  129533. * Callback called to get custom description
  129534. */
  129535. onGetDescription: () => string;
  129536. /**
  129537. * Gets a string describing the action executed by the current optimization
  129538. * @returns description string
  129539. */
  129540. getDescription(): string;
  129541. /**
  129542. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129543. * @param scene defines the current scene where to apply this optimization
  129544. * @param optimizer defines the current optimizer
  129545. * @returns true if everything that can be done was applied
  129546. */
  129547. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129548. }
  129549. /**
  129550. * Defines an optimization used to turn particles off
  129551. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129552. */
  129553. export class ParticlesOptimization extends SceneOptimization {
  129554. /**
  129555. * Gets a string describing the action executed by the current optimization
  129556. * @return description string
  129557. */
  129558. getDescription(): string;
  129559. /**
  129560. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129561. * @param scene defines the current scene where to apply this optimization
  129562. * @param optimizer defines the current optimizer
  129563. * @returns true if everything that can be done was applied
  129564. */
  129565. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129566. }
  129567. /**
  129568. * Defines an optimization used to turn render targets off
  129569. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129570. */
  129571. export class RenderTargetsOptimization extends SceneOptimization {
  129572. /**
  129573. * Gets a string describing the action executed by the current optimization
  129574. * @return description string
  129575. */
  129576. getDescription(): string;
  129577. /**
  129578. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129579. * @param scene defines the current scene where to apply this optimization
  129580. * @param optimizer defines the current optimizer
  129581. * @returns true if everything that can be done was applied
  129582. */
  129583. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129584. }
  129585. /**
  129586. * Defines an optimization used to merge meshes with compatible materials
  129587. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129588. */
  129589. export class MergeMeshesOptimization extends SceneOptimization {
  129590. private static _UpdateSelectionTree;
  129591. /**
  129592. * Gets or sets a boolean which defines if optimization octree has to be updated
  129593. */
  129594. /**
  129595. * Gets or sets a boolean which defines if optimization octree has to be updated
  129596. */
  129597. static UpdateSelectionTree: boolean;
  129598. /**
  129599. * Gets a string describing the action executed by the current optimization
  129600. * @return description string
  129601. */
  129602. getDescription(): string;
  129603. private _canBeMerged;
  129604. /**
  129605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129606. * @param scene defines the current scene where to apply this optimization
  129607. * @param optimizer defines the current optimizer
  129608. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129609. * @returns true if everything that can be done was applied
  129610. */
  129611. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129612. }
  129613. /**
  129614. * Defines a list of options used by SceneOptimizer
  129615. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129616. */
  129617. export class SceneOptimizerOptions {
  129618. /**
  129619. * Defines the target frame rate to reach (60 by default)
  129620. */
  129621. targetFrameRate: number;
  129622. /**
  129623. * Defines the interval between two checkes (2000ms by default)
  129624. */
  129625. trackerDuration: number;
  129626. /**
  129627. * Gets the list of optimizations to apply
  129628. */
  129629. optimizations: SceneOptimization[];
  129630. /**
  129631. * Creates a new list of options used by SceneOptimizer
  129632. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129633. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129634. */
  129635. constructor(
  129636. /**
  129637. * Defines the target frame rate to reach (60 by default)
  129638. */
  129639. targetFrameRate?: number,
  129640. /**
  129641. * Defines the interval between two checkes (2000ms by default)
  129642. */
  129643. trackerDuration?: number);
  129644. /**
  129645. * Add a new optimization
  129646. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129647. * @returns the current SceneOptimizerOptions
  129648. */
  129649. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129650. /**
  129651. * Add a new custom optimization
  129652. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129653. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129654. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129655. * @returns the current SceneOptimizerOptions
  129656. */
  129657. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129658. /**
  129659. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129660. * @param targetFrameRate defines the target frame rate (60 by default)
  129661. * @returns a SceneOptimizerOptions object
  129662. */
  129663. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129664. /**
  129665. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129666. * @param targetFrameRate defines the target frame rate (60 by default)
  129667. * @returns a SceneOptimizerOptions object
  129668. */
  129669. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129670. /**
  129671. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129672. * @param targetFrameRate defines the target frame rate (60 by default)
  129673. * @returns a SceneOptimizerOptions object
  129674. */
  129675. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129676. }
  129677. /**
  129678. * Class used to run optimizations in order to reach a target frame rate
  129679. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129680. */
  129681. export class SceneOptimizer implements IDisposable {
  129682. private _isRunning;
  129683. private _options;
  129684. private _scene;
  129685. private _currentPriorityLevel;
  129686. private _targetFrameRate;
  129687. private _trackerDuration;
  129688. private _currentFrameRate;
  129689. private _sceneDisposeObserver;
  129690. private _improvementMode;
  129691. /**
  129692. * Defines an observable called when the optimizer reaches the target frame rate
  129693. */
  129694. onSuccessObservable: Observable<SceneOptimizer>;
  129695. /**
  129696. * Defines an observable called when the optimizer enables an optimization
  129697. */
  129698. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129699. /**
  129700. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129701. */
  129702. onFailureObservable: Observable<SceneOptimizer>;
  129703. /**
  129704. * Gets a boolean indicating if the optimizer is in improvement mode
  129705. */
  129706. readonly isInImprovementMode: boolean;
  129707. /**
  129708. * Gets the current priority level (0 at start)
  129709. */
  129710. readonly currentPriorityLevel: number;
  129711. /**
  129712. * Gets the current frame rate checked by the SceneOptimizer
  129713. */
  129714. readonly currentFrameRate: number;
  129715. /**
  129716. * Gets or sets the current target frame rate (60 by default)
  129717. */
  129718. /**
  129719. * Gets or sets the current target frame rate (60 by default)
  129720. */
  129721. targetFrameRate: number;
  129722. /**
  129723. * Gets or sets the current interval between two checks (every 2000ms by default)
  129724. */
  129725. /**
  129726. * Gets or sets the current interval between two checks (every 2000ms by default)
  129727. */
  129728. trackerDuration: number;
  129729. /**
  129730. * Gets the list of active optimizations
  129731. */
  129732. readonly optimizations: SceneOptimization[];
  129733. /**
  129734. * Creates a new SceneOptimizer
  129735. * @param scene defines the scene to work on
  129736. * @param options defines the options to use with the SceneOptimizer
  129737. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129738. * @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)
  129739. */
  129740. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129741. /**
  129742. * Stops the current optimizer
  129743. */
  129744. stop(): void;
  129745. /**
  129746. * Reset the optimizer to initial step (current priority level = 0)
  129747. */
  129748. reset(): void;
  129749. /**
  129750. * Start the optimizer. By default it will try to reach a specific framerate
  129751. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129752. */
  129753. start(): void;
  129754. private _checkCurrentState;
  129755. /**
  129756. * Release all resources
  129757. */
  129758. dispose(): void;
  129759. /**
  129760. * Helper function to create a SceneOptimizer with one single line of code
  129761. * @param scene defines the scene to work on
  129762. * @param options defines the options to use with the SceneOptimizer
  129763. * @param onSuccess defines a callback to call on success
  129764. * @param onFailure defines a callback to call on failure
  129765. * @returns the new SceneOptimizer object
  129766. */
  129767. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129768. }
  129769. }
  129770. declare module BABYLON {
  129771. /**
  129772. * Class used to serialize a scene into a string
  129773. */
  129774. export class SceneSerializer {
  129775. /**
  129776. * Clear cache used by a previous serialization
  129777. */
  129778. static ClearCache(): void;
  129779. /**
  129780. * Serialize a scene into a JSON compatible object
  129781. * @param scene defines the scene to serialize
  129782. * @returns a JSON compatible object
  129783. */
  129784. static Serialize(scene: Scene): any;
  129785. /**
  129786. * Serialize a mesh into a JSON compatible object
  129787. * @param toSerialize defines the mesh to serialize
  129788. * @param withParents defines if parents must be serialized as well
  129789. * @param withChildren defines if children must be serialized as well
  129790. * @returns a JSON compatible object
  129791. */
  129792. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129793. }
  129794. }
  129795. declare module BABYLON {
  129796. /**
  129797. * Class used to host texture specific utilities
  129798. */
  129799. export class TextureTools {
  129800. /**
  129801. * Uses the GPU to create a copy texture rescaled at a given size
  129802. * @param texture Texture to copy from
  129803. * @param width defines the desired width
  129804. * @param height defines the desired height
  129805. * @param useBilinearMode defines if bilinear mode has to be used
  129806. * @return the generated texture
  129807. */
  129808. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129809. }
  129810. }
  129811. declare module BABYLON {
  129812. /**
  129813. * This represents the different options available for the video capture.
  129814. */
  129815. export interface VideoRecorderOptions {
  129816. /** Defines the mime type of the video. */
  129817. mimeType: string;
  129818. /** Defines the FPS the video should be recorded at. */
  129819. fps: number;
  129820. /** Defines the chunk size for the recording data. */
  129821. recordChunckSize: number;
  129822. /** The audio tracks to attach to the recording. */
  129823. audioTracks?: MediaStreamTrack[];
  129824. }
  129825. /**
  129826. * This can help with recording videos from BabylonJS.
  129827. * This is based on the available WebRTC functionalities of the browser.
  129828. *
  129829. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129830. */
  129831. export class VideoRecorder {
  129832. private static readonly _defaultOptions;
  129833. /**
  129834. * Returns whether or not the VideoRecorder is available in your browser.
  129835. * @param engine Defines the Babylon Engine.
  129836. * @returns true if supported otherwise false.
  129837. */
  129838. static IsSupported(engine: Engine): boolean;
  129839. private readonly _options;
  129840. private _canvas;
  129841. private _mediaRecorder;
  129842. private _recordedChunks;
  129843. private _fileName;
  129844. private _resolve;
  129845. private _reject;
  129846. /**
  129847. * True when a recording is already in progress.
  129848. */
  129849. readonly isRecording: boolean;
  129850. /**
  129851. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129852. * @param engine Defines the BabylonJS Engine you wish to record.
  129853. * @param options Defines options that can be used to customize the capture.
  129854. */
  129855. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129856. /**
  129857. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129858. */
  129859. stopRecording(): void;
  129860. /**
  129861. * Starts recording the canvas for a max duration specified in parameters.
  129862. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129863. * If null no automatic download will start and you can rely on the promise to get the data back.
  129864. * @param maxDuration Defines the maximum recording time in seconds.
  129865. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129866. * @return A promise callback at the end of the recording with the video data in Blob.
  129867. */
  129868. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129869. /**
  129870. * Releases internal resources used during the recording.
  129871. */
  129872. dispose(): void;
  129873. private _handleDataAvailable;
  129874. private _handleError;
  129875. private _handleStop;
  129876. }
  129877. }
  129878. declare module BABYLON {
  129879. /**
  129880. * Class containing a set of static utilities functions for screenshots
  129881. */
  129882. export class ScreenshotTools {
  129883. /**
  129884. * Captures a screenshot of the current rendering
  129885. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129886. * @param engine defines the rendering engine
  129887. * @param camera defines the source camera
  129888. * @param size This parameter can be set to a single number or to an object with the
  129889. * following (optional) properties: precision, width, height. If a single number is passed,
  129890. * it will be used for both width and height. If an object is passed, the screenshot size
  129891. * will be derived from the parameters. The precision property is a multiplier allowing
  129892. * rendering at a higher or lower resolution
  129893. * @param successCallback defines the callback receives a single parameter which contains the
  129894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129895. * src parameter of an <img> to display it
  129896. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129897. * Check your browser for supported MIME types
  129898. */
  129899. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129900. /**
  129901. * Captures a screenshot of the current rendering
  129902. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129903. * @param engine defines the rendering engine
  129904. * @param camera defines the source camera
  129905. * @param size This parameter can be set to a single number or to an object with the
  129906. * following (optional) properties: precision, width, height. If a single number is passed,
  129907. * it will be used for both width and height. If an object is passed, the screenshot size
  129908. * will be derived from the parameters. The precision property is a multiplier allowing
  129909. * rendering at a higher or lower resolution
  129910. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129911. * Check your browser for supported MIME types
  129912. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129913. * to the src parameter of an <img> to display it
  129914. */
  129915. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129916. /**
  129917. * Generates an image screenshot from the specified camera.
  129918. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129919. * @param engine The engine to use for rendering
  129920. * @param camera The camera to use for rendering
  129921. * @param size This parameter can be set to a single number or to an object with the
  129922. * following (optional) properties: precision, width, height. If a single number is passed,
  129923. * it will be used for both width and height. If an object is passed, the screenshot size
  129924. * will be derived from the parameters. The precision property is a multiplier allowing
  129925. * rendering at a higher or lower resolution
  129926. * @param successCallback The callback receives a single parameter which contains the
  129927. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129928. * src parameter of an <img> to display it
  129929. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129930. * Check your browser for supported MIME types
  129931. * @param samples Texture samples (default: 1)
  129932. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129933. * @param fileName A name for for the downloaded file.
  129934. */
  129935. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129936. /**
  129937. * Generates an image screenshot from the specified camera.
  129938. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129939. * @param engine The engine to use for rendering
  129940. * @param camera The camera to use for rendering
  129941. * @param size This parameter can be set to a single number or to an object with the
  129942. * following (optional) properties: precision, width, height. If a single number is passed,
  129943. * it will be used for both width and height. If an object is passed, the screenshot size
  129944. * will be derived from the parameters. The precision property is a multiplier allowing
  129945. * rendering at a higher or lower resolution
  129946. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129947. * Check your browser for supported MIME types
  129948. * @param samples Texture samples (default: 1)
  129949. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129950. * @param fileName A name for for the downloaded file.
  129951. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129952. * to the src parameter of an <img> to display it
  129953. */
  129954. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129955. /**
  129956. * Gets height and width for screenshot size
  129957. * @private
  129958. */
  129959. private static _getScreenshotSize;
  129960. }
  129961. }
  129962. declare module BABYLON {
  129963. /**
  129964. * A cursor which tracks a point on a path
  129965. */
  129966. export class PathCursor {
  129967. private path;
  129968. /**
  129969. * Stores path cursor callbacks for when an onchange event is triggered
  129970. */
  129971. private _onchange;
  129972. /**
  129973. * The value of the path cursor
  129974. */
  129975. value: number;
  129976. /**
  129977. * The animation array of the path cursor
  129978. */
  129979. animations: Animation[];
  129980. /**
  129981. * Initializes the path cursor
  129982. * @param path The path to track
  129983. */
  129984. constructor(path: Path2);
  129985. /**
  129986. * Gets the cursor point on the path
  129987. * @returns A point on the path cursor at the cursor location
  129988. */
  129989. getPoint(): Vector3;
  129990. /**
  129991. * Moves the cursor ahead by the step amount
  129992. * @param step The amount to move the cursor forward
  129993. * @returns This path cursor
  129994. */
  129995. moveAhead(step?: number): PathCursor;
  129996. /**
  129997. * Moves the cursor behind by the step amount
  129998. * @param step The amount to move the cursor back
  129999. * @returns This path cursor
  130000. */
  130001. moveBack(step?: number): PathCursor;
  130002. /**
  130003. * Moves the cursor by the step amount
  130004. * If the step amount is greater than one, an exception is thrown
  130005. * @param step The amount to move the cursor
  130006. * @returns This path cursor
  130007. */
  130008. move(step: number): PathCursor;
  130009. /**
  130010. * Ensures that the value is limited between zero and one
  130011. * @returns This path cursor
  130012. */
  130013. private ensureLimits;
  130014. /**
  130015. * Runs onchange callbacks on change (used by the animation engine)
  130016. * @returns This path cursor
  130017. */
  130018. private raiseOnChange;
  130019. /**
  130020. * Executes a function on change
  130021. * @param f A path cursor onchange callback
  130022. * @returns This path cursor
  130023. */
  130024. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130025. }
  130026. }
  130027. declare module BABYLON {
  130028. /** @hidden */
  130029. export var blurPixelShader: {
  130030. name: string;
  130031. shader: string;
  130032. };
  130033. }
  130034. declare module BABYLON {
  130035. /** @hidden */
  130036. export var pointCloudVertexDeclaration: {
  130037. name: string;
  130038. shader: string;
  130039. };
  130040. }
  130041. // Mixins
  130042. interface Window {
  130043. mozIndexedDB: IDBFactory;
  130044. webkitIndexedDB: IDBFactory;
  130045. msIndexedDB: IDBFactory;
  130046. webkitURL: typeof URL;
  130047. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130048. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130049. WebGLRenderingContext: WebGLRenderingContext;
  130050. MSGesture: MSGesture;
  130051. CANNON: any;
  130052. AudioContext: AudioContext;
  130053. webkitAudioContext: AudioContext;
  130054. PointerEvent: any;
  130055. Math: Math;
  130056. Uint8Array: Uint8ArrayConstructor;
  130057. Float32Array: Float32ArrayConstructor;
  130058. mozURL: typeof URL;
  130059. msURL: typeof URL;
  130060. VRFrameData: any; // WebVR, from specs 1.1
  130061. DracoDecoderModule: any;
  130062. setImmediate(handler: (...args: any[]) => void): number;
  130063. }
  130064. interface HTMLCanvasElement {
  130065. requestPointerLock(): void;
  130066. msRequestPointerLock?(): void;
  130067. mozRequestPointerLock?(): void;
  130068. webkitRequestPointerLock?(): void;
  130069. /** Track wether a record is in progress */
  130070. isRecording: boolean;
  130071. /** Capture Stream method defined by some browsers */
  130072. captureStream(fps?: number): MediaStream;
  130073. }
  130074. interface CanvasRenderingContext2D {
  130075. msImageSmoothingEnabled: boolean;
  130076. }
  130077. interface MouseEvent {
  130078. mozMovementX: number;
  130079. mozMovementY: number;
  130080. webkitMovementX: number;
  130081. webkitMovementY: number;
  130082. msMovementX: number;
  130083. msMovementY: number;
  130084. }
  130085. interface Navigator {
  130086. mozGetVRDevices: (any: any) => any;
  130087. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130088. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130089. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130090. webkitGetGamepads(): Gamepad[];
  130091. msGetGamepads(): Gamepad[];
  130092. webkitGamepads(): Gamepad[];
  130093. }
  130094. interface HTMLVideoElement {
  130095. mozSrcObject: any;
  130096. }
  130097. interface Math {
  130098. fround(x: number): number;
  130099. imul(a: number, b: number): number;
  130100. }
  130101. interface WebGLRenderingContext {
  130102. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130103. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130104. vertexAttribDivisor(index: number, divisor: number): void;
  130105. createVertexArray(): any;
  130106. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130107. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130108. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130109. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130110. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130111. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130112. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130113. // Queries
  130114. createQuery(): WebGLQuery;
  130115. deleteQuery(query: WebGLQuery): void;
  130116. beginQuery(target: number, query: WebGLQuery): void;
  130117. endQuery(target: number): void;
  130118. getQueryParameter(query: WebGLQuery, pname: number): any;
  130119. getQuery(target: number, pname: number): any;
  130120. MAX_SAMPLES: number;
  130121. RGBA8: number;
  130122. READ_FRAMEBUFFER: number;
  130123. DRAW_FRAMEBUFFER: number;
  130124. UNIFORM_BUFFER: number;
  130125. HALF_FLOAT_OES: number;
  130126. RGBA16F: number;
  130127. RGBA32F: number;
  130128. R32F: number;
  130129. RG32F: number;
  130130. RGB32F: number;
  130131. R16F: number;
  130132. RG16F: number;
  130133. RGB16F: number;
  130134. RED: number;
  130135. RG: number;
  130136. R8: number;
  130137. RG8: number;
  130138. UNSIGNED_INT_24_8: number;
  130139. DEPTH24_STENCIL8: number;
  130140. MIN: number;
  130141. MAX: number;
  130142. /* Multiple Render Targets */
  130143. drawBuffers(buffers: number[]): void;
  130144. readBuffer(src: number): void;
  130145. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130146. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130147. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130148. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130149. // Occlusion Query
  130150. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130151. ANY_SAMPLES_PASSED: number;
  130152. QUERY_RESULT_AVAILABLE: number;
  130153. QUERY_RESULT: number;
  130154. }
  130155. interface WebGLProgram {
  130156. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130157. }
  130158. interface EXT_disjoint_timer_query {
  130159. QUERY_COUNTER_BITS_EXT: number;
  130160. TIME_ELAPSED_EXT: number;
  130161. TIMESTAMP_EXT: number;
  130162. GPU_DISJOINT_EXT: number;
  130163. QUERY_RESULT_EXT: number;
  130164. QUERY_RESULT_AVAILABLE_EXT: number;
  130165. queryCounterEXT(query: WebGLQuery, target: number): void;
  130166. createQueryEXT(): WebGLQuery;
  130167. beginQueryEXT(target: number, query: WebGLQuery): void;
  130168. endQueryEXT(target: number): void;
  130169. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130170. deleteQueryEXT(query: WebGLQuery): void;
  130171. }
  130172. interface WebGLUniformLocation {
  130173. _currentState: any;
  130174. }
  130175. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130176. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130177. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130178. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130179. interface WebGLRenderingContext {
  130180. readonly RASTERIZER_DISCARD: number;
  130181. readonly DEPTH_COMPONENT24: number;
  130182. readonly TEXTURE_3D: number;
  130183. readonly TEXTURE_2D_ARRAY: number;
  130184. readonly TEXTURE_COMPARE_FUNC: number;
  130185. readonly TEXTURE_COMPARE_MODE: number;
  130186. readonly COMPARE_REF_TO_TEXTURE: number;
  130187. readonly TEXTURE_WRAP_R: number;
  130188. readonly HALF_FLOAT: number;
  130189. readonly RGB8: number;
  130190. readonly RED_INTEGER: number;
  130191. readonly RG_INTEGER: number;
  130192. readonly RGB_INTEGER: number;
  130193. readonly RGBA_INTEGER: number;
  130194. readonly R8_SNORM: number;
  130195. readonly RG8_SNORM: number;
  130196. readonly RGB8_SNORM: number;
  130197. readonly RGBA8_SNORM: number;
  130198. readonly R8I: number;
  130199. readonly RG8I: number;
  130200. readonly RGB8I: number;
  130201. readonly RGBA8I: number;
  130202. readonly R8UI: number;
  130203. readonly RG8UI: number;
  130204. readonly RGB8UI: number;
  130205. readonly RGBA8UI: number;
  130206. readonly R16I: number;
  130207. readonly RG16I: number;
  130208. readonly RGB16I: number;
  130209. readonly RGBA16I: number;
  130210. readonly R16UI: number;
  130211. readonly RG16UI: number;
  130212. readonly RGB16UI: number;
  130213. readonly RGBA16UI: number;
  130214. readonly R32I: number;
  130215. readonly RG32I: number;
  130216. readonly RGB32I: number;
  130217. readonly RGBA32I: number;
  130218. readonly R32UI: number;
  130219. readonly RG32UI: number;
  130220. readonly RGB32UI: number;
  130221. readonly RGBA32UI: number;
  130222. readonly RGB10_A2UI: number;
  130223. readonly R11F_G11F_B10F: number;
  130224. readonly RGB9_E5: number;
  130225. readonly RGB10_A2: number;
  130226. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130227. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130228. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130229. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130230. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130231. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130232. 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;
  130233. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130234. readonly TRANSFORM_FEEDBACK: number;
  130235. readonly INTERLEAVED_ATTRIBS: number;
  130236. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130237. createTransformFeedback(): WebGLTransformFeedback;
  130238. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130239. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130240. beginTransformFeedback(primitiveMode: number): void;
  130241. endTransformFeedback(): void;
  130242. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130243. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130244. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130245. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130246. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130247. }
  130248. interface ImageBitmap {
  130249. readonly width: number;
  130250. readonly height: number;
  130251. close(): void;
  130252. }
  130253. interface WebGLQuery extends WebGLObject {
  130254. }
  130255. declare var WebGLQuery: {
  130256. prototype: WebGLQuery;
  130257. new(): WebGLQuery;
  130258. };
  130259. interface WebGLSampler extends WebGLObject {
  130260. }
  130261. declare var WebGLSampler: {
  130262. prototype: WebGLSampler;
  130263. new(): WebGLSampler;
  130264. };
  130265. interface WebGLSync extends WebGLObject {
  130266. }
  130267. declare var WebGLSync: {
  130268. prototype: WebGLSync;
  130269. new(): WebGLSync;
  130270. };
  130271. interface WebGLTransformFeedback extends WebGLObject {
  130272. }
  130273. declare var WebGLTransformFeedback: {
  130274. prototype: WebGLTransformFeedback;
  130275. new(): WebGLTransformFeedback;
  130276. };
  130277. interface WebGLVertexArrayObject extends WebGLObject {
  130278. }
  130279. declare var WebGLVertexArrayObject: {
  130280. prototype: WebGLVertexArrayObject;
  130281. new(): WebGLVertexArrayObject;
  130282. };
  130283. // Type definitions for WebVR API
  130284. // Project: https://w3c.github.io/webvr/
  130285. // Definitions by: six a <https://github.com/lostfictions>
  130286. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130287. interface VRDisplay extends EventTarget {
  130288. /**
  130289. * Dictionary of capabilities describing the VRDisplay.
  130290. */
  130291. readonly capabilities: VRDisplayCapabilities;
  130292. /**
  130293. * z-depth defining the far plane of the eye view frustum
  130294. * enables mapping of values in the render target depth
  130295. * attachment to scene coordinates. Initially set to 10000.0.
  130296. */
  130297. depthFar: number;
  130298. /**
  130299. * z-depth defining the near plane of the eye view frustum
  130300. * enables mapping of values in the render target depth
  130301. * attachment to scene coordinates. Initially set to 0.01.
  130302. */
  130303. depthNear: number;
  130304. /**
  130305. * An identifier for this distinct VRDisplay. Used as an
  130306. * association point in the Gamepad API.
  130307. */
  130308. readonly displayId: number;
  130309. /**
  130310. * A display name, a user-readable name identifying it.
  130311. */
  130312. readonly displayName: string;
  130313. readonly isConnected: boolean;
  130314. readonly isPresenting: boolean;
  130315. /**
  130316. * If this VRDisplay supports room-scale experiences, the optional
  130317. * stage attribute contains details on the room-scale parameters.
  130318. */
  130319. readonly stageParameters: VRStageParameters | null;
  130320. /**
  130321. * Passing the value returned by `requestAnimationFrame` to
  130322. * `cancelAnimationFrame` will unregister the callback.
  130323. * @param handle Define the hanle of the request to cancel
  130324. */
  130325. cancelAnimationFrame(handle: number): void;
  130326. /**
  130327. * Stops presenting to the VRDisplay.
  130328. * @returns a promise to know when it stopped
  130329. */
  130330. exitPresent(): Promise<void>;
  130331. /**
  130332. * Return the current VREyeParameters for the given eye.
  130333. * @param whichEye Define the eye we want the parameter for
  130334. * @returns the eye parameters
  130335. */
  130336. getEyeParameters(whichEye: string): VREyeParameters;
  130337. /**
  130338. * Populates the passed VRFrameData with the information required to render
  130339. * the current frame.
  130340. * @param frameData Define the data structure to populate
  130341. * @returns true if ok otherwise false
  130342. */
  130343. getFrameData(frameData: VRFrameData): boolean;
  130344. /**
  130345. * Get the layers currently being presented.
  130346. * @returns the list of VR layers
  130347. */
  130348. getLayers(): VRLayer[];
  130349. /**
  130350. * Return a VRPose containing the future predicted pose of the VRDisplay
  130351. * when the current frame will be presented. The value returned will not
  130352. * change until JavaScript has returned control to the browser.
  130353. *
  130354. * The VRPose will contain the position, orientation, velocity,
  130355. * and acceleration of each of these properties.
  130356. * @returns the pose object
  130357. */
  130358. getPose(): VRPose;
  130359. /**
  130360. * Return the current instantaneous pose of the VRDisplay, with no
  130361. * prediction applied.
  130362. * @returns the current instantaneous pose
  130363. */
  130364. getImmediatePose(): VRPose;
  130365. /**
  130366. * The callback passed to `requestAnimationFrame` will be called
  130367. * any time a new frame should be rendered. When the VRDisplay is
  130368. * presenting the callback will be called at the native refresh
  130369. * rate of the HMD. When not presenting this function acts
  130370. * identically to how window.requestAnimationFrame acts. Content should
  130371. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130372. * asynchronously from other displays and at differing refresh rates.
  130373. * @param callback Define the eaction to run next frame
  130374. * @returns the request handle it
  130375. */
  130376. requestAnimationFrame(callback: FrameRequestCallback): number;
  130377. /**
  130378. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130379. * Repeat calls while already presenting will update the VRLayers being displayed.
  130380. * @param layers Define the list of layer to present
  130381. * @returns a promise to know when the request has been fulfilled
  130382. */
  130383. requestPresent(layers: VRLayer[]): Promise<void>;
  130384. /**
  130385. * Reset the pose for this display, treating its current position and
  130386. * orientation as the "origin/zero" values. VRPose.position,
  130387. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130388. * updated when calling resetPose(). This should be called in only
  130389. * sitting-space experiences.
  130390. */
  130391. resetPose(): void;
  130392. /**
  130393. * The VRLayer provided to the VRDisplay will be captured and presented
  130394. * in the HMD. Calling this function has the same effect on the source
  130395. * canvas as any other operation that uses its source image, and canvases
  130396. * created without preserveDrawingBuffer set to true will be cleared.
  130397. * @param pose Define the pose to submit
  130398. */
  130399. submitFrame(pose?: VRPose): void;
  130400. }
  130401. declare var VRDisplay: {
  130402. prototype: VRDisplay;
  130403. new(): VRDisplay;
  130404. };
  130405. interface VRLayer {
  130406. leftBounds?: number[] | Float32Array | null;
  130407. rightBounds?: number[] | Float32Array | null;
  130408. source?: HTMLCanvasElement | null;
  130409. }
  130410. interface VRDisplayCapabilities {
  130411. readonly canPresent: boolean;
  130412. readonly hasExternalDisplay: boolean;
  130413. readonly hasOrientation: boolean;
  130414. readonly hasPosition: boolean;
  130415. readonly maxLayers: number;
  130416. }
  130417. interface VREyeParameters {
  130418. /** @deprecated */
  130419. readonly fieldOfView: VRFieldOfView;
  130420. readonly offset: Float32Array;
  130421. readonly renderHeight: number;
  130422. readonly renderWidth: number;
  130423. }
  130424. interface VRFieldOfView {
  130425. readonly downDegrees: number;
  130426. readonly leftDegrees: number;
  130427. readonly rightDegrees: number;
  130428. readonly upDegrees: number;
  130429. }
  130430. interface VRFrameData {
  130431. readonly leftProjectionMatrix: Float32Array;
  130432. readonly leftViewMatrix: Float32Array;
  130433. readonly pose: VRPose;
  130434. readonly rightProjectionMatrix: Float32Array;
  130435. readonly rightViewMatrix: Float32Array;
  130436. readonly timestamp: number;
  130437. }
  130438. interface VRPose {
  130439. readonly angularAcceleration: Float32Array | null;
  130440. readonly angularVelocity: Float32Array | null;
  130441. readonly linearAcceleration: Float32Array | null;
  130442. readonly linearVelocity: Float32Array | null;
  130443. readonly orientation: Float32Array | null;
  130444. readonly position: Float32Array | null;
  130445. readonly timestamp: number;
  130446. }
  130447. interface VRStageParameters {
  130448. sittingToStandingTransform?: Float32Array;
  130449. sizeX?: number;
  130450. sizeY?: number;
  130451. }
  130452. interface Navigator {
  130453. getVRDisplays(): Promise<VRDisplay[]>;
  130454. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130455. }
  130456. interface Window {
  130457. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130458. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130459. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130460. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130461. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130462. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130463. }
  130464. interface Gamepad {
  130465. readonly displayId: number;
  130466. }
  130467. type XRSessionMode =
  130468. | "inline"
  130469. | "immersive-vr"
  130470. | "immersive-ar";
  130471. type XRReferenceSpaceType =
  130472. | "viewer"
  130473. | "local"
  130474. | "local-floor"
  130475. | "bounded-floor"
  130476. | "unbounded";
  130477. type XREnvironmentBlendMode =
  130478. | "opaque"
  130479. | "additive"
  130480. | "alpha-blend";
  130481. type XRVisibilityState =
  130482. | "visible"
  130483. | "visible-blurred"
  130484. | "hidden";
  130485. type XRHandedness =
  130486. | "none"
  130487. | "left"
  130488. | "right";
  130489. type XRTargetRayMode =
  130490. | "gaze"
  130491. | "tracked-pointer"
  130492. | "screen";
  130493. type XREye =
  130494. | "none"
  130495. | "left"
  130496. | "right";
  130497. interface XRSpace extends EventTarget {
  130498. }
  130499. interface XRRenderState {
  130500. depthNear?: number;
  130501. depthFar?: number;
  130502. inlineVerticalFieldOfView?: number;
  130503. baseLayer?: XRWebGLLayer;
  130504. }
  130505. interface XRInputSource {
  130506. handedness: XRHandedness;
  130507. targetRayMode: XRTargetRayMode;
  130508. targetRaySpace: XRSpace;
  130509. gripSpace: XRSpace | undefined;
  130510. gamepad: Gamepad | undefined;
  130511. profiles: Array<string>;
  130512. }
  130513. interface XRSession {
  130514. addEventListener: Function;
  130515. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130516. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130517. requestAnimationFrame: Function;
  130518. end(): Promise<void>;
  130519. renderState: XRRenderState;
  130520. inputSources: Array<XRInputSource>;
  130521. }
  130522. interface XRReferenceSpace extends XRSpace {
  130523. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130524. onreset: any;
  130525. }
  130526. interface XRFrame {
  130527. session: XRSession;
  130528. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130529. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130530. }
  130531. interface XRViewerPose extends XRPose {
  130532. views: Array<XRView>;
  130533. }
  130534. interface XRPose {
  130535. transform: XRRigidTransform;
  130536. emulatedPosition: boolean;
  130537. }
  130538. declare var XRWebGLLayer: {
  130539. prototype: XRWebGLLayer;
  130540. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130541. };
  130542. interface XRWebGLLayer {
  130543. framebuffer: WebGLFramebuffer;
  130544. framebufferWidth: number;
  130545. framebufferHeight: number;
  130546. getViewport: Function;
  130547. }
  130548. interface XRRigidTransform {
  130549. position: DOMPointReadOnly;
  130550. orientation: DOMPointReadOnly;
  130551. matrix: Float32Array;
  130552. inverse: XRRigidTransform;
  130553. }
  130554. interface XRView {
  130555. eye: XREye;
  130556. projectionMatrix: Float32Array;
  130557. transform: XRRigidTransform;
  130558. }
  130559. interface XRInputSourceChangeEvent {
  130560. session: XRSession;
  130561. removed: Array<XRInputSource>;
  130562. added: Array<XRInputSource>;
  130563. }